5

A brief search yielded no answers, so I'm posting this question:

Is there a way to get smallcaps to display correctly in (subsub...)section titles?

My problem in particular is in the following code:

\documentclass{article}
\newcommand*{\matlab}{\textsc{matlab}}

\begin{document}
 \section{\matlab}}
\end{document}

Instead of producing a smallcaps MATLAB in the title, it produces normal text - "matlab", i.e. what went into \textsc{} in the newcommand*{}{}.

It doesn't actually produce an error or warning and compiles, but doesn't give me the required output.

Anyone know of a work-around/solution?

jamesh625
  • 349
  • 1
    Just to clarify: You want to keep bold for most of the section header material, but you want to preserve smallcaps for selected strings? And you want to do this Computer Modern fonts, which don't feature a bol-smallcaps weight/shape combination? – Mico Apr 22 '15 at 04:00
  • This is a missing bold font issue, in my point of view, as the compiler complains about a missing font small caps.... just saw that Mico was faster than me ;-) –  Apr 22 '15 at 04:02
  • See the http://tex.stackexchange.com/questions/55664/fake-small-caps-with-xetex-fontspec and the answer by Steven B. Segletes, although it's a different question, the \fauxsc command might be of help here (or what Mico did ;-)) –  Apr 22 '15 at 04:10
  • I just want "matlab" to appear as smallcaps - bold or not is not my primary concern, although unbolded would be nicer. – jamesh625 Apr 22 '15 at 04:20
  • \newcommand*{\matlab}{{\sc matlab}} – Mark Apr 22 '15 at 04:26
  • @Mark - \sc is a Plain-TeX font instruction that's deprecated in LaTeX. – Mico Apr 22 '15 at 05:22

2 Answers2

8

What you're discovering is that the Computer Modern font family doesn't feature a bold/smallcaps weight/shape combination. To restore the "normal" weight for the smallcaps string, you need to preface it with an \mdseries directive.

enter image description here

\documentclass{article}
\newcommand*{\matlab}{\textsc{matlab}}
\newcommand*{\altmatlab}{{\mdseries\matlab}} % note the double pair of curly braces
%%% "\newcommand*{\altmatlab}{\textmd{\matlab}}" works too...
\begin{document}
 \section{A title that contains ``\matlab'' as a string}
 \section{A title that contains ``\altmatlab'' as a string}
\end{document}

Other font families, e.g., Times Roman, do feature a bold/smallcaps combination. If you were to use one of these font families, using the basic \matlab macro in section headers would be fine.

Mico
  • 506,678
2

Also possible:

\documentclass{article}

\newcommand*\matlab{{\normalfont\textsc{matlab}}}

\begin{document}

  \section{A title that contains ``\matlab'' as a string}

\end{document}
Su-47
  • 2,508