I have to typeset a table with different font sizes in different table rows. I am using the approach suggested by Werner in Different font sizes for different rows in table:
\documentclass{standalone}
\usepackage{array}
\usepackage{booktabs}
\usepackage{caption}
\makeatletter
\g@addto@macro{\endtabular}{\rowfont{}}% Clear row font
\makeatother
\newcommand{\rowfonttype}{}% Current row font
\newcommand{\rowfont}[1]{% Set current row font
\gdef\rowfonttype{#1}#1%
}
\newcolumntype{L}{>{\rowfonttype}l}
\begin{document}
\begin{tabular}[t]{ll}
\toprule
Hello & World \\
Hello & World \\
Hello & World \\
Hello & World \\
Hello & World \\
Hello & World \\
\bottomrule
\end{tabular}
\begin{tiny}
\begin{tabular}[t]{ll}
\toprule
Hello & World \\
Hello & World \\
Hello & World \\
Hello & World \\
Hello & World \\
Hello & World \\
\bottomrule
\end{tabular}
\end{tiny}
\begin{tabular}[t]{LL}
\toprule
\rowfont{\tiny}%
Hello & World \\
Hello & World \\
Hello & World \\
\rowfont{\normalsize}%
Hello & World \\
Hello & World \\
Hello & World \\
\bottomrule
\end{tabular}
\end{document}
This gives me the following result:
Apparently, \newfont
works nicely to adjust the font size in the third table, but the height of the table rows is still calculated based on normalsize
. Is there a way to adjust the height of the first three rows of the third table to the "normal" height for tiny
?
Follow-up
David's solution works fine with the MWE I provided. However, using longtable, I get the following:
\documentclass{article}
\usepackage{setspace}
\usepackage{array}
\usepackage{longtable}
\usepackage{threeparttablex}
\usepackage{booktabs}
\usepackage{caption}
\setstretch{1.25}
\renewcommand{\arraystretch}{1.00}
% Use different font sizes in table
\makeatletter
\g@addto@macro{\endtabular}{\rowfont{}}% Clear row font
\makeatother
\newcommand{\rowfonttype}{}% Current row font
\newcommand{\rowfont}[1]{% Set current row font
\gdef\rowfonttype{#1}#1%
}
\newcolumntype{P}{>{\rowfonttype}p}
\begin{document}
\begin{ThreePartTable}
\setstretch{1.00}
\begin{TableNotes}[para,flushleft]
Some caption.
\end{TableNotes}
\begin{footnotesize}
\begin{longtable}{@{}P{1cm}P{1cm}P{1cm}P{1cm}@{}}
\caption{A list}\\
\toprule
\endfirsthead
\captionsetup{labelsep=endash}
\caption[]{\emph{continued from previous page}}\\
\toprule
\endhead
\midrule
\multicolumn{4}{@{}r@{}}{\emph{Continued on next page}} \\
\endfoot
\bottomrule
\insertTableNotes
\endlastfoot
xxx & xxx & xxx & xxx \\
xxx & xxx & xxx & xxx \\
xxx & xxx & xxx & xxx \\
\rowfont{\tiny}%
xxx & xxx & xxx & xxx \\
xxx & xxx & xxx & xxx \\
xxx & xxx & xxx & xxx \ \rowfont{\normalsize}%
\end{longtable}
\end{footnotesize}
\end{ThreePartTable}
\renewcommand\arraystretch{0}
\begin{ThreePartTable}
\setstretch{1.00}
\begin{TableNotes}[para,flushleft]
Some caption.
\end{TableNotes}
\begin{footnotesize}
\begin{longtable}{@{}P{1cm}P{1cm}P{1cm}P{1cm}@{}}
\caption{A list}\\
\toprule
\endfirsthead
\captionsetup{labelsep=endash}
\caption[]{\emph{continued from previous page}}\\
\toprule
\endhead
\midrule
\multicolumn{4}{@{}r@{}}{\emph{Continued on next page}} \\
\endfoot
\bottomrule
\insertTableNotes
\endlastfoot
xxx & xxx & xxx & xxx \\
xxx & xxx & xxx & xxx \\
xxx & xxx & xxx & xxx \\
\rowfont{\tiny}%
xxx & xxx & xxx & xxx \\
xxx & xxx & xxx & xxx \\
xxx & xxx & xxx & xxx \ \rowfont{\normalsize}%
\end{longtable}
\end{footnotesize}
\end{ThreePartTable}
\end{document}
Is there a way to also have the appropriate row height for the tiny
rows here?
Best Answer