I'm writing my thesis with the document class scrbook from koma-script and want to use the package ltablex (= longtable + tabularx) for setting long tables with automatic page break calculation.
Now, I'm struggling with two problems:
- Why is the caption a bit longer than
\linewidth(please see minimal document below)? - Why do I get an latex error when I use
\caption[short]{long caption}with ltxtable?
Thank you very much for your help in advance!
% Please find below a minimal latex document, that shows the problem
%
\RequirePackage[l2tabu,orthodox]{nag}
\documentclass[pagesize=pdftex,ngerman,english,paper=a5,fontsize=10pt,%
DIV=calc,BCOR=4mm,twoside,headinclude,footinclude,open=right,%
parskip=half,numbers=noenddot,headings=small]{scrbook}
% Geometry
\usepackage[showframe]{geometry} % showframes for debugging reasons
% Input and font encoding, Babel
\usepackage{cmap}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman,english]{babel}
\usepackage{lmodern,textcomp}
% Tables
\usepackage[NewCommands]{ragged2e}
\usepackage{array}
\usepackage{tabularx,longtable,ltablex}
\usepackage{booktabs}
% Misc. packages
\usepackage[pdftex,final]{graphicx}
\usepackage{amsmath,bm}
\usepackage[babel,final]{microtype}
\usepackage{fixltx2e,ellipsis}
\usepackage{subfigure}
\usepackage{acronym}
% Hyperref
\usepackage[pdftex=true,pdfpagemode=UseNone,pdfpagelayout=TwoPageRight,%
pdfcenterwindow=true,pdffitwindow=true,colorlinks=true]{hyperref}
% Note: Not all of the above packages are used in this minimal example. They
% are included for debug reasosn, because they are used in the final
% document.
% ----------------------------------------------------------------------------
\begin{document}
%\listoftables
\chapter{First Chapter}
\begin{tabularx}{\linewidth}{XXXX}
%This is the caption of the table...
\caption{Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.} \\ % This works.
%\caption[Lorem ipsum]{Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.} \\ % This doesn't works!
%This is the header for the first page of the table...
\toprule
\textbf{A} & \textbf{B} & \textbf{C} & \textbf{D} \\
\midrule
\endfirsthead
%This is the header for the remaining page(s) of the table...
\multicolumn{4}{l}{{\tablename} \thetable{}: \ldots Continued from previous page} \\
\toprule
\textbf{A} & \textbf{B} & \textbf{C} & \textbf{D} \\
\midrule
\endhead
%This is the footer for all pages except the last page of the table...
\midrule
\multicolumn{4}{r}{Continued on next page\ldots} \\
\midrule
\endfoot
%This is the footer for the last page of the table...
\bottomrule
\endlastfoot
%Now the data...
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
1 & 2 & 3 & 4 \\
\end{tabularx}
\end{document}