[Tex/LaTex] How to define caption width in longtable

captionslongtablewidth

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?

Best Answer

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

Related Question