Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
thanks a lot! I've used this solution (and hope it will not have any unseen side effects) –  Martin Jul 16 '11 at 12:56
add comment

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.