# Dotted line instead of \hline in table environment

I am trying to get a dotted line in the table instead of \hline, but I can't get the output.

arydshln and dashrule packages are available to get the dashed line, but I can't find any packages to get a dotted line in table.

Is any package available for this style?

• take a look at this : tex.stackexchange.com/a/10261/26074 Apr 2, 2014 at 11:44
• yes i looked that page, they used arydshln package for getting the dashed line (---------------), but i need dotted lines (...........) Apr 2, 2014 at 11:47

The package arydshln by Hiroshi Nakashima provides dashed lines, but they can be changed to look like dots, somehow, by reducing the dash length and increasing the gap a little bit (both default to 4pt)

Change the lengths \dashlinedash, \dashlinegap accordingly and \arrayrulewidth eventually.

\documentclass{book}

\usepackage{arydshln}

\setlength{\dashlinedash}{0.2pt}
\setlength{\dashlinegap}{4.5pt}
\setlength{\arrayrulewidth}{0.2pt}

\begin{document}
\begin{tabular}{ll}
\hline
& \\
This is a & nice table \\
& \\
\hdashline
& \\
\end{tabular}

% Another combination of values
\setlength\dashlinedash{0.2pt}
\setlength\dashlinegap{1.5pt}
\setlength\arrayrulewidth{0.3pt}

\begin{tabular}{ll}
\hline
This is yet & another nice table \\
\hdashline
\end{tabular}

\end{document}


Edit: In a previous version I had\usepackage{array} -- this package is not needed, so I removed it from the code.

Just playing around, I came up with a way to add dashed and [true] dotted horizontal lines to tabular entities. It could be made more robust, in that it assumes one has \tabcolsep border on each side of a column (which of course can be overridden by @{} macros). That aside, it automatically works for different font sizes and different values of \arraystretch.

it provides \tabdashline and \tabdotline which are kind of like \hline, but it only works on a single column (which means it can be changed from column to column). Parameters include \rulewidth, the thickness of the dash line, \replength, a repetition length for each dash/dot on the line, and a macro \dashfrac{}, for setting the dash length as fraction of \replength. Note that \rulewidth and \dashfrac{} have no effect on the \tabdotline, since it is using a period as the repeated glyph. However, the spacing of the dots is controlled by \replength.

\documentclass[10pt]{article}
\newlength\replength
\newcommand\repfrac{.33}
\setlength\replength{1.5pt}
\newcommand\rulewidth{.6pt}
\smash{\rule[\arraystretch\ht\strutbox]{\repfrac\replength}{\rulewidth}}}\hfill}
\newcommand\tabdashline{%
\makebox[0pt][r]{\makebox[\tabcolsep]{\tdashfill\hfil}}\tdashfill\hfil%
\makebox[0pt][l]{\makebox[\tabcolsep]{\tdashfill\hfil}}%
\\[-\arraystretch\dimexpr\ht\strutbox+\dp\strutbox\relax]%
}
\smash{\raisebox{\arraystretch\dimexpr\ht\strutbox-.1ex\relax}{.}}}\hfill}
\newcommand\tabdotline{%
\makebox[0pt][r]{\makebox[\tabcolsep]{\tdotfill\hfil}}\tdotfill\hfil%
\makebox[0pt][l]{\makebox[\tabcolsep]{\tdotfill\hfil}}%
\\[-\arraystretch\dimexpr\ht\strutbox+\dp\strutbox\relax]%
}
\begin{document}

Compare tabdashline to tabdotline to hline

\begin{tabular}{|c|}
\hline
top\\
\tabdashline
bottom\\
\hline
\end{tabular}
vs.
\begin{tabular}{|c|}
\hline
top\\
\tabdotline
bottom\\
\hline
\end{tabular}
vs.
\begin{tabular}{|c|}
\hline
top\\
\hline
bottom\\
\hline
\end{tabular}

Compare multiple columns:

\begin{tabular}{|c|c|}
\hline
top & column with 0.7 dashfrac\\
\tabdashline & \replength=.4ex\relax\dashfrac{0.7}\tabdashline
bottom & and a replength of .4ex\\
\hline
\end{tabular}

With arraystretch of 1.3:

\def\arraystretch{1.3}
\begin{tabular}{|c|}
\hline
top\\
\tabdashline
bottom\\
\hline
\end{tabular}
vs.
\begin{tabular}{|c|}
\hline
top\\
\hline
bottom\\
\hline
\end{tabular}

\end{document}


The environment {NiceTabular} of nicematrix provides (among other features) a command \hdottedline to draw horizontal dotted lines and a specifier : in the preamble for the vertical rules.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}
\renewcommand{\arraystretch}{1.3}
\begin{NiceTabular}{|c:c|}
\hline
first & second \\
\hdottedline
third & last \\
\hline
\end{NiceTabular}
\end{document}


You need several compilations because nicematrix uses PGF/Tikz nodes.

• Is there an equivalent of arydshln's cdashline? Jun 20 at 4:14
• @Federico Schardong: You create a new question on this site for your question and I would give you a detailed answer. Jun 20 at 19:16

An alternative solution with tblr environment of tabularray package:

\documentclass{article}

\usepackage{tabularray}

\begin{document}

\begin{tblr}{|c|[dotted]c|[dotted]c|}
\hline
Alpha   & Beta & Gamma   \\
\hline[dotted]
Epsilon & Zeta & Eta     \\
\hline[dotted]
Iota    & Kapp & Lambdaa \\
\hline
\end{tblr}

\end{document}