3

I'm including a longtable with LTXtable and the last rule is not spanning over all columns. Instead, it has about 60% width and centers.

I get the following warning:

Package longtable Warning: Column widths have changed(longtable)
Package longtable Warning: Table widths have changed. Rerun LaTeX.

If I rerun the build (I'm using Sublime Text and LatexTools) the warning appears again.

MWE:

main.tex

\documentclass{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{longtable}
\usepackage{ltxtable}
\usepackage{booktabs}

% Column Type for Table
\newcolumntype{L}[1]{>{\hsize=#1\hsize\raggedright\arraybackslash}X}%

\begin{document}
\chapter{First Chapter}
\LTXtable{\textwidth}{Tables/table.tex}
\end{document}

table.tex

\renewcommand{\arraystretch}{1.5}
\fontsize{10}{11}
\begin{longtable}{L{0.33}L{0.33}L{0.33}}
\caption[Spielermotivationen nach Yee]{Spielermotivationen nach Yee\footnotemark}\label{tab:yeeMotivation}\\
\midrule
\endfirsthead

\caption[]{fortgesetzt} \\
\midrule
\endhead

\midrule 
\multicolumn{3}{r}{{Fortgesetzt auf nächster Seite}} \\ 
\endfoot

\midrule
\multicolumn{3}{r}{{Ende der Tabelle}} \\ 
\endlastfoot

\textbf{Achievement} & \textbf{Social} & \textbf{Immersion} \\
Advancement\linebreak\footnotesize Progress, Power, Accumulation, Status & Socializing\linebreak\footnotesize Casual chat, helping others, making friends & Discovery\linebreak\footnotesize Exploration, Lore, Finding hidden things \\

\end{longtable}
\normalsize

MWE - midrule not spanning to full width

How do I fix the \midrule at the end of the table?

0

2 Answers 2

3

Regarding the warning about \multicolumns in the ltxtable manual, I think, you should get rid of those entries, that span more than one column. At least, changing that, helped a lot.

I also took freedom, to change some other (mostly typographic relevant) things.

  1. You should not decrease the font size in your table, otherwise you tend to render it unreadable.
  2. If you use commands like \fontsize{10pt}{11pt}, you have to use \selectfont to active the changes.
  3. I am not sure, what your newly defined L-columntype shall do. Especially the part \hsize=#1\hsize. Even more, as you hand over 0.33 as content of #1. I would have suspected, that #1 must be a fully qualified dimension (i. e. it must have a dimension like pt). I replaced it with some slightly simpler column declaration.
  4. Your table should have only one \caption-command. Using it on the subsequent parts of the table is somewhat dangerous.
  5. You may use @{}to get rid of the unnecessary white margins left and right of the table. I inserted them in your header, if you don't mind. In case you don't mind, be careful to repeat those declarations on \multicolumns, which strive the first or last column. If you forget the @{}there, the \multicolumn will demolish your clean look of the table head.
  6. To save typing, I replaced the repeated L{0.33}-declarations by *{3}{L}.
  7. After having changed the fontsize to 10 pt, you can not restore the default value by typing \normalsize, as \normalsize was already set to 10pt@11pt by your above command. In case, you wanted to restore the normal fontsize due to your \footnotesize-command in the table: this has also no effect, as \footnotesize was captured inside the table and has therefore no effect to the outside of the table.

One more hint: If you plan to have more than those three columns, making them hence smaller and smaller, you should think about loading the package ragged2eand replacing the \raggedright of the column-declaration with \RaggedRight. The latter command will be able, not only to wrap lines between words, but also inbetween words by using the correct hyphenations. This will give better filled columns.

Here is my corrected MWE (using the filecontents-environment, to glue both files into one file:

\documentclass{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{longtable}
\usepackage{ltxtable}
\usepackage{array}
\usepackage{booktabs}

% Column Type for Table
% \newcolumntype{L}[1]{>{\hsize=#1\hsize\raggedright\arraybackslash}X}%
\newcolumntype{L}{>{\raggedright\arraybackslash}X}%

%% New:
%% Extra file within this file.
\begin{filecontents}{table.tex}
\renewcommand{\arraystretch}{1.5}
%\fontsize{10}{11}\selectfont %% <--- you need to use \selctfont in
                             %% order to make your font selection work
\begin{longtable}{@{} *{3}{L} @{}} %% <--- save typing
\caption[Spielermotivationen nach Yee]{Spielermotivationen nach
  Yee\footnotemark}
\label{tab:yeeMotivation}\\

\toprule  % <--- use the correct rulers
\endfirsthead

% \caption[]{fortgesetzt} \\ <--- your table should have only one caption!
\midrule
\multicolumn{1}{@{} l}{Fortsetzung \dots}\\
\endhead

\midrule
&& \multicolumn{1}{r @{}}{Fortsetzung auf nächster Seite} \\
\endfoot

\midrule
&& \multicolumn{1}{r @{}}{Ende der Tabelle} \\
\bottomrule % <--- correct ruler
\endlastfoot

\textbf{Achievement} & \textbf{Social} & \textbf{Immersion} \\
Advancement\newline
  Progress, Power, Accumulation, Status
& Socializing\newline
  Casual chat, helping others, making friends
& Discovery\newline
  Exploration, Lore, Finding hidden things \\

\end{longtable}
% \normalsize % <--- you don't need this, as \footnotesize was
% enclosed in the table.  Switching back to 10 or 12 pt fontsize as
% default font size, will not be sufficient to restore the original
% value!
\end{filecontents}


\begin{document}
\chapter{First Chapter}
\LTXtable{\textwidth}{table.tex}
\end{document}

And the result (to prove my words):

enter image description here

0
3

If you alter \hsize in an X column, then you need to make sure that the total width of the X columns is unchanged. so if, as here, you have 3 X then if you halve two of them (L{0.5}) then you need to double the third (L{2}) so that the total width of the 3 columns is .5+.5+2=3 times the width of a standard X.

You have L{.33}L{.33}L{.33} so 3 X columns but with a total width of less than 1 standard X. That will completely confuse tabularx and as seen here, make it fail to converge to any sensible values. You should use L{1} if you want all the columns the same width (as Jan already showed in his answer).

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .