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}}

  • 1
    Related question: Is there a ditto symbol? – diabonas Jul 13 '12 at 20:48
  • What is the column type of description? – Werner Jul 13 '12 at 20:56
  • @diabonas Yes, that is the symbol I'm looking for. However, I would want to center the symbol, in a (To Werner) p{5cm} column type. – cherrung Jul 13 '12 at 20:59
  • 1
    Don't use "ditto marks"; if the value can be inferred from the line above omit it, otherwise write it. You'll do a favor to your readers. :) – egreg Jul 13 '12 at 22:11
  • @egreg How come? Are there certain guidelines? – cherrung Jul 13 '12 at 22:18

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

\usepackage[T1]{fontenc}% http://ctan.org/pkg/fontenc
\usepackage{longtable}% http://ctan.org/pkg/longtable
\usepackage{xhfill}% http://ctan.org/pkg/xhfill

Title & Heading & Description & Blop \\
Bla   & A & no description & Blop \\
Blubb & B & \ditto & Blip  \\
Blop  & C & \ditto & Blubb \\
Blip  & D & \ditto[1pt] & Blop  \\

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.

  • 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: 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

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.