mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
LaTeX: let \sphinxremovefinalcolon work also if no colon in input
This commit is contained in:
parent
669bcc0a19
commit
7cdd9b2679
@ -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:
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user