summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/utf8add/utf8add.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/utf8add/utf8add.sty')
-rw-r--r--macros/latex/contrib/utf8add/utf8add.sty121
1 files changed, 71 insertions, 50 deletions
diff --git a/macros/latex/contrib/utf8add/utf8add.sty b/macros/latex/contrib/utf8add/utf8add.sty
index 90ce4b5675..4610c63830 100644
--- a/macros/latex/contrib/utf8add/utf8add.sty
+++ b/macros/latex/contrib/utf8add/utf8add.sty
@@ -1,4 +1,4 @@
-% Copyright 2020 Palle Jorgensen, hamselv@pallej.dk
+% Copyright 2020-21 Palle Jorgensen, hamselv@pallej.dk
%
% This file is part of utf8add.
%
@@ -14,7 +14,7 @@
%
% You should have received a copy of the GNU General Public License
% along with utf8add. If not, see <https://www.gnu.org/licenses/>.
-\ProvidesPackage{utf8add}[2020/05/26 Palle Jorgensen]
+\ProvidesPackage{utf8add}[2021/11/16 Palle Jorgensen]
%% Package dependencies
\RequirePackage[utf8]{inputenc}
@@ -24,13 +24,18 @@
\RequirePackage{gensymb}
\RequirePackage{nicefrac}
+\newif\if@greek@
+\@greek@true
+
%% Options
+%% Disable greek overall?
+\DeclareOptionX{nogreek}{\@greek@false}
+
%% Choosing the uppercase greek style :-/
\newif\if@uppercasegreek@default@
\newif\if@uppercasegreek@upright@
\newif\if@uppercasegreek@italic@
\@uppercasegreek@default@true
-
\DeclareOptionX{uppercasegreek}[default]{%
\csname @uppercasegreek@#1@true\endcsname}
@@ -105,70 +110,75 @@
\providecommand*\Upzeta{\mathrm{Z}}
}
+\def\auto@superior#1{\ifmmode^{#1}\else\textsuperscript{#1}\fi}
+\def\auto@inferior#1{\ifmmode^{#1}\else\textsubcript{#1}\fi}
\if@math@superior@
\AtBeginDocument{%
- \def\textonesuperior{\ensuremath{^{1}}}
- \def\texttwosuperior{\ensuremath{^{2}}}
- \def\textthreesuperior{\ensuremath{^{3}}}
- \def\textfoursuperior{\ensuremath{^{4}}}
- \def\textfivesuperior{\ensuremath{^{5}}}
- \def\textsixsuperior{\ensuremath{^{6}}}
- \def\textsevensuperior{\ensuremath{^{7}}}
- \def\texteightsuperior{\ensuremath{^{8}}}
- \def\textninesuperior{\ensuremath{^{9}}}
- \def\textzerosuperior{\ensuremath{^{0}}}
+ \def\textonesuperior{\auto@superior{1}}
+ \def\texttwosuperior{\auto@superior{2}}
+ \def\textthreesuperior{\auto@superior{3}}
+ \def\textfoursuperior{\auto@superior{4}}
+ \def\textfivesuperior{\auto@superior{5}}
+ \def\textsixsuperior{\auto@superior{6}}
+ \def\textsevensuperior{\auto@superior{7}}
+ \def\texteightsuperior{\auto@superior{8}}
+ \def\textninesuperior{\auto@superior{9}}
+ \def\textzerosuperior{\auto@superior{0}}
}
\else
\AtBeginDocument{%
- \providecommand*\textonesuperior{\ensuremath{^{1}}}
- \providecommand*\texttwosuperior{\ensuremath{^{2}}}
- \providecommand*\textthreesuperior{\ensuremath{^{3}}}
- \providecommand*\textfoursuperior{\ensuremath{^{4}}}
- \providecommand*\textfivesuperior{\ensuremath{^{5}}}
- \providecommand*\textsixsuperior{\ensuremath{^{6}}}
- \providecommand*\textsevensuperior{\ensuremath{^{7}}}
- \providecommand*\texteightsuperior{\ensuremath{^{8}}}
- \providecommand*\textninesuperior{\ensuremath{^{9}}}
- \providecommand*\textzerosuperior{\ensuremath{^{0}}}}
+ \providecommand*\textonesuperior{\auto@superior{1}}
+ \providecommand*\texttwosuperior{\auto@superior{2}}
+ \providecommand*\textthreesuperior{\auto@superior{3}}
+ \providecommand*\textfoursuperior{\auto@superior{4}}
+ \providecommand*\textfivesuperior{\auto@superior{5}}
+ \providecommand*\textsixsuperior{\auto@superior{6}}
+ \providecommand*\textsevensuperior{\auto@superior{7}}
+ \providecommand*\texteightsuperior{\auto@superior{8}}
+ \providecommand*\textninesuperior{\auto@superior{9}}
+ \providecommand*\textzerosuperior{\auto@superior{0}}}
\fi
\if@math@inferior@
\AtBeginDocument{%
- \def\textoneinferior{\ensuremath{_{1}}}
- \def\texttwoinferior{\ensuremath{_{2}}}
- \def\textthreeinferior{\ensuremath{_{3}}}
- \def\textfourinferior{\ensuremath{_{4}}}
- \def\textfiveinferior{\ensuremath{_{5}}}
- \def\textsixinferior{\ensuremath{_{6}}}
- \def\textseveninferior{\ensuremath{_{7}}}
- \def\texteightinferior{\ensuremath{_{8}}}
- \def\textnineinferior{\ensuremath{_{9}}}
- \def\textzeroinferior{\ensuremath{_{0}}}
-}
+ \def\textoneinferior{\auto@inferior{1}}
+ \def\texttwoinferior{\auto@inferior{2}}
+ \def\textthreeinferior{\auto@inferior{3}}
+ \def\textfourinferior{\auto@inferior{4}}
+ \def\textfiveinferior{\auto@inferior{5}}
+ \def\textsixinferior{\auto@inferior{6}}
+ \def\textseveninferior{\auto@inferior{7}}
+ \def\texteightinferior{\auto@inferior{8}}
+ \def\textnineinferior{\auto@inferior{9}}
+ \def\textzeroinferior{\auto@inferior{0}}}
\else
\AtBeginDocument{%
- \providecommand*\textoneinferior{\ensuremath{_{1}}}
- \providecommand*\texttwoinferior{\ensuremath{_{2}}}
- \providecommand*\textthreeinferior{\ensuremath{_{3}}}
- \providecommand*\textfourinferior{\ensuremath{_{4}}}
- \providecommand*\textfiveinferior{\ensuremath{_{5}}}
- \providecommand*\textsixinferior{\ensuremath{_{6}}}
- \providecommand*\textseveninferior{\ensuremath{_{7}}}
- \providecommand*\texteightinferior{\ensuremath{_{8}}}
- \providecommand*\textnineinferior{\ensuremath{_{9}}}
- \providecommand*\textzeroinferior{\ensuremath{_{0}}}
-}
+ \providecommand*\textoneinferior{\auto@inferior{1}}
+ \providecommand*\texttwoinferior{\auto@inferior{2}}
+ \providecommand*\textthreeinferior{\auto@inferior{3}}
+ \providecommand*\textfourinferior{\auto@inferior{4}}
+ \providecommand*\textfiveinferior{\auto@inferior{5}}
+ \providecommand*\textsixinferior{\auto@inferior{6}}
+ \providecommand*\textseveninferior{\auto@inferior{7}}
+ \providecommand*\texteightinferior{\auto@inferior{8}}
+ \providecommand*\textnineinferior{\auto@inferior{9}}
+ \providecommand*\textzeroinferior{\auto@inferior{0}}}
\fi
\def\@autofrac#1#2{%
- \@ifstar{\ensuremath{\tfrac{#1}{#2}}}{%
+ \@ifstar{%
+ \ifmmode
+ \tfrac{#1}{#2}
+ \else
+ $\frac{\text{#1}}{\text{#2}}$
+ \fi}{%
\ifmmode
\frac{#1}{#2}
\else
\if@nicefrac@
\nicefrac{#1}{#2}
\else
- \ensuremath{\tfrac{#1}{#2}}\fi\fi}}
+ $\tfrac{\text{#1}}{\text{#2}}$\fi\fi}}
%% Fractions
\if@math@fractions@
@@ -259,6 +269,15 @@
\DeclareUnicodeCharacter{2152}{\textonetenth}
\DeclareUnicodeCharacter{2189}{\textzerothirds}
+
+\if@greek@
+
+\@ifundefined{ver@lgrenc.def}{} {\PackageWarning{utf8add}{LGR font
+ encoding loaded. Output will be poor.}}
+
+\@ifpackageloaded{textalpha}{\PackageWarning{utf8add}{Package
+ 'textalpha' loaded. Output will be poor.}{}}
+
%% Lowercase Greek Letters
\if@lowercasegreek@upright@
\DeclareUnicodeCharacter{03B1}{\ensuremath{\upalpha}}
@@ -399,7 +418,7 @@
\DeclareUnicodeCharacter{03A7}{\ensuremath{\Chi}}
\DeclareUnicodeCharacter{03A8}{\ensuremath{\Psi}}
\DeclareUnicodeCharacter{03A9}{\ensuremath{\Omega}}
-\fi\fi\fi
+\fi\fi\fi\fi
%% Superior numbers 4-0
\DeclareUnicodeCharacter{2074}{\textfoursuperior}
@@ -448,10 +467,12 @@
\DeclareUnicodeCharacter{2016}{\ifmmode\Vert\else\textbardbl\fi}
%% Other miscelaneous symbols
-\DeclareUnicodeCharacter{207A}{\ensuremath{^{+}}}
-\DeclareUnicodeCharacter{207B}{\ensuremath{^{-}}}
+\DeclareUnicodeCharacter{207A}{\auto@superior{+}}
+\DeclareUnicodeCharacter{207B}{\ifmmode^{-}\else\textsuperscript{\textminus}\fi}
\DeclareUnicodeCharacter{2213}{\ensuremath{\mp}}
\DeclareUnicodeCharacter{2212}{\ifmmode-\else--\fi}
\DeclareUnicodeCharacter{0127}{\ensuremath{\hbar}}
+\providecommand*\molar{\textsc{m}}
+\DeclareUnicodeCharacter{1D0D}{\molar}
\endinput \ No newline at end of file