Let say that I have the following code:
\documentclass{article}
\usepackage{xspace}
\def\cal#1{\ensuremath{\mathcal{#1}}\xspace}
\newcommand{\calA}{\cal A}
\begin{document}
Let \calA be a linearly ordered set.
\end{document}
Now, imagine that I need to use a lot mathcal for single letters, how can I make latex auto infer/auto generate the definition for the \calX
where X is a capital letter. Of course, I could generate 26 newcommands but I would prefer not to do that.
I mean that I would like that I had not to put a space between \cal
and X
. Is there any trick available to do that?
\ensuremath
and\xspace
in place of the simpler and more semantic$\calA$
. There are a few answers on the site about defining families of commands like those you want. See, for instance, tex.stackexchange.com/a/207992/4427\ensuremath
and\xspace
. It just save two characters but takes more times to process for latex. I am more interested in how to generate such families of commands. I already tried searching but I don't think I am using the right keywords.