3

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}
1
  • Thank you @hooy. I just tried but it gave me error "LaTeX Error: \caption outside float." Any ideas?
    – lsl__
    Apr 24, 2016 at 20:38

2 Answers 2

5

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).

1
  • It appears caption also ignores LTleft, so the caption no longer aligns with the table. Feb 26, 2020 at 14:44
0

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .