[Tex/LaTex] Short names for macros

macros

Often it happens that I would like to define macros that I would use very frequently throughout the document – for example, a special symbol that I use repeatedly in many equations.

Ideally, in such situations, I would like to keep the name of the macro as short as possible. However, most of the one-letter names seem to be already defined, either in one of the standard Latex classes or in commonly-used packages. For example, \b, \c, \d, \i, \j, \l, \o, \t, \u, and \v are already defined. Usually I just give up and use something like \myX instead of \X to avoid conflicts, but it gets a bit verbose.

Two questions:

  1. Is there a list of very short names that are available and that I could (reasonably safely) use for my own purposes?

  2. Are there some clever tricks and hacks that I could use to define short names for macros? For example, the babel package makes the " character special so that you can use sequences such as "= and "a to enter symbols. Could I use a similar trick for my own purposes, using another character instead of " – or was it the only character that was not yet allocated?

I would like to stick to plain 7-bit ASCII characters.

Best Answer

You can display the definitions of this single-letter macros using:

$ texdef -t latex a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

The texdef command is available on CTAN.

Most of them seem to be diacritics. See https://en.wikibooks.org/wiki/LaTeX/Special_Characters for a table.

Here the post-formatted output of the above texdef:

Undefined:
\e \f \g \h \m \n \p \q \s \w \x \y \z
\A \B \C \D \E \F \G \I \J \K \M \N \Q \R \T \U \V \W \X \Y \Z

\a:
macro:#1->\expandafter \@changed@cmd \csname \string #1\endcsname \relax 
\b:
macro:->\OT1-cmd \b \OT1\b 
\c:
macro:->\OT1-cmd \c \OT1\c 
\d:
macro:->\OT1-cmd \d \OT1\d 
\i:
macro:->\OT1-cmd \i \OT1\i 
\j:
macro:->\OT1-cmd \j \OT1\j 
\k:
macro:->\T1-cmd \k \T1\k 
\l:
macro:->\OT1-cmd \l \OT1\l 
\o:
macro:->\OT1-cmd \o \OT1\o 
\r:
macro:->\OT1-cmd \r \OT1\r 
\t:
macro:->\OML-cmd \t \OML\t 
\u:
macro:->\OT1-cmd \u \OT1\u 
\v:
macro:->\OT1-cmd \v \OT1\v 
\H:
macro:->\OT1-cmd \H \OT1\H 
\L:
macro:->\OT1-cmd \L \OT1\L 
\O:
macro:->\OT1-cmd \O \OT1\O 


\P:
macro:->\protect \P  
\P :
\long macro:->\ifmmode \mathparagraph \else \textparagraph \fi 


\S:
macro:->\protect \S  
\S :
\long macro:->\ifmmode \mathsection \else \textsection \fi 
Related Question