15

I'd like to change the font size of all contents of a longtable to footnotesize. However the rest of the document and also the caption (!) shall be (stay) in normal size. (pdflatex is used)

How can I do that?

  • I tried to put the \footnotesizecommand outside the longtable-environment, but then the caption is also smaller.
  • If I put the command in before the first line of the table, it is only executed for the first cell of the table.
  • If I put it before \endoffirsthead, I get an error message during compiling.

EDIT: I don't want to be the whole document to be in \footnotesize, but only the content of the tables!

Minimal example:

\documentclass{scrbook}  
\usepackage{longtable, booktabs}  
\begin{document}

\begin{longtable}{ccc}
\caption{This is the caption of the table which shall be normal size!}\\ 
\toprule
aaaaaaa & bbbbbb & ccccccccc\\  
\midrule  
 a & b & c\\  
a & b & c\\
a & b & c\\  
a & b & c\\  
a & b & c\\  
a & b & c\\  
\bottomrule  
\end{longtable}
David Carlisle
  • 757,742

4 Answers4

11

Since you are using a KOMA-Script document class you can simply use \setkomafont or \addtokomafont to set the size of the caption(s):


\documentclass[captions=tableheading]{scrbook}
\usepackage{longtable, booktabs}

\setkomafont{caption}{\normalsize}

\begin{document}

\begingroup
\footnotesize
\begin{longtable}{ccc}
\caption{This is the caption of the table which shall be normal size!}\\
\toprule
aaaaaaa & bbbbbb & ccccccccc\\
\midrule
 a & b & c\\
a & b & c\\
a & b & c\\
a & b & c\\
a & b & c\\
a & b & c\\
\bottomrule
\end{longtable}
\endgroup

\end{document}

For other document classes one can include the caption package. Simply including is sufficient since \normalsize is the default caption size here (at least since version 3.1):


\documentclass{book}
\usepackage{longtable, booktabs}

\usepackage[tableposition=t]{caption}

\begin{document}

\begingroup
\footnotesize
\begin{longtable}{ccc}
\caption{This is the caption of the table which shall be normal size!}\\
\toprule
aaaaaaa & bbbbbb & ccccccccc\\
\midrule
 a & b & c\\
a & b & c\\
a & b & c\\
a & b & c\\
a & b & c\\
a & b & c\\
\bottomrule
\end{longtable}
\endgroup

\end{document}

If someone is not using a KOMA-Script document class, but don't want to use the caption package either, one can give the ltcaption package a try which is part of the caption package bundle but patches the captioning stuff for longtables only:


\documentclass{book}
\usepackage{longtable, booktabs}

\usepackage{ltcaption}
% The ltcaption package supports \CaptionLabelFont & \CaptionTextFont
% introduced by the NTG document classes
\renewcommand\CaptionLabelFont{\normalsize}
\renewcommand\CaptionTextFont{\normalsize}

\begin{document}

\begingroup
\footnotesize
\begin{longtable}{ccc}
\caption{This is the caption of the table which shall be normal size!}\\
\toprule
aaaaaaa & bbbbbb & ccccccccc\\
\midrule
 a & b & c\\
a & b & c\\
a & b & c\\
a & b & c\\
a & b & c\\
a & b & c\\
\bottomrule
\end{longtable}
\endgroup

\end{document}
6

You can modify the definition of \LT@makecaption in such a way that it uses \normalsize; since you are using scrbook one has to use its definition. I'll define a new environment that will make things easier.

\documentclass{scrbook}  
\usepackage{longtable, booktabs,etoolbox}

\makeatletter
\newenvironment{longtable*}[1]
  {%
    \renewcommand{\LT@makecaption}[3]{%
      \noalign{%
        \if@captionabove
          \vskip\belowcaptionskip
        \else
          \vskip\abovecaptionskip
        \fi
      }%
      \LT@mcol\LT@cols c{%
        \hbox to\z@{\normalsize\hss\parbox[t]\linewidth{%
            \@@makecaption{##1}{##2}{##3}%
            \endgraf
            \if@captionabove
              \vskip\abovecaptionskip
            \else
              \vskip\belowcaptionskip
            \fi
          }%
          \hss
        }%
      }%
    }%
   #1\begin{longtable}}
  {\end{longtable}}
\makeatother
\begin{document}
\hrule

\begin{longtable*}{\footnotesize}{ccc}
\caption{This is the caption of the table which shall be normal size!}\\ 
\toprule
aaaaaaa & bbbbbb & ccccccccc\\  
\midrule  
 a & b & c\\  
a & b & c\\
a & b & c\\  
a & b & c\\  
a & b & c\\  
a & b & c\\  
\bottomrule  
\end{longtable*}

\begin{longtable}{ccc}
\caption{This is the caption of the table which shall be normal size!}\\ 
\toprule
aaaaaaa & bbbbbb & ccccccccc\\  
\midrule  
 a & b & c\\  
a & b & c\\
a & b & c\\  
a & b & c\\  
a & b & c\\  
a & b & c\\  
\bottomrule  
\end{longtable}
\end{document}

The syntax of the longtable* environment is simple: it takes as argument the desired size of the table's body; the usual argument to longtable follows. I've left the two examples to show the difference.

David Carlisle
  • 757,742
egreg
  • 1,121,712
3

You can do global change by keeping the following three lines in the preamble:

\usepackage[font=normalsize]{caption}     %% make caption in normal size
\usepackage{etoolbox}
\AtBeginEnvironment{longtabu}{\footnotesize}{}{}   %% change all longtabu content to foot note size

as answered by Harish Kumar here in this question

Khaaba
  • 1,848
  • 1
  • 22
  • 34
2

You may try the new LaTeX3 package tabularray:

\documentclass{scrbook}

\usepackage{tabularray} \UseTblrLibrary{booktabs}

\begin{document}

\begin{longtblr}[ caption = {This is the caption of the table which shall be normal size!}, ]{colspec={ccc},rows={font=\footnotesize}} \toprule aaaaaaa & bbbbbb & ccccccccc \
\midrule
a & b & c \
a & b & c \ a & b & c \
a & b & c \
a & b & c \
a & b & c \
\bottomrule
\end{longtblr}

\end{document}

enter image description here

L.J.R.
  • 10,932