summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/exam-n/examndefs.sty
blob: 5ad56f1e261e7b65e0426ab4cba05ffbfa928220 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
% Generated file : DO NOT EDIT
\@ifundefined{@psfontsfalse}{\newif\if@psfonts \@psfontsfalse}{}
\@ifundefined{examn@uprightpifalse}{\newif\ifexamn@uprightpi \examn@uprightpifalse}{}
\@ifundefined{examn@mtselect}{\newcount\examn@mtselect \examn@mtselect=0}{}
\if@psfonts
  \ifcase\examn@mtselect
    % mathptm fonts
    % This is a very clumsy version, but it appears to be our only option
    \def\vec#1{\mathchoice{\mbox{\boldmath $\displaystyle #1$}}
      {\mbox{\boldmath $ #1$}}
      {\mbox{\boldmath $\scriptstyle #1$}}
      {\mbox{\boldmath $\scriptscriptstyle #1$}}}
    \ifexamn@uprightpi
      \ClassWarning{exam-n}{Can't do uprightpi in [mathptm] -- sorry}
      \let\italicpi\pi
      \examn@uprightpifalse
    \fi
  \or % mathtime (should this be the same for mathtime as for mtpro2?
    \let\vec\mathbf
    \ifexamn@uprightpi
      \ClassWarning{exam-n}{Can't do uprightpi in [mathtime] -- sorry}
      \let\italicpi\pi
      \examn@uprightpifalse
    \fi
  \or % mtpro2
    \let\vec\mathbold
    % \uppi is predefined in mtpro2
    \ifexamn@uprightpi
      \let\italicpi\pi
      \let\pi\uppi
    \fi
  \else
    % STIX2: the unicode-math package provides a \symbf for bold math symbols,
    \ifnum\examn@engine<2       % pdflatex
      \let\vec\mathbf
      % pdftex (or original tex)
      % The following should, I think, create an upright pi, but doesn't
      \def\uppi{\mathrm{\pi}}
      \let\italicpi\pi          %for consistency
      \let\symup\mathrm         %not fully the right thing, but avoid errors below
    \else                       % xelatex or lualatex
      % This is where the dependence on a recent LaTeX enters.
      \let\vec\symbf
      \typeout{stix2: upright=\ifexamn@uprightpi true\else false\fi}
      \AddToHook{begindocument/end}{\gdef\uppi{\symup{𝜋}}}
      \ifexamn@uprightpi
        \AddToHook{begindocument/end}{\gdef\italicpi{\symit{𝜋}}\global\let\pi\uppi}
      \fi
    \fi
  \fi
\else
  % CM fonts: \mathbf doesn't work with greek in CM
  \let\vec\mathbf
  \ifexamn@uprightpi
    % upright greek is hard to do portably, so give up
    % See eg https://tex.stackexchange.com/questions/145926/ for discussion
    \ClassWarning{exam-n}{Can't do uprightpi in [cmfonts] -- sorry}
    \let\italicpi\pi
    \let\uppi\pi                %but avoid errors
    \examn@uprightpifalse
  \fi
\fi
\newcommand\BSc{B.Sc.{}}
\newcommand\MSci{M.Sci.{}}
\newcommand\MSc{M.Sc.{}}
\newcommand\MA{M.A.{}}
\newcommand\MEng{M.Eng.{}}
\newcommand\BEng{B.Eng.{}}
\ifnum\examn@mtselect>2
  % ie, STIX2, and thus using the unicode-math package (see above)
  \def\e{\symup{e}}
  \newcommand{\dd}{\symup{d}}
  \newcommand{\ddd}{\,\symup{d}}
\else
  \def\e{\mathrm{e}}
  \newcommand{\dd}{\mathrm{d}}
  \newcommand{\ddd}{\,\mathrm{d}}
\fi

\def\Diffl{\@ifstar\@Difflflat\@Diffl}
\def\Partial{\@ifstar\@Partialflat\@Partial}
\def\@Partial{\@ifnextchar[{\@@Diffl\partial}{\@@Diffl\partial[]}}
\def\@Partialflat{\@ifnextchar[{\@@Difflflat\partial}{\@@Difflflat\partial[]}}
\def\@Diffl{\@ifnextchar[{\@@Diffl\dd}{\@@Diffl\dd[]}}
\def\@Difflflat{\@ifnextchar[{\@@Difflflat\dd}{\@@Difflflat\dd[]}}
\def\@@Diffl#1[#2]#3#4{%
  \def\@tempa{#2}%
  \ifx\@tempa\empty
    \frac{#1#3}{#1#4}%
  \else
    \frac{{#1}^{#2}#3}{#1{#4}^{#2}}%
  \fi}
\def\@@Difflflat#1[#2]#3#4{%
  \def\@tempa{#2}%
  \ifx\@tempa\empty
    #1#3\mskip-0.8mu/\mskip-1.2mu #1#4%
  \else
    {#1}^{#2}#3\mskip-0.8mu /\mskip-1.2mu #1{#4}^{#2}%
  \fi}
\def\units{\examn@unitswarning
  \begingroup
  \catcode`\.=\active
  \@ifstar{\let\un@tsspace\relax    \un@ts}%
          {\let\un@tsspace\thinspace\un@ts}}
\begingroup
  \catcode`\.=\active
  \gdef\un@ts#1{\let~\thinspace\let.\thinspace
    \ifmmode
      \un@tsspace\mathrm{#1}%
    \else
      \nobreak$\un@tsspace\mathrm{#1}$%
    \fi
    \endgroup}
\endgroup
\newif\ifexamn@warnunits \examn@warnunitstrue
\def\examn@unitswarning{\ifexamn@warnunits
  \ClassWarning{exam-n}{The units macro will be removed in the next
    version; the [siunitx] option is now on by default, so you can use
    the macros in the siunits package}%
  \global\examn@warnunitsfalse
\fi}