1

Is there any way of force the titles of subsections in the amsart to be in title case by default? I tried this but no luck:

\documentclass{amsart}
\usepackage[utf8]{inputenc}
\usepackage{etoolbox}
\usepackage{titlecaps}

\makeatletter \patchcmd{\subsection}{\bfseries}{\titlecap}{}{} \makeatother

\begin{document}

\maketitle

\section{Section}

\subsection{Subsection with lowercase letters}

\end{document}

  • Related: https://tex.stackexchange.com/questions/103838/converting-text-to-title-case, https://tex.stackexchange.com/questions/34796/capitalizing-strings-ignoring-closed-class-words, https://tex.stackexchange.com/questions/4809/how-can-i-force-text-to-be-displayed-in-title-case. – Marijn May 18 '21 at 13:00
  • @Marijn https://tex.stackexchange.com/questions/4809/how-can-i-force-text-to-be-displayed-in-title-case only works for the apa class – Michael Cook May 18 '21 at 13:43

2 Answers2

2

The reason why replacing \bfseries with \titlecap does not work is that \bfseries is a declaration that does not take an argument, whereas \titlecap is a macro requiring an argument.

However, this approach may work, of redefining \@sect to look for subsections (when #2 = 2) and, upon finding so, replace the subsection title #8 with \titlecap{#8}. I also turned off \bfseries in #6 since that seems to be what the OP wanted.

\documentclass{amsart}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{etoolbox}
\usepackage{titlecaps}

\makeatletter \let\sv@sect@sect \def@sect#1#2#3#4#5#6[#7]#8{% \ifnum#2=2 \def\next{\sv@sect{#1}{#2}{#3}{#4}{#5}{\normalfont}[#7]{\titlecap{#8}}}% \else \def\next{\sv@sect{#1}{#2}{#3}{#4}{#5}{#6}[#7]{#8}}% \fi \next } \makeatother

\begin{document}

\section{Section}

\subsection{Subsection with lowercase letters}

\subsection{another test case}

\end{document}

enter image description here

0

look at my code. It solves your problem by using \uppercase

\documentclass{amsart}
\usepackage[utf8]{inputenc}
\usepackage{etoolbox}
\usepackage{titlecaps}

\makeatletter \patchcmd{\subsection}{\bfseries}{\titlecap}{}{} \makeatother

\begin{document}

\maketitle

\section{\uppercase{Section}}

\subsection{\uppercase{Subsection with lowercase letters}}

\end{document}

Hope this works.

enter image description here

Bpi
  • 188
  • 6