# Faked Small Caps as style

I am sorry if this has somehow already been asked, but after searching for about 2 hours I didn't manage to find anything.

So, I am using the Greek Linux Libertine font which does not provide for Small Caps, which means I had to define the \fauxsc{} command, as suggested by egreg here. This works well whenever I use it as \fauxsc{Text text text}. However, when I have to use it as a style (for example if I want Small Caps in a Chapter's Name and thus have to redefine \titleformat{\chapter}), it can't work, since it needs text as an argument.

In other words, if \fauxsc{...} is the alternative to \textsc{...}, I am looking for the alternative to \scshape.

• titlesec does allow you to wrap a macro around the title if you load it with the option explicit (say).
– user194703
Oct 28, 2019 at 2:51
• Welcome! I guess you already know this is a Bad Idea, right?
– cfr
Oct 28, 2019 at 3:23
• Hello cfr! Having read most topics concerning the matter in here, of course I understand the problems of the method I am trying to implement. Howerver, since the greek language has a very limited variety of fonts, believe it or not, this has become my best option. Oct 28, 2019 at 9:38

Welcome! If your reason for the question is that you want to use \textsc for section titles, you can use the explicit option here to wrap the title text in a macro.

\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage{graphicx}
\usepackage{plex-serif}
\usepackage{roboto}
% from https://tex.stackexchange.com/a/499046/194703
\let\textsc\relax
\DeclareRobustCommand{\textsc}[1]{%
\sbox0{x\xdef\testA{\the\font}}%
\sbox0{\scshape x\xdef\testB{\the\font}}%
\ifx\testA\testB\fauxsc{#1}\else{\scshape #1}\fi
}

\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
\MakeUppercase{#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>\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}

% explicit title format
\titleformat{name=\section}
[block]
{\large}
{\thesection}
{10pt}
{ \textsc{#1}}
[]
\begin{document}
\section{A Test Section}
\end{document}


Note that if you want to make this work in the table of contents, too, you will need to use titletoc and instruct it to use \textsc as well. See here for a concrete example.

• +1. But: \texsc or \textsc?
– Mico
Oct 28, 2019 at 4:53
• Hello and sincerely thank you for your answer. Indeed, the reason I need this is for chapters, sections and subsections. I tried to implement your way and indeed, it does work for sections. However, the problem is then that the section is added at the Table of Contents without the fauxsc effect. Furthermore, and more importantly, when trying to apply it to chapters it does not work at all - the compiler sends me lots of error messages concerning the table of contents, such as "Improper Alphabetic Constant". Oct 28, 2019 at 9:37
• @Mico Thanks! That's a typo in the blablabla before the code, I think in the code it is correct. ;-) (BTW, recently autocorrection got auto-installed, it does very interesting things to me, but the above one is on me.)
– user194703
Oct 28, 2019 at 13:29
• @Kugene You will also need titletoc`, I think. Can you please provide us with a complete minimal example that shows what you are doing? Otherwise it is hard to make concrete suggestions.
– user194703
Oct 28, 2019 at 13:32
• @Schrödinger's_cat Never mind, nothing's wrong with the Chapters anymore, using the "Explicit" properly indeed did the trick! The only problem that remains is that I can't get the ToC to show chapters, sections, etc. in (fake) small caps. Interestingly, I used a \makeatletter \makeatother to make all ToC contents uppercase through \MakeTextUppercase, but whenever I replace \MakeTextUppercase with \fauxsc I get all sorts of errors such as "Improper alphabetic constant". I'm happy with everything so far, I'd just appreciate it if I could get fauxsc to work on the ToC elements as well! Oct 28, 2019 at 13:43