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.

  • 1
    Possibly do something similar to what Christian Linding is doing here?
    – pmav99
    Commented May 26, 2011 at 12:06
  • 3
    @Seamus: I am fairly certain that these 2 answers are not an exhaustive list of all possible tricks that you can use in TeX to construct short, non-conflicting macro names... So I encourage all other TeX hackers to give it a try! Besides, while the current answers are a great starting point, they could be improved: @Martin's answer does not cover commonly-used packages, just core Latex. @Niel's answer shows how to use ", but I already know that " conflicts with Babel. So there is +250 points available for the best answer to question 1, question 2, or both. Commented May 28, 2011 at 17:27
  • 2
    @David: I attest that it really does help. I routinely use \C as shorthand for \mathbb C, and \x for \times. This is as close as one can get with a standard keyboard to having the same orthography as I type that I would have on a chalkboard. I then spend more time concentrating on what it is I want to write if the objects I refer to over, and over, and over again have names which are as simple as possible. If your mental name for "the complex numbers" is the glyph ℂ, why give it a more complex name? So long as the name visually represents how it is typeset, this is not unreasonable. Commented May 28, 2011 at 20:44
  • 3
    It is not really that relevant how long it takes to type something – what matters is how easy it is to read (and edit) the source code. Anyway, this is not really an answer to the question; I hope the moderators could convert it into a comment. Commented May 28, 2011 at 23:51
  • 3
    Having worked at an academic publisher for years, I want to remark that in my opinion, such macros are a terrible nuisance. Your input may be consistent with itself, but it will not be consistent with anyone else's. Commented May 29, 2011 at 9:49

8 Answers 8


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:

\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

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

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

macro:->\protect \S  
\S :
\long macro:->\ifmmode \mathsection \else \textsection \fi 
  • This is a cool thing to know about. I gather that the various control sequences expanding to \OT1-cmd \? \OT1\? are non-latin characters which are accessible in the OT1 input encoding. Is there any handy list as to how these appear in a document? Commented May 26, 2011 at 12:15
  • @Niel: They seem to be mostly diacritics. I'm searching for a list. Commented May 26, 2011 at 12:19
  • 5
    This can also be implemented with TeX itself easily: \usepackage{etextools} \forcsvlist\csshow{a,b,c,d,e,f,g}
    – Leo Liu
    Commented May 28, 2011 at 17:50
  • 5
    @Leo: Sure, but the idea behind texdef is that you don't need to code any LaTeX file but can simply use the command line. This is much quicker. Commented May 29, 2011 at 17:00
  • 1
    To summarize: available single small letter character macros: \e, \f, \g, \h, \m, \n, \p, \q, \s, \w, \x, \y, \z, available single cap letter character macros: \A, \B, \C, \D, \E, \F, \G, \I, \J, \K, \M, \N, \Q, \R, \T, \U, \V, \W, \X, \Y, \Z Commented Sep 27, 2016 at 14:55

Summary. This answer (which I have been expanding upon in several iterations) describes how one may take a single character (such as "), make it active, and use it to produce alternative single-character control sequences (such "a) which behave much like a normal control sequence might.

(#1) Repurposing a typical non-letter character. If you're not using any package which redefines " for its own purposes, you can use it to define an alternative namespace for macros, as follows.



   \def"#1{\csname @mymacro#1\endcsname}

       \@ifnextchar [{%
           \expandafter\newcommand\csname @mymacro#1\endcsname
            \expandafter\def\csname @mymacro#1\endcsname{%
                \csname @@mymacro#1\endcsname\ignorespaces}%
            \expandafter\newcommand\csname @@mymacro#1\endcsname

       \@ifnextchar [{%
           \expandafter\renewcommand\csname @mymacro#1\endcsname
            \expandafter\def\csname @mymacro#1\endcsname{%
                \csname @@mymacro#1\endcsname\ignorespaces}%
            \expandafter\renewcommand\csname @@mymacro#1\endcsname


What this does is make " active (interpreted as a single-character control sequence), and then provides a definition for it which causes "a or "q (for instance) to invoke the control sequences \@mymacroa and \@mymacroq, respectively. The macros \newmacro and \renewmacro provide a simple interface for defining the macros invoked using the " character, with the syntax \newmacro"a{...}, \renewmacro"q{...}, etc. using syntax similar to \newcommand and \renewcommand, including any (optional) arguments that you want. We perform some extra testing when the macros are defined, to check whether they take arguments: if not, we add an extra layer of commands with a trailing \ignorespaces to ensure that any white-space after the macros "a or "q (or whatever) is consumed.

If you need to interoperate with babel or another package which provides a special meaning for ", you may need to use a different character — which you use is at your discretion, although it should be a character with catcode 12 (or if you're daring, a letter which normally has catcode 11 if there's a letter which is almost never used in the language of your document, e.g. w in French). One can also adopt a multi-character solution (e.g. such as the one exhibited in Christian Lindig's solution for quickly switching to bold typeface). But multi-character solutions will probably defeat the purpose if you're particularly concerned with number of keystrokes and such.

(#2) Limited repurposing of a special character. I notice in the comments that you are mostly interested in using these alternative macros in math-mode. This allows us to make use of further techniques. At the same time, the limited scope makes it feasible to be more adventurous in the character which we usurp for the purpose.

In this case, I will show how to achieve a similar effect as above using the # character, which is normally involved in enumerating arguments to macros. What we will do is make # active only within mathmode (and displayed environments), where a prudent LaTeX user can usually refrain from defining new macros. This will also involve some cosmetic differences to the way that we implement the interface.


      \def#$1{\csname @mymacro$1\endcsname}

       \@ifnextchar [{%
           \expandafter\newcommand\csname @mymacro#1\endcsname
            \expandafter\def\csname @mymacro#1\endcsname{%
                \csname @@mymacro#1\endcsname\ignorespaces}%
            \expandafter\newcommand\csname @@mymacro#1\endcsname

       \@ifnextchar [{%
           \expandafter\renewcommand\csname @mymacro#1\endcsname
            \expandafter\def\csname @mymacro#1\endcsname{%
                \csname @@mymacro#1\endcsname\ignorespaces}%
            \expandafter\renewcommand\csname @@mymacro#1\endcsname



The first few commands define what the character # does when it is active: i.e. the same thing that " did in the example before. To do this, we make # active, and temporarily make $ the character which denotes arguments to macros. We then restore the usual meanings of # and $ before proceeding, if only to prevent headaches.

One will typically define macros in the pre-amble, which is ipso facto outside of math-mode. So, we will need a slightly different syntax for defining macros with \newmacro and \renewmacro which does not assume that # is active (not to mention that # may be needed to describe arguments!). The simplest approach is to use the syntax \newmacro\#a{something} or \renewmacro\#q[1]{something}, using the command sequence \# as part of the syntax of these commands. Note that these commands can also be used in the document body, in normal text mode.

Finally, we redefine the hooks \everymath and \everydisplay, which are invoked whenever you use $ math mode $ or \[ displayed math \] (including the environments provided by the amsmath package), to make # an active character. Its normal status as the character denoting arguments are restored when one leaves math/display mode.

If you wish, try the following in a document body to try out this code, in a document with the code above and which uses the amsmath package. This is intended to demonstrate the faithful interoperation of this code with mathmode and with subsequent definition of macros.

\newmacro\#a[2]{#1 \stackrel?= #2}

$ #abc $

            #a 1 2  \\
            #a {\mathsf{P}}{\mathsf{NP}}
    & &

\newcommand\test[2][\bfseries]{\textsf{#1 #2}}
\test{bold and sans-serif}
\test[\itshape]{italic and sans-serif}

(#3) Remarks on these techniques. The macros defined in this way will behave differently than normal control sequences, as the example with # illustrates. Specifically, the mechanism I've described here really is designed for single-character macro names.

Taking the example where we make " active for the sake of discussion: the source-code "abc will expand to \@mymacroa bc rather than \@mymacroabc. (The name of the "macro" stops at the very first argument to the " character, which is a in this case.) And if you try to define a macro using \newmacro"abc{something}, the effect will be the same as writing


rather than defining a macro \@newmacroabc which produces {something}.

You can define macros with longer names such as \newmacro"{abc}, but that's silly. Alternatively, you can define " to try and obtain as many letter-characters (having catcode 11) as possible to constitute the name of a macro, as Bruno has done in another answer. But I'm not really interested in doing so, especially as the point is to define alternative single-character macros. This is already a non-standard mechanism; without further motivation, one should have in mind a specific idea of a special case when one should want to use it. I present the solution for when that special case is "access to extremely short macro names".

  • Why use \expandafter\def\@mymacro rather than a direct \def"? Commented May 26, 2011 at 15:05
  • @Bruno: Hmm. That does work in this case. Edited to simplfy. — I adapted my answer from another source, which happened to be the .dtx for a style file I wrote, with the typical modification in such files. I remember trying to redefine active characters in that way, and using this as a work-around; but perhaps those obstacles only arise in conjunction with ltxdoc.cls or something. Any insights? Commented May 26, 2011 at 15:33
  • @Niel, I can't think of a reason right now why you would need to do that there. The typical reason is if you want to use the active " in a region where the double quote is not active: typing " would not bring the active meaning of the character, but using \@mymacro would. By the way, it should be \def"#1{...}. Commented May 27, 2011 at 13:46
  • @Bruno: Thanks for pointing out the silly mistake. I shall have to keep an eye out for the conditions under which I have the problem I mentioned before; thanks. Commented May 27, 2011 at 14:06
  • 1
    @Niel: I think it would be help a lot if you emphasised that the macros defined this way do not need to be terminated by a non-letter character. That is, if you define a macro such as "a, then foo"abar works fine, just like foo{"a}bar, and in foo"a bar the whitespace is preserved. This is great in short macros like this, but it is not necessarily obvious to someone who is just reading the code (I am no TeX hacker - I had to test it to see how it actually behaves). Commented May 28, 2011 at 19:40

Having worked at an academic publisher for years, I want to remark that in my opinion, such macros are a terrible nuisance. Your input may be consistent with itself, but it will not be consistent with anyone else's.

But if you absolutely have to define syntactical macros for some (to me) unfathomable reason, then by far the best ones are those that actually describe their content. These are not generally the shortest ones, but at least then when another person has to edit your text, the input syntax gives clues to the produced output. For example:

A \in \Q

is somewhat reasonable if \Q is \mathbb{Q}, but

\theta \neq \Q

I consider bad whatever the definition of \Q is.

Macros that use active characters instead of backlash are absolutely horrible, and for much these same reason: imagine editing someone else's file where stuff like a simple @ sign suddenly is a macro.

Secondary argument: in some workflows, your actual TeX input can become part of the result (for example as alternate text for a bitmap in a html/epub view). none of the macro definitions will survive, so the reader (even one that understands LaTeX well) would have to make a guess at the intended meaning.

  • 5
    This is certainly a valid opinion, but it is not an answer to the question; I have therefore flagged this post for moderator attention. Comments do not get lost if people upvote them; highly upvoted comments will be easily visible. Commented May 29, 2011 at 10:32
  • 7
    @Jukka: I think Taco's point here is that if you load this page, only the first few comments show up but you see all of the answers. There is a point to saying 'sometimes, the correct answer to a question is "do not do this because ..."'.
    – Joseph Wright
    Commented May 29, 2011 at 10:35
  • 1
    @Joseph: Actually, it is not the first few comments that show up, but the highly-voted comments. The system falls back to displaying the first comments only if there are no highly-voted comments. Commented May 29, 2011 at 10:52
  • 5
    @Taco: I agree that comments that were added later have a disadvantage, as fewer people will notice and upvote them, but I don't think that is a good excuse to post comments as answers. But in this particular case, there is a simple solution: edit your answer so that it actually tries to answer the question. For example, you could tell what kind of short macro names would be best from the perspective of a publisher. I don't think short macro names as such are inherently bad; I would guess that macros that don't look like macros are bad. Commented May 29, 2011 at 13:40
  • 1
    @Taco: Thanks for elaborating your response. For my part, I define short macros as a part of my workflow essentially to quickly prototype a document; this is not incompatible with later mechanically replacing macros afterwards by the author. As for the macros that I describe in my answer, even I hold it self-evident that they are an abomination never to be used in public! I entertained the question to amuse myself, to be honest. But then again, I also write documents (not professional articles) for which I don't care whether anyone else will ever see the source. Commented May 30, 2011 at 15:34

A typical way of getting special effects in math mode is to set the "mathcode" of some characters to "8000. TeX looks at the mathcode when encountering a character of category code 11 (letter) or 12 (other). Normally, the mathcode indicates what character of the font should be used, as well as its family (responsible for the spacing), but the special value "8000 tells TeX to treat the charcter instead as if it were active.

EDIT: I had earlier some code which read token by token, stopping at the first non-letter, and making a control sequence out of what was found. Niel points out that it is rather useless since we want short macro names. I replaced it by a more useful feature: now, the active character used will typeset itself if followed by a space token.

  {\edef\@sm@char{\string #1}\futurelet\@let@token\@sm@test}
  {\ifx \@sptoken\@let@token
     \csname @sm@\@sm@char\endcsname
  {\csname @sm@\@sm@char @#1\endcsname}

  {\expandafter\@sm@new\csname @sm@\string #1\endcsname #1}
    \AtBeginDocument{\mathcode`#2="8000 }%
   \expandafter\newcommand\csname @sm@\string #2@\string #3\endcsname

% Used as
There are many examples of fields: \(!C?>!R?>.c?>!Q\).
And a very nice matrix:
\be ?I=!(1&0&.c&0\\0&1&.d&.v\\.v&.d&.d&0\\0&.c&0&1!)\,! \ee

I'm not convinced that this is very readable.

  • Re-defining ` in the math mode is an excellent idea; this really sounds like an unused character in a math context. For example, mapping `X to \mathcal{X} (for all X) might help a lot in many documents that I write. Commented May 29, 2011 at 0:08
  • 2
    @Jukka: you should then probably go for some code based on @Niel's: I haven't really tested my code thorougly. In fact, I'd say that any of <*>!?"@#.~';, could be made active in a similar way: they should check (with \futurelet) if the following token is a space. If it is, they should typeset their usual counterpart. Otherwise, they should grab an argument as in Niel's answer. Even $ can be used (if you use LaTeX's \(...\) but who doesn't?). Commented May 29, 2011 at 1:40
  • @BrunoLeFloch, I'm not so sure that < and > are unused in math. :-) (Maybe you like to delimit them with spaces—I do!—but not everyone does.)
    – LSpice
    Commented Jun 15, 2015 at 17:25

The macros \0, \1, ..., \9 are generally regarded as userspace scratch csnames: you can repurpose them as short macro names in the way that you want.

You can define a macro that \lets all these macro names be equal to the long csname you used in their definitions, and if you are worried that some badly behaved package is repurposing them, then you can have another macro that tests that equality with the long csname, using \ifx, has not been violated.


Again this is not really an answer to the question, but if you really want to save on keystrokes, then perhaps a better option to catcode-fu is to use a smart text editor. For example emacs has a funky LaTeX-math-abbrev-prefix which is ` by default.

This gives you access to a bunch of mathmode symbols in two keystrokes. For example, you can get \subset by typing ` {

By customising LaTeX-math-list you can get whatever you like out of this prefix command.

Vim with some snippet add-on can almost certainly achieve the same thing. I don't know what other editors will allow you this sort of prefix key control, but I'm sure there are others. If you're interested in efficiency to the level of worrying about a handful of keystrokes, then I think this is a better option than fiddling with making other characters active...

Postscript: The weird paragraphing was needed to allow ` to display properly. I really hit the limits of markdown typing this...


There's the at package by Mark Wooding. It makes possible to say

\newatcommand X{Whatever you like}
\newatcommand Y[2]{Whatever you like with #1 and #2}

and then use @X or @Y{a}{b}. However this is likely to conflict with hyperref (the package is quite old and not developed any more), so it's best not to use the newly defined @-commands in moving arguments. But one can at least try.

  • 1
    Conflicts with hyperref is a good point; some other approaches seem to have problems with hyperref as well, if we happen to overload a character that may occur in a URL. It also looks like \verb, etc., might produce surprising results... Commented May 28, 2011 at 23:44

A completely different approach, which saves keystrokes while maintaining full portability and avoiding definitional conflicts, is to create keyboard shortcuts using a 3rd-party task automation or text expander program. I use Keyboard Maestro (KM) for Mac, but equivalent apps may be available for Windows and Linux.

For example, I've configured KM so that, when I'm working in my favored TeX editor, and press CtrlT, the macro pastes the following where my cursor is:

\ensuremath{\text{ }}

Here's a screenshot of the macro. Simple ones like this are quite easy to write; the only wrinkle was that I had to escape the backslashes:

enter image description here

You must log in to answer this question.

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