7

When I have a table, where one row has the same content as above, is there a representation for that in latex?

In Germany we sometimes use ------- " -------- to say that the line here is the same as above.

So instead of having this:

| title | description          |
| Bla   | no description       |
| Blubb | no description       |
| Blop  | no description       |
| Blip  | no description       |

Have something like this:

| title | description          |
| Bla   | no description       |
| Blubb | ---------"---------- |
| Blop  | ---------"---------- |
| Blip  | ---------"---------- |

Maybe not with the dashed line, but a straight line. Is there a command for that or any other way to say that one line is above the other, without writing "see above"?

Forgot to mention: I use the longtable environment. My column types are {c|lp{4cm}p{4cm}}

cherrung
  • 3,759

1 Answers1

9

Here's a draft of what you might be after, using the xhfill package (for leaders) and \textquotedbl (via the T1 encoding from fontenc, as suggested in Is there a ditto symbol?):

enter image description here

\documentclass[a4paper]{scrartcl}
\usepackage[T1]{fontenc}% http://ctan.org/pkg/fontenc
\usepackage{longtable}% http://ctan.org/pkg/longtable
\usepackage{xhfill}% http://ctan.org/pkg/xhfill
\newcommand{\ditto}[1][.4pt]{\xrfill{#1}~\textquotedbl~\xrfill{#1}}
\begin{document}

\begin{longtable}{c|lp{4cm}p{4cm}}
\hline
Title & Heading & Description & Blop \\
Bla   & A & no description & Blop \\
Blubb & B & \ditto & Blip  \\
Blop  & C & \ditto & Blubb \\
Blip  & D & \ditto[1pt] & Blop  \\
\hline
\end{longtable}
\end{document}​

xhfill is not really required, but it's small enough to use as-is. The default width of the leader/rule drawn by \xrfill is .4pt according to the definition of \ditto[<width>], unless specified otherwise.

Moriambar
  • 11,466
Werner
  • 603,163
  • Very nice. My textquotedbl results in curved quotes, instead of straigt ones. Is there a way to force straight ones? And I noticed that the lines are pretty close to the top row, especially if the text in a preceding column spans multiple rows. Is it possible to have a top margin? – cherrung Jul 13 '12 at 21:49
  • If, by "pretty close to the top row" you mean that the leader (horizontal line) is "too high", you can use \xrfill[.7ex]{#1} in your definition of \ditto instead. \xrfill takes an optional argument that raises the horizontal leader (default is 1ex). – Werner Jul 13 '12 at 22:00
  • 2
    It may also be feasible to use \renewcommand{\textquotedbl}{\texttt{"}} if you don't want to use a different font encoding that supplies \textquotedbl (like T1 does). – Werner Jul 13 '12 at 22:00
  • Thanks for the advice with \renewcommand. By "too close" I actually mean that if I have an \hline both the hline and the \ditto are very close to each other. See: http://d.pr/i/OHbM Would be nice to have a "top margin". – cherrung Jul 13 '12 at 22:06
  • Perhaps try this definition of \ditto: \newcommand{\ditto}[1][1ex]{\xrfill[.7ex]{.4pt}~\rule{0pt}{#1}\textquotedbl~\xrfill[.7ex]{.4pt}} and then you can use \ditto[\normalbaselineskip] for the first row with an \hline above it, and just \ditto everywhere else. The optional argument to \ditto now takes a length that denotes the vertical strut inserted rather than the width of the leader. The width is now fixed to .4pt (the usual LaTeX default rule width). – Werner Jul 13 '12 at 22:15
  • Yes, I like that, but was wondering, if it is also possible to just align it vertically? So that it's horizontally AND vertically aligned? – cherrung Jul 14 '12 at 08:18
  • @cherrung: You can move \textquotedbl up/down using \strut\smash{\raisebox{<len>}{\textquotedbl}} where you specify any <len>. The \strut is in lieu of the zero-height \smash, although it may not be entirely necessary since there's content on the same row in other cells. – Werner Jul 14 '12 at 13:19