diff Doc/texinputs/python.sty @ 9542:1437c2335b3b legacy-trunk

Make \var work correctly in math mode.
author Fred Drake <fdrake@acm.org>
date Mon, 30 Nov 1998 14:42:59 +0000
parents c6a1103efa8a
children a58f36352c4f
line wrap: on
line diff
--- a/Doc/texinputs/python.sty	Mon Nov 30 14:36:26 1998 +0000
+++ b/Doc/texinputs/python.sty	Mon Nov 30 14:42:59 1998 +0000
@@ -626,8 +626,14 @@
 \newcommand{\samp}[1]{`\code{#1}'}
 % This weird definition of \var{} allows it to always appear in roman
 % italics, and won't get funky in code fragments when we play around
-% with fonts.
-\newcommand{\var}[1]{\normalsize\textrm{\textit{#1\/}}}
+% with fonts.  This also works directly in math mode.
+\newcommand{\var}[1]{%
+  \ifmmode%
+    \hbox{\normalsize\textrm{\textit{#1\/}}}%
+  \else%
+    \normalsize\textrm{\textit{#1\/}}%
+  \fi%
+}
 \renewcommand{\emph}[1]{{\em #1}}
 \newcommand{\dfn}[1]{\emph{#1}}
 \newcommand{\strong}[1]{{\bf #1}}