When a reStructuredText document starts with a lone "title" section header (e.g., the attached example.rst), the output produced by rst2latex.py and rst2xetex.py declares the title like so:
\title{Title Goes Here%
\label{title-goes-here}}
Unfortunately, when the memoir document class is used (--documentclass=memoir), something about its \title and/or \label definition causes the pdflatex example.tex command to fail with the following error message:
! Undefined control sequence.
\MNR@label ...sphack \begingroup \def \label@name
{#1}\label@hook \protected...
l.31 \label{title-goes-here}}
Interestingly, when --template=titlepage.tex is set, the error message is instead:
! Argument of \reserved@a has an extra }.
<inserted text>
\par
l.31 \label{title-goes-here}}
The build succeeds if \protect is inserted before the \label in \title. I believe that unconditionally inserting \protect before \label in \title (or possibly even before all \labels) will cause no harm in other document classes, but I'm not a LaTeX guru, so don't quote me on that.
This behavior was observed on the following systems:
The following files are attached:
- Dockerfile — a Dockerfile for reproducing the Debian environment listed above
- example.rst — a sample input file whose LaTeXification exhibits the above behavior
- example.tex — the output from rst2latex.py --documentclass=memoir example.rst; running pdflatex on it will fail with the above error message
Thank you for reporting.
Unfortunately, "Memoir" has a considerable number of deviations from standard LaTeX so that LaTeX-generator have trouble supporting it (cf. the number of "Memoir" related bug reports to LyX). You may consider "Memoir" unsupported and try the KOMA-skript classes instead.
Alternatvely, you may try the attached patch to the LaTeX writer.
Fixed in r8523.
Thank you for analysis and reporting.
Fixed in Docutils 0.17.
Thanks again for your contribution.