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 the post Fake small caps with XeTeX/fontspec? I have found the following definitions to fake small caps

   \def\mycommandaux#1{\mycommandauxii #1\relax\relax\egroup}
   \ifnum`#1=\uccode`#1 {\normalsize #1}\else {\footnotesize \uppercase{#1}}\fi   

   % ...

   \mycommand{This text is set in fake small caps.}

\mycommand works properly in the main text. However, when \mycommand is used inside other commands like \title of \footnote it removes the spaces between the words.

So I wonder if there is any way to make the above command to work inside other commands or if there are other ways to achieve the same result.

In the code above \normalsize and \footnotesize can be replaced some \fontspec instructions. An advantage of the approach (or similar) is that it could work for generic fonts without small caps (I am aware of fontinst and the support for creating small caps in fontforge)

share|improve this question
What is the question? – Marc van Dongen Jul 25 '12 at 2:01
@MarcvanDongen The question is why does the posted code not work when used within another command like \title or \footnote. – Alan Munn Jul 25 '12 at 4:18
It can't work: it's a verbatim-like approach as \obeyspaces alters the tokenization of spaces. You need to use an alternative token-by-token mapping that respects spaces. These are always a bit tricky! – Joseph Wright Jul 25 '12 at 6:13
Any suggestion on how to do the alternative token-to-token mapping? – Guido Jul 25 '12 at 7:04
@AlanMunn Thanks for the clarification. It was sort of clear but Guido would do himself a favour if he stated an explicit question. – Marc van Dongen Jul 25 '12 at 11:41
up vote 5 down vote accepted

A different approach: with \fakesc you can store the "faked" text in a control sequence for later use.


\NewDocumentCommand{\fakesc}{ o m }
  \guido_fakesc:n { #2 }
    \tl_use:N \l__guido_temp_tl
    \cs_set_eq:NN #1 \l__guido_temp_tl
\cs_new_protected:Npn \guido_fakesc:n #1
  \tl_set:Nn \l__guido_text_tl { #1 }
  \tl_replace_all:Nnn \l__guido_text_tl { ~ } { \q_space }
  \tl_set:Nn \l__guido_temp_tl { \group_begin: \footnotesize }
  \tl_map_inline:Nn \l__guido_text_tl
    \token_if_eq_meaning:NNTF ##1 \q_space
      \tl_put_right:Nn \l__guido_temp_tl { ~ }
      \int_compare:nTF { \char_value_uccode:n { `##1 } = `##1 }
        \tl_put_right:Nn \l__guido_temp_tl { {\normalsize ##1} }
        \tl_put_right:Nn \l__guido_temp_tl { \tl_to_uppercase:n { ##1 } }
  \tl_put_right:Nn \l__guido_temp_tl { \group_end: }
\quark_new:N \q_space
\tl_new:N \l__guido_text_tl
\tl_new:N \l__guido_temp_tl

\fakesc[\mytitle]{This is the title}

\author{An Author}

\fakesc{All inside this are fake caps} and this is normal


But this is just a hack and real small caps should be preferred. The argument to \fakesc must consist only of letters and spaces. No fancy characters or commands.

enter image description here

share|improve this answer
Who's guido (from \guido_fakes)? – einpoklum Mar 9 '14 at 20:21
@einpoklum Guido is the questioner; I usually take the OP's nickname for the prefix. – egreg Mar 9 '14 at 20:38

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.