5

In this post I learned that single letter macros purportedly have a significant impact on the typesetting process. For the past n many years I have been redefining letters like '\d', '\x', '\z', and '\e' because of the ubiquity of corresponding mathematical symbols. My questions are

  1. What is the real purpose of the symbols? Why isn't my PDF corrupted, and
  2. what is the real harm in redefining them if its not really messing with anything?

1 Answers1

11

It is not that they are single letter particularly it is that they are used internally already in latex (and plain tex) most accent commands are single character \c, \r \v etc If you redefine these commands then you break accented letters even if they are input as characters via inputenc.

\documentclass{article}

\usepackage[utf8]{inputenc}

\begin{document}

aaa \c{c} bbb \r{a} \v{c}

aaaa ç bbb å č

but...

\def\c{oops}
\def\r{boo}
\def\v{hmm}

aaa \c{c} bbb \r{a} \v{c}

aaaa ç bbb å č

\end{document}

enter image description here

Note this is particularly dangerous as you get no error, just corrupt output, so if you redefine the accent commands but have accented letters (for example in a .bib file) then the output will be nonsense without warning.

So it is better to use \newcommand than \def and if \newcommand says the command is already defined, think hard before deciding to redefine it.

David Carlisle
  • 757,742
  • The user hasn't been using \def but \renewcommand. I wouldn't have bothered answering in the comments if I'd known the OP had already asked a new question. – cfr Jun 24 '16 at 01:18
  • And you know what the OP will say: so if I don't need accented characters, this is just fine! They are even redefining \a. Which isn't to say what you say isn't right, of course. – cfr Jun 24 '16 at 01:30
  • 1
    @cfr -- a relatively frequent error found at ams is when an author has redefined \c for a math variable, and the bibliography (which is "normalilzed" with data from mathscinet) contains a name that contains a cedilla. this does result in an error message, and a screeching halt in production, which requires a search through the entire file for the use of \c and a manual change of the input. can lead to real errors in the output, for which the author's bad practice is to blame. so "don't need accented characters" is not a good excuse. – barbara beeton Jun 24 '16 at 14:34
  • @barbarabeeton I agree. I'm certainly recommending it. It is just that I'm pretty sure what the OP will think/say in response. I would, however, be happy to be wrong about this. – cfr Jun 24 '16 at 21:23
  • Is there a list of all such single-letter commands so that one can redefine "the remaining available" ones? – Jim May 19 '22 at 20:29
  • 4
    @Jim a b c d i j k l o r t u v and H L O P S – David Carlisle May 19 '22 at 20:41
  • @DavidCarlisle I just tested your MWE with LuaLaTeX and XeLaTeX instead of LaTeX, and it works fine there, which makes me wonder: if those engines are being used, is redefining single-letter commands still just as dangerous — provided that the bibliography doesn't use them or is processed outside of the new definition's scope? – steve Feb 06 '24 at 21:55
  • 1
    @steve well the classic accent commands are still defined so undefining them is probably unwise but it's less likely to bite you by surprise as say ç just goes straight through to the font it doesn't have an internal normalization via \c{c} as it does in pdflatex's inputenc utf-8 handler. – David Carlisle Feb 06 '24 at 21:59