Skip to content

Commit 7cdd9b2

Browse files
committed
LaTeX: let \sphinxremovefinalcolon work also if no colon in input
1 parent 669bcc0 commit 7cdd9b2

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

doc/latex.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,16 @@ Macros
14981498
\renewcommand\sphinxwarningtitle[1]{%
14991499
\underline{\textbf{\sphinxremovefinalcolon{#1}}}\par
15001500
}
1501+
\renewcommand{\sphinxnotetitle}[1]{%
1502+
\textit{\textbf{\sphinxremovefinalcolon{#1}}}\par\nobreak
1503+
% LaTeX syntax is complex and we would be better off using \hrule here.
1504+
{\parskip0pt\noindent}%
1505+
\raisebox{1ex}%
1506+
{\makebox[\linewidth]{\textcolor{sphinxnoteBorderColor}{\dotfill}}}
1507+
% It is complex to obtain nice vertical spacing for both a paragraph or
1508+
% a list following up; this set-up is better for a text paragraph next.
1509+
\par\vskip-\parskip
1510+
}
15011511

15021512
- More text styling:
15031513

sphinx/texinputs/sphinxlatexstyletext.sty

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,26 @@
1919
\let\sphinxerrortitle \sphinxnotetitle
2020
\def\sphinxseealsotitle#1{\sphinxstrong{#1}\par\nopagebreak}
2121
%
22-
% A utility to remove a final colon
23-
% (one must be certain the semi-colon is there)
24-
\protected\def\sphinxremovefinalcolon #1{%
22+
% A utility to remove a final colon. Removing last token is not easy in
23+
% LaTeX, and there are additional complications:
24+
% - some languages will make the : "active" in document body,
25+
% - the generic admonition ends up using "note", so for \sphinxnotetitle to
26+
% use it safely, the utility has to allow an input not having any final colon.
27+
% - a bit far-fetched but maybe there is more than one colon inside the input
28+
% (possible from a generic admonition title).
29+
% Hence the scary code.
30+
\def\sphinxremovefinalcolon#1{% #1 is the "active" : TeX token
31+
\protected\def\sphinxremovefinalcolon ##1{%
2532
% complications due to : possibly "active"
2633
\begingroup\ifnum\catcode`:=\active
27-
\lccode`~=`:\lowercase{\def\x##1~}{##1}%
28-
\else\def\x##1:{##1}\fi
29-
\expandafter\endgroup\x#1%
30-
}%
34+
\def\x####1#1\relax{####1}%
35+
\else\def\x####1:\relax{####1}\fi
36+
\expandafter\endgroup\x##1\relax
37+
% trick to let \x work also if input ##1 has no ending colon
38+
\@gobblefour#1\relax:\relax\relax\relax
39+
}%
40+
}% end of wrapper to inject active :
41+
\begingroup\catcode`:\active\expandafter\endgroup\sphinxremovefinalcolon:
3142
% See doc/latex.rst for an example.
3243

3344
% Some custom font markup commands.

0 commit comments

Comments
 (0)