serhii.net

In the middle of the desert you can say anything you want

15 Apr 2024

Latex automated title case in titles

With the help of ChatGPT

\documentclass{article}
\usepackage{titlecaps}
\usepackage{etoolbox}

% Specify words to remain in lowercase unless they are the first word
\Addlcwords{the and but or nor for a an at by to in on with of}

\let\oldchapter\chapter
\renewcommand{\chapter}[1]{\oldchapter{\titlecap{#1}}}

\let\oldsection\section
\renewcommand{\section}[1]{\oldsection{\titlecap{#1}}}

\let\oldsubsection\subsection
\renewcommand{\subsection}[1]{\oldsubsection{\titlecap{#1}}}

\begin{document}

\section{an example of a section with and without uppercasing specific words}
This is some text.

\subsection{exploring the integration of tools in the workplace}
More text here.

\end{document}
Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus