3

I'm trying to alter \scshape in XeLaTeX, but for some reason, three reasonable attempts (xpatch, \def, and \renewcommand) seem to have no effect whatsoever (only in XeLaTeX). A nonworking example is below (note that the 5 em space is just to make it clear when the redefinition is working, and obviously not intended for use in a real document):

\documentclass{article}
\usepackage{xpatch}
\xapptocmd{\scshape}
  {\spaceskip=5em}
  {}{}
%\let\myscshape\scshape
%\def\scshape{\spaceskip=5em\myscshape}
%\renewcommand{\scshape}{\myscshape\spaceskip=5em}



\begin{document}
\noindent\textsc{Test thing test}\\
\scshape Test thing test\\
\scshape\spaceskip=5em Test thing test
\end{document}
1
  • 2
    The given code doesn't change anything in lualatex either. \scshape might be protected. If you append to a hook (parameterless macro), \appto{\xscshape}{\spaceskip=5em >>\color{red}}, it works; if you append to an unprotected macro, \newcommand\xscshape{\scshape}\xapptocmd{\xscshape} {\spaceskip=5em >>\color{red}} {}{}, it also works. The prepends also work. If you pre/append to a command (=parametered macro, like \textsc), the replacement text is per/appended to as expected.
    – Cicada
    Jun 24 at 3:39
4

Do the patch at begin document.

\documentclass{article}
\usepackage{xpatch}
\usepackage{fontspec}

\AtBeginDocument{%
\xapptocmd{\scshape}
  {\spaceskip=5em}
  {}{}%
}

\begin{document}

\textsc{Test thing test}

\scshape Test thing test

\end{document}

enter image description here

4
  • Brilliant—many thanks!
    – tex_user_7
    Jun 24 at 15:14
  • Out of intellectual curiousity, why does using \AtBeginDocument make it work?
    – tex_user_7
    Jun 24 at 15:15
  • 1
    @ezgranet A great part of font setup is done at begin document; different font packages may have different ideas about how to realize small caps.
    – egreg
    Jun 24 at 15:47
  • thank you—very interesting.
    – tex_user_7
    Jun 24 at 16:57

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.