Graphics, Figures & Tablesltablex | Multi-column Problem

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
guitarmanjon
Posts: 8
Joined: Tue Jul 12, 2011 12:39 pm

ltablex | Multi-column Problem

Post by guitarmanjon »

Hi

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}
I've also attached a couple of PDFs showing the results. The file mwe_ltablex.pdf shows the result with a small amount of text in the multicolumn command. The file mwe_ltablex_wrong.pdf shows the result I get when I put in a more realistic amount of text.

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
Attachments
mwe_ltablex_wrong.pdf
PDF result with lots of text in the multicolumn command.
(71.86 KiB) Downloaded 196 times
mwe_ltablex.pdf
PDF result with a small amount of text in multicolumn.
(68.29 KiB) Downloaded 211 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

guitarmanjon
Posts: 8
Joined: Tue Jul 12, 2011 12:39 pm

ltablex | Multi-column Problem

Post by guitarmanjon »

I now have an answer thanks to Herbert over at tex.stackexchange.com. Here is a link to his response:
http://tex.stackexchange.com/questions/ ... 6976#26976
Thanks
jon
Post Reply