[Tex/LaTex] Can a table include a horizontal dashed line

formattingrulestables

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?

Best Answer

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]
Related Question