[XeTeX] Problem with bidi + longtable + caption packages

David Carlisle d.p.carlisle at gmail.com
Wed Oct 21 14:28:37 CEST 2015


The caption wasn't really centred (hard to tell as the text was short)
it is a justified paragraph (set in a centred box) the problem is that
bidi doesn't "patch" the caption code to add \beginR it redefines the
standard one, so over-writing the caption package changes.


The following simply preserves the longtable/caption package version
of \caption when bidi is loaded  (so it doesn't get patched to right
to left usage, so you may need to add \beginR \endR explicitly in a
right to left caption, patching automatically might be tricky as you
have to cope with caption, ltcaption, longtable and bidi being loaded
or not, in different package loading orders.

\documentclass{report}

\usepackage{longtable}
%Tell the caption pkg to do ragged right at load time:
\usepackage[singlelinecheck=off
           ,justification=raggedright
           ]{caption}
\usepackage{ltcaption}
\LTcapwidth=\linewidth
\makeatletter
\let\temp\LT at makecaption
\usepackage{bidi}
\let\LT at makecaption\temp
%Tell the caption pkg again:
\captionsetup{singlelinecheck=off
             ,justification=raggedright
             }

\begin{document}

\begin{table}
\caption{A normal table
xxxx xxxx xxxx xxxx xxxx xxxxxxxx
xxxx xxxx xxxx xxxx xxxx xxxxxxxx
xxxx xxxx xxxx xxxx xxxx xxxxxxxx
xxxx xxxx xxxx xxxx xxxx xxxxxxxx
}
\end{table}

\begin{longtable}{llll}
\caption{A long table
xxxx xxxx xxxx xxxx xxxx xxxxxxxx
xxxx xxxx xxxx xxxx xxxx xxxxxxxx
xxxx xxxx xxxx xxxx xxxx xxxxxxxx
xxxx xxxx xxxx xxxx xxxx xxxxxxxx
}%Should be ragged right, but is centered instead
\tabularnewline
 {AAAA} & {BBBB} & {CCCC} & {DDDD}
\tabularnewline
\end{longtable}

\end{document}


More information about the XeTeX mailing list