56

In a normal table, you can use the \hline command to draw a horizontal line. I am trying to make this line a dashed horizontal line.

I have found the package dashrule via this answer, but this only works for \rule situations; i.e. it can't be directly used as a line in a table, and LaTeX won't compile it. Conversely, I've tried wrapping the \hdashrule in a multicolumn:

\multicolumn{5}{|c|}{\hdashrule{130mm}{1pt}{4pt}} \

However, the padding around the table cell breaks the flow of the table, and the horizontal rule is not aligned with the other \hlines of the table. (It also means that the rule width must be specified manually.)

Is there any way to make a \hline dashed without resorting to tables-in-tables? Can you force a single table cell to have no vertical or horizontal margins and padding?

86

The arydshln package offers you the \hdashline and \cdashline commands which are the dashed counterparts of \hline and \cline, respectively. A little example (including also a vertical dashed line):

\documentclass{report}
\usepackage{arydshln}

\begin{document}

\begin{tabular}{c:cc}
   column1a & column2a & column3a \\
   column1b & column2b   & column3b\\ \hdashline
   column1c & column2c & column3c \\ \cdashline{1-2}
   column1d & column2d & column3d \\
\end{tabular}

\end{document}

You can also specify how wide the dashes should be by specifying a ratio. For a dotted line write

\hdashline[0.5pt/5pt]
  • 7
    It seems like that \usepackage{arydshln} is not compatible with \usepackage{tabularx}. They cannot coexist. Is there any resolution for this? – wonderich Apr 14 '14 at 22:46
  • 1
    Maybe you can help on this question: tex.stackexchange.com/questions/171518/…? – wonderich Apr 14 '14 at 23:23
  • spacing never comes our right when I use \hdashline, not sure what the deal is. – travelingbones Nov 2 '16 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.