1

I would like to have my section titles in bold and small caps, but they do not seem to work.

\documentclass[12pt,a4paper]{article}
\usepackage[
    left = 2cm, 
    right = 2.5cm, 
    top = 1.5cm, 
    bottom = 2cm
]{geometry}
\usepackage{microtype}
\usepackage{titlesec}
\usepackage{fancyhdr}

\titleformat{\section}{\Large\sc\bfseries}{}{0cm}{}[\titlerule] \titleformat{\subsection}[runin]{\bfseries\sc}{}{0cm}{}[ --] \titleformat{\subsubsection}{\large\bfseries\sc}{}{0cm}{}

\renewcommand{\labelitemi}{--} \newcommand{\tabitem}{\makebox[0pt][r]{--}}

%Manipulation of headers and footers \pagestyle{fancy} %Clear fields \fancyhf{} %Page numbering in footer \fancyfoot[C]{\thepage} %Separation line header and footer \renewcommand{\footrulewidth}{0.4pt} \renewcommand{\headrulewidth}{0pt}

\begin{document} \thispagestyle{fancy}

\begin{center} \Huge \textbf{\textsc{Eating\hspace{0.5cm}Foods}} \end{center}

\section{How to eat food} Food is important \subsection{Using hands} Most versatile \subsection{using chopsticks} Requires practice \subsection{using spoons} Kind of a middle ground \subsubsection{Types of spoons} There are many types of spoons

\end{document}

Currently, all titles only come in bold font or small caps depending on their order of appearance in the \titleformat argument.

Miloop
  • 783

1 Answers1

4

As Alan Munn mentioned in the comments, you need to use \scshape rather than the plain TeX \sc (which cannot be combined with other formatting). You will then get the warning:

LaTeX Font Warning: Font shape `OT1/cmr/bx/sc' undefined

OT1 is the original 7-bit TeX encoding from the ’80s (back when network hardware would often use the eighth bit for error correction and mangle 8-bit data). It’s still the default output encoding in PDFTeX (although the default input encoding is now UTF-8). The default font, Computer Modern Roman (cmr), doesn’t define a bold extended (bx) small-caps (sc) face in OT1.

In PDFTeX, you can fix this by switching to a slightly-less-obsolete 8-bit encoding from the ’90s.

\usepackage[T1]{fontenc}

If you can, I would recommend changing to LuaLaTeX and modern fonts. The default font in LuaLaTeX does not come in bold small-caps either, but you can switch to a clone that does, such as New Computer Modern. (The settings I used will get you a slightly-heavier font, but you can tweak this if you want with a package option.)

\documentclass[12pt,a4paper]{article}
\usepackage{iftex}

\iftutex \usepackage{newcomputermodern} \else \usepackage[T1]{fontenc} \fi

\usepackage[ left = 2cm, right = 2.5cm, top = 1.5cm, bottom = 2cm ]{geometry} \usepackage{microtype} \usepackage{titlesec} \usepackage{fancyhdr}

\titleformat{\section}{\Large\scshape\bfseries}{}{0cm}{}[\titlerule] \titleformat{\subsection}[runin]{\bfseries\scshape}{}{0cm}{}[ --] \titleformat{\subsubsection}{\large\bfseries\scshape}{}{0cm}{}

\renewcommand{\labelitemi}{--} \newcommand{\tabitem}{\makebox[0pt][r]{--}}

%Manipulation of headers and footers \pagestyle{fancy} %Clear fields \fancyhf{} %Page numbering in footer \fancyfoot[C]{\thepage} %Separation line header and footer \renewcommand{\footrulewidth}{0.4pt} \renewcommand{\headrulewidth}{0pt}

\begin{document} \thispagestyle{fancy}

\begin{center} \Huge \textbf{\textsc{Eating\hspace{0.5cm}Foods}} \end{center}

\section{How to eat food} Food is important \subsection{Using hands} Most versatile \subsection{using chopsticks} Requires practice \subsection{using spoons} Kind of a middle ground \subsubsection{Types of spoons} There are many types of spoons

\end{document}

Davislor
  • 44,045
  • 1
    Another easy option for a font with bold small caps would be Linux Libertine, which can be used by simply loading \usepackage{libertine}, in case one does not want to use LuaLaTeX or XeTeX. – schoekling Feb 23 '21 at 22:11
  • 1
    @shekura Yes. I believe that package also sets the T1 encoding. – Davislor Feb 23 '21 at 23:25
  • It seems that the newcomputermodern font does not play well with the amsmath package(s) – Raven Jun 04 '21 at 07:18
  • @Raven newcomputermodern loads unicode-math, which loads amsmath. Loading amsmath with different options ought to work if you load it before newcomputermodern and unicode-math. – Davislor Jun 04 '21 at 14:29
  • @Raven But, what problem were you having? – Davislor Jun 04 '21 at 14:29
  • Ah okay then maybe that was the issue. I got a bunch of error messages that seemingly came from the amsmath package but I included them after newcomputermodern. Thanks for pointing this out. – Raven Jun 06 '21 at 14:21