Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
take a look at this : tex.stackexchange.com/a/10261/26074 –  Hakan Apr 2 '14 at 11:44
    
yes i looked that page, they used arydshln package for getting the dashed line (---------------), but i need dotted lines (...........) –  venkatesan Ramachandiran Apr 2 '14 at 11:47
    
Why are people voting to close this? The question seems pretty clear to me, and there is a decent answer. Just because the OP hasn't accepted it or given any feedback, doesn't mean it should be closed, I don't think. –  Adam Liter Feb 20 at 22:05

2 Answers 2

up vote 5 down vote accepted

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}
\newcommand\dashfrac[1]{\renewcommand\repfrac{#1}}
\setlength\replength{1.5pt}
\newcommand\rulewidth{.6pt}
\newcommand\tdashfill[1][\repfrac]{\cleaders\hbox to \replength{%
  \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]%
}
\newcommand\tdotfill[1][\repfrac]{\cleaders\hbox to \replength{%
  \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}

enter image description here

share|improve this answer

The package arydshln 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)

\documentclass{scrbook}

\usepackage{array}
\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}  

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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