4

I'd like to create a list of default font sizes. The list should not just include the point values, but the actual LaTeX commands used in achieving those sizes.

Problem

The baselines are not equal on each respective line in the example.

Example

\documentclass{article}
\usepackage{fontspec}
\usepackage[margin=3cm]{geometry}
\makeatletter
\newcommand\thefontsize[1]{{#1 The current font size is: \f@size pt\par}}
\makeatother
\begin{document}
\section{Font Sizes}
\thefontsize\tiny \hfill tiny\\
\thefontsize\scriptsize \hfill scriptsize\\
\thefontsize\footnotesize \hfill footnotesize\\
\thefontsize\small \hfill small\\
\thefontsize\normalsize \hfill normalsize\\
\thefontsize\large \hfill large\\
\thefontsize\Large \hfill Large\\
\thefontsize\LARGE \hfill LARGE\\
\thefontsize\huge \hfill huge\\
\thefontsize\Huge \hfill Huge\\
\end{document}

2 Answers 2

6

It depends on what you mean by “The baselines are not equal on each respective line in the example”: they can't be equal if you don't set the baseline equal to the one needed for the largest size.

If you instead want that the leading (the distance between lines) is the same in all cases, you need to disable the interline skip mechanism and set \lineskip to the amount you wish.

Note that \par uses the value of \baselineskip that's current at the moment \par is executed; for both realizations, just use \par outside the group in which you typeset the sample line.

\documentclass{article}
\usepackage[margin=3cm]{geometry}

\makeatletter
\newcommand\thefontsize[1]{%
  {#1 The current font size is: \f@size pt \hfill\texttt{\string#1}}\par}
\makeatother

\begin{document}
\section{Font Sizes}

\begingroup\Huge\setlength{\parindent}{0pt}
\thefontsize\tiny
\thefontsize\scriptsize
\thefontsize\footnotesize
\thefontsize\small
\thefontsize\normalsize
\thefontsize\large
\thefontsize\Large
\thefontsize\LARGE
\thefontsize\huge
\thefontsize\Huge
\endgroup

\bigskip
\begingroup\offinterlineskip\setlength{\lineskip}{4pt}
\thefontsize\tiny
\thefontsize\scriptsize
\thefontsize\footnotesize
\thefontsize\small
\thefontsize\normalsize
\thefontsize\large
\thefontsize\Large
\thefontsize\LARGE
\thefontsize\huge
\thefontsize\Huge
\endgroup


\end{document}

enter image description here

1
  • Ah \string, the missing ingredient! (and of course the \offinterlineskip) Commented Mar 29, 2015 at 13:29
0

Well, I discovered my own problem. Just remove \par from the custom command \thefontsize. From my understanding, \par ends the baseline for a given line.

\documentclass{article}
\usepackage{fontspec}
\usepackage[margin=3cm]{geometry}
\makeatletter
\newcommand\thefontsize[1]{{#1 The current font size is: \f@size pt}}
\makeatother
\begin{document}
\section{Font Sizes}
\thefontsize\tiny \hfill tiny\\
\thefontsize\scriptsize \hfill scriptsize\\
\thefontsize\footnotesize \hfill footnotesize\\
\thefontsize\small \hfill small\\
\thefontsize\normalsize \hfill normalsize\\
\thefontsize\large \hfill large\\
\thefontsize\Large \hfill Large\\
\thefontsize\LARGE \hfill LARGE\\
\thefontsize\huge \hfill huge\\
\thefontsize\Huge \hfill Huge\\
\end{document}

In my attempt to achieve my goal, I experimented with adding literal information to my commands such that I could print the input variable (e.g. \Huge). I ended up with some unexpected results.

Added listings package

Changed command to:

\makeatletter
\newcommand\thefontsize[1]{{#1 The current font size is: \f@size pt\hfill\lstinline|test|\par}}
\makeatother

enter image description here

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .