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. ไก่ตัน Says:
    November 2nd, 2024 at 20:38

    … [Trackback]

    […] Here you will find 88149 more Info to that Topic: compdigitec.com/labs/2016/02/13/latex-macros-ending-in-numbers/ […]

  2. ตู้เชื่อม Says:
    November 9th, 2024 at 03:52

    … [Trackback]

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

  3. 2 tokens por pm cams Says:
    November 11th, 2024 at 06:07

    … [Trackback]

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

  4. dark168 Says:
    November 12th, 2024 at 13:45

    … [Trackback]

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

  5. Jaxx Liberty Says:
    November 14th, 2024 at 19:59

    … [Trackback]

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

  6. ประวัติความเป็นมาของเว็บหวยออนไลน์ HiHUAY Says:
    December 2nd, 2024 at 19:01

    … [Trackback]

    […] There you will find 59275 additional Information to that Topic: compdigitec.com/labs/2016/02/13/latex-macros-ending-in-numbers/ […]

  7. สล็อตเว็บใหญ่ทุนหนา โบนัสแตกเท่าไหร่ ถอนได้ไม่อั้น Says:
    December 19th, 2024 at 07:56

    … [Trackback]

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

  8. แพคเกจทัวร์ Says:
    December 20th, 2024 at 21:32

    … [Trackback]

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

Comments