SF.net SVN: docutils:[10322 ] trunk/docutils

milde--- via Docutils-checkins <[email protected]> Thu, 30 Apr 2026 19:18:47 +0000
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 10322
          http://sourceforge.net/p/docutils/code/10322
Author:   milde
Date:     2026-04-30 19:18:46 +0000 (Thu, 30 Apr 2026)
Log Message:
-----------
latex-footnotes: Fix footnotes in titles.

`\protect` the `\footnote` command in the title of the document, sections,
admonitions, topics and sidebars.

Add use case to functional test sample.

Document the failure of footnotes in sidebars (can be fixed by re-defining
DUsidebar using a minipage instead of a parbox).

Modified Paths:
--------------
    trunk/docutils/docs/user/latex.rst
    trunk/docutils/docutils/writers/latex2e/__init__.py
    trunk/docutils/test/functional/expected/latex_footnotes.tex
    trunk/docutils/test/functional/input/data/footnote-targets.rst

Modified: trunk/docutils/docs/user/latex.rst
===================================================================
--- trunk/docutils/docs/user/latex.rst	2026-04-30 19:18:34 UTC (rev 10321)
+++ trunk/docutils/docs/user/latex.rst	2026-04-30 19:18:46 UTC (rev 10322)
@@ -1089,10 +1089,11 @@
   footnote reference.
 * There is no distinction between numbered footnotes and
   `symbol footnotes`_, by default all footnotes are numbered.
-* Footnote numbers depend on the order of the `footnote references`.
+* Footnotes are sorted and numbered in the order of the `footnote references`.
 * There is no backlink from footnote to footnote reference.
 
-.. important:: LaTeX footnotes `do not work in figures and table captions`__!
+.. important:: LaTeX footnotes `do not work in figures and table captions`__
+   nor in the box created by the "sidebar" directive!
 
 LaTeX offers a wide range of footnote configuration options
 (cf. the `LaTeX WikiBook`__ and the `TeX FAQ`__).

Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py	2026-04-30 19:18:34 UTC (rev 10321)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py	2026-04-30 19:18:46 UTC (rev 10322)
@@ -2416,6 +2416,8 @@
             # `target` is a new top-level footnote:
             self.footnote_queue.append(href)
             footnote_cmd = '%\n\\footnote'
+            if isinstance(node.parent, nodes.title):
+                footnote_cmd = '%\n \\protect\\footnote'
             add_label = target['names'] and self.document.refnames.get(
                                                 target['names'][0], [])
             while self.footnote_queue:

Modified: trunk/docutils/test/functional/expected/latex_footnotes.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_footnotes.tex	2026-04-30 19:18:34 UTC (rev 10321)
+++ trunk/docutils/test/functional/expected/latex_footnotes.tex	2026-04-30 19:18:46 UTC (rev 10322)
@@ -26,7 +26,10 @@
 \begin{document}
 
 
-\section{Test features of rST footnotes}
+\section{Test features of rST footnotes%
+ \protect\footnote{\label{top}%
+  referenced from a section title
+}}
 
 \emph{Numbered} footnotes%
 \footnote{\label{exi}%

Modified: trunk/docutils/test/functional/input/data/footnote-targets.rst
===================================================================
--- trunk/docutils/test/functional/input/data/footnote-targets.rst	2026-04-30 19:18:34 UTC (rev 10321)
+++ trunk/docutils/test/functional/input/data/footnote-targets.rst	2026-04-30 19:18:46 UTC (rev 10322)
@@ -1,5 +1,5 @@
-Test features of rST footnotes
-==============================
+Test features of rST footnotes [#top]_
+======================================
 
 *Numbered* footnotes [#exi]_ [#]_ [4]_ [#]_ may be referenced more than
 once and also via hyperlink references:
@@ -32,6 +32,7 @@
 .. [*] second auto-symbol
 .. [#] referenced from the first auto-symbol footnote
 .. [*] referenced from the first auto-symbol footnote, too
+.. [#top] referenced from a section title
 
 4
 ===

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.