2

I have a longtable within a landscape environment. Not sure the landscape is relevant but ...

\begin{landscape}
\begin{longtable}{lll}
 \caption{bla bla bla long ...}
 table & table & table
\end{longtable}
\begin{landscape}

I would like to change the width of the caption that is too narrow for my taste.

I tried with the caption package that is supposed to work within the table environment

\captionsetup{width=5cm}

I also tried to put my caption in a parbox

\parbox{5cm}{\caption{Lorem ipsum dolor sit amet...}}

As proposed here https://stackoverflow.com/questions/3322563/make-latex-table-caption-same-width-as-table

But it does not change anything or throws out an error.

Would you have an idea?

  • I don't know what you're doing but a) your example above does not work at all and b) if I use a small document it works ;-) – user31729 Jan 12 '16 at 16:24
3

The error is most likely due to a wrongly place \captionsetup.

I doubt the usefulness of landscape and longtable but here's an example:

\documentclass{article}

\usepackage{longtable}
\usepackage{lscape}
\usepackage{caption}


\usepackage{blindtext}

\begin{document}

\captionsetup{width=5cm}
\begin{landscape}
\begin{longtable}{lll}
 \caption{\blindtext} 
\endfirsthead
 table & table & table \tabularnewline
 table & table & table \tabularnewline 
 table & table & table \tabularnewline
 table & table & table \tabularnewline
 table & table & table \tabularnewline 
 table & table & table \tabularnewline
 table & table & table \tabularnewline
 table & table & table \tabularnewline 
 table & table & table \tabularnewline
 table & table & table \tabularnewline
 table & table & table \tabularnewline 
 table & table & table \tabularnewline
 table & table & table \tabularnewline
 table & table & table \tabularnewline 
 table & table & table \tabularnewline
 table & table & table \tabularnewline
 table & table & table \tabularnewline 
 table & table & table \tabularnewline
 table & table & table \tabularnewline
 table & table & table \tabularnewline 
 table & table & table \tabularnewline
 table & table & table \tabularnewline
 table & table & table \tabularnewline 
 table & table & table \tabularnewline
 table & table & table \tabularnewline
 table & table & table \tabularnewline 
 table & table & table \tabularnewline
 table & table & table \tabularnewline
 table & table & table \tabularnewline 
 table & table & table \tabularnewline
 table & table & table \tabularnewline
 table & table & table \tabularnewline 
 table & table & table \tabularnewline
\end{longtable}
\end{landscape}
\end{document}

enter image description here

  • Hum I feel rather stupid right now. Actually, I used \captionsetup within the table and not outside of it! And yes, sorry for the example given a little too quickly. No need for \tabularnewline though. So thanks, it's working now :-) – tuculuxu Jan 12 '16 at 16:50
  • @tuculuxu The \captionsetup should work inside the longtable. If not, this is a bug and should be reported... I just tried it out using the test document above; placing \captionsetup{...} right before \caption inside the longtable works fine here. If you have a document where it does not, please report. – Axel Sommerfeldt Nov 2 at 9:18
0

As indicated in the documents of longtable package. You can

Set the width of the caption with a command such as \setlength{\LTcapwidth}{2in} in the preamble of your document.

For example, to fit the caption length to table width (equals to textwidth), you can do

\setlength{\LTcapwidth}{\textwidth}

Then it should be work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.