summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/maybemath/maybemath.sty
blob: 0b88a0c127f770c911b48bb7d144f3530bc74cfb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
\ProvidesPackage{maybemath}[2004/11/29]
\RequirePackage{bm}

%% 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
%% boldness in section titles causing unwanted boldness
%% in e.g. the table of contents.
%%
%% Thanks to Viet-Trung Luu on comp.text.tex for providing 
%% the first steps to solving this problem.
%%
%% This material is subject to the LaTeX Project Public License. 
%% See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html
%% for the details of that license.
%%
%% Author: Andy Buckley <andy@insectnation.org>


%% 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}%
    \else%
        #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%
    {#1}%
  \else%
    {\mathrm{#1}}%
  \fi%
}

%% Maybe-italic subscript shifting
\DeclareRobustCommand{\maybeitsubscript}[1]{%
  \ifx\f@shape\italname%
    {\!\!#1}%
  \else%
    {#1}%
  \fi%
}