4

I just received a .tex file from a colleague of mine and the file has several \rm commands in math mode. We are both using windows, but he is using WinEdt and I'm using TeXmaker. On his computer this file is compiled without errors, but on my notebook I get error messages saying \rm is an undefined command. What is going on?

Thank you very much.

David Carlisle
  • 757,742
Gabu
  • 995
  • 5
    TeXmaker and WinEdt are just the front-ends, not the TeX distributions that do the actual compilation work. Which TeX distributions do you (TeXlive? MikTeX? which versions?) and your co-author use, and which document classes do you employ? – Mico Nov 17 '16 at 15:48
  • The .tex file is using scrartcl class and I'm using MikteX 2.9. He just told me he is using the same distribution. – Gabu Nov 17 '16 at 15:55
  • 1
    The scrartcl class will indeed issue copious warnings about deprecated commands such as \rm. I guess one of your front-ends is set to simply ignore these warnings whereas the other is not. :-) See the posting Is there any reason not to use \let to redefine a deprecated control sequence to the currently recommended one? and, in particular, Ulrike Fischer's answer for more information on the subject of deprecated font-switching commands. – Mico Nov 17 '16 at 15:59
  • 2
    Moral of the story: Both of you should get a move on and no longer use deprecated macros. Really. – Mico Nov 17 '16 at 16:02
  • 1
    @Mico In my version of scrartcl (3.21) the use of \rm causes an error. I'm guessing they have different versions of KOMA-script, where one only gives a warning and the other (newer) gives an error. – Torbjørn T. Nov 17 '16 at 16:03
  • @TorbjørnT. - So, maybe the KOMA-script document classes have changed some of their settings since April 2016, which is when the linked postings mentioned in my earlier posting were written? I don't use these document classes all that much, and I for sure never use the deprecated font-switching commands in my own work, so I wouldn't be aware of any such changes... – Mico Nov 17 '16 at 16:06
  • @Mico That was my thought, but I don't use KOMA either, nor do I follow the development, so I can't say for certain. – Torbjørn T. Nov 17 '16 at 16:07
  • @Gabu -- Which version of scrartcl is installed on your system and on that of your co-author? – Mico Nov 17 '16 at 16:09
  • @Mico I sort of half-understand why Koma would not want to support pre LaTeX2e \rm and \bf (if, but here I should check LaTeX2e predates the Koma classes). But I just don't understand at all why it is so universally repeated not to use \rm, \bf, ... they are supported by article class and the LaTeX team will definitely not break compatibilty suddenly after 20 years with old documents. They accomplish something which has its value. For example I may really want \bf and not \bfseries. Why force me to write \normalfont\rmfamily\bfseries suddenly after twenty years ? –  Nov 17 '16 at 16:47
  • @jfbu - Thanks. I've posted an answer in which I provide a solution for those who simply must use the deprecated font-switching commands, in either text or math mode, and also need to use a recent version of one the KOMA-Script document classes. :-) – Mico Nov 17 '16 at 17:29

2 Answers2

12

\rm is not defined in the latex format. Some classes define it for compatibility with LaTeX 2.09 (that is, documents written before 1993). The Koma classes previously defined it with a warning but more recent releases do not define it, so you get an error if it is used.

After 20 years of deprecation the scrartcl author not unreasonably thought it should no longer be needed.

The editor (winedt, texmaker, etc.) you use to write the file has no bearing on this at all.

David Carlisle
  • 757,742
5

The editor you use is irrelevant. What matters is which vintage of scrartcl you use. Until recently (June 2016), the KOMA-script document classes -- scrartcl, scrreprt, and scrbook -- sort of tolerated the deprecated font-switching instructions \rm, \bf, \it, etc., while issuing copious warning messages if they were encountered. In June 2016, however, support for these directives in the KOMA-Script classes ceased entirely.

If you truly, positively, absolutely must use \rm and the other deprecated font-switching instructions, you could add the following code -- which is lifted straight from article.cls -- to your preamble:

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

Note that \sl and \sc will only work in text mode, but not in math mode. See this posting for more information on this subject.


A full MWE:

enter image description here

\documentclass{scrartcl}
% The following code is from the file `article.cls`
\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}

\begin{document}
$a$ $\it a$ $\rm a$ $\bf a$ $\sf a$ $\tt a$ 
\end{document}
Mico
  • 506,678