1

I am creating longtables rotated sideways with sidewaystable from rotating package. I am shocked and irritated to see that it is increasing table reference numbers 2 at a time! If I am adding the \caption{}s before the longtable, it is starting from Table No. 1 and the next Table No. is 3. On the other hand, if I am adding \caption{} after the longtable, it is starting from Table No. 2 and the next Table No. is 4. Following is an MWE:

\documentclass{book}
\usepackage{longtable}
\usepackage{rotating}
\begin{document}
    \begin{sidewaystable}
%       \caption{text}
        \begin{longtable}{cc}
            a & b
        \end{longtable}
        \caption{text}
    \end{sidewaystable}
    \begin{sidewaystable}
%       \caption{text}
        \begin{longtable}{cc}
            a & b
        \end{longtable}
        \caption{text}
    \end{sidewaystable}
\end{document}

I want to place my table caption below the table and want the table referencing in the natural order (reset after a chapter). Please help.

PS: I also have tables in tabular, tabularx, tabular* and longtable (without sidewaystable) modes in my original document.

4
  • 2
    In a long table, the \caption command is inside the long table environment, usually in the firsthead section, so that readers do not have to turn pages to discover the table title.
    – Bernard
    Jan 17, 2021 at 17:25
  • 4
    As far as I know, the contents of a sidewaystable can not be broken across pages, so placing a longtable which can break across pages in such an unbreakable environment does not make much sense. To get a longtable on a landscape page, use landscape from pdflscape.
    – leandriis
    Jan 17, 2021 at 17:25
  • 1
    longtable in sidewaystable does not make sense as you can have no page breaking inside sidewaystable. So no need to be shocked or irritated, just fix your document. Jan 17, 2021 at 20:34
  • Yes. I understand that now. Thank you everyone for the help. Actually I am working with a LOT of tables in my document and struggling to fit each one of them properly using different methods. This particular table had many rows and columns which did not look good in the longtable format in the the portrait mode. So I rotated that sideways to fit in one page using sidewaystable forgetting completely about inappropriate application of longtable. This was due to more of an inertial mental block. I have changed that to tabular* and is fine now. Thanks again for your efforts. Jan 18, 2021 at 6:04

1 Answer 1

2

sidewaystable environments, like table environments, cannot span more than a page. Hence, it's not a good idea to embed a longtable environment in a sidewaystable environment.

Do load the pdflscape package, though, employ its landscape environment, and embed the longtable environment in the landscape environment.

\documentclass{book}
\usepackage{longtable}
\usepackage{pdflscape} % for 'landscape' env.
\begin{document}
\begin{landscape}
    \begin{longtable}{cc}
        
        \caption{text} \\
        \hline
        \endhead
        
        \hline
        \endfoot
        
        a & b \\
        c & d 
    \end{longtable}     
\end{landscape}
\end{document}
1
  • Thank you so much for your help. Please see my comment upwards for posting this silly question. Though not relevant now, but your answer may help me in typesetting even bigger tables in future. Thanks again. Jan 18, 2021 at 6:09

You must log in to answer this question.

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