2

I'm using longtable. But the caption is too short that it splits up my 12 word caption into two lines centered, only 1/3 of the table width.

I would like to show the caption in one line. Any advice? Below is my code:

\documentclass[a4paper,12pt]{article}
\usepackage{longtable} 
\usepackage{pdflscape} 
\usepackage{graphicx}

\begin{document}
\begin{landscape}
\setlength\LTleft{-40pt}           
\setlength\LTright{-40pt}           
\begin{longtable}{@{\extracolsep{\fill}}llllllllll@{}}
\caption{Why My Caption is Squeezed Here Can I Make The Length Longer?}\\
\hline\hline
Short Name & Full Name  & Source                                     \\
\hline
\\
\hline
\end{longtable}
\end{landscape}
\end{document}
  • Thank you @hooy. I just tried but it gave me error "LaTeX Error: \caption outside float." Any ideas? – sileli Apr 24 '16 at 20:38
3

Add

\setlength\LTcapwidth{\linewidth}

to your code, right after (or before) setting \LTleft and \LTright.

Background: As opposite to the regular \caption the one from longtable is limited to the width \LTcapwidth. When using in portrait mode, the default value is quite reasonable, but too short in landscape mode.

Complete example document:

\documentclass[a4paper,12pt]{article}
\usepackage{longtable} 
\usepackage{pdflscape} 
\usepackage{graphicx}

\begin{document}
\begin{landscape}
\setlength\LTleft{-40pt}    
\setlength\LTright{-40pt}           
\setlength\LTcapwidth{\linewidth}
\begin{longtable}{@{\extracolsep{\fill}}llllllllll@{}}
\caption{Why My Caption is Squeezed Here Can I Make The Length Longer?}\\
\hline\hline
Short Name & Full Name  & Source                                     \\
\hline
\\
\hline
\end{longtable}
\end{landscape}
\end{document}

Shameless self-advertisement: Adding \usepackage{caption} would have solved the issue, too, since it ignores \LTcapwidth (unless set to a specific value).

0

Use \caption package and add the following line into your preamble:

\usepackage{caption}
\captionsetup[table]{labelfont=bf,textfont=normalfont,singlelinecheck=on,justification=raggedright}

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.