SF.net SVN: docutils:[10320 ] trunk/docutils
milde--- via Docutils-checkins <[email protected]> Thu, 30 Apr 2026 19:17:51 +0000
| Newsgroups | gmane.text.docutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 10320
http://sourceforge.net/p/docutils/code/10320
Author: milde
Date: 2026-04-30 19:17:50 +0000 (Thu, 30 Apr 2026)
Log Message:
-----------
latex-footnotes: Indent footnote text.
In the LaTeX source, indent the content of footnotes
to offset it from the main text.
Modified Paths:
--------------
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/latex_footnotes.tex
trunk/docutils/test/test_writers/test_latex2e.py
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2026-04-30 19:17:38 UTC (rev 10319)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2026-04-30 19:17:50 UTC (rev 10320)
@@ -2415,7 +2415,7 @@
raise nodes.SkipNode
# `target` is a new top-level footnote:
self.footnote_queue.append(href)
- footnote_cmd = r'\footnote'
+ footnote_cmd = '%\n\\footnote'
add_label = target['names'] and self.document.refnames.get(
target['names'][0], [])
while self.footnote_queue:
@@ -2426,8 +2426,14 @@
if add_label:
self.out += [r'\label{', ID, '}']
self.out.append('%')
+ # get footnote content
+ self.push_output_collector([])
footnote.walkabout(self) # visit/depart footnote & content
- self.out.append('}')
+ note = ''.join(self.pop_output_collector())
+ # indent lines
+ note = '\n '.join(note.splitlines())
+ self.out.append(note)
+ self.out.append('\n}')
self.footnote_queue.pop(0)
# subsequent items have their reference already set:
footnote_cmd = '%\n\\refstepcounter{footnote}\\footnotetext'
Modified: trunk/docutils/test/functional/expected/latex_footnotes.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_footnotes.tex 2026-04-30 19:17:38 UTC (rev 10319)
+++ trunk/docutils/test/functional/expected/latex_footnotes.tex 2026-04-30 19:17:50 UTC (rev 10320)
@@ -28,14 +28,18 @@
\section{Test features of rST footnotes}
-\emph{Numbered} footnotes\footnote{\label{exi}%
-autonumber-label
-}\footnote{\label{footnote-2}%
-auto-numbered (skipping 2)
-}\footnote{\label{footnote-1}%
-manually numbered
-}\footnote{%
-second auto-numbered (skipping \hyperref[footnote-1]{4} and \hyperref[section-2]{5})
+\emph{Numbered} footnotes%
+\footnote{\label{exi}%
+ autonumber-label
+}%
+\footnote{\label{footnote-2}%
+ auto-numbered (skipping 2)
+}%
+\footnote{\label{footnote-1}%
+ manually numbered
+}%
+\footnote{%
+ second auto-numbered (skipping \hyperref[footnote-1]{4} and \hyperref[section-2]{5})
} may be referenced more than
once and also via hyperlink references:
@@ -53,16 +57,18 @@
auto-numbered footnote is added or removed).
\end{description}
-\emph{Symbol} footnotes\footnote{%
-auto-symbol with nested footnotes\footref{footnote-6}\footref{footnote-7}
+\emph{Symbol} footnotes%
+\footnote{%
+ auto-symbol with nested footnotes\footref{footnote-6}\footref{footnote-7}
}%
\refstepcounter{footnote}\footnotetext{\label{footnote-6}%
-referenced from the first auto-symbol footnote
+ referenced from the first auto-symbol footnote
}%
\refstepcounter{footnote}\footnotetext{\label{footnote-7}%
-referenced from the first auto-symbol footnote, too
-}\footnote{%
-second auto-symbol
+ referenced from the first auto-symbol footnote, too
+}%
+\footnote{%
+ second auto-symbol
} do not have a reference name.
They can only be referenced once and only with a footnote-reference.
Modified: trunk/docutils/test/test_writers/test_latex2e.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e.py 2026-04-30 19:17:38 UTC (rev 10319)
+++ trunk/docutils/test/test_writers/test_latex2e.py 2026-04-30 19:17:50 UTC (rev 10320)
@@ -1008,19 +1008,23 @@
""",
r"""
Paragraphs contain text and may contain footnote references (manually
-numbered\footnote{\label{footnote-1}%
-A footnote.
-}, anonymous auto-numbered\footnote{%
-This footnote is numbered automatically and anonymously using a
-label of \textquotedbl{}\#\textquotedbl{} only.
-}, labeled auto-numbered\footnote{\label{label}%
-Footnotes may be numbered, either manually or
-automatically using a \textquotedbl{}\#\textquotedbl{}-prefixed label. This footnote has a
-label so it can be referred to from multiple places, both as a
-footnote reference (\footref{label}) and as a \hyperref[label]{hyperlink reference}.
-}, or symbolic\footnote{%
-With \textquotedbl{}latex-footnotes\textquotedbl{}, symbolic footnotes and numbered footnotes
-are merged, the choice of symbol vs. number is done by LaTeX styling.
+numbered%
+\footnote{\label{footnote-1}%
+ A footnote.
+}, anonymous auto-numbered%
+\footnote{%
+ This footnote is numbered automatically and anonymously using a
+ label of \textquotedbl{}\#\textquotedbl{} only.
+}, labeled auto-numbered%
+\footnote{\label{label}%
+ Footnotes may be numbered, either manually or
+ automatically using a \textquotedbl{}\#\textquotedbl{}-prefixed label. This footnote has a
+ label so it can be referred to from multiple places, both as a
+ footnote reference (\footref{label}) and as a \hyperref[label]{hyperlink reference}.
+}, or symbolic%
+\footnote{%
+ With \textquotedbl{}latex-footnotes\textquotedbl{}, symbolic footnotes and numbered footnotes
+ are merged, the choice of symbol vs. number is done by LaTeX styling.
}).
"""],
# multi-nested footnotes
@@ -1042,30 +1046,32 @@
We can also write a hyperlink to multi_.
""",
r"""
-A footnote\footnote{\label{multi}%
-This is a footnote with nested\footref{footnote-1} footnotes.\footref{footnote-2}\footref{footnote-3}
+A footnote%
+\footnote{\label{multi}%
+ This is a footnote with nested\footref{footnote-1} footnotes.\footref{footnote-2}\footref{footnote-3}
}%
\refstepcounter{footnote}\footnotetext{\label{footnote-1}%
-First nested\footref{footnote-4} footnote.\footref{footnote-5}
+ First nested\footref{footnote-4} footnote.\footref{footnote-5}
}%
\refstepcounter{footnote}\footnotetext{\label{footnote-2}%
-Second nested footnote.\footref{footnote-6}
+ Second nested footnote.\footref{footnote-6}
}%
\refstepcounter{footnote}\footnotetext{\label{footnote-3}%
-Third nested footnote.
+ Third nested footnote.
}%
\refstepcounter{footnote}\footnotetext{\label{footnote-4}%
-First double-nested footnote.
+ First double-nested footnote.
}%
\refstepcounter{footnote}\footnotetext{\label{footnote-5}%
-Second double-nested footnote.
+ Second double-nested footnote.
}%
\refstepcounter{footnote}\footnotetext{\label{footnote-6}%
-First triple-nested footnote.
+ First triple-nested footnote.
}
-Ref to a new footnote\footnote{%
-Not nested, referenced after footnote text.
+Ref to a new footnote%
+\footnote{%
+ Not nested, referenced after footnote text.
}
A second reference to the first one\footref{multi}.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.