7

I've been looking into this, and I have encountered two main "solutions":

\usepackage{arydshln}

As decribed here.

And this one:

\usepackage{dashrule}

As described in this other post.

However, since I'm loading these packages:

\usepackage{array}
\usepaclage{tabularx}
\usepackage{longtable}
\usepackage{tabu}

It seems I can't use neither arydshln nor dashline.

Any idea why this is happening? How can I get a dashed horizontal line inside my tabularx which is at the same time- inside a table environment?

This is what I have:

\documentclass{article}

\usepackage{multirow}
\usepackage{array}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{tabu}


\begin{document}
Hello.

\begin{longtabu}{l p{0.8\linewidth}}
WHO                 &   \hspace{5mm} World Health Organization\\[1mm]
GDP                 & \hspace{5mm} Gross Domestic Product\\[1mm]
PPP                 & \hspace{5mm} Purchasing Power Parities\\[1mm]

\end{longtabu}

\begin{table}\tiny
    \caption{Muscles of the thigh}
    \newcolumntype{Y}{>{\raggedright\arraybackslash}X}
    \begin{tabularx}{\textwidth}{YYYYY}
        Muscle & Origin & Insertion& Nerve & Action \\
        \firsthline\\
            \textbf{Anterior Compartment}   & & &   &   \\[3mm]

            Quadriceps femoris                                                                                          &
            Rectus Femoris: anterior inferior iliac spine. Vastus Lateralis: greater trochanter and linea aspera of femur. Vastus Intermedius: body of femur.  Vastus Medialis: linea aspera of femur                &
            Patella and onto tibial tuberosity through patellar ligament        &
            Femoral                                                                                                                 &
            Extends knee; rectus femoris also flexes hip\\\\

            Sartorius                                                                                                               &
            Anterior superiro iliac spine                                                                       &
            Medial side of tibial tuberosity                                                                &
            Femoral                                                                                                                 &
            Flexes hip and knee; rotates thigh laterally and leg medially\\\\

            \hline\\% I want this line to be dashed
            \textbf{Medial Compartment} & & &   &   \\[3mm]

            Adductor brevis                                                                                                 &
            Pubis                                                                                                                       &
            Pectineal line and linea aspera of femur                                                &
            Obturator                                                                                                               &
            Adducts, laterally rotates thigh; flexes hip\\\\

            Adductor longus                                                                                                 &
            Pubis                                                                                                                       &
            Linea aspera of femur                                                                                       &
            Obturator                                                                                                               &
            Adducts, laterally rotates thigh; flexes hip\\\\

            \lasthline\\
    \end{tabularx}
    \label{tab:ThighMuscles2}
\end{table} 


\end{document}

Now, if I use \dashrule where the \hline is (after loading the dashrule package, of course), I get an Undefined control sequence error.

If I use the \hdashline (of the arydshln package) I get 101 errors which point me to other tables in my document, so I'm guessing it has something to do with incompatibility with the other packages I loaded.

David Carlisle
  • 757,742
Mario S. E.
  • 18,609

1 Answers1

7

enter image description here

It worked for me without error, if it doesn't work for you you need to make an example that shows the problem.

\documentclass{article}

\usepackage{multirow}
\usepackage{array}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{arydshln}

\begin{document}
Hello.

\begin{table}\tiny
    \caption{Muscles of the thigh}
    \newcolumntype{Y}{>{\raggedright\arraybackslash}X}
    \begin{tabularx}{\textwidth}{YYYYY}
        Muscle & Origin & Insertion& Nerve & Action \\
        \firsthline\\
            \textbf{Anterior Compartment}   & & &   &   \\[3mm]

            Quadriceps femoris                                                                                          &
            Rectus Femoris: anterior inferior iliac spine. Vastus Lateralis: greater trochanter and linea aspera of femur. Vastus Intermedius: body of femur.  Vastus Medialis: linea aspera of femur                &
            Patella and onto tibial tuberosity through patellar ligament        &
            Femoral                                                                                                                 &
            Extends knee; rectus femoris also flexes hip\\\\

            Sartorius                                                                                                               &
            Anterior superiro iliac spine                                                                       &
            Medial side of tibial tuberosity                                                                &
            Femoral                                                                                                                 &
            Flexes hip and knee; rotates thigh laterally and leg medially\\\\

            \hdashline\\% I want this line to be dashed
            \textbf{Medial Compartment} & & &   &   \\[3mm]

            Adductor brevis                                                                                                 &
            Pubis                                                                                                                       &
            Pectineal line and linea aspera of femur                                                &
            Obturator                                                                                                               &
            Adducts, laterally rotates thigh; flexes hip\\\\

            Adductor longus                                                                                                 &
            Pubis                                                                                                                       &
            Linea aspera of femur                                                                                       &
            Obturator                                                                                                               &
            Adducts, laterally rotates thigh; flexes hip\\\\

            \lasthline\\
    \end{tabularx}
    \label{tab:ThighMuscles2}
\end{table} 


\end{document}

With the updated example using longtabu It works if you change longtabu to longtable The tabu package has some nice ideas but unfortunately it incorrectly defines the standard latex array package >{..} syntax (This is an intentional, documented feature of the package, not a bug as such) and has other incompatibilities, so often you need to go "the tabu way" and just use the features of that package or use a combination of packages that are designed to cooperate and not clash when used at the same time.

David Carlisle
  • 757,742
  • I got what causes the error! I know I shouldn't be happy (since I haven't found a solution), but at least now I know how to replicate it: It happens when you use one of these tables with the longtable environment along in the same project. I'm not sure why. I'll edit my post to show how this happens when both tables are used. – Mario S. E. Apr 02 '13 at 11:50
  • @MarioS.E. This is why we always ask people to put a complete example that shows the problem – David Carlisle Apr 02 '13 at 11:57
  • I know, I'm very sorry; but it was also very difficult for me to actually find it. As you can imagine, my work at this point is full of tables, and I had no clue where to start. I just had a hunch to start commenting all the "tabu"'s. @Jon pointed my out a few hours ago that the author of tabu is building a new version that is not going to be backwards compatible, so I panicked and start changing everything. – Mario S. E. Apr 02 '13 at 12:03
  • I added some notes re tabu – David Carlisle Apr 02 '13 at 12:05
  • As the arydshln package will also have issues with hyperref, the easiest for a layout as the above is to define the dash line with xleaders and be done with it? – yannisl Apr 02 '13 at 12:33
  • @YiannisLazarides does it? (why are they clashing:-) Yes it is true that horizontal leaders are fairly easy anyway the more interesting part of arydshln is getting vertical dashed lines which are trickier. – David Carlisle Apr 02 '13 at 12:40
  • 2
    Not too sure why---I didn't check it, but is in the hyperef hot list. Correct loading order is
    \usepackage{longtable}
    \usepacakge{hyperref}
    \usepackage{arydshln}
    
    – yannisl Apr 02 '13 at 12:52
  • How do I do this with xleaders? – Mario S. E. Apr 03 '13 at 09:25
  • Maybe you can help on this question: http://tex.stackexchange.com/questions/171518/how-to-create-vertical-and-horizontal-dotted-lines-in-a-matrix? – wonderich Apr 14 '14 at 23:23