% Use this to type Japanese
\usepackage{CJKutf8}

\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathrsfs}

\usepackage{mathtools}
\usepackage{nicefrac}

% Show only the numbers of the equations that are referred.
\mathtoolsset{showonlyrefs}

%%%%% For auto referencing  
% Ref: https://tex.stackexchange.com/questions/737438/why-does-autoref-give-the-wrong-type-of-a-reference
\usepackage{aliascnt}

\usepackage{hyperref}    

% \usepackage[colorlinks,citecolor=black]{hyperref}
\hypersetup{
    colorlinks=true,
    % linkcolor=black,
    % filecolor=black,      
    % urlcolor=black,
    % citecolor=black,
    allcolors=black
}


% Reference
% https://stackoverflow.com/questions/56209968/redefine-footnote-to-change-color-of-index-in-latex
% \newcommand{\cfootnote}[2][black]{%
    % {\color{#1}\footnote{#2}}%
% }

% \let \footnote\cfootnote


\newtheorem{theorem}{Theorem}[section]

\newcommand{\addtheorem}[2]{%
  \newaliascnt{#1}{theorem}%
  \newtheorem{#1}[#1]{#2}%
  \aliascntresetthe{#1}%
  % \ExpandArgs{c}\newcommand{#1autorefname}{#2}% Commented out and replaced with below because it didn't compile locally
\expandafter\newcommand\csname #1autorefname\endcsname{#2}%
}

\addtheorem{corollary}{Corollary}
\addtheorem{lemma}{Lemma}
\addtheorem{proposition}{Proposition}
\addtheorem{conjecture}{Conjecture}

\theoremstyle{definition}
\addtheorem{definition}{Definition}
\addtheorem{remark}{Remark}
\addtheorem{assumption}{Assumption}
\addtheorem{example}{Example}
\addtheorem{question}{Question}


% Since ISTA setup uses \usepackage[english]{babel}, we need this to renewcommand
\addto\extrasenglish{%
  \renewcommand{\chapterautorefname}{Chapter}%
  \renewcommand{\sectionautorefname}{Section}%
  \renewcommand{\subsectionautorefname}{Section}%
  \renewcommand{\subsubsectionautorefname}{Section}%  
  \renewcommand{\algorithmautorefname}{Algorithm}%  
}




% \newtheorem{theorem}{Theorem}[section]
% \newtheorem*{theorem*}{Theorem}
% \newtheorem{lemma}[theorem]{Lemma}
% \newtheorem{proposition}[theorem]{Proposition}
% \newtheorem{corollary}[theorem]{Corollary}
% \newtheorem{conjecture}[theorem]{Conjecture}

% \theoremstyle{definition}
% \newtheorem{definition}[theorem]{Definition}
% \newtheorem{example}[theorem]{Example}
% \newtheorem{xca}[theorem]{Exercise}

% \theoremstyle{plain}
% \theoremstyle{remark}
% \newtheorem{remark}[theorem]{Remark}
% \newtheorem{problem}[theorem]{Problem}
% \newtheorem{question}[theorem]{Question}

\numberwithin{equation}{section}

\let\oldring\ring     % Save the original \ring
\usepackage{accents}  % Load accents (which redefines \ring)
\let\ring\oldring     % Restore original \ring

%%%%%%%%%%%%%%%%%%%% 
% For algorithms

% Needed to force non-italic fonts in "While" of algorithm
\SetArgSty{textnormal}
\usepackage{algpseudocode}

%%%%%%%%%%%%%%%%%%%% 

\usepackage{overpic}

\let\amslrcorner\lrcorner
\usepackage{mathabx}
\usepackage{nicematrix}


\usepackage{tikz-cd}

\usepackage{xcolor}



\usepackage{wrapfig}
\usepackage{graphicx} % Required for including pictures

\usepackage{pb-diagram}

% AMS's preferred absolute value notation
\newcommand{\abs}[1]{\lvert#1\rvert}

%----------------------------------------------------------------------------------------
%	New colors
%----------------------------------------------------------------------------------------
\definecolor{darkblue}{rgb}{0.0, 0.0, 0.55}

%----------------------------------------------------------------------------------------
%	Comments
%----------------------------------------------------------------------------------------

\usepackage[draft]{pdfcomment}


\usepackage[subrefformat=parens]{subcaption}
\captionsetup{compatibility=false}

\newcommand{\COMMENT}[3]{\textcolor{#2}{{[\textbf{#1:} \textsl{#3}}]}}  % For work in progress using in-text comments
\newcommand{\TODO}[1]{\COMMENT{TODO}{red}{#1}}
\newcommand{\Sadashige}[1]{\COMMENT{Sadashige}{blue}{#1}}
\newcommand{\Albert}[1]{{\color[rgb]{0.2,0.4,0.8}\textbf{Albert} #1}}
\newcommand{\Chris}[1]{\COMMENT{Chris}{cyan}{#1}}

\definecolor{revcolor}{rgb}{0.0, 0.3, 0.8}

% \newcommand{\rev}[1]{\begingroup\color{revcolor}#1\endgroup}
\newcommand{\rev}[1]{#1}


%================
% REFERENCING
%================
% \newcommand{\figref}[1]{Figure~\ref{#1}}
% \newcommand{\tabref}[1]{Table~\ref{#1}}
% \newcommand{\teqref}[1]{Eq.~(\ref{#1})}
% \newcommand{\chref}[1]{Chapter~\ref{#1}}
% \newcommand{\secref}[1]{Section~\ref{#1}}
% \newcommand{\appref}[1]{Appendix~\ref{#1}}
% % \renewcommand{\algref}[1]{Algorithm~\ref{#1}}
% \newcommand{\thmref}[1]{Theorem~\ref{#1}}
% \newcommand{\lemref}[1]{Lemma~\ref{#1}}
% \newcommand{\rmkref}[1]{Remark~\ref{#1}}


% \newcommand{\defref}[1]{Definition~\ref{#1}}
% \newcommand{\propref}[1]{Proposition~\ref{#1}}
% \newcommand{\corref}[1]{Corollary~\ref{#1}}
% \newcommand{\exref}[1]{Example~\ref{#1}}
% \newcommand{\exerref}[1]{Exercise~\ref{#1}}
% \newcommand{\notref}[1]{Notation~\ref{#1}}


\newcommand{\on}[1]{\operatorname{#1}}



%=================== 
% LATINS
%===================
\def\etal{\emph{et al.}}
\def\cf{\emph{cf.}}
\def\ie{\emph{i.e.}}
\def\eg{\emph{e.g.}}
\def\etc{\emph{etc.}}
\def\etcnp{\emph{etc}}



%===================
% FONT SHORTHANDS
%===================
\def\AA{\mathbb{A}}
\def\BB{\mathbb{B}}
\def\CC{\mathbb{C}}
\def\DD{\mathbb{D}}
\def\EE{\mathbb{E}}
\def\FF{\mathbb{F}}
\def\GG{\mathbb{G}}
\def\HH{\mathbb{H}}
\def\II{\mathbb{I}}
\def\JJ{\mathbb{J}}
\def\KK{\mathbb{K}}
\def\LL{\mathbb{L}}
\def\MM{\mathbb{M}}
\def\NN{\mathbb{N}}
\def\OO{\mathbb{O}}
\def\PP{\mathbb{P}}
\def\QQ{\mathbb{Q}}
\def\RR{\mathbb{R}}
\def\SS{\mathbb{S}}
\def\TT{\mathbb{T}}
\def\UU{\mathbb{U}}
\def\VV{\mathbb{V}}
\def\WW{\mathbb{W}}
\def\XX{\mathbb{X}}
\def\YY{\mathbb{Y}}
\def\ZZ{\mathbb{Z}}

\def\bA{\mathbf{A}}
\def\bB{\mathbf{B}}
\def\bC{\mathbf{C}}
\def\bD{\mathbf{D}}
\def\bE{\mathbf{E}}
\def\bF{\mathbf{F}}
\def\bG{\mathbf{G}}
\def\bH{\mathbf{H}}
\def\bI{\mathbf{I}}
\def\bJ{\mathbf{J}}
\def\bK{\mathbf{K}}
\def\bL{\mathbf{L}}
\def\bM{\mathbf{M}}
\def\bN{\mathbf{N}}
\def\bO{\mathbf{O}}
\def\bP{\mathbf{P}}
\def\bQ{\mathbf{Q}}
\def\bR{\mathbf{R}}
\def\bS{\mathbf{S}}
\def\bT{\mathbf{T}}
\def\bU{\mathbf{U}}
\def\bV{\mathbf{V}}
\def\bW{\mathbf{W}}
\def\bX{\mathbf{X}}
\def\bY{\mathbf{Y}}
\def\bZ{\mathbf{Z}}

\def\cA{\mathcal{A}}
\def\cB{\mathcal{B}}
\def\cC{\mathcal{C}}
\def\cD{\mathcal{D}}
\def\cE{\mathcal{E}}
\def\cF{\mathcal{F}}
\def\cG{\mathcal{G}}
\def\cH{\mathcal{H}}
\def\cI{\mathcal{I}}
\def\cJ{\mathcal{J}}
\def\cK{\mathcal{K}}
\def\cL{\mathcal{L}}
\def\cM{\mathcal{M}}
\def\cN{\mathcal{N}}
\def\cO{\mathcal{O}}
\def\cP{\mathcal{P}}
\def\cQ{\mathcal{Q}}
\def\cR{\mathcal{R}}
\def\cS{\mathcal{S}}
\def\cT{\mathcal{T}}
\def\cU{\mathcal{U}}
\def\cV{\mathcal{V}}
\def\cW{\mathcal{W}}
\def\cX{\mathcal{X}}
\def\cY{\mathcal{Y}}
\def\cZ{\mathcal{Z}}

\def\sA{\mathscr{A}}
\def\sB{\mathscr{B}}
\def\sC{\mathscr{C}}
\def\sD{\mathscr{D}}
\def\sE{\mathscr{E}}
\def\sF{\mathscr{F}}
\def\sG{\mathscr{G}}
\def\sH{\mathscr{H}}
\def\sI{\mathscr{I}}
\def\sJ{\mathscr{J}}
\def\sK{\mathscr{K}}
\def\sL{\mathscr{L}}
\def\sM{\mathscr{M}}
\def\sN{\mathscr{N}}
\def\sO{\mathscr{O}}
\def\sP{\mathscr{P}}
\def\sQ{\mathscr{Q}}
\def\sR{\mathscr{R}}
\def\sS{\mathscr{S}}
\def\sT{\mathscr{T}}
\def\sU{\mathscr{U}}
\def\sV{\mathscr{V}}
\def\sW{\mathscr{W}}
\def\sX{\mathscr{X}}
\def\sY{\mathscr{Y}}
\def\sZ{\mathscr{Z}}

\def\ba{\mathbf{a}}
\def\bb{\mathbf{b}}
\def\bc{\mathbf{c}}
\def\bd{\mathbf{d}}
\def\be{\mathbf{e}}
\def\bff{\mathbf{f}}
\def\bg{\mathbf{g}}
\def\bh{\mathbf{h}}
\def\bi{\mathbf{i}}
\def\bj{\mathbf{j}}
\def\bk{\mathbf{k}}
\def\bl{\mathbf{l}}
\def\bm{\mathbf{m}}
\def\bn{\mathbf{n}}
\def\bo{\mathbf{o}}
\def\bp{\mathbf{p}}
\def\bq{\mathbf{q}}
\def\br{\mathbf{r}}
\def\bs{\mathbf{s}}
\def\bt{\mathbf{t}}
\def\bu{\mathbf{u}}
\def\bv{\mathbf{v}}
\def\bw{\mathbf{w}}
\def\bx{\mathbf{x}}
\def\by{\mathbf{y}}
\def\bz{\mathbf{z}}

\def \fX{\mathfrak{X}}

\def\io{\iota} 
\def\ka{\kappa} 
\def\la{\lambda} 
\def\rh{\rho} 
\def\si{\sigma} 
\def\ta{\tau} 
\def\ph{\varphi} 
\def\ch{\chi} 
\def\ps{\psi} 
\def\om{\omega} 
\def\Ga{\Gamma} 
\def\De{\Delta} 
\def\Th{\Theta} 
\def\th{\theta} 

\def\delgam{{\delta_\gamma} }

\def\La{\Lambda} 
\def\Si{\Sigma} 
\def\Ph{\Phi} 
\def\Ps{\Psi} 
\def\Om{\Omega}

\newcommand{\id}{\mathrm{id}}
\newcommand{\Rot}{\mathrm{Rot}}
\newcommand{\Imm}{\mathrm{Imm}}
\newcommand{\Emb}{\mathrm{Emb}}
\newcommand{\Gre}{\mathrm{Gr}_e}
\newcommand{\Gri}{\mathrm{Gr}_i}
\newcommand{\UEmb}{\mathrm{UEmb}}
\newcommand{\UImm}{\mathrm{UImm}}


\newcommand{\Prob}{\operatorname{Prob}(S^1)}
\newcommand{\Dens}{\operatorname{Dens}_+(S^1)}

\newcommand{\reg}{\operatorname{reg}}
\newcommand{\Mreg}{M^{\reg\phi}}

%=====================
% QUATERNIONS
%=====================
\usepackage{bbm}
%%%%%makes a stylized 1%%%%%%%%%
\DeclareSymbolFont{bbold}{U}{bbold}{m}{n}
\DeclareSymbolFontAlphabet{\mathbbold}{bbold}
\newcommand{\one}{\mathbbold{1}}%%%%%%%%%makes stylized 1
% \newcommand{\ii}{\mathbbm i}
% \newcommand{\jj}{\mathbbm j}
% \newcommand{\kk}{\mathbbm k}
\newcommand{\ii}{\mkern1.5mu\mathbbold{i}\mkern1.5mu}
\newcommand{\jj}{\mkern1.5mu\mathbbold{j}\mkern1.5mu}
\newcommand{\kk}{\mkern1.5mu\mathbbold{k}\mkern1.5mu} 
%%%%%%%%%%%%%%%%%%%%

%============================
% Conjugate, Double bracket
%============================
\newcommand{\overbar}[1]{\mkern 1.5mu\overline{\mkern-1.5mu#1\mkern-1.5mu}\mkern 1.5mu}
\newcommand*{\conj}[1]{\overbar{#1}}

%=====================
% PROJECTIVE SPACES
%=====================
\newcommand{\RP}{\mathbb{RP}}
\newcommand{\CP}{\mathbb{CP}}
\newcommand{\HP}{\mathbb{HP}}

%=====================
% MATH OPERATORS
%=====================

% real, imaginary, and other parts of numbers
\renewcommand{\Im}{\operatorname{Im}}
\renewcommand{\Re}{\operatorname{Re}}
\newcommand{\sgn}{\operatorname{sgn}}
\DeclareMathOperator{\atan}{atan2}

% linear algebra
\def\tr {\operatorname{tr}}
\def\det{\operatorname{det}}
\def\End{\operatorname{End}}
\def\Hom{\operatorname{Hom}}
\DeclareMathOperator{\Map}{Map}
\def\im {\operatorname{im}}
\def\ker{\operatorname{ker}}
\def\spanset{\operatorname{span}}
\def\adj{\operatorname{adj}}
\def\cof{\operatorname{cof}}

% optimization
\DeclareMathOperator*{\argmin}{argmin}
\DeclareMathOperator*{\argmax}{argmax}
\DeclareMathOperator*{\arginf}{arginf}
\DeclareMathOperator*{\argsup}{argsup}

% Lie groups and Lie algebras
\DeclareMathOperator{\GL}{GL}
\DeclareMathOperator{\SL}{SL}
\DeclareMathOperator{\PSL}{PSL}
\DeclareMathOperator{\PSU}{PSU}
\DeclareMathOperator{\SO}{SO}
\DeclareMathOperator{\SU}{SU}
% \so is reserved by ams format 
% \DeclareMathOperator{\so}{\mathfrak{so}}
\DeclareMathOperator{\su}{\mathfrak{su}}
\DeclareMathOperator{\gl}{\mathfrak{gl}}
\DeclareMathOperator{\slla}{\mathfrak{sl}}
\DeclareMathOperator{\Diff}{Diff}
\DeclareMathOperator{\SDiff}{SDiff}
\DeclareMathOperator{\Diffp}{Diff^+}
\DeclareMathOperator{\SDiffp}{SDiff^+}
\DeclareMathOperator{\diff}{diff}%{\frak{diff}}
\DeclareMathOperator{\sdiff}{sdiff}%{\frak{sdiff}}
\DeclareMathOperator{\exdiff}{exdiff}%{\frak{sdiff}}

\DeclareMathOperator{\diffp}{diff^+}%{\frak{diff}}
\DeclareMathOperator{\sdiffp}{sdiff^+}%{\frak{diff}}
\DeclareMathOperator{\Spin}{Spin}

\DeclareMathOperator{\Ad}{Ad}
\DeclareMathOperator{\ad}{ad}

\DeclareMathOperator{\SemiD}{\on{DC}}
\DeclareMathOperator{\AlgSemiD}{\mathfrak{DC}}

\DeclareMathOperator{\dd}{\mathfrak{d}}

\newcommand{\flux}{\on{Flux}}
\newcommand{\fluxMone}{\on{Flux}_{m-1}}
\newcommand{\fluxMtwo}{\on{Flux}_{m-2}^{\on{ex}}}

\newcommand{\Exp}{\on{Exp}}
\newcommand{\oneOverTwoPi}{\frac{1}{2\pi}}
\newcommand{\twoPi}{2\pi}

\newcommand{\Arg}{\on{Arg}}

\def\x{\times}
\def\image{\operatorname{Image}}

% Making tiny circle
% Ref: 
% https://tex.stackexchange.com/questions/580581/small-hollow-circle-in-math-smaller-than-circ
\newcommand{\tinycirc}{\raisebox{1pt}{\tikz \draw[line width=0.3pt] circle(1.0pt);}}



% Second fundamental form
\DeclareMathOperator{\sff}{I\!I}

% Vector Calculus
\newcommand{\grad}{\mathop{\mathrm{grad}}\nolimits}
\newcommand{\sgrad}{\mathop{\mathrm{sgrad}}\nolimits}
\newcommand{\curl}{\mathop{\mathrm{curl}}\nolimits}
\newcommand{\rot}{\mathop{\mathrm{rot}}\nolimits}
\renewcommand{\div}{\mathop{\mathrm{div}}\nolimits}
\newcommand{\LD}{\mathop{\mathscr{L}}\nolimits}
\newcommand{\Hess}{\mathop{\mathrm{Hess}}\nolimits}

% Probability
\def\Cov{\operatorname{Cov}}
\def\Var{\operatorname{Var}}

% Exterior Calculus
\def\wedgetimes{\mathbin{\underset{\times}{\wedge}}}
\def\wedgecomma{\mathbin{\hspace{0.5ex}\raisebox{-0.5ex}{,}\hspace{-1ex}{\wedge}}}

% Interior Calculus
\def\tt{\mathbbold{t}}
\def\nn{\mathbbold{n}}
\def\contract{\lrcorner}
\def\ip{i}
\def\ext{\operatorname{ext}}

% Geometry
\DeclareMathOperator{\Area}{Area}
\DeclareMathOperator{\Length}{Length}
\DeclareMathOperator{\Vol}{Vol}
\DeclareMathOperator{\Dihedral}{Dihedral}
\def\cp{\mathbbold{cp}}

% Submanifolds
\def\paramgam{{\tilde{\gamma}}}
\def\gam{{\gamma}}

% Numerics
\def\timestep{{\Deltait} t}

\let\on=\operatorname

% Prequantizability
\newcommand{\normalized}{{\cN}}
\newcommand{\normconst}{\cN}

% For symplectic project
\newcommand{\OmMW}{\Omega^{\operatorname{MW}}}
\newcommand{\simtime}[1]{\vspace{-5mm}\subcaption*{$t={#1}$}}


