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 | 8 Comments »

8 Responses to “LaTeX macros ending in numbers”

  1. Mostbet Says:
    March 25th, 2025 at 18:44

    … [Trackback]

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

  2. Werewolf\'s Hunt Says:
    March 27th, 2025 at 22:13

    … [Trackback]

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

  3. pinco Says:
    April 25th, 2025 at 23:17

    … [Trackback]

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

  4. ร้านเค้กวันเกิดใกล้ฉัน Says:
    April 28th, 2025 at 20:54

    … [Trackback]

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

  5. Green Tube Book of Ra Says:
    May 9th, 2025 at 06:36

    … [Trackback]

    […] There you can find 8589 additional Info on that Topic: compdigitec.com/labs/2016/02/13/latex-macros-ending-in-numbers/ […]

  6. สั่งของจากจีน Says:
    May 16th, 2025 at 21:39

    … [Trackback]

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

  7. รับซื้อแบรนด์มือสอง Says:
    June 12th, 2025 at 21:10

    … [Trackback]

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

  8. pinco indir Says:
    June 18th, 2025 at 17:12

    … [Trackback]

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

Comments