Using XeTeX and fontspec, I use the Liberation font family in of my documents. Unfortunately those fonts (esp. Liberation Serif) do not natively support small caps.
Is there a way to enable fake small caps in fontspec?
Using XeTeX and fontspec, I use the Liberation font family in of my documents. Unfortunately those fonts (esp. Liberation Serif) do not natively support small caps.
Is there a way to enable fake small caps in fontspec?
Here I compare an alternative to Yan's approach. I label his method "fake" as he did and label this approach as "faux". I have found (see Good small caps font to use with arev?, for example) that an unequal scaling of horizontal and vertical dimension is better able to capture the proportions of small caps. For Minion Pro, shown in this example, I use 83% horizontal, and 72% vertical scaling to create faux small caps, with 100% horizontal scaling (no change) on the sc Caps. By comparison, I use 91% horizontal and 75% vertical scaling on Computer Modern, with 111% horizontal scaling on sc Caps, and on Palatino, 76% horizontal, 68% vertical scaling, with no change on the sc Caps.
In addition, my \fauxsc macro is able to automatically differentiate lower-case from upper-case arguments, and render them appropriately, which eases the input syntax.
In this MWE, I compare both "fake" and "faux" small caps to the real McCoy for Computer Modern, Minion Pro, and Palatino, respectively.
EDITED to handle UNICODE inputs in Xelatex. Previously, I detected lowercase by seeing if ˋ#1 was in the ASCII lowercase range. This, obviously does not work for UNICODE. Therefore, I adapted macro \fauxschelphelp to test for lowercase-ness using \lccode.
Result can now be seen in last line.
\documentclass{article}
\usepackage{fontspec,graphicx}
\usepackage{graphicx}
\makeatletter
\newlength\fake@f
\newlength\fake@c
\def\fakesc#1{%
\begingroup%
\xdef\fake@name{\csname\curr@fontshape/\f@size\endcsname}%
\fontsize{\fontdimen8\fake@name}{\baselineskip}\selectfont%
\uppercase{#1}%
\endgroup%
}
\makeatother
\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=\lccode`#1\relax\scalebox{\Hscale}[\Vscale]{\char\uccode`#1}\else%
\scalebox{\Cscale}[1]{#1}\fi%
\ifx\relax#2\relax\else\fauxschelphelp#2\relax\fi}
\begin{document}
\LARGE
{\def\Hscale{.91}\def\Vscale{.75}\def\Cscale{1.11}
\makebox[1.2in][l]{This is fake} S\fakesc{mall} C\fakesc{aps} $\leftarrow$ other answer\par
\makebox[1.2in][l]{This is real} \textsc{Small Caps}\par
\makebox[1.2in][l]{This is faux} \fauxsc{Small Caps} $\leftarrow$ this answer
\par}\smallskip
\fontspec{Minion Pro}
\makebox[1.2in][l]{This is fake} S\fakesc{mall} C\fakesc{aps} $\leftarrow$ other answer\par
\makebox[1.2in][l]{This is real} \textsc{Small Caps}\par
\makebox[1.2in][l]{This is faux} \fauxsc{Small Caps} $\leftarrow$ this answer
\par\smallskip
{\fontspec{Palatino Linotype}
\def\Hscale{.76}\def\Vscale{.68}\def\Cscale{1.0}
\makebox[1.2in][l]{This is fake} S\fakesc{mall} C\fakesc{aps} $\leftarrow$ other answer\par
\makebox[1.2in][l]{This is real} \textsc{Small Caps}\par
\makebox[1.2in][l]{This is faux} \fauxsc{Small Caps Œœ} $\leftarrow$ this answer
\par}
\end{document}
\fauxsc works with pdflatex, and without fontspec, provided you load the graphicx package.
– jarnosc
Nov 21 '16 at 19:28
\addfontfeature{LetterSpace=5.0} does not take effect.
– LaTechneuse
Nov 22 '17 at 17:21
\fauxschelphelp macro, here .5pt: \def\fauxschelphelp#1#2\relax{\kern.5pt% \ifnum\#1>``\ifnum`#1<`{\scalebox{\Hscale}[\Vscale]{\uppercase{#1}}\else%
\scalebox{\Cscale}[1]{#1}\fi\else\scalebox{\Cscale}[1]{#1}\fi%
\kern.5pt\ifx\relax#2\relax\else\fauxschelphelp#2\relax\fi}`
– Steven B. Segletes
Nov 22 '17 at 20:48
\textit{this is a \fauxsc{Test}} produces italic small caps which it should not do?
– Steven B. Segletes
Apr 11 '18 at 11:04
\fauxsc{\textit{Foo}} doesn't italicise, when I'd hoped that it would, like with \textsc{\textit{Foo}}
– Alec
Apr 11 '18 at 11:28
\textit{\fauxsc{Foo}}
– Steven B. Segletes
Apr 11 '18 at 11:30
\fauxsc{\itshape Test} were acceptable to you, then this redefinition would handle it: \def\fauxschelphelp#1#2\relax{%
\ifcat\relax#1#1\else%
\ifnum`#1>``\ifnum#1<\{\scalebox{\Hscale}[\Vscale]{\uppercase{#1}}\else%
\scalebox{\Cscale}[1]{#1}\fi\else\scalebox{\Cscale}[1]{#1}\fi%
\fi%
\ifx\relax#2\relax\else\fauxschelphelp#2\relax\fi}
– Steven B. Segletes
Apr 11 '18 at 13:11
\@title to fauxsc and getting: Improper alphabetic constant.
A one-character control sequence belongs after a ` mark. So I'm essentially inserting \0 here.
\@title is valid inside packages, but recall @ in documents is not a letter but an "other" (not catcode 11, but 12), and so unless you surround that section of code with \makeatletter...\makeatother, the invocation of \@title will be interpreted as the macro \@ (a one-character control sequence) followed by the tokens t, i, t, l, and e. Thus, the issue is not \fauxsc but rather your illegal use of @ in a macro name.
– Steven B. Segletes
Dec 15 '18 at 21:37
\def\foo{Foo} and \fauxsc{\foo}, gets Improper alphabetic constant.
A one-character control sequence belongs after a ` mark. So I'm essentially inserting \0 here.
\fauxsc macro is not set up to read macros in general. If the macro expands directly to your desired text, you would use \expandafter\fauxsc\expandafter{\foo}, so that \foo is expanded to text before it is seen by \fauxsc.
– Steven B. Segletes
Dec 15 '18 at 21:56
expandafter but never in this combination. Need to learn a little more on the details. Worked!
– Alberto
Dec 15 '18 at 21:57
\expandafter skips over \fauxsc and executes the 2nd \expandafter, which skips over { and expands \foo. Then what is left is \fauxsc{<expanded-version-of-foo>}.
– Steven B. Segletes
Dec 15 '18 at 21:59
\ifnum\#1>``\ifnum`#1<`\{to ascertain whether a letter is lowercase. In pdflatex, the use of\oewill break that code. And in Xelatex, usingœ, if fails to find a character-code in the "lowercase range" that would trigger a call to\uppercase`.
– Steven B. Segletes
May 09 '21 at 02:01
\fauxschelphelp, change \char\uccode\#1to\ifcat A#1\char\uccode`#1\else#1\fi`
– Steven B. Segletes
Nov 05 '23 at 15:38
\titleformat?
– Jason Murray
Nov 05 '23 at 16:54
\titlecap; here you want it with \fauxsc).
– Steven B. Segletes
Nov 05 '23 at 20:22
\usepackage{titlesec} \usepackage{xcolor}
\titleformat{\chapter}[block] {} {\llap{\color{gray}\chapterNumber\thechapter \hspace{10pt}\vline}} {10pt} {\formatchaptertitle}
\newcommand{\formatchaptertitle}[1]{% \parbox[t]{\dimexpr\textwidth-10pt}{\raggedright\LARGE\fauxsc{#1}}}
\newcommand{\chapterNumber}{%
\fontsize{50}{50}\usefont{U}{eur}{b}{n}}added to the preample works at making\chapterarguments in\fauxsc`.
Here is a simple solution
\documentclass{article}
\usepackage{fontspec}
\makeatletter
\newlength\fake@f
\newlength\fake@c
\def\fakesc#1{%
\begingroup%
\xdef\fake@name{\csname\curr@fontshape/\f@size\endcsname}%
\fontsize{\fontdimen8\fake@name}{\baselineskip}\selectfont%
\uppercase{#1}%
\endgroup%
}
\makeatother
\begin{document}
\Huge
\fontspec{Minion Pro}
This is real \textsc{small caps} \par
This is fake \fakesc{small caps} \par
\medskip
\fontspec{Didot Lt Std}
This is real \textsc{small caps} \par
This is fake \fakesc{small caps} \par
\end{document}
The effect is here,

Clearly, this will not universally work. The \fakesc will resize the font to Cap size without changing the baselineskip. However, this will depend on the design of the font. With Minion Pro, set in \Huge and thus Minion Pro Disp is in use, setting the fake small caps will use Minion Pro Subh, and thus looks not too bad, since Subh is slightly heavier than Disp. But set in a non-optical size font, say Didot, the contrast of weights is even more observable. In addition, due to different x-height, the fake small caps will looks a little too large. So you would need to adjust the \fontsize accordingly.
fontspec and one's font, like Junicode, has native small-caps in normal shape, but lacks them in bold - then a remapping to fontspec's 'FakeBold' can be performed using \DeclareFontShape. Cheers!
– sdaau
May 16 '12 at 15:53
\fakesc is nearly what I need. The only problem is that it doesn't work with \def and \newcommand. Example: \newcommand{\mycmd}{Something that is supposed to be printed using small caps}, \fakesc{\mycmd}. How can I solve it?
– patryk.beza
Feb 27 '17 at 13:10
\uppercase to \MakeUppercase solved the problem (see explanation). :-)
– patryk.beza
Feb 27 '17 at 18:25
The best – and IMHO only acceptable – way to get small caps is to use a font containing them every fake looks bad, since the stroke widths of faked small caps won’t match the real uppercase letter.
Take a look at these images showing Linux Libertine, and make your own decision …

real small caps

faked small caps
You can also use FontForge to add automatically generated real small caps to the font. It's still not the same as real real small caps but it's way better than faked small caps: http://fontforge.sourceforge.net/Styles.html#Smallcaps
Edit: Just had an experience that makes me decidedly modify the above statement to: "It has the potential to be way better than faked small caps. The result can also be utterly useless, however."
Yeah if your font does not provide native small caps you can try the following code to make fake caps. Works fine on my side...
\documentclass[]{article}
%\usepackage{fontspec}
\begin{document}
\makeatletter
\def\mycommand{\bgroup\obeyspaces\mycommandaux}
\def\mycommandaux#1{\mycommandauxii #1\relax\relax\egroup}
\def\mycommandauxii#1{%
\ifx\relax#1\else \ifcat#1\@sptoken{} \expandafter\expandafter\expandafter\mycommandauxii\else
\ifnum`#1=\uccode`#1 {\normalsize #1}\else {\footnotesize \uppercase{#1}}\fi \expandafter\expandafter\expandafter\mycommandauxii\expandafter\fi\fi}
\mycommand{All inside this are fake caps}
\end{document}
Hope it helps ++
I’m a bit late to the game. Nevertheless, this was a fun project to learn expl3 with, so here’s my solution.
The updated version is better in a number of ways: it calculates font metrics (with fewer bugs) once per invocation of the function rather than once per character, detects more lowercase letters, scales the font rather than putting each letter in a box. It automatically detects the current language selected with Polyglossia and uses its special rules (if any) to capitalize the lowercase letters.
The bottom output line shows a word in different languages, each in a font face that does not come with real small caps: Latin Modern Roman Demibold, Latin Modern Roman Dunhill and Latin Modern Roman Bold Italic. You’ll notice that TÜRKİYE has a dot over the İ in Turkish and that Frauenfußball became FRAUENFUSSBALL.
\documentclass[varwidth, preview]{standalone}
\usepackage{fontspec}
\defaultfontfeatures{Scale=MatchUppercase}
\setmainfont[
Scale=1.0,
FontFace={sb}{n}{LMRomanDemi10-Regular},
FontFace={sb}{i}{LMRomanDemi10-Oblique}
]{Latin Modern Roman}
\DeclareRobustCommand\sbseries{\fontseries{sb}\selectfont}
\DeclareTextFontCommand{\textsb}{\sbseries}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage{turkish}
\setotherlanguage{german}
\setotherlanguage{danish}
\newfontfamily\germanfont{Latin Modern Roman Dunhill}
\RequirePackage{expl3}
\ExplSyntaxOn
% As of June 2018, l3regex does not support Unicode, e.g. (\p{Ll}\p{M}*)+
% This regex is therefore incomplete.
\regex_const:Nn \c_ersatz_lower_regex
{[[:lower:]ßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıĵķĸĺļľŀłńņňʼnŋōŏőŕŗřśŝşšţťŧũūŭůűųŵŷźżžıLjljNjnjǣDzdzƀƶǥǿȼɇɉɍɏɟɨʄᴓᵽⱥⱦꝁꝉαβγδεζηθικλμνξοπρςστυφχψωΐέήίΰϊϋόύώϙἀἁἂἃἄἅἆἇἐἑἒἓἔἕἠἡἢἣἤἥἦἧἰἱἲἳἴἵἶἷὀὁὂὃὄὅὐὑὒὓὔὕὖὗὠὡὢὣὤὥὦὧὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾲᾳᾴᾶᾷῂῃῄῆῇῐῑῒΐῖῗῠῡῢΰῤῥῦῧῲῳῴῶῷ]}
\cs_new:Npn \ersatz_helper:nnnn #1 #2 #3 #4 {
{\addfontfeatures{ Scale={#3}, FakeStretch={#4} }
\text_uppercase:nn{#2}{#1}
}
}
\cs_new:Npn \ersatz_force:x #1 {
\str_clear_new:N \l_ersatz_str_str
\str_set:Nn \l_ersatz_arg_str {#1}
%\tl_log:N \l_ersatz_arg_str
\dim_zero_new:N \l_ersatz_ex_dim
\dim_set:Nn \l_ersatz_ex_dim {\fontdimen5\l_fontspec_font}
% The ratio of the font’s official ex metric to the actual height
% of the letter x is a rough-and-ready approximation of the current
% font scaling.
\box_clear_new:N \l_ersatz_x_box
\vbox_set:Nn \l_ersatz_x_box {x}
\dim_zero_new:N \l_ersatz_xheight_dim
\dim_set:Nn \l_ersatz_xheight_dim {\box_ht:N \l_ersatz_x_box}
\box_clear_new:N \l_ersatz_cap_box
\vbox_set:Nn \l_ersatz_cap_box {H}
\dim_zero_new:N \l_ersatz_capheight_dim
\dim_set:Nn \l_ersatz_capheight_dim {\box_ht:N \l_ersatz_cap_box}
\fp_zero_new:N \l_ersatz_prevscale_fp
\fp_set:Nn \l_ersatz_prevscale_fp
{\l_ersatz_xheight_dim / \l_ersatz_ex_dim}
\fp_zero_new:N \l_ersatz_scale_fp
\fp_set:Nn \l_ersatz_scale_fp
{\l_ersatz_xheight_dim / \l_ersatz_capheight_dim}
% A good horizontal scale factor, by eyeball, is the vertical scaling
% factor to the power of 0.75. That is, fonts with a relatively high
% x-height should be stretched a little and fonts with a relatively lower
% x-height should be stretched by a lot. The ratio of hstretch / vscale
% is therefore vscale**(0.75 - 1) = vscale**(-0.25).
%
% Alternative: take the ratio of the width of the lowercase m to 1 em?
\fp_zero_new:N \l_ersatz_hstretch_fp
\fp_set:Nn \l_ersatz_hstretch_fp {\l_ersatz_scale_fp ** (-0.25)}
% We previously calculated the vertical scale factor relative to the
% current one, so we need to convert it to a scale factor relevant to
% \f@size.
\fp_zero_new:N \l_ersatz_vshrink_fp
\fp_set:Nn \l_ersatz_vshrink_fp
{\l_ersatz_scale_fp * \l_ersatz_prevscale_fp}
\str_clear_new:N \l_ersatz_lang_str
% These languages are the only ones that currently have special-case
% handling in expl3, according to the manual. OpenType language codes
% are at
% https://docs.microsoft.com/en-us/typography/opentype/spec/languagetags
{\fontspec_if_current_language:nTF{TRK}
{\str_set:Nn \l_ersatz_lang_str {tr}}
{\fontspec_if_current_language:nTF{AZE}
{\str_set:Nn \l_ersatz_lang_str {az}}
{\fontspec_if_current_language:nTF{LTH}
{\str_set:Nn \l_ersatz_lang_str {lt}}
{\fontspec_if_current_language:nTF{NLD}
{\str_set:Nn \l_ersatz_lang_str {nl}}
{\str_set:Nn \l_ersatz_lang_str {en}}
}
}
}
}
\regex_replace_all:NnN
\c_ersatz_lower_regex
{\c{ersatz_helper:nnnn}\cB\{\0\cE\}\cB\{\u{l_ersatz_lang_str}\cE\}\cB\{\c{fp_to_decimal:N} \u{l_ersatz_vshrink_fp}\cE\}\cB\{\c{fp_to_decimal:N} \u{l_ersatz_hstretch_fp}\cE\}}
\l_ersatz_arg_str
\l_ersatz_arg_str
}
\newcommand\dubioussc[1]{%
\fontspec_if_small_caps:TF{\textsc{#1}}{\ersatz_force:x{#1}}%
}
\newcommand\ersatzsc[1]{\ersatz_force:x{#1}}
\ExplSyntaxOff
\newcommand\test[1]{\fbox{#1}
\fbox{\emph{\ersatzsc{Ersatz}}\ersatzsc{ Small Caps}}
\fbox{\dubioussc{\emph{True} Small Caps?}}\relax}
\begin{document}
{\fontspec{lmroman5-regular.otf}[
ItalicFont=lmroman7-italic.otf,
SmallCapsFont=lmromancaps10-regular.otf,
ItalicFeatures={SmallCapsFont=lmromancaps10-oblique.otf}]
\test{Latin Modern 5}}
{\fontspec{lmroman10-regular.otf}[
ItalicFont=lmroman10-italic.otf,
SmallCapsFont=lmromancaps10-regular.otf,
ItalicFeatures={SmallCapsFont=lmromancaps10-oblique.otf}]
\test{Latin Modern 10}}
{\fontspec{lmroman17-regular.otf}[
ItalicFont=lmroman12-italic.otf,
SmallCapsFont=lmromancaps10-regular.otf,
ItalicFeatures={SmallCapsFont=lmromancaps10-oblique.otf}]
\test{Latin Modern 17}}
{\fontspec{TeX Gyre Pagella}
\test{Pagella}}
{\fontspec{TeX Gyre Termes}
\test{Termes}}
{\fontspec{TeX Gyre Adventor}
\test{Adventor}}
\textsb{\textturkish{Türkiye \ersatzsc{Türkiye}}}
\textgerman{Frauenfußball \ersatzsc{Frauenfußball}}
\textit{\textbf{\textdanish{København \ersatzsc{København }}}}
\end{document}
\documentclass[varwidth, preview]{standalone}
\usepackage{fontspec}
\defaultfontfeatures{Scale=MatchUppercase}
\RequirePackage{expl3}
\ExplSyntaxOn
\regex_const:Nn \c_ersatz_lower_regex {[[:lower:]]}
\cs_new:Npn \ersatz_helper:N #1 {
\regex_match:NnTF
\c_ersatz_lower_regex
{#1}
{
\box_clear_new:N \l_ersatz_sc_box
% Optionally add a language code to \text_uppercase:nn
% (see l3kernel manual).
\hbox_set:Nn \l_ersatz_sc_box {\text_uppercase:nn{#1}}
\dim_zero_new:N \l_ersatz_wd_dim
\dim_set:Nn \l_ersatz_wd_dim {\box_wd:N \l_ersatz_sc_box}
\dim_zero_new:N \l_ersatz_ht_dim
\dim_set:Nn \l_ersatz_ht_dim {\box_ht:N \l_ersatz_sc_box}
\dim_zero_new:N \l_ersatz_xheight_dim
\dim_set:Nn \l_ersatz_xheight_dim {\fontdimen5\font}
\box_clear_new:N \l_ersatz_cap_box
\vbox_set:Nn \l_ersatz_cap_box {H}
\dim_zero_new:N \l_ersatz_capheight_dim
\dim_set:Nn \l_ersatz_capheight_dim {\box_ht:N \l_ersatz_cap_box}
\fp_zero_new:N \l_ersatz_vscale_fp
\fp_set:Nn \l_ersatz_vscale_fp
{\l_ersatz_xheight_dim / \l_ersatz_capheight_dim}
\fp_zero_new:N \l_ersatz_hscale_fp
\fp_set:Nn \l_ersatz_hscale_fp {\l_ersatz_vscale_fp ** 0.75}
\box_resize_to_wd_and_ht:Nnn
\l_ersatz_sc_box
{\fp_to_dim:n {\l_ersatz_hscale_fp * \l_ersatz_wd_dim}}
{\fp_to_dim:n {\l_ersatz_vscale_fp * \l_ersatz_ht_dim}}
\box_use:N \l_ersatz_sc_box
}
{#1}
}
\cs_new:Npn \ersatz_force:x #1 {
\str_clear_new:N \l_ersatz_arg_str
\str_set:Nn \l_ersatz_arg_str {#1}
\tl_log:N \l_ersatz_arg_str
\str_map_function:NN \l_ersatz_arg_str \ersatz_helper:N
}
\newcommand\dubioussc[1]{%
\fontspec_if_small_caps:TF{\textsc{#1}}{\ersatz_force:x{#1}}%
}
\newcommand\ersatzsc[1]{\ersatz_force:x{#1}}
\ExplSyntaxOff
\newcommand\test[1]{\fbox{#1}
\fbox{\emph{\ersatzsc{Ersatz}}\ersatzsc{ Small Caps}}
\fbox{\dubioussc{\emph{True} Small Caps?}}\relax}
\begin{document}
\fontspec{lmroman5-regular.otf}[
ItalicFont=lmroman7-italic.otf,
SmallCapsFont=lmromancaps10-regular.otf,
ItalicFeatures={SmallCapsFont=lmromancaps10-oblique.otf}]
\test{Latin Modern 5}
\fontspec{lmroman10-regular.otf}[
ItalicFont=lmroman10-italic.otf,
SmallCapsFont=lmromancaps10-regular.otf,
ItalicFeatures={SmallCapsFont=lmromancaps10-oblique.otf}]
\test{Latin Modern 10}
\fontspec{lmroman17-regular.otf}[
ItalicFont=lmroman12-italic.otf,
SmallCapsFont=lmromancaps10-regular.otf,
ItalicFeatures={SmallCapsFont=lmromancaps10-oblique.otf}]
\test{Latin Modern 17}
\fontspec{Palatino Linotype}
\test{Palatino}
\fontspec{TeX Gyre Termes}
\test{Termes}
\fontspec{TeX Gyre Adventor}
\test{Adventor}
\end{document}
fontspec knows about them, and falls back to ersatz small caps only when necessary.calc and graphicx first.)\emph{\ersatzsc{Ersatz}}, not \ersatzsc{\emph{Ersatz}}.l3boxes rather than fontspec font features.egregdoesnotlikesansseriftitles :)
– TeXnician
Aug 07 '18 at 15:10
egregdoesnotlikesansseriftitles.
– Davislor
Aug 07 '18 at 15:17
\ersatzsc{\frotz} doesn't yield "\FROTZ" but the text that \frotz gives me, thereby making it possible to use as replacement for \textsc in more situations.
– pst
Apr 21 '21 at 14:14
Here is a very simple solution which I use when I'm forced by editors to use the Times New Roman font, which have no Small Caps implemented. Since I want to leave the rest of my document intact, I simple redefine \textsc in the following way:
\renewcommand{\textsc}[1]{{\footnotesize \uppercase{#1}}}