I'm making a new command like which goes kind of like this:


So, what I what is to type \mycommand{sub}{blah} to output \subsection{blah} and \mycommand{subsub}{blah} to output \subsubsection{blah}. Is this even possible?


\csname allows to construct command sequence names:


If the constructed command is not defined, then it does not throw an error. Instead, the constructed command has the meaning \relax.

  • Nice, so \csname allows you to construct command sequence names, but is there anything that allows you to construct variables defined with \def? – Skeleton Bow Jul 4 '17 at 20:02
  • @SkeletonBow The "command sequence names" are just command tokens that start with the escape char (backslash). Macros (defined by \def, \newcommand, ...) belong to them. – Heiko Oberdiek Jul 4 '17 at 20:04
  • Oh, okay. Then my problem must lie elsewhere. I just checked and confirmed what you said, anyway :) ) – Skeleton Bow Jul 4 '17 at 20:05
  • @SkeletonBow Probably, a missing \expandafter: \expandafter\def\csname ...\endcsname – Heiko Oberdiek Jul 4 '17 at 20:09
  • 1
    @SkeletonBow -- to make this question "persistent", please insert your mwe in the question itself, not linked elsewhere. (even though it links to another tex.sx question, which probably won't disappear, this one will be more helpful to future visitors if it is complete.) – barbara beeton Jul 4 '17 at 23:51

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.