Menu

#390 LaTeX writer puts \label in \title, which breaks when using memoir.cls

None
closed-fixed
nobody
2021-04-03
2020-06-14
No

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:

  • Mac OS X 10.13.6
    • Python 3.7.6
    • docutils 0.16
    • TeX Live 2017
    • memoir v3.7f (2016-06-24)
  • Debian GNU/Linux 10 (buster)
    • Python 3.7.3
    • docutils snapshot, revision 8516
    • TeX Live 2020
    • memoir v3.7l (2020-06-02) (latest version at time of writing)

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

3 Attachments

Discussion

  • Günter Milde

    Günter Milde - 2020-06-15

    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.

     
  • Günter Milde

    Günter Milde - 2020-07-10
    • status: open --> open-fixed
     
  • Günter Milde

    Günter Milde - 2020-07-10

    Fixed in r8523.
    Thank you for analysis and reporting.

     
  • Günter Milde

    Günter Milde - 2021-04-03
    • status: open-fixed --> closed-fixed
     
  • Günter Milde

    Günter Milde - 2021-04-03

    Fixed in Docutils 0.17.
    Thanks again for your contribution.

     

Log in to post a comment.

MongoDB Logo MongoDB
Gen AI apps are built with MongoDB Atlas
Atlas offers built-in vector search and global availability across 125+ regions. Start building AI apps faster, all in one place.