I want to put different sizes of fonts (smaller) into different rows of my LaTeX table. I found that it is possible to have different font sizes for different columns of this post. Is there any simple way to put different fonts to LaTeX table rows ?
-
See also https://tex.stackexchange.com/a/26364/94816 – Watson Mar 29 '21 at 11:55
3 Answers
You can use the package tabu which provides the command \rowfont:
\documentclass{article}
\usepackage{tabu}
\begin{document}
\begin{tabu}{ll}
\rowfont{\scriptsize}
Hello & World \\
Foo & Bar \\
\rowfont{\huge}
Hello & World
\end{tabu}
\end{document}
- 11,466
- 95,681
-
1Too bad
tabuis no longer maintained. Not recommended to use anymore. https://github.com/tabu-issues-for-future-maintainer/tabu – Gherman Mar 08 '21 at 12:50
I tested all other methods above with packages but I found this simple method by David most useful -- actually I got all kind of malfunctioning with other answers such as only one element in a row changed the size of the text and so on, this may be due to rotating's sidewaystable but anyway -- this most simplest method works!
\footnotesize \begin{tabular} then \normalsize\bfseries hello for the title
and other fontsizes contain \tiny, \scriptsize, \footnotesize, \small, \normalsize, \large, \Large, \LARGE, \huge and \Huge. More in here.
- 8,743
-
3(+1) would you please provide a mwe in your answer. many thanks. – Hosein Rahnama Sep 21 '17 at 16:50
Creating your own \rowfont{<font>} switch is also possible.
Using the array package, you can insert elements in front of every column via the definition of a new column type. This insertion helps span the group associated with each tabular cell.

\documentclass{article}
\usepackage{array}% http://ctan.org/pkg/array
\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}{LL}
\rowfont{\scriptsize}%
Hello & World \\
\rowfont{\normalsize}%
Foo & Bar \\
\rowfont{\huge}%
Hello & World
\end{tabular}
\end{document}
\rowfont{<font>} globally (re)defines \rowfonttype, and also inserts it into the current cell. Resetting the font is required in a subsequent row (via \rowfont{\normalsize} or otherwise).
End-of-tabular resetting is automated by appending \rowfont{} to \endtabular.
-
1
-
@Alenanno: One may have to tap into the definition of
\tabularwhere\\is defined and add\rowfont{}similar to what was done for\endtabular. – Werner May 10 '15 at 17:06 -
-
If you use
\makecell(from makecell package) in one cell, the font size stops being applied from that cell on unless also including\rowfontin that cell. – pcworld Aug 24 '21 at 18:15