0

I'm experimenting with landscape tables. I came accross this question, and I'm trying to modify it to get fancier tables. I would like to use commands like \toprule, to draw horizontal lines.

Here's my take:

\documentclass{article}

\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{capt-of}% or use the larger `caption` package

\usepackage{lipsum}% dummy text
\begin{document}
\lipsum % Text before
\afterpage{%
    \clearpage% Flush earlier floats (otherwise order might not be correct)
    \thispagestyle{empty}% empty page style (?)
    \begin{landscape}% Landscape page
        \centering % Center table
        \begin{tabular}{llll}
            \toprule
            A & B & C & D \\
            \bottomrule
        \end{tabular}
        \captionof{table}{Table caption}% Add 'table' caption
    \end{landscape}
    \clearpage% Flush page
}
\lipsum % Text after
\end{document}

Which unfortunately does not compile.

I get the following error:

{/usr/local/texlive/2019/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] [2]
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <7> on input line 25.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <5> on input line 25.
! Undefined control sequence.
\AP@ ...centering \begin {tabular}{llll} \toprule 
                                                  A & B & C & D \\ \bottomru...
l.25 \end
         {document}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
<recently read> \bottomrule 

l.25 \end
         {document}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

Any idea tosolve this? I also would like to use tabularx package in a similar fashion.

Best, Andrea

  • 2
    If I add the booktabs package to the preamble, the code compiles just fine on my computer. – leandriis Mar 30 at 19:32
  • @a_bet did the answer meet your requirement – js bibra May 9 at 1:35
0

enter image description here

\documentclass{article}

\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{capt-of}% or use the larger `caption` package
\usepackage{booktabs}%<-----------------------------------ADD
\usepackage{lipsum}% dummy text
\begin{document}
    \lipsum % Text before
%   \afterpage{%
%       \clearpage% Flush earlier floats (otherwise order might not be correct)
%       \thispagestyle{empty}% empty page style (?)
        \begin{landscape}% Landscape page
            \centering % Center table
            \begin{tabular}{lllllllllllllllllll}
                \toprule
                A & B & C & D&&&&&&X&Y&&&&&& \\
                \bottomrule
            \end{tabular}
            \captionof{table}{Table caption}% Add 'table' caption
        \end{landscape}
        \clearpage% Flush page
%   }
    \lipsum % Text after
\end{document}
| improve this answer | |
  • Thanks! But why? In my other document where I use regular tables I don't need that to use \toprule – a_bet Mar 31 at 7:52
  • @a_bet, please show us an example of document with table, which use rules defined in the booktabs package without loading it. – Zarko Apr 30 at 1:51
  • @a_bet in other tables normally \hline is used but with addition of package booktabs the horizontal lines are customized and visually better-- please read the documentation -- request accept the answer if it meets your stated requirement – js bibra Apr 30 at 2:20

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.