TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In LaTeX, 'active' declarations (commands without argument) like \Gamma produce printable characters to the output stream while 'passive' ones like \itshape do not. Is there a macro (or how to write one) which, given a LaTeX declaration as argument, will resolve whether the declaration is active or passive?

I need to be able to resolve this issue in order to correctly format the rendering of an input LaTeX argument with embedded declarations.

share|improve this question
Welcome to TeX.sx! A tip: you can use backticks ` to mark your inline code as I did in my edit. – doncherry Aug 7 '11 at 17:31
The distinction between commands with and without arguments is not equivalent to that between those that write to the output document and those that do not - consider \textit vs \itshape and all the analogous font-changing commands for example. – Ant Aug 7 '11 at 17:32
Not really, your distinction of "active" and "passive" macros doesn't exist like that. Actually \textit is much more 'active' because it's changing the font(!) while \Gamma only prints a character. Also note that 'active' normally mean active characters with (La)TeX, like ~. You could of course use a savebox (see \sbox) and measure the width of the resulting text which should be zero for "passive" macros. However, you need to provide the right number of dummy arguments.... – Martin Scharrer Aug 7 '11 at 17:41
My use of the descriptions 'active' and 'passive' were coined ad hoc to distinguish between those declarations that write to the output stream and those that do not. I am not concerned with what is going on 'behind the scene' so to speak. I think you misunderstand my question. I need to know a priori if a LaTex command will or will not produce output. For example I need to be able to determine for the Latex inputfor any conmmand \declaration – darrelld Aug 7 '11 at 18:05
@darrelld: I understood you correctly and my answer stands: You can't! The only way is to measure the result. If you explain your actual problem than we might be able to help you better. – Martin Scharrer Aug 7 '11 at 18:17

This is not an answer to the question as currently stated. Given some comments of darrelld, I believe that the goal is to define a macro, \TitleCase, which puts its argument in, well, title case. This can be done with varying degrees of robustness, but one way is to read tokens one at a time and convert letters using \uppercase and \lowercase.

Here, \TitleCase@case is at all times either \uppercase or \lowercase: it is set to \uppercase at the very start of the \TitleCase command, and after each space. It is set to \lowercase by any letter.

The result is stored one piece at a time into \TitleCase@tl, and used at the end.

    \ifcase 0%
        \ifcat\noexpand\@let@token\bgroup 1\fi
        \ifx\@let@token\@sptoken 2\fi
        \ifx\@let@token\TitleCase@marker 3\fi
    \or \expandafter\TitleCase@group
    \or \expandafter\TitleCase@space
    \or \expandafter\@gobble
          {\TitleCase@tl #1}%
    \ifcat A\noexpand\@let@token
      \TitleCase@ #1\TitleCase@marker
  {\afterassignment\TitleCase@space@\let\@let@token= }
  \section{\TitleCase{helLo, \itshape wo\textup{Rl}D!}}
share|improve this answer
@ Bruno Le Floch: Thank you for putting time and thought into this macro. It is along the same lines as I have already done but, not being a TEXnician, using higher level LaTex commands from the xstring package. Your macro renders what I would call Initial Capital Case which is somewhat different from what I understand by the more subtle Title Case. Never mind, I think that I can see my way forward using save boxes as Martin Scharrer suggests. Strangely I have tried that approach before but without success till now. – darrelld Aug 8 '11 at 16:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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