1

This code:

\documentclass[12pt]{article}
\begin{document}

\noindent
\begin{minipage}[t]{0.5\textwidth}
  \hrule
  TEXT TEXT TEXT TEXT TEXT
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
  \hrule
  \begin{tabular}[t]{rc}
    TEXT & TEXT \\
    TEXT & TEXT \\
  \end{tabular}
\end{minipage}

\end{document}

produces two side-by-side minipages that start with a horizontal line. The left minipage contains ordinary text. The right minipage contains a table. The horizontal lines are at the same height. The baselines of the text are not:

enter image description here

I want that the baseline of the ordinary text (on the left) is the same as the baseline of the text in the first cell of the table (on the right). This would require either moving the text down, or moving the text in the table up.

What I tried:

  • \renewcommand\arraystretch{0} eliminates the top padding, but it also eliminates the bottom padding and changes the height of the cells
  • Setting \arraystretch to 0 and then replacing table rows by

    TEXT & TEXT \\[0.5ex]
    

    seems to eliminate the top padding and to do roughly what I want, but I would prefer to not contaminate every line of the table with non-DRY magic numbers.

What would be the proper way to align the baselines in the text (left) and the table (right)?

7
  • 1
    Do you really want the rule touches the text on the left side?
    – Bernard
    Mar 5 '19 at 19:50
  • @Bernard The horizontal lines are merely supposed to show that the minipages are aligned properly. I the end of the day, I don't want to have any horizontal lines at all. All I want is to make the baselines of text on the left be the same as the baseline of the text on the right. The extra whitespace prevents this from happening. My assumption is that the whitespace marked with red arrows is some kind of table cell padding. I want to set it to zero, somehow. Mar 5 '19 at 19:57
  • The simplest solution would be to slightly lower the text on the left side: just add a \strut before the text.
    – Bernard
    Mar 5 '19 at 20:16
  • the following mwe works perfectly: \documentclass[12pt]{article} \begin{document} \begin{minipage}[t]{0.22\linewidth} TEXT TEXT \end{minipage}\begin{minipage}[t]{0.22\linewidth} \begin{tabular}[t]{cc} TEXT & TEXT \\ TEXT & TEXT \\ \end{tabular} \end{minipage} \end{document}. it seems that unknown option H in tabular environment cause (together with hrule) troubles ...
    – Zarko
    Mar 5 '19 at 20:44
  • 1
    BTW, tabular is not a float, so no H option. The t/b/c option controls where the baseline is placed: top line, bottom line or center. Default is center. Mar 6 '19 at 16:33
3

Here is an explicitation of my comment: adding a strut in the first line of the left-hand side tex lowers this line exactly at the same level as the first row of the tabular:

\documentclass[12pt]{article}
\begin{document}

\noindent
\begin{minipage}[t]{0.5\textwidth}
  \hrule
  \strut TEXT TEXT TEXT TEXT TEXT

\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
  \hrule
  \begin{tabular}[H]{rc}
    TEXT & TEXT \\
    TEXT & TEXT \\
  \end{tabular}
\end{minipage}

\end{document} 

enter image description here

0

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.