On Sun, Dec 04, 2011 at 07:31:59AM +0800, Daniel Greenhoe wrote:
> When I put a tabular in a footnote, the tabular often is extended
> outside the text area. Besides placing a newline directive after the
> tabular environment, is there anything I can do to prevent this
> behavior? That is, how can I best ensure that tabulars in a footnote
> get typeset completely within the text area? Here is an example:
>
> \documentclass[12pt]{book}
> \usepackage[xetex,a4paper,noheadfoot,nomarginpar,margin=20mm,showframe]{geometry}
> \begin{document}%
> xyz\footnote{%
> %\raisebox{2.5mm}{
> \begin{tabular}[t]{|l|}
> \hline
> abc\\
> def\\
> ghj\\
> klm\\
> \hline
> \end{tabular}%\\
> %}%
> }
> xyz\footnote{%
> %\raisebox{2.5mm}{
> \begin{tabular}[t]{|l|}
> \hline
> abc\\
> def\\
> ghj\\
> klm\\
> \hline
> \end{tabular}%\\
> %}%
> }
> \end{document}%
I don't see a relation to XeTeX, thus the mailing list texhash
might be the better choice for this question.
The following example addresses calculates the shift to align
the baseline of the footnote line with the first line of
the tabular. No time for looking at the problem with the overfull \vbox.
\documentclass[12pt]{book}
\usepackage{array}
\usepackage[
a4paper,noheadfoot,nomarginpar,margin=20mm,showframe
]{geometry}
\usepackage{zref-savepos}
\makeatletter
\newsavebox\tl@box
\newcount\c@tlcount
\setcounter{tlcount}{0}
\def\thetlcount{\the\c@tlcount}
\newenvironment*{tltabular}[1]{%
\stepcounter{tlcount}%
\begin{lrbox}{\tl@box}%
\begin{tabular}[t]{|#1|}%
\hline
\zref@savepos
\zref@labelbyprops{tl@b\thetlcount}{posy}%
\ignorespaces
}{%
\hline
\end{tabular}%
\end{lrbox}%
\zref@refused{tl@a\thetlcount}%
\zref@refused{tl@b\thetlcount}%
\dimen@=\dimexpr
\zposy{tl@a\thetlcount}sp-\zposy{tl@b\thetlcount}sp%
\relax
\raisebox{\dimen@}{%
\zref@savepos
\zref@labelbyprops{tl@a\thetlcount}{posy}%
\box\tl@box
}%
}
\begin{document}%
xyz\footnote{%
\begin{tltabular}{l}
abc\\
def\\
ghj\\
klm\\
\end{tltabular}%\\
}
xyz\footnote{%
\begin{tltabular}{l}
abc\\
def\\
ghj\\
klm\\
\end{tltabular}%\\
}
\end{document}%
Yours sincerely
Heiko Oberdiek
--------------------------------------------------
Subscriptions, Archive, and List information, etc.:
http://tug.org/mailman/listinfo/xetex