17

I understand that \bf and \it are both deprecated in the current version of LaTeX. To the best of my knowledge, the correct control sequences replacing them are \bfseries and \itshape.

Is there any reason(s) not to use \let to redefine \bf to \bfseries and \it to \itshape as in,

\let\bf\bfseries

\let\it\itshape

so that if the old form of control sequence is used by mistake, it will nonetheless still be correct when compiled?

  • 5
    \bfseries and \itshape ... don't work in math mode – touhami Apr 14 '16 at 16:50
  • @touhami So you are saying that these particular deprecated control sequences work in math mode, unlike their non--deprecated control sequence equivalents, and are therefore useful notwithstanding that they are deprecated? – A Feldman Apr 14 '16 at 16:53
  • 4
    i think the suggestion is that unless a user is thoroughly indoctrinated to use \bfseries, etc., and has given up \bf "forever" when using latex, that user is likely to inadvertently use the "plain" sequences in places where they would work in plain tex, leading to possibly confusing errors. – barbara beeton Apr 14 '16 at 17:03
  • @barbarabeeton the confused user is me. I'm trying to learn some plain tex and sometimes inadvertently mixing things up between latex and plain tex commands. Thanks for understanding me. – A Feldman Apr 14 '16 at 17:54
23

Is there any reason(s) not to use \let to redefine \bf to \bfseries and \it to \itshape?

Yes, there are good reasons. :-) With the above \let-based setup, {\bf\it ...} produces bold-italic. In contrast, in a plain-TeX document {\bf\it ...} produces italic text. If the goal is to make \bf and \it behave the same way in LaTeX and plain-TeX, the \let-based setup isn't the way to go.

The LaTeX kernel doesn't define \bf, \it, \rm, \sc, \sf, \sl, and \tt. However, the standard LaTeX document classes -- article, report, and book -- and classes that are based on the standard classes do define these macros. For instance, article.cls features the following instructions:

\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}
\DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf}
\DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}
\DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}
\DeclareOldFontCommand{\it}{\normalfont\itshape}{\mathit}
\DeclareOldFontCommand{\sl}{\normalfont\slshape}{\@nomath\sl}
\DeclareOldFontCommand{\sc}{\normalfont\scshape}{\@nomath\sc}

The macro \DeclareOldFontCommand takes three arguments. It is defined in latex.ltx (the LaTeX "kernel") as follows:

\def\DeclareOldFontCommand #1#2#3{\DeclareRobustCommand #1{\@fontswitch {#2}{#3}}}

As you can see, considerable care is being taken in the "porting" of the plain-TeX font-switching macros to LaTeX. For one, different commands are needed for text mode and for math mode. And, the \normalfont instructions (in the text-mode cases) assure that the font-switching commands behave the same in LaTeX as they do in plain-TeX.

Incidentally, \@nomath is defined as follows:

\def\@nomath#1{\relax\ifmmode
   \@font@warning{Command \noexpand#1invalid in math mode}\fi}

Attempts to use \sl and \sc in math mode will therefore trigger warning messages, to the effect that these commands are invalid in math mode. (Of course, to generate words rendered in slanted or small-cap letters while in math mode, one can use \textsl{...} and \textsc{...}.)

Addendum: For completeness, here's the definition of \@fontswitch (also from latex.ltx):

\def \@fontswitch #1#2{%
  \ifmmode
     \let \math@bgroup \relax
     \def \math@egroup {\let \math@bgroup \@@math@bgroup
                        \let \math@egroup \@@math@egroup}%
     #2\relax
  \else
     #1%
  \fi
}

Thus, if one of the deprecated commands is encountered in text mode, the command appropriate for text mode is chosen; conversely, if it's encountered in math mode, the math-mode-appropriate command is selected after fine-tuning some of the math-grouping commands.

  • So, if I understand this right, the plain tex control sequence \it is redefined by \DeclareOldFontCommand to expand to \normalfont\itshape in text mode, and \mathit in math mode, I assume using \@fontswitch (which I have no idea how it functions) to choose between the two modes? – A Feldman Apr 14 '16 at 17:12
  • @AFeldman - The \it demand isn't being redefined by LaTeX. Instead, it's being defined from scratch, in a way that makes it behave very differently in text mode and it math mode. I'll add the definition of \@fontswitch to my answer. As you've guessed, it provides branching between text and math mode. – Mico Apr 14 '16 at 17:21
  • Both of the answers are wonderful, and this one very, very complete. Thanks much. – A Feldman Apr 14 '16 at 17:34
22

The commands \rm, \bf etc are called "deprecated" because they have been removed from the latex kernel. The way the commands work don't fit in the (much better) "new font selection scheme" (nfss) used by latex2e.

A number of classes nevertheless provide the definitions for these commands, but the definitions differ. E.g.

memoir: \@memoldfonterr {\rm }{\textrm }{\rmfamily }

KOMA: \scr@DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}

article: \DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}

So depending on the class you get an error (memoir and now also KOMA), or large warnings (older version of KOMA) or some output (article).

In the cases where the commands work, they normally work also in math. In text the commands switch to a special font as this was the way they worked in latex 2.09. That means that \bf\it doesn't give like \bfseries\itshape a bold-italic font, but the \it wins and you get only italic.

You have every right to redefine these commands -- e.g. to get rid of the KOMA-warnings.

  • 1
    This is a great answer. It is one of those times I wish I could pick two as "the" answer. I particularly appreciate the question answering what is really meant by "deprecated", and the class dependent nature of the error warnings. And I really appreciate you sticking up for my rights. :) – A Feldman Apr 14 '16 at 17:49

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.