TransWikia.com

Problem with 'longtable' caption number with 'sidewaystable' from 'rotating' package

TeX - LaTeX Asked on April 26, 2021

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.

One Answer

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}

Correct answer by Mico on April 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP