5

Is it possible to combine small caps (\textsc) and sans serif (\textsf)? I am using the default LaTeX fonts.

2
  • 3
    The Computer Sans typeface has no small caps font.
    – egreg
    Oct 4, 2019 at 16:02
  • @egreg Is there another (similar) font which does have small caps?
    – taninamdar
    Oct 4, 2019 at 19:35

2 Answers 2

6

You can nest \textsf and \textsc in either order, but unless there is a font of that form, LaTeX will issue a warning and substitute a different style.

One that does work with no warnings is the newtxtext font set.

enter image description here

\documentclass{article}
\usepackage{newtxtext}
\begin{document}

sc-sf \textsc{\textsf{One two Three}}


sf-sc \textsf{\textsc{One two Three}}

\end{document}
2
  • 2
    If you’re using fontspec, many sans-serif fonts have small caps, including TeX Gyre Heros and Adventor. You can also give the \setsansfont command the SmallCapsFont = option.
    – Davislor
    Oct 4, 2019 at 19:58
  • @Davislor well that's true but I guess the OP isn't, but it wouldn't hurt if you posted a fontspec based answer as a comparison. Oct 4, 2019 at 20:41
2

For the case the font does not support small caps, I recently wrote a small script that transforms lowercase letters into smaller uppercase versions. It even works with ä, ö, ü and ß.

\c{textsmaller}[2] can be replaced by \c{textscale}\cB\{0.7\cE\} to make customisability more granular.

When one's specific case is not covered, these steps might help:

  • include a special exception in the regex command
  • replace [^A-Z] with [a-z]
  • replace \0 with \1
\usepackage[utf8]{inputenc}
\usepackage{xparse,relsize}

\ExplSyntaxOn

\NewDocumentCommand{\textsmallcaps}{ m }{% Define new command with one mandatory argument
    \textapperance_smallcaps:n { #1 }% Call
}%

\tl_new:N \l__textapperance_textsmallcaps_input_tl% Initialize string variable
\cs_new_protected:Npn \textapperance_smallcaps:n #1 
{% Create hidden command with one argument
    \tl_set:Nx \l__textapperance_textsmallcaps_input_tl { #1 } % Fully expand contents and store them in the variable
    \regex_replace_all:nnN 
    { ([^A-Z]+) } 
    { \c{textsmaller}[2]\cB\{\c{uppercase}\cB\{\0\cE\}\cE\} } 
    \l__textapperance_textsmallcaps_input_tl % Replace everything thats NOT a capital letter by \textsmaller[2]{\uppercase{<match>}}
    \tl_use:N \l__textapperance_textsmallcaps_input_tl   % Return
}
 
\ExplSyntaxOff
1
  • ä, ö, ü have to be lowercase! The reason is, that l3regex does not support utf8 for pdfLaTeX, yet.
    – learex
    Apr 12, 2021 at 20:36

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .