comparison Doc/texinputs/python.sty @ 25979:d812b8aaefb3 legacy-trunk

Define abstract way to get the normal and smaller font sizes that work even in the footnote context.
author Fred Drake <fdrake@acm.org>
date Thu, 31 Oct 2002 21:04:34 +0000
parents 6662f9d4220b
children 5be5c84dea23
comparison
equal deleted inserted replaced
25978:4f1b7396a3c5 25979:d812b8aaefb3
132 \pagenumbering{roman} % ToC & chapters 132 \pagenumbering{roman} % ToC & chapters
133 133
134 % Use this to set the font family for headers and other decor: 134 % Use this to set the font family for headers and other decor:
135 \newcommand{\py@HeaderFamily}{\sffamily} 135 \newcommand{\py@HeaderFamily}{\sffamily}
136 136
137 % Set up abstract ways to get the normal and smaller font sizes that
138 % work even in footnote context.
139 \newif\ifpy@infootnote \py@infootnotefalse
140 \let\py@oldfootnotetext\@footnotetext
141 \def\@footnotetext#1{%
142 \bgroup%
143 \py@infootnotetrue
144 \py@oldfootnotetext{#1}%
145 \egroup%
146 }
147 \def\py@defaultsize{%
148 \ifpy@infootnote\footnotesize\else\normalsize\fi%
149 }
150 \def\py@smallsize{%
151 \ifpy@infootnote\scriptsize\else\small\fi%
152 }
153
137 % Redefine the 'normal' header/footer style when using "fancyhdr" package: 154 % Redefine the 'normal' header/footer style when using "fancyhdr" package:
138 \@ifundefined{fancyhf}{}{ 155 \@ifundefined{fancyhf}{}{
139 % Use \pagestyle{normal} as the primary pagestyle for text. 156 % Use \pagestyle{normal} as the primary pagestyle for text.
140 \fancypagestyle{normal}{ 157 \fancypagestyle{normal}{
141 \fancyhf{} 158 \fancyhf{}
815 832
816 \newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font 833 \newcommand{\bfcode}[1]{\code{\bfseries#1}} % bold-faced code font
817 \newcommand{\csimplemacro}[1]{\code{#1}} 834 \newcommand{\csimplemacro}[1]{\code{#1}}
818 \newcommand{\kbd}[1]{\code{#1}} 835 \newcommand{\kbd}[1]{\code{#1}}
819 \newcommand{\samp}[1]{`\code{#1}'} 836 \newcommand{\samp}[1]{`\code{#1}'}
820 % This weird definition of \var{} allows it to always appear in roman
821 % italics, and won't get funky in code fragments when we play around
822 % with fonts. This also works directly in math mode.
823 % XXX \normalsize is bad in footnotes, though; we need a way to
824 % determine when we're in a footnote.
825 \newcommand{\var}[1]{% 837 \newcommand{\var}[1]{%
826 \ifmmode% 838 \ifmmode%
827 \hbox{\normalsize\textrm{\textit{#1\/}}}% 839 \hbox{\py@defaultsize\textrm{\textit{#1\/}}}%
828 \else% 840 \else%
829 \normalsize\textrm{\textit{#1\/}}% 841 \py@defaultsize\textrm{\textit{#1\/}}%
830 \fi% 842 \fi%
831 } 843 }
832 \renewcommand{\emph}[1]{{\em #1}} 844 \renewcommand{\emph}[1]{{\em #1}}
833 \newcommand{\dfn}[1]{\emph{#1}} 845 \newcommand{\dfn}[1]{\emph{#1}}
834 \newcommand{\strong}[1]{{\bf #1}} 846 \newcommand{\strong}[1]{{\bf #1}}
835 % let's experiment with a new font: 847 % let's experiment with a new font:
836 \newcommand{\file}[1]{`{\small\textsf{#1}}'} 848 \newcommand{\file}[1]{`\filenq{#1}'}
837 \newcommand{\filenq}[1]{{\small\textsf{#1}}} 849 \newcommand{\filenq}[1]{{\py@smallsize\textsf{#1}}}
838 850
839 % Use this def/redef approach for \url{} since hyperref defined this already, 851 % Use this def/redef approach for \url{} since hyperref defined this already,
840 % but only if we actually used hyperref: 852 % but only if we actually used hyperref:
841 \ifpdf 853 \ifpdf
842 \newcommand{\url}[1]{{% 854 \newcommand{\url}[1]{{%
843 \noindent% 855 \noindent%
844 \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}% 856 \pdfstartlink attr{/Border [0 0 0]} user{/S /URI /URI (#1)}%
845 \py@LinkColor% color of the link text 857 \py@LinkColor% color of the link text
846 \small\sf #1% 858 \py@smallsize\sf #1%
847 \py@NormalColor% Turn it back off; these are declarative 859 \py@NormalColor% Turn it back off; these are declarative
848 \pdfendlink}% and don't appear bound to the current 860 \pdfendlink}% and don't appear bound to the current
849 }% formatting "box". 861 }% formatting "box".
850 \else 862 \else
851 \newcommand{\url}[1]{\mbox{\small\textsf{#1}}} 863 \newcommand{\url}[1]{\mbox{\py@smallsize\textsf{#1}}}
852 \fi 864 \fi
853 \newcommand{\email}[1]{{\small\textsf{#1}}} 865 \newcommand{\email}[1]{{\py@smallsize\textsf{#1}}}
854 \newcommand{\newsgroup}[1]{{\small\textsf{#1}}} 866 \newcommand{\newsgroup}[1]{{\py@smallsize\textsf{#1}}}
855 867
856 \newcommand{\py@varvars}[1]{{% 868 \newcommand{\py@varvars}[1]{{%
857 {\let\unspecified=\py@unspecified% 869 {\let\unspecified=\py@unspecified%
858 \let\moreargs=\py@moreargs% 870 \let\moreargs=\py@moreargs%
859 \var{#1}}}} 871 \var{#1}}}}
885 897
886 \newcommand{\cfunction}[1]{\texttt{#1}} 898 \newcommand{\cfunction}[1]{\texttt{#1}}
887 \newcommand{\ctype}[1]{\texttt{#1}} % C struct or typedef name 899 \newcommand{\ctype}[1]{\texttt{#1}} % C struct or typedef name
888 \newcommand{\cdata}[1]{\texttt{#1}} % C variable, typically global 900 \newcommand{\cdata}[1]{\texttt{#1}} % C variable, typically global
889 901
890 \newcommand{\mailheader}[1]{{\small\textsf{#1:}}} 902 \newcommand{\mailheader}[1]{{\py@smallsize\textsf{#1:}}}
891 \newcommand{\mimetype}[1]{{\small\textsf{#1}}} 903 \newcommand{\mimetype}[1]{{\py@smallsize\textsf{#1}}}
892 % The \! is a "negative thin space" in math mode. 904 % The \! is a "negative thin space" in math mode.
893 \newcommand{\regexp}[1]{% 905 \newcommand{\regexp}[1]{%
894 {\tiny$^{^\lceil}\!\!$% 906 {\tiny$^{^\lceil}\!\!$%
895 {\normalsize\code{#1}}% XXX should use \footnotesize in footnotes 907 {\py@defaultsize\code{#1}}%
896 $\!\rfloor\!$% 908 $\!\rfloor\!$%
897 }} 909 }}
898 \newcommand{\envvar}[1]{% 910 \newcommand{\envvar}[1]{%
899 #1% 911 #1%
900 \index{#1}% 912 \index{#1}%