62

I understand that \bf and \it are now obsolete in LaTeX and that \textbf and \textit are proper, as they produce more sophisticated (in particular, cumulative and properly kerned) changes to font style. I have read the English version of "Obsolete commands and packages", v. 1.8.5.7 of l2tabu, Sec. 2.1 and I understand the rules and their reasons, as well as the several other commands that are affected.

However, I find it convenient to use LaTeX for notetaking during lectures, and in that rushed environment, shortening a command by any number of keystrokes helps keep me from falling behind. \bf and its two-letter kin are still very useful to me for that reason, and once a presentation is finished I can go through and replace all appearances of \bf et al. with \textbf et al.

My question is this: is there a plan eventually to replace the short font style commands like \bf with the implementations of \textbf etc. some day, or should I expect \bf always to remain in existence but obsolete, for reasons of backward compatibility with original TeX? Original TeX has been greatly improved on in countless ways, but in the heat of transcription I sometimes miss its conciseness.

7
  • 27
    You can alias the commands, \let\tt\texttt and you will be ok.
    – yannisl
    Apr 9, 2011 at 3:37
  • 9
    Perhaps you could migrate to a markdown format like multimarkdown?
    – Emre
    Apr 9, 2011 at 3:41
  • 4
    Why don't you use a LaTeX editor that has keyboard shortcut support for the formatting commands? If you know how to use Emacs (or are willing to learn), AucTeX is best-of-breed, but there are other more GUI-oriented options (Texmaker, to name one) as well.
    – Aaron
    Apr 9, 2011 at 8:48
  • 6
    @Yiannis: I think you mean \let\tt\ttfamily! Jul 29, 2011 at 20:10
  • 4
    \tt has the clear advantage to switch to a fully defined font, which is not achieved by \ttfamily but rather by \normalfont\ttfamily (as done not by LaTeX format, but by LaTeX standard classes when providing a \tt macro; I am skipping here math mode discussion). Why do people hate \tt will remain an eternal mystery to me. KOMA-script turned it into an error in recent releases, breaking old, possibly useful packages, now unmaintained, which used it. Is this reasonable? No.
    – user4686
    Jan 5, 2019 at 11:43

6 Answers 6

45

The simple answer is no, because the new font commands work better for the reasons in the links you cite.

The best way to reduce your typing to customize your editor. In my editor (TeXShop on a Mac) I have the command \textbf{} bound to Command-B, and \emph{} to Command-I. (I generally don't use textit{}) This makes it simple to use the "new" font commands in my source but with drastically reduced typing.

Most editors should be able to do this sort of shortcut.

5
  • 4
    I'd imagine that if we ever succeed in writing LaTeX3 as a stand-alone format, we won't even include \bf, etc. There's nothing stopping you doing \let\bf\textbf, though.
    – Joseph Wright
    Apr 9, 2011 at 7:37
  • 2
    @Joseph: Shouldn't it be \let\bf\bfseries? After all \bf doesn't take an argument. Apr 9, 2011 at 10:03
  • 1
    @Martin: From the question, it seemed that the idea was to use \bf as a short-hand for \textbf, not for \bfseries. Hence my suggestion. (I'd say that \bf is not a LaTeX command, so it does not have a 'defined' LaTeX syntax. So the OP can do what he likes!)
    – Joseph Wright
    Apr 9, 2011 at 10:05
  • 3
    @Joseph: Ok, in his own document he can. As long no one still used \bf in some package. Apr 9, 2011 at 10:08
  • \textbf is to make text bold, which is similar to \textit. \emph is to emphasise text not necessarily with italics as far as I know. I think that, if you use \emph, you better define something like \strong for strong emphasis instead of using \textbf.
    – matj1
    May 10, 2023 at 12:20
33

EDIT2: There is now a markdown package, which can be used with the LuaTeX engine.

Following on the markdown idea mentionned in comments by @Emre, it can be coded in LaTeX. For instance, the code below gets *italics* and **bold** to work (with nesting as well).

\documentclass{article}
\makeatletter
\newcommand{\star@out}{%
  \star@ifnext{\bgroup\bfseries\let\star@current\star@inbf\@gobble}%
              {\bgroup\itshape\let\star@current\star@init}}
\newcommand{\star@inbf}{%
  \star@ifnext{\egroup\@gobble}{\bgroup\itshape\let\star@current\star@initbf}}
\newcommand{\star@init}{%
  \star@ifnext{\bgroup\bfseries\let\star@current\star@initbf}{\egroup}}
\newcommand{\star@initbf}{\star@ifnext{\egroup\@gobble}{\egroup}}
\let\star@current\star@out

\newcommand{\star@ifnext}[2]{%
  \def \reserved@a {#1}%
  \def \reserved@b {#2}%
  \futurelet \@let@token \star@ifnext@aux 
}
\begingroup
\catcode`\*=13
\@firstofone{\endgroup
  \newcommand{*}{\star@current}
  \newcommand{\star@ifnext@aux}{%
    \ifx \@let@token *\let \reserved@c \reserved@a 
    \else             \let \reserved@c \reserved@b 
    \fi 
    \reserved@c
  }
}
\makeatother

\AtBeginDocument{\catcode`\*=13}


\begin{document}

Hello, *th**i**s* is a **test, *to see* whether** it works.

\end{document}

EDIT as per Hendrik Vogt's suggestion. The construction

\begingroup
\catcode`\*=13
\@firstofone{\endgroup ... }

ensures that every * within the argument of \@firstofone has catcode 13. Namely, a group is started, in which * are active, then \@firstofone does nothing but forces TeX to read its argument, converting characters of the input file to tokens (with catcode fixed, except if someone later uses \scantokens), and the group then ends with \endgroup. The catcode of * is restored, which means that any * which is read later (i.e., not those in the argument of \@firstofone) will be of catcode 12 (other). The advantage of this construction over doing \catcode`=13 before and \catcode`=12 after is that the catcode of * keeps whichever value it had, even if it wasn't 12.

4
  • 1
    It would be great to see an explanation what \@firstofone does here. Jun 21, 2011 at 15:38
  • Thanks for the edit! Now I remember: This trick reminded me of the \lccode trick I saw in several of Phillip Goutet's answers, but it's somewhat different. Jun 22, 2011 at 9:08
  • @Hendrik: it is definitely inspired from the \lccode trick (which I think I learnt from Philippe Goutet). It is less powerful, though, since that won't work to change the catcode of a letter (except if that letter appears nowhere in control sequences in the argument). Jun 22, 2011 at 12:50
  • 4
    Surely it would be easier at this stage to just write in markdown and then use e.g. Pandoc to convert it to LaTeX later…
    – Seamus
    May 26, 2012 at 15:38
32

To expand on Alan's good answer (and to reiterate his ‘no’) there's another big reason that \bf and \it are not recommended now: they are short and easy to type, but they do not have semantics. LaTeX attempts to separate content and formatting in its markup, and these font changing commands break such ideals.

In the rough, commands to type often as part of your document should be short and meaningful; commands to define formatting decisions should be long and descriptive.

11

Following the answer of Bruno, the wiki package allow a very simplified entry of boldface and italics fonts using the Wikipedia syntax:

\documentclass{article}
\usepackage{wiki}
\begin{document}
\wikimarkup
Write in '''bold''', ''italic'' or '''''both'''''.
\end{document}

Bold and italics can be nested and even overlapped, so that you can obtain the eqivalent to \textit{inter\textbf{sec}}\textbf{tion} with ''inter'''sec''tion'''.

7

First, regarding the use of the PlainTeX-based font switching commands \rm, \sf, \tt, etc in a LaTeX document: Even though the LaTeX2e kernel does not define these commands, they are in fact still available if you use one of the "standard" document classes -- article, report, and book -- or a document class that's based on these three classes. For more on how \rm, \sf, etc are implemented in the article, report, and book classes see, e.g., this answer to the posting Is there any reason not to use \let to redefine a deprecated control sequence to the currently recommended one?

Second, here's a solution that uses LuaLaTeX to convert some simple markdown-type text formatting "instructions" into LaTeX code. Specifically, text inside matched pairs of ***, **, and * characters in a line of input is rendered in bold-italics, bold, and italics, respectively.

The operation of the Lua function that does the main work can be initiated and terminated via two LaTeX macros named \MarkdownOn and \MarkdownOff. The Lua function doesn't operate on material contained in verbatim-like environments.

enter image description here

\documentclass{article}

%% Lua-side code
\usepackage{luacode}
\begin{luacode}
in_verbatim = false
function markdown ( line ) 
-- don't operate on input if we're in a verbabim-type environment
if string.find ( line , "\\begin{[vV]erbatim}" ) then
  in_verbatim = true
elseif string.find ( line , "\\end{[vV]erbatim}" ) then
  in_verbatim = false
elseif in_verbatim == false then
  line = string.gsub ( line, "%*%*%*(.-)%*%*%*" , "\\textbf{\\textit{%1}}")
  line = string.gsub ( line, "%*%*(.-)%*%*" ,     "\\textbf{%1}")
  line = string.gsub ( line, "%*(.-)%*" ,         "\\textit{%1}" )
end
return line
end
\end{luacode}

%% TeX-side code
\newcommand\MarkdownOn{\directlua{luatexbase.add_to_callback( 
   "process_input_buffer", markdown, "markdown" )}}
\newcommand\MarkdownOff{\directlua{luatexbase.remove_from_callback( 
   "process_input_buffer", "markdown" )}}

\setlength\parindent{0pt} % just for this example

\begin{document}
\MarkdownOn
Lua function \texttt{markdown} turned on:

*italic*, **bold**, ***bold italic***

\bigskip
A line inside a \texttt{verbatim} environment:

\begin{verbatim}
*italic*, **bold**, ***bold italic***
\end{verbatim}

\bigskip
\MarkdownOff
Lua function \texttt{markdown} turned off:

*italic*, **bold**, ***bold italic***
\end{document}
6
  • 1
    Did the LaTeX kernel ever define those commands? As far as I know, \bf, \it etc. are TeX font switches and nothing to do with LaTeX.
    – cfr
    Aug 20, 2016 at 21:34
  • @cfr - It depends on the version of LaTeX: The LaTeX2.09 kernel -- yes, I'll admit to being old enough to having used LaTeX2.09 for real work ... -- did define \rm, \bf, etc. In contrast, the LaTeX2e kernel does not. However, the "standard" document classes (but not the memoir class) designed for LaTeX2e do provide definitions for \rm, \bf etc, and the definitions are set up to ensure that these font switching macros behave exactly as they would in a Plain-TeX document.
    – Mico
    Aug 20, 2016 at 21:38
  • Fair enough. I never used 2.09. Memoir can define them, I think, if you use the relevant class option, but it will still complain with warnings, I believe.
    – cfr
    Aug 20, 2016 at 21:45
  • @Mico "*the definitions are set up to ensure that these font switching macros behave exactly as they would in a Plain-TeX document. *" is not exactly true. Try in LaTeX \Large\tt AAA\showoutput, you will see it uses \OT1/cmtt/m/n/14.4 and the meaning of the latter is select font cmtt12 at 14.4pt, which is not the same as in Plain TeX where \tt would also reset the fontsize, as it expands in text mode to the font switch \tentt and \font\tentt=cmtt10 % typewriter from plain.tex.
    – user4686
    Jan 5, 2019 at 14:46
  • 1
    :) I could not find my quote of you in your answer but I had picked it from your comment, thus the sin is already attenuated as comments are more volatile :)
    – user4686
    Jan 5, 2019 at 14:53
2

I had the same problem recently:

scrartcl Error: undefined old font command `\bf'.

After some investigations, I found this on the tug.org web site:

\makeatletter
\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}
\makeatother

It allows to recover all "old" TeX commands we all like...

9
  • 5
    It allows, but you shouldn't. The class you are using does not provide them on purpose, because they are obsolete. You really should change to the proper font change commands. Besides, the question does not ask how to get the commands, to your answer misses the point a little. Jan 5, 2019 at 11:22
  • 2
    see my comment to OP
    – user4686
    Jan 5, 2019 at 11:45
  • 1
    Sorry I wanted to answer to tex.stackexchange.com/questions/346870/… that has been redirected to this question as a duplicate. So it may seems a little bit away from the original question, but it is the only way to answer to the other one (since as a duplicate, its answers are closed...)
    – lehalle
    Jan 5, 2019 at 11:48
  • 2
    This does not answer the question. The question is whether there are plans to reintegrate the old TeX commands into LaTeX… You could have left a comment below David Carlisle's answer linking to that TUG site.
    – TeXnician
    Jan 5, 2019 at 12:27
  • 2
    @TeXnician, Phelype Pleinik: The question is "Will two-letter font style commands ever be resurrected in LaTeX?". This answer is basically like "Yes, using these lines of code". Therefore this counts as an answer. Maybe not spot-on, but I really see other LaTeX users which come here and find this useful. Thats what this site is about! If you don't like it, feel free to use your right of downvoting. There is no need to flag this as "not an answer". Even bad answers are answers, and this one is not even THAT bad, just not very recommendable, which can be and already has been stated in a comment! Jan 17, 2019 at 9:43

You must log in to answer this question.

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