3

I was reading this question and I was wondering whether there is any package in LaTeX compatible with PDFtex that returns the name of the font, not the family font as an alphanumeric string. What comes to mind is using this list here or the documentation for fontname on texdoc; however, I haven't been able to find a command that does what I want. The reason is that I'm teaching an introductory course to LaTeX and I have this font comparison file:

\documentclass[12pt]{article}

\usepackage{ae}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage[margin=1.7cm]{geometry}
\usepackage{pgffor}

\newlength{\la}
\setlength{\la}{0.21\textwidth}

\begin{document}
%%%%%%%%%%%%%%%%%

\noindent
\foreach \fuent in {ppl,qbk,ptm,qzc,put,pbk,bch,BaskervilleF-TLF}
    {
    \begin{minipage}{\la}
        {\fontfamily{\fuent}\selectfont\par
            \fbox{\fontname\font} \\
            \lipsum[1][1-5]
        }   
    \end{minipage}\hfill
    }
\end{document}

This is going to be analysed at some point during the course, but first I just want to print the output PDF and distribute it, with the font names at the top of each column.

Does this exist? Is it necessary to dwell into the nuts and bolts of @s and \relax for this? Thanks in advance!

  • 1
    You mean names like "TeX Gyre Termes"? They are not accessible from pdflatex. Btw: don't use the ae package. This is not needed in a modern tex system. – Ulrike Fischer Mar 6 at 7:30
  • Thanks! I use ae because otherwise the Trajan font won't compile. – Óscar Guajardo Mar 6 at 17:54
  • Then correct these fonts, or don't use them. A file meant for a introduction in latex shouldn't use a package like ae. – Ulrike Fischer Mar 6 at 18:05
  • how can the Trajan font require you to use ae package so affecting the default fonts for the whole document? – David Carlisle Mar 6 at 18:50
  • I don't know; I just know that if I don't load ae, this font doesn't appear; I get an error line in the log file saying the trjn family doesn't exist. – Óscar Guajardo Mar 7 at 19:08
1

You can use \meaning as in :

enter image description here

\documentclass{article}

\begin{document}

1: \expandafter\meaning\the\font

2: \bfseries \expandafter\meaning\the\font
\end{document}

However while this can be useful for low level debugging of the font handling I would not use it in any tutorial. The whole point of the font selection system is to refer to a font via meaningful attributes like bold or italic, the mapping to the actual name in the filesystem such as cmbx10 is a low level implementation detail contained in the .fd files but should not be of interest to any normal use of the system

| improve this answer | |
  • That's interesting. However, apparently what I want is impossible using pdflatex :( – Óscar Guajardo Mar 6 at 17:54
  • @ÓscarGuajardo yes I realised later that you meant "name of font" in a different sense. I might delete – David Carlisle Mar 6 at 18:48

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.