First post requesting some help, please be gentle!
I am trying to use ltablex. It works fine except when I put in a multicolumn command with lots of text in. Putting a lot of text in a multicolumn command causes the text and the table to run off of the side of the page.
I've attached a MWE which includes all the packages I am using to still get this problem and make the MWE work (my full thesis has many more packages but I went through taking each one out to see if the problem resolved...it didn't).
Code: Select all
% ************ Preamble ****************
\documentclass[a4paper,12pt]{report}
\usepackage[top=2cm, bottom=2cm, left=3.5cm, right=2cm]{geometry} % sets margins
\usepackage{natbib} % for harvard style referencing
\usepackage[margin=10pt, labelfont=bf, format=hang, textfont={small,it}]{caption} % for more interesting captions
\captionsetup[subfigure]{style=default, margin=0pt, labelfont=bf, textfont={small,it}, singlelinecheck=true} % makes subfigure captions a bit more interesting.
\usepackage{multirow} % allows merging of rows in tables
\usepackage{ltablex} % Combines tabularx and longtable functionality
\usepackage{booktabs} % For professional looking tables
% *********** BEGIN! ******************
\begin{document}
\begin{center}
\begin{tabularx}{\textwidth}{p{4cm} p{2.5cm} X}
\caption{My table which I would like to be a summary of some MATLAB\textsuperscript{\textregistered} functions. The table will span a number of pages.}\\
% First page header of table
\toprule
\textbf{Training function} &
\textbf{MATLAB\textsuperscript{\textregistered} code} &
\textbf{Description} \\
\midrule
\endfirsthead
%subsequent page header of table
\toprule
\textbf{Training function} &
\textbf{MATLAB\textsuperscript{\textregistered} code} &
\textbf{Description} \\
\midrule
\endhead
%footer for all but last page of table
\multicolumn{3}{r}{\small\sl continued on next page\ldots}\\
\bottomrule
\endfoot
%footer for last page of table
\bottomrule
\endlastfoot
% Table contents
Some text & \texttt{train} & null.\\
More text & \texttt{traingd} & null\\
A bit more text & \texttt{traingdm} & null\\
\multicolumn{3}{l}{Here is the text that is too long for the table. If I insert ``null'' instead of all this text, the table is fine. However, the text I would like to put in here is about 100 words long. Repeat: Here is the text that is too long for the table. If I insert ``null'' instead of all this text, the table is fine. However, the text I would like to put in here is about 100 words long. Repeat: Here is the text that is too long for the table. If I insert ``null'' instead of all this text, the table is fine. However, the text I would like to put in here is about 100 words long.}\\
\multirow{3}{*}{Multirow Text} & Text & Blah \\
& blah & blah \\
& more blah & blah \\
\label{label}
\end{tabularx}
\end{center}
\end{document}
Any pointers on this problem would be greatly appreciated. The documentation I have found for ltablex isn't very detailed (includes an example and that is all). Google has failed to turn up any solutions.
Many thanks in advance
jon