1

Edit:

After @samcarter's comment with the existing list on CTAN I updated my question to make it useful:

What are the possible commands-packages that will change the font globally or locally?

The purpose of the question is to have a way to recognize all these commands and maybe make a tool that will search and find such commands+ the packages that changes the font.

PS: The CTAN list that @samcarter mentioned is already half the answer...

Old Question: Coming from this question: https://tex.stackexchange.com/a/411063/120578 and thought it would be nice to create a list with the packages that change the font in LaTeX so that someone will easily recognize them (as in case of the linked question) or can play around and use them to see if some of them is appropriate for his needs:

PS: Feel free to ask me to delete the question if you think it will not be useful.

koleygr
  • 20,105
  • https://ctan.org/topic/font as starting point – samcarter_is_at_topanswers.xyz Jan 18 '18 at 22:15
  • @samcarter, Thanks!... I suppose I have to delete or to edit my question... Don't you thing? – koleygr Jan 18 '18 at 22:18
  • 1
    The LaTeX Font Catalogue is also a useful resource. – Nicola Talbot Jan 18 '18 at 23:50
  • @cfr the whole question started from the linked question, I am taliking about "standard ways" meaning commands like \sfdefault or \setsansfont{} etc... I don't think they are really many. I mean that usually in a template, has to be used one of thes main commands as a starter to set a main font. Then if the command will be included in another macro, if you find this first command in there you can find the next ones to.... The whole question was about finding a global solution of that linked question and gain some more benefits out of it. (Feel free to delete the post and don't even ask) – koleygr Jan 19 '18 at 00:38
  • So you mean LaTeX? \setsansfont is not standard: it is added by fontspec. You might as well say \sishape is standard (which is added by nfssext-cfr) or \scslshape (which is, if I remember right, added by fontaxes). Look at nfssext-cfr.sty and you will see many definitions of macros which don't include one of the standard LaTeX NFSS macros. Similarly for fontaxes.sty. – cfr Jan 19 '18 at 01:48
  • 1
    See https://tex.stackexchange.com/questions/162622/what-is-the-difference-between-normal-text-and-roman-upright/162630#162630, https://tex.stackexchange.com/questions/352194/making-slanted-small-capital-letter (one answer with fontaxes and one with snippets modified from nfssext-cfr), https://tex.stackexchange.com/questions/59403/what-font-packages-are-installed-in-tex-live (font sampler), etc. etc. – cfr Jan 19 '18 at 02:03

1 Answers1

4

For packages, see What font packages are installed in TeX live?.

For coverage of NFSS, see What font packages are installed in TeX live?.

For coverage of macros added by fontspec, see fontspec.

For macros added by nfssext-cfr, see nfssext-cfr.

For macros added by fontaxes, see fontaxes.

Note that both nfssext-cfr and fontaxes provide some macros which are simple extensions of NFSS, but include others which change weight, width or shape by changing family, where the limitations of NFSS make it impossible to have things 'work as expected' otherwise. Moreover, nfssext-cfr, at least, redefines some standard font macros, specifically those affecting the selection of italic and/or small-caps, in order to allow changes to accumulate 'normally'.

For example, here's the new definition of \itshape:

\DeclareRobustCommand{\itshape}{%
  \not@math@alphabet\itshape\mathit
  \exfs@merge@shape{\itdefault}{\scdefault}{\sidefault}}

and here's \scshape:

\DeclareRobustCommand{\scshape}{%
  \not@math@alphabet\scshape\relax
  \def\tempu{u}%
  \def\tempo{ol}%
  \ifx\f@shape\tempu
        \exfs@merge@shape{\scdefault}{\udefault}{\scudefault}%
  \else
        \ifx\f@shape\tempo
                \exfs@merge@shape{\scdefault}{\oldefault}{\scoldefault}%
        \else
                \exfs@merge@shape{\scdefault}{\itdefault}{\sidefault}%
        \fi
  \fi}

What does \exfs@merge@shape do?

\newcommand*{\exfs@merge@shape}[3]{%
  \edef\exfs@tempa{#1}%
  \edef\exfs@tempb{#2}%
  \ifx\f@shape\exfs@tempb
    \expandafter\ifx\csname\f@encoding/\f@family/\f@series/#3\endcsname\relax
    \else
      \edef\exfs@tempa{#3}%
    \fi
  \fi
  \fontshape{\exfs@tempa}\selectfont}

This is relatively straightforward - we are not switching families here.

But suppose we look at \tlstyle:

\DeclareRobustCommand{\tlstyle}{%
        \lstyle\tstyle}

Well, neither \lstyle nor \tstyle is standard. What do they do?

\DeclareRobustCommand{\tstyle}{%                tabular figures
        \not@math@alphabet\tstyle\relax
        \exfs@unmerge@families{2}}
\DeclareRobustCommand{\lstyle}{%                lining figures (cf. command above)
        \not@math@alphabet\lstyle\relax
        \exfs@unmerge@families{j}}

Here's what \exfs@unmerge@families does:

\newcounter{taken}%
\newcommand*\exfs@unmerge@families[1]{%
        \edef\exfs@tempf{#1}%
        \edef\tempa{\expandafter\exfs@get@variants\f@family\@nil}%
        \let\exfs@tempq\@empty
        \edef\exfs@tempg{}%
        \setcounter{taken}{0}%
        % check whether there are variants - if not do nothing
        \ifx\tempa\@empty
                \edef\exfs@tempq{}%
        \else
                % o/w go through the variants to find the one to delete
                \whiledo{\value{taken}<1}{%
                        % get the next variant
                        \edef\exfs@tempn{\expandafter\exfs@next\tempa\@nil}%
                        % see if the next variant is the thing we seek and, if so, eliminate it
                        \ifx\exfs@tempf\exfs@tempn
                                \edef\tempa{\expandafter\exfs@shift\tempa\@nil}%
                                \edef\exfs@tempq{\exfs@tempg\tempa}%
                                \stepcounter{taken}%
                        % o/w save the next variant and move on if any variants remain
                        \else
                                \edef\exfs@tempg{\exfs@tempg\exfs@tempn}%
                                \edef\tempa{\expandafter\exfs@shift\tempa\@nil}%
                                \ifx\tempa\@empty% if there are no variants left, we're done
                                        \edef\exfs@tempq{\exfs@tempg}%
                                        \stepcounter{taken}%
                                \fi
                        \fi
                }%
        \fi
        \exfs@try@family{\expandafter\exfs@get@base\f@family\@nil \exfs@tempq}}

As you might guess, there is also a \exfs@merge@families which is needed, for example, for \pstyle and \ostyle, used by \postyle etc.

There is nothing to stop a 'template' using something like \plstyle in \AtBeginDocument to change the style of figures globally. (Of course, nfssest-cfr must be loaded to avoid an error and more must be done for it to have any effect.)

Similar comments apply to fontaxes, I believe. Certainly if faces the same problems in terms of the limitations of NFSS. I've focused on nfssext-cfr only because I happen to be rather more familiar with its eccentricities. (It is based on nfssext.sty, which I did not write and cannot be blamed for, but I certainly added my own share of shenanigans, for which I presumably can.)

All of this is to say, that there is no useful set of standard macros you can search for and be reasonably confident you've found what you're looking for. fontspec, fontaxes and nfssext-cfr are three ways of extending the standard set, but individual font packages often add macros, too.

Furthermore, a 'template' might not load a package, even if there is one. It might instead input the .fd file directly or set up the font families directly. Nor is this always a symptom of bad design: there are cases where this is the only way to get the desired result.

And of course, this answer only addresses fonts for text mode: fonts for maths mode are configured using an almost entirely different set of macros. The glimmer of hope here is that there are far fewer packages attempting to extend or alter these, so the situation is, in at least some sense, more manageable. Still unicode-math and mathspec are both options, here, so the situation is only really more manageable in their absence.

TeXnician
  • 33,589
cfr
  • 198,882
  • 1
    My favorite never used package: https://ctan.org/pkg/typeface – cgnieder Jan 19 '18 at 08:32
  • 1
    @Dr.ManuelKuehner NFSS says italic is shape it and small-caps sc. So switching to small-caps or italic is generally just a matter of setting the appropriate shape. But if you have italic small-caps, you want \textsc{\textit{abc}} and \textit{\textsc{abc}} should use those. But now it is complicated, because we can't just set a new shape (e.g. si), we need to redefine what \scshape and \itshape do, so that they check if we're already using italics or small-caps respectively. Thus are created nightmares. ;) – cfr Jan 20 '18 at 01:42
  • @clemens Interesting indeed - I'd never heard of it. Do you mean you haven't used it or that people generally don't? That is, I'm not clear if you are saying you've found it to be great and it should be recognised more widely or that you've never used it, but it sure sounds good. – cfr Jan 20 '18 at 01:45
  • 1
    @clemens Too bad that typeface doesn't make use of the support provided by cfr-lm :-). That would be both better and more comprehensive. The method for supporting hanging figures is not very nice, in my view (and the .sty file comments as much, although it is more optimistic than I would be about likely fallout). Sadly, it doesn't provide access to proportional figures at all, as far as I can tell - either hanging or lining. However, no doubt this is rather nit-picking of me. ;) It is certainly an ambitious package. Does anybody use it? – cfr Jan 20 '18 at 01:58
  • 1
    @cfr I've never seen it used and I don't use it myself. I quite like the idea behind the package (which is what I meant by “favorite”). It's been a while since I took a look at it but IIRC the current release status is rather to gain feedback than general usage. – cgnieder Jan 20 '18 at 13:04