0

for my thesis I have several long tables, thus I'm using xltabular. I need to add captions below the tables, but this seems to be possible only if I put it in a table environment :

\begin{table}
\begin{small}
    \begin{xltabular}{\linewidth}{|X|X|X|}
        \hline
        text & text & text \\ 
        \hline
        text & text & text \\
        \hline
    \end{xltabular} 
\caption{example}
\end{small}
\end{table}

This provides the right table output (caption below not above table}, but now the float option doesn't seem to work anymore; the table apprears in the wrong place. I tried adding [!h], but nothing works, except removing the table environment which makes my caption disappear when placed below the table.

In other cases, I also have footnotes in the tables. Before, I used tabularx and it worked well (except that the numbering of the tables was wrong, that's why I'm using xltabular now), but with the xltabular environment, the footnotes appear on the wrong page.

Any idea what I can do to solve this issue?

Here is part of my code :

\documentclass[openany,ngerman]{book}
\usepackage[main=french,italian, spanish, portuguese, latin, greek]{babel}
\usepackage[small]{dgruyter}
\usepackage{microtype}
\baretabulars

\usepackage{fontspec}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{graphicx,lmodern}
\usepackage{enumitem}
\usepackage{slantsc}
\usepackage{float}
\usepackage{tablefootnote}
\usepackage{tabularx}
\usepackage{xltabular}
\usepackage{array}
\usepackage{caption}
\usepackage{makecell}
\usepackage{multirow}
\usepackage{ltablex}

\begin{document}
\begin{small}
    \begin{xltabular}{\linewidth}{|X|X|X|}
        \hline
        text\footnotemark{} & text & text \\
        \hline
    \end{xltabular} 
\end{small}
\caption{text}
\footnotetext{Cf. ci-dessus \ref{reconstructionmorphologiqueI} pour l'explication de la place de l'accent.}
 \end{table}

\end{document}

I'd appreciate your help very much.

  • 1
    xltabular is intended to be used when you want the table to split across several pages. Such a table can not be placed inside of a table environment. – leandriis May 09 '20 at 09:44
  • 1
    Also, small is not an environment. – leandriis May 09 '20 at 09:45
  • 1
    Side note regarding: "Before, I used tabularx and it worked well (except that the numbering of the tables was wrong, that's why I'm using xltabular now)," This is not because you used tabularx but due to the ltablex package that you added to the preamble. If you want to use xltabular, remove `ltablex. (For an explanation see also: https://tex.stackexchange.com/a/375104/134144) – leandriis May 09 '20 at 09:51

1 Answers1

1

If you want to use xltabular, place the \caption inside of the xltabular environment and add a \\ after the caption. To place the caption below the table (on the last page of the table), add \endlastfoot after the \caption. In the following MWE, I have also replaced the non-existant small environment by the \small command. (Make sure, you surround \small and the xltabular with a set of {}.

Side note: As a reader, I would expect a table's caption above as opposed to below a table. This is especially true for tables spanning multiple pages.

\documentclass[openany,ngerman]{book}

\usepackage{xltabular}
\usepackage{caption}

\begin{document}

{\small
    \begin{xltabular}{\linewidth}{|X|X|X|}
    \caption{text} \label{key}\\
    \endlastfoot
        \hline
        text\footnotemark{} & text & text \\
        \hline
    \end{xltabular} 
}
\footnotetext{Cf. ci-dessus \ref{reconstructionmorphologiqueI} pour l'explication de la place de l'accent.}


\end{document}
Bernard
  • 271,350
leandriis
  • 62,593