59

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.

  • 25
    You can alias the commands, \let\tt\texttt and you will be ok. – Yiannis Lazarides Apr 9 '11 at 3:37
  • 9
    Perhaps you could migrate to a markdown format like multimarkdown? – Emre Apr 9 '11 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 '11 at 8:48
  • 5
    @Yiannis: I think you mean \let\tt\ttfamily! – Martin Scharrer Jul 29 '11 at 20:10
  • 2
    \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 at 11:43
42

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.

  • 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 '11 at 7:37
  • 1
    @Joseph: Shouldn't it be \let\bf\bfseries? After all \bf doesn't take an argument. – Martin Scharrer Apr 9 '11 at 10:03
  • @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 '11 at 10:05
  • 3
    @Joseph: Ok, in his own document he can. As long no one still used \bf in some package. – Martin Scharrer Apr 9 '11 at 10:08
30

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.

27

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.

  • 1
    It would be great to see an explanation what \@firstofone does here. – Hendrik Vogt Jun 21 '11 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. – Hendrik Vogt Jun 22 '11 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). – Bruno Le Floch Jun 22 '11 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 '12 at 15:38
6

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'''.

5

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}
  • 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 '16 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 '16 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 '16 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 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 at 14:53
1

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...

  • 4
    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. – Phelype Oleinik Jan 5 at 11:22
  • 2
    see my comment to OP – user4686 Jan 5 at 11:45
  • 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 at 12:27
  • 1
    @PhelypeOleinik I'm not sure if you have received the ping by Martin Scharrer. – TeXnician Jan 17 at 11:00
  • 1
    @TeXnician: It's not about the quality of the answer. Moderator flags are not for technical incorrect or just "wrong" answers. The "not an answer" is for posts which do not even try to answer the question: spam posts, follow-up questions or me-too posts, etc. There are not intended for quality control. For this the voting system is in place. – Martin Scharrer Jan 17 at 12:02

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.