Compdigitec Labs

« | Home | »

LaTeX macros ending in numbers

By admin | February 13, 2016

Only letters are directly permitted in macro names, but by using csname to create definitions along with a variable command, we can simulate them.

First, define the macros with numbers using \csname:

\expandafter\def\csname xR1\endcsname{-3}
\expandafter\def\csname xR2\endcsname{9}

Now, create a command which takes in one variable argument, and simply expands it to call the appropriate macro (“xR” + variable) defined above.

\newcommand{\xR}[1]{\expandafter\csname xR#1\endcsname}

And to use the macros:

The first is \xR1 and the second is \xR2.

If you found this article helpful or interesting, please help Compdigitec spread the word. Don’t forget to subscribe to Compdigitec Labs for more useful and interesting articles!

Topics: Linux | 7 Comments »

7 Responses to “LaTeX macros ending in numbers”

  1. visit website Says:
    August 13th, 2025 at 15:12

    … [Trackback]

    […] Info to that Topic: compdigitec.com/labs/2016/02/13/latex-macros-ending-in-numbers/ […]

  2. clothing manufacturer Says:
    August 16th, 2025 at 22:34

    … [Trackback]

    […] Find More on on that Topic: compdigitec.com/labs/2016/02/13/latex-macros-ending-in-numbers/ […]

  3. https://sweetbonanzatunisia.com/ Says:
    August 20th, 2025 at 11:16

    … [Trackback]

    […] Information on that Topic: compdigitec.com/labs/2016/02/13/latex-macros-ending-in-numbers/ […]

  4. รับสร้างโกดัง Says:
    August 31st, 2025 at 18:28

    … [Trackback]

    […] Find More on that Topic: compdigitec.com/labs/2016/02/13/latex-macros-ending-in-numbers/ […]

  5. y8 Says:
    September 4th, 2025 at 08:28

    … [Trackback]

    […] Info to that Topic: compdigitec.com/labs/2016/02/13/latex-macros-ending-in-numbers/ […]

  6. จอสัมผัสอัจฉริยะ Says:
    September 9th, 2025 at 20:37

    … [Trackback]

    […] Read More Information here on that Topic: compdigitec.com/labs/2016/02/13/latex-macros-ending-in-numbers/ […]

  7. como jugar el bono de 1win Says:
    September 14th, 2025 at 08:02

    … [Trackback]

    […] Read More to that Topic: compdigitec.com/labs/2016/02/13/latex-macros-ending-in-numbers/ […]

Comments