[XeTeX] tabular in footnote

Heiko Oberdiek heiko.oberdiek at googlemail.com
Mon Dec 5 09:16:19 CET 2011


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 at box
\newcount\c at tlcount
\setcounter{tlcount}{0}
\def\thetlcount{\the\c at tlcount}
\newenvironment*{tltabular}[1]{%
  \stepcounter{tlcount}%
  \begin{lrbox}{\tl at box}%
  \begin{tabular}[t]{|#1|}%
  \hline
  \zref at savepos
  \zref at labelbyprops{tl at b\thetlcount}{posy}%
  \ignorespaces
}{%
  \hline
  \end{tabular}%
  \end{lrbox}%
  \zref at refused{tl at a\thetlcount}%
  \zref at refused{tl at b\thetlcount}%
  \dimen@=\dimexpr
    \zposy{tl at a\thetlcount}sp-\zposy{tl at b\thetlcount}sp%
  \relax
  \raisebox{\dimen@}{%
    \zref at savepos
    \zref at labelbyprops{tl at a\thetlcount}{posy}%
    \box\tl at 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


More information about the XeTeX mailing list