0

I'm trying to format my section headings using titlecaps so I have used the command

\titleformat{\section}{\normalfont}{\thesection}{.5em}{%
    \titlecap{#1}}

which worked for texLive 2017. Recently, I upgraded to TexLive2021 (for other reasons), and now any \section commands fail with Illegal parameter number in definition of \the@@@string.

The log file shows the additional message after the first error of:

 You meant to type ## instead of #, right?
Or maybe a } was forgotten somewhere earlier, and things
are all screwed up? I'm going to assume that you meant ##.

which I'm interpreting as not expanding the #1 macro correctly. Any suggestions? MWE follows

\documentclass{article} % documentclass for TR
\usepackage{titlesec}
\usepackage{titlecaps}
\titleformat{\section}{\bfseries}{\thesection}{.5em}{\normalfont\titlecap{#1}}
\listfiles
\begin{document}
Lorem
\section{my head}
citations
\end{document}

2 Answers 2

1

Your code generates errors in every version of TeX Live I have on my machine (from 2012 to 2021).

The titlesec package is clear about this: either use the explicit option (but this is rarely necessary) or use the standard feature that the last token in the last mandatory argument to \titleformat will be followed by

{<the current title>}

at point of usage. So, if the last token requires an argument, it finds exactly what it wants.

\documentclass{article} % documentclass for TR
\usepackage{titlesec}
\usepackage{titlecaps}
\titleformat{\section}{\bfseries}{\thesection}{.5em}{\normalfont\titlecap}
\listfiles
\begin{document}
Lorem
\section{my head}
citations
\end{document}
0

Ok,I found a solution. The titlesec package defines an option explicit that enables the expansion of the #1 macro correctly. So change line 2 above to

\usepackage[explicit]{titlesec}

and all works.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .