% Copyright 2020-21 Palle Jorgensen, hamselv@pallej.dk
%
% This file is part of utf8add.
%
% utf8add is free software: you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% utf8add is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
% General Public License for more details.
%
% 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}[2021/11/16 Palle Jorgensen]

%% Package dependencies
\RequirePackage[utf8]{inputenc}
\RequirePackage{upgreek}
\RequirePackage{amsmath}
\RequirePackage{xkeyval}
\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}

%% Choosing the lowercase greek style :-/
\newif\if@lowercasegreek@default@
\newif\if@lowercasegreek@upright@
\newif\if@lowercasegreek@italic@
\@lowercasegreek@default@true
\DeclareOptionX{lowercasegreek}[default]{%
  \csname @lowercasegreek@#1@true\endcsname}

%% Choosing the overall greek style :-D
\DeclareOptionX{greek}[default]{%
  \csname @uppercasegreek@#1@true\endcsname
  \csname @lowercasegreek@#1@true\endcsname}

%% Italic lowercase is default
\if@lowercasegreek@italic@
\@lowercasegreek@default@true\fi

%%
\newif\if@math@inferior@
\@math@inferior@false
\newif\if@math@superior@
\@math@superior@false
\newif\if@math@fractions@
\@math@fractions@false
\newif\if@nicefrac@
\@nicefrac@false

%% Superior and inferieor numbers; fractions: Math or built-in support?
\DeclareOptionX{mathinferior}{\@math@inferior@true}
\DeclareOptionX{mathsuperior}{\@math@superior@true}
\DeclareOptionX{mathfigures}{\s@math@superior@true\@math@inferior@true}
\DeclareOptionX{mathfractions}{\@math@fractions@true}
\DeclareOptionX{math}{\@math@superior@true\@math@inferior@true\@math@fractions@true}
\DeclareOptionX{nicefrac}{\@nicefrac@true}

\ProcessOptionsX

%% Default provisions
\AtBeginDocument{%
%% Italic greek/latin characters. Supplementary
  \providecommand*\omicron{\mathit{o}}
  \providecommand*\Alpha{\mathit{A}}
  \providecommand*\Beta{\mathit{B}}
  \providecommand*\Chi{\mathit{X}}
  \providecommand*\Epsilon{\mathit{E}}
  \providecommand*\Eta{\mathit{H}}
  \providecommand*\Iota{\mathit{I}}
  \providecommand*\Kappa{\mathit{K}}
  \providecommand*\Mu{\mathit{M}}
  \providecommand*\Nu{\mathit{N}}
  \providecommand*\Omicron{\mathit{O}}
  \providecommand*\Rho{\mathit{P}}
  \providecommand*\Tau{\mathit{T}}
  \providecommand*\Zeta{\mathit{Z}}
%% Upright greek/latin characters. Supplementary
  \providecommand*\Upomicron{\mathrm{o}}
  \providecommand*\Upalpha{\mathrm{A}}
  \providecommand*\Upbeta{\mathrm{B}}
  \providecommand*\Upchi{\mathrm{X}}
  \providecommand*\Upepsilon{\mathrm{E}}
  \providecommand*\Upeta{\mathrm{H}}
  \providecommand*\Upiota{\mathrm{I}}
  \providecommand*\Upkappa{\mathrm{K}}
  \providecommand*\Upmu{\mathrm{M}}
  \providecommand*\Upnu{\mathrm{N}}
  \providecommand*\Upomicron{\mathrm{O}}
  \providecommand*\Uprho{\mathrm{P}}
  \providecommand*\Uptau{\mathrm{T}}
  \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{\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{\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{\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{\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{%
    \ifmmode
    \tfrac{#1}{#2}
    \else
    $\frac{\text{#1}}{\text{#2}}$
    \fi}{%
    \ifmmode
    \frac{#1}{#2}
    \else
    \if@nicefrac@
    \nicefrac{#1}{#2}
    \else
    $\tfrac{\text{#1}}{\text{#2}}$\fi\fi}}

%% Fractions
\if@math@fractions@
\AtBeginDocument{%
%% Defining the math fractions
  \def\textonehalf          {\@autofrac{1}{2}}
  \def\textonethird         {\@autofrac{1}{3}}
  \def\texttwothirds        {\@autofrac{2}{3}}
  \def\textzerothirds       {\@autofrac{0}{3}}
  \def\textonequarter       {\@autofrac{1}{4}}
  \def\textthreequarters    {\@autofrac{3}{4}}
  \def\textonefifth         {\@autofrac{1}{5}}
  \def\texttwofifths        {\@autofrac{2}{5}}
  \def\textthreefifths      {\@autofrac{3}{5}}
  \def\textfourfifths       {\@autofrac{4}{5}}
  \def\textonesixth         {\@autofrac{1}{6}}
  \def\textfivesixths       {\@autofrac{5}{6}}
  \def\textoneseventh       {\@autofrac{1}{7}}
  \def\textoneeighth        {\@autofrac{1}{8}}
  \def\textthreeeighths     {\@autofrac{3}{8}}
  \def\textfiveeighths      {\@autofrac{5}{8}}
  \def\textseveneighths     {\@autofrac{7}{8}}
  \def\textonenininth       {\@autofrac{1}{9}}
  \def\textonetenth         {\@autofrac{1}{10}}
  %% Different spellings
  \let\texttwothird\texttwothirds
  \let\textthreequarter\textthreequarters
  \let\texttwofifth\texttwofifths
  \let\textthreefifth\textthreefifths
  \let\textfourfifth\textfourfifths
  \let\textfivesixth\textfivesixths
  \let\textthreeeighth\textthreeeighths
  \let\textfiveeighth\textfiveeighths
  \let\textseveneighth\textseveneighths
}
\else
%% Math commandsfractions as backup
\AtBeginDocument{%
  \providecommand*\textonehalf          {\@autofrac{1}{2}}
  \providecommand*\textonethird         {\@autofrac{1}{3}}
  \providecommand*\texttwothirds        {\@autofrac{2}{3}}
  \providecommand*\textzerothirds       {\@autofrac{0}{3}}
  \providecommand*\textonequarter       {\@autofrac{1}{4}}
  \providecommand*\textthreequarters    {\@autofrac{3}{4}}
  \providecommand*\textonefifth         {\@autofrac{1}{5}}
  \providecommand*\texttwofifths        {\@autofrac{2}{5}}
  \providecommand*\textthreefifths      {\@autofrac{3}{5}}
  \providecommand*\textfourfifths       {\@autofrac{4}{5}}
  \providecommand*\textonesixth         {\@autofrac{1}{6}}
  \providecommand*\textfivesixths       {\@autofrac{5}{6}}
  \providecommand*\textoneseventh       {\@autofrac{1}{7}}
  \providecommand*\textoneeighth        {\@autofrac{1}{8}}
  \providecommand*\textthreeeighths     {\@autofrac{3}{8}}
  \providecommand*\textfiveeighths      {\@autofrac{5}{8}}
  \providecommand*\textseveneighths     {\@autofrac{7}{8}}
  \providecommand*\textonenininth       {\@autofrac{1}{9}}
  \providecommand*\textonetenth         {\@autofrac{1}{10}}
  %% Different spellings
  \providecommand*\texttwothird{\texttwothirds}
  \providecommand*\textthreequarter{\textthreequarters}
  \providecommand*\texttwofifth{\texttwofifths}
  \providecommand*\textthreefifth{\textthreefifths}
  \providecommand*\textfourfifth{\textfourfifths}
  \providecommand*\textfivesixth{\textfivesixths}
  \providecommand*\textthreeeighth{\textthreeeighths}
  \providecommand*\textfiveeighth{\textfiveeighths}
  \providecommand*\textseveneighth{\textseveneighths}
}
\fi

\DeclareUnicodeCharacter{00BD}{\textonehalf}
\DeclareUnicodeCharacter{2153}{\textonethird}
\DeclareUnicodeCharacter{2154}{\texttwothirds}
\DeclareUnicodeCharacter{00BC}{\textonequarter}
\DeclareUnicodeCharacter{00BE}{\textthreequarters}
\DeclareUnicodeCharacter{2155}{\textonefifth}
\DeclareUnicodeCharacter{2156}{\texttwofifths}
\DeclareUnicodeCharacter{2157}{\textthreefifths}
\DeclareUnicodeCharacter{2158}{\textfourfifths}
\DeclareUnicodeCharacter{2159}{\textonesixth}
\DeclareUnicodeCharacter{215A}{\textfivesixths}
\DeclareUnicodeCharacter{2150}{\textoneseventh}
\DeclareUnicodeCharacter{215B}{\textoneeighth}
\DeclareUnicodeCharacter{215C}{\textthreeeighths}
\DeclareUnicodeCharacter{215D}{\textfiveeighths}
\DeclareUnicodeCharacter{215E}{\textseveneighths}
\DeclareUnicodeCharacter{2151}{\textonenininth}
\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}}
\DeclareUnicodeCharacter{03B2}{\ensuremath{\upbeta}}
\DeclareUnicodeCharacter{03B3}{\ensuremath{\upgamma}}
\DeclareUnicodeCharacter{03B4}{\ensuremath{\updelta}}
\DeclareUnicodeCharacter{03B5}{\ensuremath{\upepsilon}}
\DeclareUnicodeCharacter{03F5}{\ensuremath{\upvarepsilon}}
\DeclareUnicodeCharacter{03B6}{\ensuremath{\upzeta}}
\DeclareUnicodeCharacter{03B7}{\ensuremath{\upeta}}
\DeclareUnicodeCharacter{03B8}{\ensuremath{\uptheta}}
\DeclareUnicodeCharacter{03B9}{\ensuremath{\upiota}}
\DeclareUnicodeCharacter{03BA}{\ensuremath{\upkappa}}
\DeclareUnicodeCharacter{03BB}{\ensuremath{\uplambda}}
\DeclareUnicodeCharacter{03BC}{\ensuremath{\upmu}}
\DeclareUnicodeCharacter{03BD}{\ensuremath{\upnu}}
\DeclareUnicodeCharacter{03BE}{\ensuremath{\upxi}}
\DeclareUnicodeCharacter{03BF}{\ensuremath{\upomicron}}
\DeclareUnicodeCharacter{03C0}{\ensuremath{\uppi}}
\DeclareUnicodeCharacter{03C1}{\ensuremath{\uprho}}
\DeclareUnicodeCharacter{03C3}{\ensuremath{\upsigma}}
\DeclareUnicodeCharacter{03C2}{\ensuremath{\upvarsigma}}
\DeclareUnicodeCharacter{03C4}{\ensuremath{\uptau}}
\DeclareUnicodeCharacter{03C5}{\ensuremath{\upupsilon}}
\DeclareUnicodeCharacter{03C6}{\ensuremath{\upphi}}
\DeclareUnicodeCharacter{03C7}{\ensuremath{\upchi}}
\DeclareUnicodeCharacter{03C8}{\ensuremath{\uppsi}}
\DeclareUnicodeCharacter{03C9}{\ensuremath{\upomega}}

\else\if@lowercasegreek@default@

\DeclareUnicodeCharacter{03B1}{\ensuremath{\alpha}}
\DeclareUnicodeCharacter{03B2}{\ensuremath{\beta}}
\DeclareUnicodeCharacter{03B3}{\ensuremath{\gamma}}
\DeclareUnicodeCharacter{03B4}{\ensuremath{\delta}}
\DeclareUnicodeCharacter{03B5}{\ensuremath{\varepsilon}}
\DeclareUnicodeCharacter{03F5}{\ensuremath{\epsilon}}
\DeclareUnicodeCharacter{03B6}{\ensuremath{\zeta}}
\DeclareUnicodeCharacter{03B7}{\ensuremath{\eta}}
\DeclareUnicodeCharacter{03B8}{\ensuremath{\theta}}
\DeclareUnicodeCharacter{03D1}{\ensuremath{\vartheta}}
\DeclareUnicodeCharacter{03B9}{\ensuremath{\iota}}
\DeclareUnicodeCharacter{03BA}{\ensuremath{\kappa}}
\DeclareUnicodeCharacter{03BB}{\ensuremath{\lambda}}
\DeclareUnicodeCharacter{03BC}{\ensuremath{\mu}}
\DeclareUnicodeCharacter{03BD}{\ensuremath{\nu}}
\DeclareUnicodeCharacter{03BE}{\ensuremath{\xi}}
\DeclareUnicodeCharacter{03BF}{\ensuremath{\omicron}}
\DeclareUnicodeCharacter{03C0}{\ensuremath{\pi}}
\DeclareUnicodeCharacter{03C1}{\ensuremath{\rho}}
\DeclareUnicodeCharacter{03C2}{\ensuremath{\varsigma}}
\DeclareUnicodeCharacter{03C3}{\ensuremath{\sigma}}
\DeclareUnicodeCharacter{03C4}{\ensuremath{\tau}}
\DeclareUnicodeCharacter{03C5}{\ensuremath{\upsilon}}
\DeclareUnicodeCharacter{03D5}{\ensuremath{\phi}}
\DeclareUnicodeCharacter{03C6}{\ensuremath{\varphi}}
\DeclareUnicodeCharacter{03C7}{\ensuremath{\chi}}
\DeclareUnicodeCharacter{03C8}{\ensuremath{\psi}}
\DeclareUnicodeCharacter{03C9}{\ensuremath{\omega}}
\fi\fi

%% Uppercase Greek Letters 
\if@uppercasegreek@upright@
\DeclareUnicodeCharacter{0391}{\ensuremath{\Upalpha}}
\DeclareUnicodeCharacter{0392}{\ensuremath{\Upbeta}}
\DeclareUnicodeCharacter{0393}{\ensuremath{\Upgamma}}
\DeclareUnicodeCharacter{0394}{\ensuremath{\Updelta}}
\DeclareUnicodeCharacter{0395}{\ensuremath{\Upepsilon}}
\DeclareUnicodeCharacter{0396}{\ensuremath{\Upzeta}}
\DeclareUnicodeCharacter{0397}{\ensuremath{\Upeta}}
\DeclareUnicodeCharacter{0398}{\ensuremath{\Uptheta}}
\DeclareUnicodeCharacter{0399}{\ensuremath{\Upiota}}
\DeclareUnicodeCharacter{039A}{\ensuremath{\Upkappa}}
\DeclareUnicodeCharacter{039B}{\ensuremath{\Uplambda}}
\DeclareUnicodeCharacter{039C}{\ensuremath{\Upmu}}
\DeclareUnicodeCharacter{039D}{\ensuremath{\Upnu}}
\DeclareUnicodeCharacter{039E}{\ensuremath{\Upxi}}
\DeclareUnicodeCharacter{039F}{\ensuremath{\Upomicron}}
\DeclareUnicodeCharacter{03A0}{\ensuremath{\Uppi}}
\DeclareUnicodeCharacter{03A1}{\ensuremath{\Uprho}}
\DeclareUnicodeCharacter{03A3}{\ensuremath{\Upsigma}}
\DeclareUnicodeCharacter{03A4}{\ensuremath{\Uptau}}
\DeclareUnicodeCharacter{03A5}{\ensuremath{\Upupsilon}}
\DeclareUnicodeCharacter{03A6}{\ensuremath{\Upphi}}
\DeclareUnicodeCharacter{03A7}{\ensuremath{\Upchi}}
\DeclareUnicodeCharacter{03A8}{\ensuremath{\Uppsi}}
\DeclareUnicodeCharacter{03A9}{\ensuremath{\Upomega}}

\else\if@uppercasegreek@italic@

\DeclareUnicodeCharacter{0391}{\ensuremath{\varAlpha}}
\DeclareUnicodeCharacter{0392}{\ensuremath{\varBeta}}
\DeclareUnicodeCharacter{0393}{\ensuremath{\varGamma}}
\DeclareUnicodeCharacter{0394}{\ensuremath{\varDelta}}
\DeclareUnicodeCharacter{0395}{\ensuremath{\varEpsilon}}
\DeclareUnicodeCharacter{0396}{\ensuremath{\varZeta}}
\DeclareUnicodeCharacter{0397}{\ensuremath{\varEta}}
\DeclareUnicodeCharacter{0398}{\ensuremath{\varTheta}}
\DeclareUnicodeCharacter{0399}{\ensuremath{\varIota}}
\DeclareUnicodeCharacter{039A}{\ensuremath{\varKappa}}
\DeclareUnicodeCharacter{039B}{\ensuremath{\varLambda}}
\DeclareUnicodeCharacter{039C}{\ensuremath{\varMu}}
\DeclareUnicodeCharacter{039D}{\ensuremath{\varNu}}
\DeclareUnicodeCharacter{039E}{\ensuremath{\varXi}}
\DeclareUnicodeCharacter{039F}{\ensuremath{\varOmicron}}
\DeclareUnicodeCharacter{03A0}{\ensuremath{\varPi}}
\DeclareUnicodeCharacter{03A1}{\ensuremath{\varRho}}
\DeclareUnicodeCharacter{03A3}{\ensuremath{\varSigma}}
\DeclareUnicodeCharacter{03A4}{\ensuremath{\varTau}}
\DeclareUnicodeCharacter{03A5}{\ensuremath{\varUpsilon}}
\DeclareUnicodeCharacter{03A6}{\ensuremath{\varPhi}}
\DeclareUnicodeCharacter{03A7}{\ensuremath{\varChi}}
\DeclareUnicodeCharacter{03A8}{\ensuremath{\varPsi}}
\DeclareUnicodeCharacter{03A9}{\ensuremath{\varOmega}}

\else\if@uppercasegreek@default@
\DeclareUnicodeCharacter{0391}{\ensuremath{\Alpha}}
\DeclareUnicodeCharacter{0392}{\ensuremath{\Beta}}
\DeclareUnicodeCharacter{0393}{\ensuremath{\Gamma}}
\DeclareUnicodeCharacter{0394}{\ensuremath{\Delta}}
\DeclareUnicodeCharacter{0395}{\ensuremath{\Epsilon}}
\DeclareUnicodeCharacter{0396}{\ensuremath{\Zeta}}
\DeclareUnicodeCharacter{0397}{\ensuremath{\Eta}}
\DeclareUnicodeCharacter{0398}{\ensuremath{\Theta}}
\DeclareUnicodeCharacter{0399}{\ensuremath{\Iota}}
\DeclareUnicodeCharacter{039A}{\ensuremath{\Kappa}}
\DeclareUnicodeCharacter{039B}{\ensuremath{\Lambda}}
\DeclareUnicodeCharacter{039C}{\ensuremath{\Mu}}
\DeclareUnicodeCharacter{039D}{\ensuremath{\Nu}}
\DeclareUnicodeCharacter{039E}{\ensuremath{\Xi}}
\DeclareUnicodeCharacter{039F}{\ensuremath{\Omicron}}
\DeclareUnicodeCharacter{03A0}{\ensuremath{\Pi}}
\DeclareUnicodeCharacter{03A1}{\ensuremath{\Rho}}
\DeclareUnicodeCharacter{03A3}{\ensuremath{\Sigma}}
\DeclareUnicodeCharacter{03A4}{\ensuremath{\Tau}}
\DeclareUnicodeCharacter{03A5}{\ensuremath{\Upsilon}}
\DeclareUnicodeCharacter{03A6}{\ensuremath{\Phi}}
\DeclareUnicodeCharacter{03A7}{\ensuremath{\Chi}}
\DeclareUnicodeCharacter{03A8}{\ensuremath{\Psi}}
\DeclareUnicodeCharacter{03A9}{\ensuremath{\Omega}}
\fi\fi\fi\fi

%% Superior numbers 4-0
\DeclareUnicodeCharacter{2074}{\textfoursuperior}
\DeclareUnicodeCharacter{2075}{\textfivesuperior}
\DeclareUnicodeCharacter{2076}{\textsixsuperior}
\DeclareUnicodeCharacter{2077}{\textsevensuperior}
\DeclareUnicodeCharacter{2078}{\texteightsuperior}
\DeclareUnicodeCharacter{2079}{\textninesuperior}
\DeclareUnicodeCharacter{2070}{\textzerosuperior}
%% Inferieor numbers 0-9
\DeclareUnicodeCharacter{2080}{\textzeroinferior}
\DeclareUnicodeCharacter{2081}{\textoneinferior}
\DeclareUnicodeCharacter{2082}{\texttwoinferior}
\DeclareUnicodeCharacter{2083}{\textthreeinferior}
\DeclareUnicodeCharacter{2084}{\textfourinferior}
\DeclareUnicodeCharacter{2085}{\textfiveinferior}
\DeclareUnicodeCharacter{2086}{\textsixinferior}
\DeclareUnicodeCharacter{2087}{\textseveninferior}
\DeclareUnicodeCharacter{2088}{\texteightinferior}
\DeclareUnicodeCharacter{2089}{\textnineinferior}
%% Miscelaneous symbols
%% Redefining various symbols to work in math mode
\DeclareUnicodeCharacter{00B7}{\ifmmode\cdot\else\textperiodcentered\fi}
\DeclareUnicodeCharacter{00D7}{\ifmmode\times\else\texttimes\fi}
\DeclareUnicodeCharacter{00F7}{\ifmmode\div\else\textdiv\fi}
\DeclareUnicodeCharacter{2190}{\ifmmode\leftarrow\else\textleftarrow\fi}
\DeclareUnicodeCharacter{2191}{\ifmmode\uparrow\else\textuparrow\fi}
\DeclareUnicodeCharacter{2192}{\ifmmode\rightarrow\else\textrightarrow\fi}
\DeclareUnicodeCharacter{2193}{\ifmmode\downarrow\else\textdownarrow\fi}
\DeclareUnicodeCharacter{2329}{\ifmmode\langle\else\textlangle\fi}
\DeclareUnicodeCharacter{232A}{\ifmmode\rangle\else\textrangle\fi}
\DeclareUnicodeCharacter{27E8}{\ifmmode\langle\else\textlangle\fi}
\DeclareUnicodeCharacter{27E9}{\ifmmode\rangle\else\textrangle\fi}
\DeclareUnicodeCharacter{2026}{\ifmmode\ldots\else\textellipsis\fi}
\DeclareUnicodeCharacter{00AC}{\ifmmode\lnot\else\textlnot\fi}
\DeclareUnicodeCharacter{00B1}{\ifmmode\pm\else\textpm\fi}
\DeclareUnicodeCharacter{00B0}{\ifmmode\degree\fi}
\DeclareUnicodeCharacter{2022}{\ifmmode\bullet\else\textbullet\fi}
\DeclareUnicodeCharacter{2020}{\ifmmode\dagger\else\textdagger\fi}
\DeclareUnicodeCharacter{2021}{\ifmmode\ddagger\else\textdaggerdbl\fi}
\DeclareUnicodeCharacter{25E6}{\ifmmode\circ\else\textopenbullet\fi}
\DeclareUnicodeCharacter{25EF}{\ifmmode\bigcirc\else\textbigcircle\fi}
\DeclareUnicodeCharacter{2126}{\ohm}
\DeclareUnicodeCharacter{2103}{\celsius}
\DeclareUnicodeCharacter{2030}{\perthousand}
\DeclareUnicodeCharacter{2016}{\ifmmode\Vert\else\textbardbl\fi}

%% Other miscelaneous symbols
\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