3

I have been using "FauxSC" from Steven B. Segletes and am pretty happy with it. Except one thing which im unable to solve: Giving it normal text as input is all fine, but as soon as its \today or \jobname or any such command (that ends up spitting out text), it breaks with an Improper alphabetic constant.

MWE is over in Stevens original, just copy that and put a \fauxsc{\today} in.

My TeX is, unfortunately, not good enough to fix it. I guess it's the \ifnum breaking, but I don't know how to get it to take the value of the \today.

Any help would be great, thanks!

  • 1
    Welcome to TeX.SX! Possibly \expandafter\fauxsc\expandafter{\today} works. But, if your font has no real small caps, emulating them will result in poor typesetting. – egreg Nov 18 '16 at 22:11
  • Thanks, it solves it for \jobname, but \today errors out with an Improper alphabetic constant on a \number.

    And yes, I know that emulating them isn't the worlds best thing, but one can't always have it perfect. It's a small part of the document only, the alternative would be an entire new set of fonts...

    – Joerg Jaspert Nov 18 '16 at 22:28
  • Perhaps \edef\tmp{\today}\expandafter\fauxsc\expandafter{\tmp}. Depends if you're using the default definition of \today or if you're using a package that redefines it. – Nicola Talbot Nov 18 '16 at 22:40
  • You hit it there (and so my MWE link to Stevens original was faulty, my bad, sorry), I actually use babel... Luckily I got rid of `\today? needing to be in smallcaps, so it won't hurt me here. – Joerg Jaspert Nov 19 '16 at 22:36

1 Answers1

2

You can define a \fauxscexp for the cases you have a control sequence to expand.

\documentclass{article}
\usepackage{fontspec}

\newcommand\fauxsc[1]{\fauxschelper#1 \relax\relax}
\def\fauxschelper#1 #2\relax{%
  \fauxschelphelp#1\relax\relax%
  \if\relax#2\relax\else\ \fauxschelper#2\relax\fi%
}
\def\Hscale{.83}\def\Vscale{.72}\def\Cscale{1.00}
\def\fauxschelphelp#1#2\relax{%
  \ifnum`#1>``\ifnum`#1<`\{\scalebox{\Hscale}[\Vscale]{\uppercase{#1}}\else%
    \scalebox{\Cscale}[1]{#1}\fi\else\scalebox{\Cscale}[1]{#1}\fi%
  \ifx\relax#2\relax\else\fauxschelphelp#2\relax\fi}
\newcommand{\fauxscexp}[1]{%
  \begingroup\edef\x{\endgroup\noexpand\fauxschelper#1 \relax\relax}\x
}

\begin{document}

Normal: \fauxsc{Small Caps}

Job name: \fauxscexp{\jobname}

Today: \fauxscexp{\today}

\end{document}

enter image description here

egreg
  • 1,121,712
  • Thanks, that does the trick. I actually managed to get \today out of the need to be in (faux)sc, which is always a good thing, but the jobname needs it and works nicely. – Joerg Jaspert Nov 19 '16 at 22:34