Title case for theorem argument

capitalizationtitlesec

I would like to make the optional argument I pass to a theorem environment (which puts the argument in a parenthetical next to the theorem number – typically for naming a theorem) have title case i.e. non-articles should be capitalized. I am able to do this for section headings using the titlecaps and titlesec packages (see the MWE below), but I'm unsure how this behavior can be obtained without manually doing it each time in the theorem argument.

I'm using a self made definition environment (through amsthm) and have a lot of named definitions in the beginning of my document so it would be nice not to have to capitalize all of their titles by hand.

MWE:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{titlesec,titlecaps}


\theoremstyle{definition}
\newtheorem{theorem}{Theorem}[subsection]
\newtheorem{definition}[theorem]{Definition}

\Addlcwords{is with the a an}
\titleformat{\section}[block]{}{\normalfont\Large\bfseries\thesection.\;}{0pt}{\formatsectiontitle}
\newcommand{\formatsectiontitle}[1]{\normalfont\Large\bfseries\titlecap{#1}}

\begin{document}


\section{this is an automatically title capitalized section}
\begin{definition}[I wish this was title capitalized]
Definition.
\end{definition}

\end{document}

Best Answer

The following redefines the definition environment and inserts \titlecap{...} around the optional argument supplied to it:

enter image description here

\documentclass{article}

\usepackage{amsthm}
\usepackage{titlecaps}

\theoremstyle{definition}
\newtheorem{theorem}{Theorem}[subsection]
\newtheorem{definition}[theorem]{Definition}

\Addlcwords{is with the a an}

\begin{document}

Original definition:

\begin{definition}[I wish this was capitalized]
Definition.
\end{definition}

Manual title case for definition:

\begin{definition}[\titlecap{I wish this was capitalized}]
Definition.
\end{definition}

\let\olddefinition\definition
\let\endolddefinition\enddefinition
\RenewDocumentEnvironment{definition}{ o }{%
  \IfValueTF{#1}
    {\olddefinition[\titlecap{#1}]}
    {\olddefinition}%
}{%
  \endolddefinition
}

Automated title cap definition:

\begin{definition}[I wish this was capitalized]
Definition.
\end{definition}

\end{document}

This only holds for the definition environment. You'll need to \usepackage{xparse} if you don't have an up-to-date LaTeX.

Related Question