summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/maybemath/maybemath.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/maybemath/maybemath.sty')
-rw-r--r--Master/texmf-dist/tex/latex/maybemath/maybemath.sty85
1 files changed, 63 insertions, 22 deletions
diff --git a/Master/texmf-dist/tex/latex/maybemath/maybemath.sty b/Master/texmf-dist/tex/latex/maybemath/maybemath.sty
index 0b88a0c127f..0cbe49e8550 100644
--- a/Master/texmf-dist/tex/latex/maybemath/maybemath.sty
+++ b/Master/texmf-dist/tex/latex/maybemath/maybemath.sty
@@ -1,9 +1,11 @@
-\ProvidesPackage{maybemath}[2004/11/29]
+\ProvidesPackage{maybemath}[2005/2/22]
+\RequirePackage{amsmath}
\RequirePackage{bm}
+%\RequirePackage{xspace}
-%% A few commands for making math fonts bold or italic
-%% according to the context of surrounding text. It is
-%% particularly useful for avoiding problems with math
+%% A few commands for making math fonts bold, upright, italic
+%% or sans-serif according to the context of surrounding text.
+%% It is particularly useful for avoiding problems with math
%% boldness in section titles causing unwanted boldness
%% in e.g. the table of contents.
%%
@@ -17,35 +19,74 @@
%% Author: Andy Buckley <andy@insectnation.org>
+%% Mode names for bold, ext-bold, italic and sans-serif contexts
+\def\@boldname{b}%
+\def\@boldexname{bx}%
+\def\@italname{it}%
+\def\@sfname{cmss}%
+
+
%% Use the bold symbol if reqd for math fonts
-\DeclareRobustCommand{\maybebm}[1]{%
- \def\boldname{b}%
- \def\boldexname{bx}%
- \ifx\f@series\boldname%
- \boldsymbol{#1}%
- \else\ifx\f@series\boldexname%
- \boldsymbol{#1}%
+\DeclareRobustCommand{\maybebm}[1]{\ensuremath{%
+ \ifx\f@series\@boldname%
+ {{\bm{#1}}}%
+ \else\ifx\f@series\@boldexname%
+ {{\bm{#1}}}%
\else%
- #1%
+ {{#1}}%
\fi\fi%
-}
+}}
%% Use \mathrm if not in italic context
-%% (``backward logic'' for a reason)
-\def\italname{it}%
-\DeclareRobustCommand{\maybeit}[1]{%
- \ifx\f@shape\italname%
+\DeclareRobustCommand{\mayberm}[1]{\ensuremath{%
+ \ifx\f@shape\@italname%
{#1}%
\else%
{\mathrm{#1}}%
\fi%
-}
+}}
+
+%% Use \mathit if in italic context
+\DeclareRobustCommand{\maybeit}[1]{\ensuremath{%
+ \ifx\f@shape\@italname%
+ {\mathit{#1}}%
+ \else%
+ {#1}%
+ \fi%
+}}
+
+%% Use \mathrm if not in italic context
+%% and \mathit if in italic context
+\DeclareRobustCommand{\maybeitrm}[1]{\ensuremath{%
+ \ifx\f@shape\@italname%
+ {\mathit{#1}}%
+ \else%
+ {\mathrm{#1}}%
+ \fi%
+}}
%% Maybe-italic subscript shifting
-\DeclareRobustCommand{\maybeitsubscript}[1]{%
- \ifx\f@shape\italname%
- {\!\!#1}%
+\DeclareRobustCommand{\maybeitsubscript}[1]{\ensuremath{%
+ \ifx\f@shape\@italname%
+ {\!\mspace{1mu}#1}%
+ \else%
+ {#1}%
+ \fi%
+}}
+
+%% Maybe-sans font change
+\DeclareRobustCommand{\maybesf}[1]{\ensuremath{%
+ \ifx\f@family\@sfname%
+ {\mathsf{#1}}%
\else%
{#1}%
\fi%
-} \ No newline at end of file
+}}
+
+%% Convenience command for following bold and sans-serif contexts
+\DeclareRobustCommand{\maybebmsf}[1]{%
+ {\maybebm{\maybesf{#1}}}%
+}
+
+%% For reference purposes :-)
+%\DeclareRobustCommand{\maybemath}{\texttt{maybemath}\xspace}