Under LaTeX, one should avoid the TeX primitive \font and instead use the lower-level font selection method documented in the fntguide. Computer Modern Roman (cmr) is the default font. Selecting the font size can be done depending either on the base font size:
Code: Select all
\documentclass[10pt]{article}% This is the default of article.
\usepackage{booktabs}
\newcommand*{\thefontsize}{}
\newcommand*{\getfontsize}[1]{%
#1\strut\csname f@size\endcsname\,pt
}
\newcommand*{\fontsizerow}[1]{\texttt{\string#1} & \getfontsize#1 }
\begin{document}
\begin{tabular}{@{}lr@{}}
\toprule
Font size command & resulting size \\
\midrule
\fontsizerow\tiny\\
\fontsizerow\scriptsize\\
\fontsizerow\footnotesize\\
\fontsizerow\small\\
\fontsizerow\normalsize\\
\fontsizerow\large\\
\fontsizerow\Large\\
\fontsizerow\LARGE\\
\fontsizerow\huge\\
\fontsizerow\Huge\\
\bottomrule
\end{tabular}
And always (not) working: {\fontsize{22pt}{27pt}\selectfont\strut 22\,pt \textbf{bold}}.
\end{document}
or
Code: Select all
\documentclass[11pt]{article}
\usepackage{booktabs}
\newcommand*{\thefontsize}{}
\newcommand*{\getfontsize}[1]{%
#1\strut\csname f@size\endcsname\,pt
}
\newcommand*{\fontsizerow}[1]{\texttt{\string#1} & \getfontsize#1 }
\begin{document}
\begin{tabular}{@{}lr@{}}
\toprule
Font size command & resulting size \\
\midrule
\fontsizerow\tiny\\
\fontsizerow\scriptsize\\
\fontsizerow\footnotesize\\
\fontsizerow\small\\
\fontsizerow\normalsize\\
\fontsizerow\large\\
\fontsizerow\Large\\
\fontsizerow\LARGE\\
\fontsizerow\huge\\
\fontsizerow\Huge\\
\bottomrule
\end{tabular}
And always (not) working: {\fontsize{22pt}{27pt}\selectfont\strut 22\,pt \textbf{bold}}.
\end{document}
or
Code: Select all
\documentclass[12pt]{article}
\usepackage{booktabs}
\newcommand*{\thefontsize}{}
\newcommand*{\getfontsize}[1]{%
#1\strut\csname f@size\endcsname\,pt
}
\newcommand*{\fontsizerow}[1]{\texttt{\string#1} & \getfontsize#1 }
\begin{document}
\begin{tabular}{@{}lr@{}}
\toprule
Font size command & resulting size \\
\midrule
\fontsizerow\tiny\\
\fontsizerow\scriptsize\\
\fontsizerow\footnotesize\\
\fontsizerow\small\\
\fontsizerow\normalsize\\
\fontsizerow\large\\
\fontsizerow\Large\\
\fontsizerow\LARGE\\
\fontsizerow\huge\\
\fontsizerow\Huge\\
\bottomrule
\end{tabular}
And always (not) working: {\fontsize{22pt}{27pt}\selectfont\strut 22\,pt \textbf{bold}}.
\end{document}
Why is there the "(not)" in the last sentence? Because of these warnings in the log-file:
Code: Select all
LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size <22> not available
(Font) size <20.74> substituted on input line 27.
LaTeX Font Warning: Font shape `OT1/cmr/bx/n' in size <22> not available
(Font) size <20.74> substituted on input line 27.
LaTeX Font Warning: Size substitutions with differences
(Font) up to 1.26pt have occurred.
The reason for these warning is: Computer Modern Roman has discrete font design sizes. So usually not all sizes are available in LaTeX. However there are two methods to solve this:
- Add
\RequirePackage{fix-cm}
before \documentclass
.
- Use a scalable font, e.g., adding
\usepackage{lmodern}
somewhere between \documentclass[…]{article}
and \begin{document}
So either:
Code: Select all
\RequirePackage{fix-cm}
\documentclass[10pt]{article}% This is the default of article.
\usepackage{booktabs}
\newcommand*{\thefontsize}{}
\newcommand*{\getfontsize}[1]{%
#1\xdef\thefontsize{\csname f@size\endcsname}%
\strut\thefontsize\,pt
}
\newcommand*{\fontsizerow}[1]{\texttt{\string#1} & \getfontsize#1 }
\begin{document}
\begin{tabular}{@{}lr@{}}
\toprule
Font size command & resulting size \\
\midrule
\fontsizerow\tiny\\
\fontsizerow\scriptsize\\
\fontsizerow\footnotesize\\
\fontsizerow\small\\
\fontsizerow\normalsize\\
\fontsizerow\large\\
\fontsizerow\Large\\
\fontsizerow\LARGE\\
\fontsizerow\huge\\
\fontsizerow\Huge\\
\bottomrule
\end{tabular}
And always working: {\fontsize{22pt}{27pt}\selectfont\strut 22\,pt \textbf{bold}}.
\end{document}
or
Code: Select all
\documentclass[10pt]{article}% This is the default of article.
\usepackage{lmodern}
\usepackage{booktabs}
\newcommand*{\thefontsize}{}
\newcommand*{\getfontsize}[1]{%
#1\xdef\thefontsize{\csname f@size\endcsname}%
\strut\thefontsize\,pt
}
\newcommand*{\fontsizerow}[1]{\texttt{\string#1} & \getfontsize#1 }
\begin{document}
\begin{tabular}{@{}lr@{}}
\toprule
Font size command & resulting size \\
\midrule
\fontsizerow\tiny\\
\fontsizerow\scriptsize\\
\fontsizerow\footnotesize\\
\fontsizerow\small\\
\fontsizerow\normalsize\\
\fontsizerow\large\\
\fontsizerow\Large\\
\fontsizerow\LARGE\\
\fontsizerow\huge\\
\fontsizerow\Huge\\
\bottomrule
\end{tabular}
And always working: {\fontsize{22pt}{27pt}\selectfont\strut 22\,pt \textbf{bold}}.
\end{document}
would do it.
Note, if you are using a different base font, you may have so use
\fontfamily
to select Computer Modern Roman.
See the fntguide and a proper introduction to LaTeX for more information about font selection commands with LaTeX.