4

I have a table illustrating a row in a table, like this:

\begin{table}
    \begin{tabular}{|l|l|l|}
        Cell 1 & Cell 2 & Cell 3 \\
    \end{tabular}
    %caption, label ++
\end{table}

How can I best make dashed lines up/down at the top/bottom of the table, to indicate that there are more rows? Desired output will be something like this:

enter image description here

The dashed lines between cell 1&2 and 2&3 are not strictly necessary.

I know I can achieve this with TikZ but I would like to know if there is a way to do it with the tabular environment or something similar.

  • @AndrewSwann thanks I guess? I've used the site (and all of SE) a lot, first question here... – Hans Petter Taugbøl Kragset Sep 22 '17 at 11:42
6

Of course you have read the booktabs documentation and know you should not be using vertical lines anyway, so you could just put \vdots in the cells above and below. For example,

No verts sample

\documentclass{article}

\usepackage{booktabs}

\begin{document}

\begin{table}
  \begin{tabular}{lll}
    \multicolumn{1}{c}{\vdots}&\multicolumn{1}{c}{\vdots}&\multicolumn{1}{c}{\vdots}\\
    \midrule
    Cell 1 & Cell 2 & Cell 3 \\
    \midrule
    \multicolumn{1}{c}{\vdots}&\multicolumn{1}{c}{\vdots}&\multicolumn{1}{c}{\vdots}
  \end{tabular}
\end{table}
\end{document}

Anyway, given that you wish to persist with vertical lines a relatively simply way to do this is to use \multicolumns to restyle cells and to place \vdots at the boundaries:

Sample output

\documentclass{article}

\usepackage{array}

\begin{document}
\begin{table}
  \begin{tabular}{|l|l|l|}
    \multicolumn{1}{@{\vdots}c}{}&\multicolumn{1}{@{\vdots}c}{}&\multicolumn{1}{@{\vdots}c@{\vdots}}{}\\
    \hline
    Cell 1 & Cell 2 & Cell 3 \\
    \hline
    \multicolumn{1}{@{\vdots}c}{}&\multicolumn{1}{@{\vdots}c}{}&\multicolumn{1}{@{\vdots}c@{\vdots}}{}\\
  \end{tabular}
\end{table}
\end{document}

Note that there is some misalignment here, which can be overcome by using a version of \vdots without width:

\newcommand{\narrowvdots}{\hbox to 0pt{\hss\vdots\hss}}

You can do this with dashes as follows:

Dashed sample

\documentclass{article}

\usepackage{array}

\newcommand{\myvdashes}{\raisebox{1ex}{\oalign{\vrule height 1ex\cr\vrule height
1ex\cr \vrule height 1ex}}}

\begin{document}
\begin{table}
  \begin{tabular}{|l|l|l|}
    \multicolumn{1}{@{\myvdashes}c@{\myvdashes}}{}&\multicolumn{1}{c@{\myvdashes}}{}&\multicolumn{1}{c@{\myvdashes}}{}\\
    \hline
    Cell 1 & Cell 2 & Cell 3 \\
    \hline
    \multicolumn{1}{@{\myvdashes}c@{\myvdashes}}{}&\multicolumn{1}{c@{\myvdashes}}{}&\multicolumn{1}{c@{\myvdashes}}{}
  \end{tabular}
\end{table}
\end{document}
  • Thanks, the last approach is very neat. I will wait a bit and accept if no one else has a different (better) approach. – Hans Petter Taugbøl Kragset Sep 22 '17 at 12:02

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.