4

I am using kpfonts and I know I have to use \textscsl to get a slanted small caps but is there any way in which I can substitute automatically to \textscsl{slanted-small-caps} whenever I have the text of the form {\scshape \textit{slanted-small-caps}}?

To exemplify, refer to the MWE below:

\documentclass{memoir}
\usepackage{kpfonts}
\usepackage[T1]{fontenc}

\renewcommand*{\printchaptertitle}[1]{\scshape{#1}}

\begin{document}

\chapter{small caps \textit{slanted-small-caps}}

\end{document}

So, I want the 'slanted-small-caps' to be a slanted small caps. How do I force substitute anything of that nature automatically as \textscsl? And at the same time, I want to preserve the \textit{} as I want it to be an italic font in, say, the table of content.

  • Some fonts and packages do not support slanted small caps. I don't know about kpfonts. I suggest you read the package documentation. – user10274 Feb 5 '17 at 18:37
  • I'm afraid your write-up is a bit confusing. For sure, "slanted" and "italic" are not synonyms, even though sloppy terminology might occasionally suggest otherwise. To wit, note the difference between textsl{Hello World} and \textit{Hello World} using either kpfonts or Computer/Latin Modern. Please rephrase your posting and be a bit clearer about what you're trying to achieve. – Mico Feb 5 '17 at 18:51
  • @Mico. Yes, I'm aware of the differences between "slanted" and "italic". Several days ago, before I updated my MiKTeX, it always automatically substituted any text of the form \textsc\textit{} to slanted\italicized small caps. I'm not sure why but it did, and it stopped doing so right after I updated my MiKTeX. Though I'm not really sure whether it was slanted or italicized back then, I don't really mind now if the final solution is to be italicized or slanted as long as it is, you know, "turned"-small caps. So I thought one is able to force substitute like what it did before in my MiKTeX. – Anonymouse Feb 5 '17 at 19:20
  • @Mico This is true, but italic and oblique small-caps tend to mean more-or-less the same thing, because italic capitals tend to look pretty much like the slanted versions. Of course, a font could be designed so that this was not the case, but they tend not to be. At least, that's been my impression. Moreover, some LaTeX packages use si and some use scsl for italic/oblique small-caps. So in LaTeX terms, they tend to be synonymous, which unfortunately means you have to know which a font is using .... – cfr Feb 5 '17 at 21:03
2

You can, by using fontaxes and helping the font selection scheme so it substitutes scsl for scit, because kpfonts only knows about the former.

\documentclass{memoir}
\usepackage[T1]{fontenc}
\usepackage{fontaxes}
\usepackage{kpfonts}
\usepackage{etoolbox}

\renewcommand*{\printchaptertitle}[1]{\scshape#1}

\AtBeginDocument{%
  \csletcs{T1/\familydefault/m/scit}{T1/\familydefault/m/scsl}%
  \csletcs{T1/\familydefault/b/scit}{T1/\familydefault/b/scsl}%
  \csletcs{T1/\familydefault/bx/scit}{T1/\familydefault/bx/scsl}%
}

\begin{document}

\chapter{small caps \textit{slanted-small-caps}}

\end{document}

enter image description here

2

There are two problems.

The first is that the code in your example does not set chapter titles in small-caps. This is easily solved. We just need to check Memoir's documentation and use a modified version of the example command it gives us:

\renewcommand{\chaptitlefont}{\normalfont\scshape}

The second problem is more fundamental: the New Font Selection Scheme (NFSS), which LaTeX 2e uses to select fonts by default, does not support italic small-caps at all. Hence, different packages and fonts provide different commands and different names and so on. There is, simply, no standard. In particular, whether something like

\textsc{abc \textit{def}}

behaves as expected depends entirely on the whims of the author of the relevant font support package and any extended interface that package plugs into.

kpfonts itself doesn't support this.

And since a general solution requires the font to be set up in a way which supports it, which isn't the case here, we can't just plug into the interface provided by nfssext-cfr (or fontaxes or whatever).

However, we can provide modified versions of a couple of definitions from nfssext-cfr, tailored to kpfonts and these shapes, in particular.

\documentclass{memoir}
\usepackage{kpfonts}
\usepackage[T1]{fontenc}

\renewcommand{\chaptitlefont}{\normalfont\scshape}

\makeatletter
% based on definitions in nfssext-cfr, which is based on nfssext
% this stuff is almost certainly from the original nfssext
\DeclareRobustCommand{\itshape}{%
  \not@math@alphabet\itshape\mathit
  \anonymouse@test@shape{\itdefault}{\scdefault}{\scsldefault}}
\newcommand*\anonymouse@test@shape[3]{%
  \edef\anonymouse@tempa{#2}%
  \ifx\f@shape\anonymouse@tempa\fontshape{#3}\else\fontshape{#1}\fi
  \selectfont
}
\newcommand*\scsldefault{scsl}
\makeatother

\begin{document}

\chapter{small caps \textit{slanted-small-caps}}

\end{document}

slanted small-caps automatically

Note that the above code only fixes the relevant case. It is not general at all! If you write

\textsc{abc \textsl{def}}

def will be in italic lower-case. If you write

\textit{abc \textsc{def}}

def will be in upright small-caps.

Because kpfonts doesn't support one of the general frameworks for extending NFSS, each of these cases would need to be handled separately, if required. This is perfectly straightforward, however, and you can simply adapt the example above if you require this.

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.