summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-François B <2589111+jfbu@users.noreply.github.com>2023-03-27 12:21:26 +0200
committerJean-François B <2589111+jfbu@users.noreply.github.com>2023-03-27 12:21:26 +0200
commit7cdd9b26799c811d76d8e3bfaf3c7a3f801d8195 (patch)
tree6746786fa1228cbe844724da303be8337e314a83
parent669bcc0a190ce9921451bad28431886fbaad170b (diff)
downloadsphinx-git-7cdd9b26799c811d76d8e3bfaf3c7a3f801d8195.tar.gz
LaTeX: let \sphinxremovefinalcolon work also if no colon in input
-rw-r--r--doc/latex.rst10
-rw-r--r--sphinx/texinputs/sphinxlatexstyletext.sty25
2 files changed, 28 insertions, 7 deletions
diff --git a/doc/latex.rst b/doc/latex.rst
index 7e376fff1..90420f615 100644
--- a/doc/latex.rst
+++ b/doc/latex.rst
@@ -1498,6 +1498,16 @@ Macros
\renewcommand\sphinxwarningtitle[1]{%
\underline{\textbf{\sphinxremovefinalcolon{#1}}}\par
}
+ \renewcommand{\sphinxnotetitle}[1]{%
+ \textit{\textbf{\sphinxremovefinalcolon{#1}}}\par\nobreak
+ % LaTeX syntax is complex and we would be better off using \hrule here.
+ {\parskip0pt\noindent}%
+ \raisebox{1ex}%
+ {\makebox[\linewidth]{\textcolor{sphinxnoteBorderColor}{\dotfill}}}
+ % It is complex to obtain nice vertical spacing for both a paragraph or
+ % a list following up; this set-up is better for a text paragraph next.
+ \par\vskip-\parskip
+ }
- More text styling:
diff --git a/sphinx/texinputs/sphinxlatexstyletext.sty b/sphinx/texinputs/sphinxlatexstyletext.sty
index 33a247b71..213814d30 100644
--- a/sphinx/texinputs/sphinxlatexstyletext.sty
+++ b/sphinx/texinputs/sphinxlatexstyletext.sty
@@ -19,15 +19,26 @@
\let\sphinxerrortitle \sphinxnotetitle
\def\sphinxseealsotitle#1{\sphinxstrong{#1}\par\nopagebreak}
%
-% A utility to remove a final colon
-% (one must be certain the semi-colon is there)
-\protected\def\sphinxremovefinalcolon #1{%
+% A utility to remove a final colon. Removing last token is not easy in
+% LaTeX, and there are additional complications:
+% - some languages will make the : "active" in document body,
+% - the generic admonition ends up using "note", so for \sphinxnotetitle to
+% use it safely, the utility has to allow an input not having any final colon.
+% - a bit far-fetched but maybe there is more than one colon inside the input
+% (possible from a generic admonition title).
+% Hence the scary code.
+\def\sphinxremovefinalcolon#1{% #1 is the "active" : TeX token
+\protected\def\sphinxremovefinalcolon ##1{%
% complications due to : possibly "active"
\begingroup\ifnum\catcode`:=\active
- \lccode`~=`:\lowercase{\def\x##1~}{##1}%
- \else\def\x##1:{##1}\fi
- \expandafter\endgroup\x#1%
-}%
+ \def\x####1#1\relax{####1}%
+ \else\def\x####1:\relax{####1}\fi
+ \expandafter\endgroup\x##1\relax
+ % trick to let \x work also if input ##1 has no ending colon
+ \@gobblefour#1\relax:\relax\relax\relax
+ }%
+}% end of wrapper to inject active :
+\begingroup\catcode`:\active\expandafter\endgroup\sphinxremovefinalcolon:
% See doc/latex.rst for an example.
% Some custom font markup commands.