4

Could you help me align Text2, within tabular and textblock*, to the baseline of Text1?

Would be much appreciated.

\documentclass{article}
\usepackage[absolute,overlay]{textpos}

\begin{document}
\begin{textblock*}{30mm}(30mm,30mm)
    Text1
\end{textblock*}

\begin{textblock*}{30mm}(30mm,30mm)
\begin{tabular}[t]{@{}l}
    Text2
\end{tabular}
\end{textblock*}

\end{document}

enter image description here

6

Struts are added in the lines of a tabular. If \arraystretch is not redefined, \strut can be added:

\documentclass{article}
\usepackage[absolute,overlay]{textpos}

\begin{document}
\begin{textblock*}{30mm}(30mm,30mm)
    Text1\strut
\end{textblock*}

\begin{textblock*}{30mm}(30mm,30mm)
\begin{tabular}[t]{@{}l}
    Text2
\end{tabular}
\end{textblock*}

\end{document}

Otherwise:

\documentclass{article}
\usepackage[absolute,overlay]{textpos}

\renewcommand*{\arraystretch}{1.2}

\newcommand*{\arstrut}{%
  \vrule height\arraystretch\ht\strutbox
         depth\arraystretch\dp\strutbox
         width0pt\relax
}

\begin{document}
\begin{textblock*}{30mm}(30mm,30mm)
    Text1\arstrut
\end{textblock*}

\begin{textblock*}{30mm}(30mm,30mm)
\begin{tabular}[t]{@{}l}
    Text2
\end{tabular}
\end{textblock*}

\end{document}

Result

Update: Reverse the correction by moving the tabular block.

\documentclass{article}
\usepackage[absolute,overlay]{textpos}

\renewcommand*{\arraystretch}{1.2}

\begin{document}
\begin{textblock*}{30mm}(30mm,30mm)
    Text1
\end{textblock*}

\begin{textblock*}{30mm}(30mm,30mm)
\settoheight{\dimen0}{Text1}%
\kern\dimen0\relax
\kern-\arraystretch\ht\strutbox\relax
\begin{tabular}[t]{@{}l}
    Text2
\end{tabular}
\end{textblock*}

\end{document}
  • Thanks a lot! Would it be possible to have normal text height in tabular? Your solution aligns Text1 to baseline of Text2, which is not exactly the same as aligning Text2 to baseline of Text1. – Frank Seifert Sep 8 '12 at 22:29
  • Great update! . – Frank Seifert Sep 8 '12 at 22:49

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.