4

I have a table where some cells may contain an additional qualifier element right above their contents.

Imagine 3 houses and their owners at certain points in time. Some owners may be related to previous owners as marked in the example below.

MWE:

\documentclass{article}

\usepackage{stackengine}

\begin{document}
  \begin{tabular}{rccc}
  Year & 1 & 2 & 3 \\
  \hline
  1810 & John Doe & John Deere & John Denver \\
  1820 &  &  &  \\
  1830 &  & \stackon{James Deere}{\tiny{(son)}} &  \\
  1840 & \stackon{Jane Doe}{\tiny{(daughter)}} &  &  \\
  1850 &  &  & Jack Johnson \\
  \end{tabular}
\end{document}

example

As you can see, this causes the rows to be of different heights. I would like the relationship qualifiers to extend outside their row and into the row above. I'd prefer not to put them in the actual above cells.

How do I accomplish this?

  • Note you can define \newcommand\relation[2]{\strut\smash{\stackon{#2}{\tiny{(#1)}}}} and use it with an easier syntax as \relation{daughter}{Jane Doe}. – Steven B. Segletes Sep 20 '17 at 12:37
  • Thanks for the suggestion. I ended up doing something similar. – meide Sep 22 '17 at 18:22
6

You can \smash the \stacked-on construction:

enter image description here

\documentclass{article}

\usepackage{stackengine}

\let\oldstackon\stackon

\renewcommand{\stackon}[2]{\strut\smash{\oldstackon{#1}{\tiny(#2)}}}

\begin{document}

\begin{tabular}{ r ccc }
  Year &              1               &           2                &      3       \\
  \hline
  1810 &          John Doe            &       John Deere           &  John Denver \\
  1820 &                              &                            &              \\
  1830 &                              & \stackon{James Deere}{son} &              \\
  1840 & \stackon{Jane Doe}{daughter} &                            &              \\
  1850 &                              &                            & Jack Johnson \\
\end{tabular}

\end{document}

I've introduced some consistency-considerations for your use-case. If you always use a \tiny(..) setup for what is stacked on top, it's best to wrap this inside a macro.

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.