Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

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}
share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.