1

I'm trying to follow an example from the kaobook documentation (4.3):

The caption of a longtable is always positioned below the table, and it has the same width as the text (it doesn’t extend into the margin). However, sometimes you may need a longtable that is so wide that it trespass into the margins; in those cases, you may want to also increase the width of the caption. To do so, you’ll have to write two additional commands, one before and one after the longtable.

The example is given as:

\floatsetup[longtable]{margins=centering,LTcapwidth=table} % Add this line before the longtable to increase the caption width
\begin{longtable}{lp{8cm}p{5cm}p{2cm}}
...
\end{longtable}
\floatsetup[longtable]{margins=raggedright,LTcapwidth=\textwidth}
% Add this line after the longtable to revert the previous change

I tried to replicate this example. However, it doesn't seem to work:

Misaligned caption in longtable environment

\floatsetup[longtable]{margins=centering,LTcapwidth=table}
\begin{longtable}{lp{8cm}p{5cm}p{2cm}}
    \hline
    One & Two & Three \\
    Left & Center & Center \\
    \hline
    \caption{\textbf{longtable}---\blindtext}
\end{longtable}
\floatsetup[longtable]{margins=raggedright,LTcapwidth=\textwidth}

I was expecting the caption to align with the table to the left and have full width.

The same applies to xltabular:

Misaligned caption in xltabular environment

\floatsetup[xltabular]{margins=centering,LTcapwidth=table}
\begin{xltabular}{17cm}{lp{8cm}p{5cm}p{2cm}}
    \hline
    One & Two & Three \\
    Left & Center & Center \\
    \hline
    \caption{\textbf{xltabular}---\blindtext}
\end{xltabular}
\floatsetup[xltabular]{margins=raggedright,LTcapwidth=\textwidth}

How can I achieve a full-width caption from an xltabular in kaobook?

6
  • you should show a complete example. When I extend your code with some basic preamble it works fine: i.sstatic.net/p0oCT.png. Commented Jan 12 at 9:25
  • @UlrikeFischer care to share the basic preamble?
    – mritz_p
    Commented Jan 12 at 15:46
  • 2
    no, it is your job to provide a minimal example of your problem. Commented Jan 12 at 16:08
  • @mritz_p I can confirm that the example works fine in a minimal example, so I don't know why it doesn't work for you. Have you tried running your example code completely on its own in a separate .tex file? There is almost no preamble code needed for it to successfully compile.
    – bonk
    Commented Jan 16 at 5:32
  • If you really want to have your problem solved, as the bounty suggests, why don't you provide a minimal working example, from \documentclass to \end{document}, that illustrates the problem and would enable people to help? As the comments show, the issue is not related to the code snippets that you show, so there is now way people on this site can contribute.
    – gernot
    Commented Jan 16 at 9:35

0

Browse other questions tagged .