[Tex/LaTex] How to change font size of longtable-lines without changing font size of caption

captionsfontsizekoma-scriptlongtabletables

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}

Best Answer

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.