0

floatrow settings seem to break xltabular but only in certain cases. If all columns have X, it will work with no problem. Also note that tabularx is not impacted.

Consider the following MWE:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{tabularx}
\usepackage{xltabular}
\usepackage{floatrow}
\usepackage{booktabs}

\floatsetup[table]{font = small, capposition = top}

\begin{document} \begin{xltabular}{\linewidth}{|ccX|} \caption{Not correct.} \ \toprule 1 & 2 & 3 \ \bottomrule \end{xltabular} \begin{xltabular}{\linewidth}{|ccX|} \caption{Not correct either.} \ \toprule 1 longer text & 2 emmm & 3 \ \bottomrule \end{xltabular}

\begin{xltabular}{\linewidth}{|XXX|} \caption{But this works.} \ \toprule 1 longer text & 2 emmm & 3 \ \bottomrule \end{xltabular}

\null

\begin{table}[h] \caption{No problem for \texttt{tabularx}.} \begin{tabularx}{\linewidth}{|ccX|} \toprule 1 longer text & 2 emmm & 3 \ \bottomrule \end{tabularx} \end{table}

\end{document}

Result

1 Answers1

0

Here is the solution after I look into the .sty source files.

floatrow and xltabular all have some definitions about \LTxxx, so loading floatrow before xltabular can solve the width issue. Some related discussions about floatrow and longtable is here.

The side effect is that the font setting in \floatsetup does not apply now. As a workaround, we can \renewenvironment the xltabular to hard code the font size into it.

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{tabularx}
\usepackage{floatrow}
\usepackage{xltabular}
\usepackage{booktabs}

\makeatletter \renewenvironment{xltabular}[1][x]% {% \small % <-- font size change \par \if l#1% \LTleft\z@ \LTright\fill \else\if r#1% \LTleft\fill \LTright\z@ \else\if c#1% \LTleft\fill \LTright\fill \fi\fi\fi \let\TX@endtabularx=\XLT@ii@TX@endtabularx \let\endtabularx\endxltabular \XLT@ii@tabularx} {\def@currenvir{tabularx}} \makeatletter

\floatsetup[table]{font = small, capposition = top}

\begin{document} \begin{xltabular}{\linewidth}{|ccX|} \caption{Not correct.} \ \toprule 1 & 2 & 3 \ \bottomrule \end{xltabular} \begin{xltabular}{\linewidth}{|ccX|} \caption{Not correct either.} \ \toprule 1 longer text & 2 emmm & 3 \ \bottomrule \end{xltabular}

\begin{xltabular}{\linewidth}{|XXX|} \caption{But this works.} \ \toprule 1 longer text & 2 emmm & 3 \ \bottomrule \end{xltabular}

\null

\begin{table}[h] \caption{No problem for \texttt{tabularx}.} \begin{tabularx}{\linewidth}{|ccX|} \toprule 1 longer text & 2 emmm & 3 \ \bottomrule \end{tabularx} \end{table}

ALL is working now.

\end{document}

Correct Result