2

I would like to have 2 very simple tables like these:

\begin{center}
  \begin{tabular}{rl}
         text:&text2\\
              &text3\\
    something:&other stuff
  \end{tabular}
  \vspace{\stretch{2}}
  \begin{tabular}{rl}
                             text:&text2\\
                                  &text3\\
    something of different length:&other stuff
  \end{tabular}
\end{center}

to be aligned. This answers that question: Two tables vertically align but it does not work with \stretch{X} because the stretch within the tabular environment seems to be ignored. Is there another way to align those two tables? I need the \stretch{2} between these two tables, because other stuff on that title page is of varying height and I don't want to hard code some values and recalculate them every time the rest of that page changes.

4
  • force the first column to be of fixed width say p{3cm} and use \raggedleft in that column to get right alignment instead of r as they are fixed width column, alignment is automatic Nov 28, 2014 at 14:35
  • the alignment would be automatic if I use fixed width for both columns, as the both tables are supposed to be centred they have to be of exact same width to be aligned. But I think I might go with that, and just centre the middle of the columns.
    – Garonenur
    Nov 28, 2014 at 14:54
  • I don't understand what the \vspace{\stretch{2}} is supposed to do. If the two tables fit on one line, the vertical space will be after the two tables. What alignment do you have in mind?
    – egreg
    Nov 28, 2014 at 16:16
  • they don't fit on one line, and \vspace{\stretch{x}} allows for variable vertical space, where the x is the amount of variable units latex can use to evenly spread all \stretch{x} spaces. My original page includes more then the two tabular things, but extracting a complete example from a huge document, especially when the title page configuration I am working on is within a class was to much work :).
    – Garonenur
    Dec 1, 2014 at 10:25

2 Answers 2

3

A couple of possibilities:

enter image description here

\documentclass{article}
\usepackage{array,longtable}

\begin{document}

\begin{center}
  \begin{tabular}{>{\raggedleft}p{4cm}>{\raggedright\arraybackslash}p{4cm}}
         text:&text2\\
              &text3\\
    something:&other stuff
  \end{tabular}

  \vspace{\stretch{2}}

  \begin{tabular}{>{\raggedleft}p{4cm}>{\raggedright\arraybackslash}p{4cm}}
                             text:&text2\\
                                  &text3\\
    something of different length:&other stuff
  \end{tabular}
\end{center}

zzzzzzzzzzzzzzzzzzzzzzzzzzz

  \begin{longtable}{rl}
         text:&text2\\
              &text3\\
    something:&other stuff\\
  \noalign{\vspace{\stretch{2}}}
                             text:&text2\\
                                  &text3\\
    something of different length:&other stuff
\end{longtable}

\end{document}
4
  • right now, in the document were I want to use this I get ! Use of \@array doesn't match its definition. errors if I use the >{} column specification, I will have to try the longtables one!
    – Garonenur
    Nov 28, 2014 at 15:18
  • I forgot to use \RequirePackage{array}. Your first Solution works, too now. (Writing a class here)
    – Garonenur
    Nov 28, 2014 at 15:25
  • I endet up using the first solution, the second does not seem to work in my case, all vspace on my titlepage gets ignored with the longtable, not only the space within in.
    – Garonenur
    Nov 28, 2014 at 15:38
  • @Garonenur impossible to say why that should happen. Note I posted full document, fragments aren't useful for reproducing things, but anyway you have something working:-) Nov 28, 2014 at 15:52
0

one possible way:

\begin{center}
  \begin{tabular}{rl}
         text:&text2\\
              &text3\\
    something:&other stuff\\
    \hphantom{something of different length}&\hphantom{other stuff?}
  \end{tabular}
  \vspace{\stretch{2}}
  \begin{tabular}{rl}
                             text:&text2\\
                                  &text3\\
    something of different length:&other stuff\\
    \hphantom{something of different length}&\hphantom{other stuff?}
  \end{tabular}
\end{center}

the problem with this answer is to know which line is the longest on the left hand side of both tables and similar for the right hand side. If those text elements are variable, too, it gets complicated.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .