I've searched for but not found an answer to this.

I am using two layers of \newcommands to create symbols inline with text, using \includegraphics. (It's for music symbols.)

At present, I have this as the generic command:


And then many commands of the form:


This works, but it is cumbersome to type the same text twice during set up. Of course, I could employ a command with arguments in my document body, but I don't want to do that. Is there a way to replace the specific commands with something of the form:

  • 1
    Try something like \def\newnote#1{\edef\csname #1\endcsname\inlineImage{-1.5}{#1}}
    – Eddy_Em
    Aug 13, 2013 at 19:01

2 Answers 2


The etoolbox package provides the \csdef command:


Then use


to create the macros \Eighth and \Sixteenth as you wanted.

  • LaTeX provides \@namedef. Aug 23, 2013 at 5:50

To make command from text use \csname .. \endcsname macros. For example, if you will write

\def\newnote#1{\expandafter\def\csname #1\endcsname{\inlineImage{-1.5}{#1}}}

then commands like


will define notes \Fourth, \Eighth and \Sixteenth, which will insert appropriate images.

  • Thanks Eddy_Em: this gets me a lot closer! However, part of the problem is that I need to adjust the raisebox variable. It was daft of me not to make that explicit with my example, which I have now corrected. How can I adapt the above answer to do this? This is beyond my abilities at the moment! Aug 22, 2013 at 23:11
  • It may be noteworthy that you can also do \expandafter\newcommand\csname #1\endcsname to still have the possibilities to use \newcommand syntax. Aug 23, 2013 at 6:11
  • @Qrrbrbirlbel, \newcommand is overhead for such simple task.
    – Eddy_Em
    Aug 24, 2013 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.