Skip to content

Commit 40caf0c

Browse files
authored
Merge pull request #10696 from jfbu/latex_fix_for_old_latex
Fix #10695: old LaTeX does not allow \@ifpackageloaded usage in body
2 parents afac558 + d1b4a75 commit 40caf0c

File tree

5 files changed

+31
-26
lines changed

5 files changed

+31
-26
lines changed

sphinx/texinputs/sphinx.sty

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,27 @@
685685
%% FRAMED ENVIRONMENTS
686686
%
687687
\RequirePackage{sphinxpackageboxes}
688+
% This macro is possibly executed at begin document if the check
689+
% whether radii setting options have been used turns out positive
690+
\def\spx@RequirePackage@PictIIe{%
691+
\IfFileExists{pict2e.sty}
692+
{\RequirePackage{pict2e}}
693+
{\PackageWarningNoLine{sphinx}{%
694+
The package pict2e is required for rounded boxes.\MessageBreak
695+
It does not seem to be available on your system.\MessageBreak
696+
Options for setting radii will thus be ignored}%
697+
\AtEndDocument{\PackageWarningNoLine{sphinx}{%
698+
I issued a warning which may have gotten lost in the\MessageBreak
699+
gigantic console output: pict2e.sty was not found,\MessageBreak
700+
and radii setting options have been ignored}}%
701+
\def\spx@boxes@fcolorbox@rounded{\spx@boxes@fcolorbox}%
702+
}%
703+
}%
704+
% This at begin document will be executed after \spx@RequirePackage@PictIIe
705+
\AtBeginDocument{%
706+
\@ifpackageloaded{pict2e}{\let\spx@ifpackageloaded@pictiie\@firstoftwo}%
707+
{\let\spx@ifpackageloaded@pictiie\@secondoftwo}%
708+
}%
688709
\input{sphinxlatexadmonitions.sty}
689710
\input{sphinxlatexliterals.sty}
690711
\input{sphinxlatexshadowbox.sty}

sphinx/texinputs/sphinxlatexadmonitions.sty

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
\ifdim\spx@boxes@radius@bottomleft >\z@0\fi
163163
1\spx@boxes@fcolorbox{##1}%
164164
\else
165-
\@ifpackageloaded{pict2e}%
165+
\spx@ifpackageloaded@pictiie
166166
{\ifspx@boxes@insetshadow
167167
\spx@boxes@fcolorbox{##1}%
168168
\else

sphinx/texinputs/sphinxlatexliterals.sty

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
\ifdim\spx@pre@radius@bottomleft >\z@0\fi
165165
1\spx@boxes@fcolorbox{\box\z@}%
166166
\else
167-
\@ifpackageloaded{pict2e}%
167+
\spx@ifpackageloaded@pictiie
168168
{\ifspx@pre@insetshadow
169169
\spx@boxes@fcolorbox{\box\z@}%
170170
\else

sphinx/texinputs/sphinxlatexshadowbox.sty

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
\ifdim\spx@topic@radius@bottomleft >\z@0\fi
8080
1\spx@boxes@fcolorbox{\box\z@}%
8181
\else
82-
\@ifpackageloaded{pict2e}%
82+
\spx@ifpackageloaded@pictiie
8383
{\ifspx@topic@insetshadow
8484
\spx@boxes@fcolorbox{\box\z@}%
8585
\else

sphinx/texinputs/sphinxpackageboxes.sty

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,6 @@
7272
% if nothing else is changed (perhaps in future the title itself could be also
7373
% rendered in a rounded box?)
7474

75-
\def\spx@RequirePackage@PictIIe{%
76-
\IfFileExists{pict2e.sty}
77-
{\RequirePackage{pict2e}}
78-
{\PackageWarningNoLine{sphinx}{%
79-
The package pict2e is required for rounded boxes.\MessageBreak
80-
It does not seem to be available on your system.\MessageBreak
81-
Options for setting radii will thus be ignored}%
82-
\AtEndDocument{\PackageWarningNoLine{sphinx}{%
83-
I issued a warning which may have gotten lost in the\MessageBreak
84-
gigantic console output: pict2e.sty was not found,\MessageBreak
85-
and radii setting options have been ignored}}%
86-
\def\spx@boxes@fcolorbox@rounded{\spx@boxes@fcolorbox}%
87-
}%
88-
}%
89-
90-
9175
%//// \spx@boxes@fcolorbox
9276
% This box will have the same baseline as its argument (which is typeset in
9377
% horizontal mode). It takes into account four border widths parameters, four
@@ -378,16 +362,16 @@
378362
\dimexpr\dp\spx@tempboxa+\spx@boxes@padding@bottom+\spx@boxes@border\relax
379363
\hbox{%
380364
\begin{picture}%
381-
% \strip@pt\dimexpr fot work around "old" LaTeX picture limitation
365+
% \strip@pt\dimexpr to work around "old" LaTeX picture limitation
382366
% (we could use the "picture" package, this would add another dependency)
383-
(\strip@pt\wd\spx@tempboxa,\strip@pt\dimexpr\ht\spx@tempboxa+\dp\spx@tempboxa)%
384-
(\strip@pt\dimexpr-.5\spx@boxes@border,\strip@pt\dimexpr-.5\spx@boxes@border)%
367+
(\strip@pt\wd\spx@tempboxa,\strip@pt\dimexpr\ht\spx@tempboxa+\dp\spx@tempboxa\relax)%
368+
(\strip@pt\dimexpr-.5\spx@boxes@border\relax,\strip@pt\dimexpr-.5\spx@boxes@border\relax)%
385369
\ifspx@boxes@withshadow
386370
\color{spx@boxes@shadowcolor}%
387-
\put(\dimexpr\ifdim\spx@boxes@shadow@xoffset<\z@-\fi
388-
0.5\spx@boxes@border+\spx@boxes@shadow@xoffset,%
389-
\dimexpr\ifdim\spx@boxes@shadow@yoffset<\z@\else-\fi
390-
0.5\spx@boxes@border-\spx@boxes@shadow@yoffset)
371+
\put(\strip@pt\dimexpr\ifdim\spx@boxes@shadow@xoffset<\z@-\fi
372+
0.5\spx@boxes@border+\spx@boxes@shadow@xoffset\relax,%
373+
\strip@pt\dimexpr\ifdim\spx@boxes@shadow@yoffset<\z@\else-\fi
374+
0.5\spx@boxes@border-\spx@boxes@shadow@yoffset\relax)
391375
{\spx@boxes@borderpath\fillpath}%
392376
{\ifspx@boxes@withbackgroundcolor\else
393377
\color{white}% or rather try to use page color?

0 commit comments

Comments
 (0)