|
9 | 9 | % by the Sphinx LaTeX writer.
|
10 | 10 |
|
11 | 11 | \NeedsTeXFormat{LaTeX2e}[1995/12/01]
|
12 |
| -\ProvidesPackage{sphinx}[2024/11/23 v8.2.0 Sphinx LaTeX package (sphinx-doc)] |
| 12 | +\ProvidesPackage{sphinx}[2025/04/24 v8.3.0 Sphinx LaTeX package (sphinx-doc)] |
13 | 13 |
|
14 | 14 | % provides \ltx@ifundefined
|
15 | 15 | % (many packages load ltxcmds: graphicx does for pdftex and lualatex but
|
|
672 | 672 | % defaults for them remain not to have specific colour.
|
673 | 673 | %
|
674 | 674 | % 7.4.0 adds keys for admonition titles: for background and foreground colors,
|
675 |
| -% and for icons (whose defaults are picked from Free Fontawesome 5). |
| 675 | +% and for icons. |
676 | 676 | \def\spx@tempa#1{%
|
677 | 677 | \expandafter\spx@tempb
|
678 | 678 | \csname if#1withshadowcolor\expandafter\endcsname
|
|
869 | 869 | }
|
870 | 870 |
|
871 | 871 | % 7.4.0 Support for icons in admonition titles
|
872 |
| -% We try to |
873 |
| -% - get Sphinx PDF builds to process fine in absence of fontawesome5 |
874 |
| -% - use fontawesome5 if present, but not if user prefers another package |
875 |
| -% - provide an interface for using other LaTeX code for icons |
876 |
| -% - provide an interface for using some other package than fontawesome5 |
877 |
| -% Indeed we can't load fontawesome5 unconditionally even if available, |
878 |
| -% as it proves incompatible with fontawesome package. |
879 |
| -% We thus must delay its loading. |
880 |
| -\IfFileExists{fontawesome5.sty}{% |
881 |
| - \DeclareStringOption[fontawesome5]{iconpackage}% |
| 872 | +% |
| 873 | +% We let Sphinx use in order of priority: some user-specifid package, |
| 874 | +% fontawesome6 (since 8.3.0), fontawesome5, fontawesome, or nothing (and then |
| 875 | +% not draw any icon). To allow a user-specified package, an extra interface |
| 876 | +% is provided for specifying the icon-drawing LaTeX code. |
| 877 | +% |
| 878 | +% We can't load fontawesome6 (or 5) unconditionally even if available, as it |
| 879 | +% is incompatible with fontawesome package which may be preferred by user. We |
| 880 | +% thus must delay loading the package to at begin document, and for now can |
| 881 | +% only set the default value of iconpackage key.. |
| 882 | +\IfFileExists{fontawesome6.sty}{% |
| 883 | + \DeclareStringOption[fontawesome6]{iconpackage}% |
882 | 884 | }%
|
883 | 885 | {%
|
| 886 | + \IfFileExists{fontawesome5.sty}{% |
| 887 | + \DeclareStringOption[fontawesome5]{iconpackage}% |
| 888 | + }% |
| 889 | + {% |
884 | 890 | \IfFileExists{fontawesome.sty}
|
885 | 891 | {\DeclareStringOption[fontawesome]{iconpackage}}
|
886 | 892 | {\DeclareStringOption[none]{iconpackage}}%
|
| 893 | + }% |
887 | 894 | }%
|
888 |
| -\newcommand\spx@faIcon[2][]{}% |
889 |
| -% The above \spx@faIcon which gobbles one mandatory and one optional |
890 |
| -% argument is put into use only if both fontawesome5 and fontawesome |
891 |
| -% LaTeX packages are not available, as part of the defaults for the |
892 |
| -% div.*_title-icon keys (these keys can be redefined via the sphinxsetup |
893 |
| -% interface). |
894 |
| -% |
895 |
| -\def\spxstring@fontawesome{fontawesome} |
896 |
| -\def\spxstring@fontawesomev{fontawesome5} |
| 895 | +% Unfortunately icon names differ between fontawesome, fontawesome5, and |
| 896 | +% fontawesome6 LaTeX packages. At 8.3.0 we refactor the icon support code |
| 897 | +% into something easier to maintain in future in case of a fontawesome7, |
| 898 | +% etc... |
| 899 | +% |
| 900 | +% TODO: Handle spaces possibly caused by bad user usage of iconpackage key? |
| 901 | +% This would need to check how LaTeX handle spaces in package name |
| 902 | +% in \RequirePackage command. Things in this area may have changed |
| 903 | +% recently (2025/04). |
897 | 904 | \AtBeginDocument{%
|
898 | 905 | \ifx\spx@opt@iconpackage\spxstring@none
|
899 | 906 | \else
|
900 | 907 | \IfFileExists{\spx@opt@iconpackage.sty}
|
901 |
| - {\RequirePackage{\spx@opt@iconpackage}% |
902 |
| - \ifx\spx@opt@iconpackage\spxstring@fontawesomev |
903 |
| - \renewcommand\spx@faIcon{\faIcon}% |
904 |
| - \else |
905 |
| - \ifx\spx@opt@iconpackage\spxstring@fontawesome |
906 |
| - \renewcommand\spx@faIcon[2][]{\faicon{##2}}% |
907 |
| - % The \ifdefined's are a bit silly because we know that |
908 |
| - % fontawesome.sty does not provide it, but perhaps |
909 |
| - % there can be some new release of that package? |
910 |
| - \ifdefined\faicon@lightbulb\else |
911 |
| - \let\faicon@lightbulb\faLightbulbO |
912 |
| - \fi |
913 |
| - \ifdefined\faicon@radiation\else |
914 |
| - \let\faicon@radiation\faBolt |
915 |
| - \fi |
916 |
| - \ifdefined\faicon@pen\else |
917 |
| - \let\faicon@pen\faPencil |
918 |
| - \fi |
919 |
| - % if neither has been required, \spx@faIcon will simply swallow |
920 |
| - % its argument and it is up to user |
921 |
| - % to set the various div.*_title-icon keys appropriately. |
922 |
| - \fi\fi % |
923 |
| - }% |
| 908 | + {\RequirePackage{\spx@opt@iconpackage}}% |
924 | 909 | {%
|
925 |
| - \sphinxbuildwarning{badiconpackage}% |
926 |
| - \PackageWarningNoLine{sphinx}{% |
| 910 | + \sphinxbuildwarning{badiconpackage}% |
| 911 | + \PackageWarningNoLine{sphinx}{% |
927 | 912 | You have set iconpackage=\spx@opt@iconpackage\MessageBreak
|
928 | 913 | But \spx@opt@iconpackage.sty is not found by LaTeX}
|
| 914 | + \let\spx@opt@iconpackage\spxstring@none |
929 | 915 | }%
|
930 | 916 | \fi
|
931 | 917 | }
|
932 | 918 |
|
| 919 | +% Icon defaults depending on package used. |
| 920 | +% Attention! no extra spaces for alignment when using \@namedef! |
| 921 | +\@namedef{spx@fontawesome6@note}{\faIcon{circle-info}} |
| 922 | +\@namedef{spx@fontawesome6@hint}{\faIcon[regular]{lightbulb}} |
| 923 | +\@namedef{spx@fontawesome6@tip}{\faIcon[regular]{lightbulb}} |
| 924 | +\@namedef{spx@fontawesome6@seealso}{\faIcon{share}} |
| 925 | +\@namedef{spx@fontawesome6@todo}{\faIcon{pen}} |
| 926 | +\@namedef{spx@fontawesome6@important}{\faIcon{circle-pause}} |
| 927 | +\@namedef{spx@fontawesome6@caution}{\faIcon{radiation}} |
| 928 | +\@namedef{spx@fontawesome6@warning}{\faIcon{triangle-exclamation}} |
| 929 | +\@namedef{spx@fontawesome6@attention}{\faIcon{triangle-exclamation}} |
| 930 | +\@namedef{spx@fontawesome6@danger}{\faIcon{radiation}} |
| 931 | +\@namedef{spx@fontawesome6@error}{\faIcon{circle-xmark}} |
| 932 | + |
| 933 | +\@namedef{spx@fontawesome5@note}{\faIcon{info-circle}} |
| 934 | +\@namedef{spx@fontawesome5@hint}{\faIcon[regular]{lightbulb}} |
| 935 | +\@namedef{spx@fontawesome5@tip}{\faIcon[regular]{lightbulb}} |
| 936 | +\@namedef{spx@fontawesome5@seealso}{\faIcon{share}} |
| 937 | +\@namedef{spx@fontawesome5@todo}{\faIcon{pen}} |
| 938 | +\@namedef{spx@fontawesome5@important}{\faIcon{pause-circle}} |
| 939 | +\@namedef{spx@fontawesome5@caution}{\faIcon{radiation}} |
| 940 | +\@namedef{spx@fontawesome5@warning}{\faIcon{exclamation-triangle}} |
| 941 | +\@namedef{spx@fontawesome5@attention}{\faIcon{exclamation-triangle}} |
| 942 | +\@namedef{spx@fontawesome5@danger}{\faIcon{radiation}} |
| 943 | +\@namedef{spx@fontawesome5@error}{\faIcon{times-circle}} |
| 944 | + |
| 945 | +\def\spx@fontawesome@note {\faicon{info-circle}} |
| 946 | +\def\spx@fontawesome@hint {\faicon{lightbulb-o}} |
| 947 | +\def\spx@fontawesome@tip {\faicon{lightbulb-o}} |
| 948 | +\def\spx@fontawesome@seealso {\faicon{share}} |
| 949 | +\def\spx@fontawesome@todo {\faicon{pencil}} |
| 950 | +\def\spx@fontawesome@important{\faicon{pause-circle}} |
| 951 | +\def\spx@fontawesome@caution {\faicon{bolt}} |
| 952 | +\def\spx@fontawesome@warning {\faicon{exclamation-triangle}} |
| 953 | +\def\spx@fontawesome@attention{\faicon{exclamation-triangle}} |
| 954 | +\def\spx@fontawesome@danger {\faicon{bolt}} |
| 955 | +\def\spx@fontawesome@error {\faicon{times-circle}} |
| 956 | + |
| 957 | +% \spx@none@{note,hint,...} left undefined, the \@nameuse will be \relax |
| 958 | +\def\spx@titleicon@default#1{\@nameuse{spx@\spx@opt@iconpackage @#1}} |
933 | 959 | \setkeys{sphinx}{
|
934 |
| -% Icon defaults. |
935 |
| - div.note_title-icon = \spx@faIcon{info-circle}, |
936 |
| - div.hint_title-icon = \spx@faIcon[regular]{lightbulb}, |
937 |
| - div.tip_title-icon = \spx@faIcon[regular]{lightbulb}, |
938 |
| - div.seealso_title-icon = \spx@faIcon{share}, |
939 |
| - div.todo_title-icon = \spx@faIcon{pen}, |
940 |
| - div.important_title-icon = \spx@faIcon{pause-circle}, |
941 |
| - div.caution_title-icon = \spx@faIcon{radiation}, |
942 |
| - div.warning_title-icon = \spx@faIcon{exclamation-triangle}, |
943 |
| - div.attention_title-icon = \spx@faIcon{exclamation-triangle}, |
944 |
| - div.danger_title-icon = \spx@faIcon{radiation}, |
945 |
| - div.error_title-icon = \spx@faIcon{times-circle}, |
| 960 | + div.note_title-icon = \spx@titleicon@default{note}, |
| 961 | + div.hint_title-icon = \spx@titleicon@default{hint}, |
| 962 | + div.tip_title-icon = \spx@titleicon@default{tip}, |
| 963 | + div.seealso_title-icon = \spx@titleicon@default{seealso}, |
| 964 | + div.todo_title-icon = \spx@titleicon@default{todo}, |
| 965 | + div.important_title-icon = \spx@titleicon@default{important}, |
| 966 | + div.caution_title-icon = \spx@titleicon@default{caution}, |
| 967 | + div.warning_title-icon = \spx@titleicon@default{warning}, |
| 968 | + div.attention_title-icon = \spx@titleicon@default{attention}, |
| 969 | + div.danger_title-icon = \spx@titleicon@default{danger}, |
| 970 | + div.error_title-icon = \spx@titleicon@default{error}, |
946 | 971 | % MEMO: the new at 8.1.0 defaults for contents/topic/sidebar directives
|
947 | 972 | % use no icons, they use \sphinxdotitlerow which detects automatically
|
948 | 973 | % whether title-icon key has been set or not.
|
|
0 commit comments