5

I was searching here to find a way to change the font size from normal to \footnotesize for the longtabu tables. However, the answer in longtable question didn't work in my case. They made corrections for scriptbook style.

Basically, the question is the same: I want to change the font size of the main text in table without changing the caption size. Here is the example I tried to use what have been suggested: {\footnotesize ... } But it makes the caption footnotesized.

Here is the MWE:

\documentclass[12pt,oneside]{report} 
\usepackage{tabu}
\usepackage{longtable}
\usepackage{booktabs, multicol, multirow}

\begin{document}
\chapter{Minimum Working Example}
Composition of samples
{\footnotesize
\begin{longtabu} to \linewidth{X[l3.0] X[c] X[c] X[c] X[c] X[c]} 
\caption{Composition of samples} \\ 
\toprule
\textbf{Component} & \textbf{Text1} & \textbf{Text2} & \textbf{Text3} & \textbf{Text4} & \textbf{Text5} \\
\midrule
H$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
O$_2$   & 0.38  & 0.10  & 0.30  & 0.91  & 0.99 \\
C$_1$    & 11.98 & 11.30 & 10.98 & 11.94 & 11.09 \\
C$_2$    & 0.44  & 0.39  & 0.43  & 0.91  & 0.33 \\
N$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
S$_2$    & 0.81  & 0.81  & 0.81  & 0.11  & 0.83 \\
C$_3$    & 9.19  & 9.01  & 9.10  & 9.84  & 9.18 \\
H$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
O$_2$   & 0.38  & 0.10  & 0.30  & 0.91  & 0.99 \\
C$_1$    & 11.98 & 11.30 & 10.98 & 11.94 & 11.09 \\
C$_2$    & 0.44  & 0.39  & 0.43  & 0.91  & 0.33 \\
N$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
S$_2$    & 0.81  & 0.81  & 0.81  & 0.11  & 0.83 \\
C$_3$    & 9.19  & 9.01  & 9.10  & 9.84  & 9.18 \\
H$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
O$_2$   & 0.38  & 0.10  & 0.30  & 0.91  & 0.99 \\
C$_1$    & 11.98 & 11.30 & 10.98 & 11.94 & 11.09 \\
C$_2$    & 0.44  & 0.39  & 0.43  & 0.91  & 0.33 \\
N$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
S$_2$    & 0.81  & 0.81  & 0.81  & 0.11  & 0.83 \\
C$_3$    & 9.19  & 9.01  & 9.10  & 9.84  & 9.18 \\
H$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
O$_2$   & 0.38  & 0.10  & 0.30  & 0.91  & 0.99 \\
C$_1$    & 11.98 & 11.30 & 10.98 & 11.94 & 11.09 \\
C$_2$    & 0.44  & 0.39  & 0.43  & 0.91  & 0.33 \\
N$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
S$_2$    & 0.81  & 0.81  & 0.81  & 0.11  & 0.83 \\
C$_3$    & 9.19  & 9.01  & 9.10  & 9.84  & 9.18 \\
\bottomrule
\end{longtabu}}

\end{document}
  • 1
    Please reduce your MWE to a minimum. Is the csm.sty having any effect on your desired result? Remove all packages you don't need for this question. tabu to multirow should already be enough here. Do you want all tabus or all longtabus or just this one to be scriptsize? – LaRiFaRi Mar 8 '14 at 22:15
4

I've cut your code down a bit for demonstration purposes, to make it a bit more minimal. But one way to do this is to specify the font size for each entry through the setup of the longtabu environment. For example:

\documentclass{report}
\usepackage{tabu}
\usepackage{longtable}
\usepackage{booktabs}

\begin{document}

Composition of samples

\begin{longtabu} to \linewidth{>{\footnotesize}X[l3.0] *{5}{>{\footnotesize}X[c]}}
\caption{Composition of samples} \\
\toprule
\textbf{Component} & \textbf{Text1} & \textbf{Text2} & \textbf{Text3} & \textbf{Text4} & \textbf{Text5} \\
\midrule
H$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
\bottomrule
\end{longtabu}

\end{document}

Because the declaration \footnotesize affects only the relevant column, it does not affect the caption. However, you do need to specify it for each column. If you have several consecutive columns with the same definition, however, you can combine those using the *{<number>}{<column specification>} syntax as I've done for 5 of the 6 columns in this case.

This produces:

Footnotesize text in <code>longtabu</code> with regular sized caption

3

You can take help from caption package to keep captions in normal font size. To ease the conversion of \footnotesize inside all longtabu environments, you can employ \AtBeginDocument macro from etoolbox package. This means, you don't have to type \footnotesize inside all longtabu environments. The essence is, add the following in your preamble:

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

Full code:

\documentclass[12pt,oneside]{report}
\usepackage{tabu}
\usepackage{longtable}
\usepackage{booktabs, multicol, multirow}
\usepackage[font=normalsize]{caption}
\usepackage{etoolbox}
\AtBeginEnvironment{longtabu}{\footnotesize}{}{}

\begin{document}
\chapter{Minimum Working Example}
Composition of samples

\begin{longtabu} to \linewidth{X[l3.0] X[c] X[c] X[c] X[c] X[c]}
\caption{Composition of samples} \\
\toprule
\textbf{Component} & \textbf{Text1} & \textbf{Text2} & \textbf{Text3} & \textbf{Text4} & \textbf{Text5} \\
\midrule
H$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
O$_2$   & 0.38  & 0.10  & 0.30  & 0.91  & 0.99 \\
C$_1$    & 11.98 & 11.30 & 10.98 & 11.94 & 11.09 \\
C$_2$    & 0.44  & 0.39  & 0.43  & 0.91  & 0.33 \\
N$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
S$_2$    & 0.81  & 0.81  & 0.81  & 0.11  & 0.83 \\
C$_3$    & 9.19  & 9.01  & 9.10  & 9.84  & 9.18 \\
H$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
O$_2$   & 0.38  & 0.10  & 0.30  & 0.91  & 0.99 \\
C$_1$    & 11.98 & 11.30 & 10.98 & 11.94 & 11.09 \\
C$_2$    & 0.44  & 0.39  & 0.43  & 0.91  & 0.33 \\
N$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
S$_2$    & 0.81  & 0.81  & 0.81  & 0.11  & 0.83 \\
C$_3$    & 9.19  & 9.01  & 9.10  & 9.84  & 9.18 \\
H$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
O$_2$   & 0.38  & 0.10  & 0.30  & 0.91  & 0.99 \\
C$_1$    & 11.98 & 11.30 & 10.98 & 11.94 & 11.09 \\
C$_2$    & 0.44  & 0.39  & 0.43  & 0.91  & 0.33 \\
N$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
S$_2$    & 0.81  & 0.81  & 0.81  & 0.11  & 0.83 \\
C$_3$    & 9.19  & 9.01  & 9.10  & 9.84  & 9.18 \\
H$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
O$_2$   & 0.38  & 0.10  & 0.30  & 0.91  & 0.99 \\
C$_1$    & 11.98 & 11.30 & 10.98 & 11.94 & 11.09 \\
C$_2$    & 0.44  & 0.39  & 0.43  & 0.91  & 0.33 \\
N$_2$   & 3.94  & 3.81  & 4.03  & 3.88  & 4.01 \\
S$_2$    & 0.81  & 0.81  & 0.81  & 0.11  & 0.83 \\
C$_3$    & 9.19  & 9.01  & 9.10  & 9.84  & 9.18 \\
\bottomrule
\end{longtabu}

\end{document}

enter image description here

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.