.. -*- mode: rst -*-

.. math stuff

.. \newcommand has to appear in a math environment for MathJax to use it. Unfortunately
   \newcommand included in a math environment in LaTeX is limited to this environment, so
   we need to define custom commands twice: once for HTML (MathJax), once for LaTeX.

.. only:: html

   .. math::

      \newcommand{\Diff}[2]{ \frac{\mathrm{d}#1}{\mathrm{d}#2} }
      \newcommand{\diff}[2]{ \frac{\partial #1}{\partial #2} }
      \newcommand{\var}[2]{ {#1}_{\text{#2}} }
      \newcommand{\h}[1]{ \var{h}{#1} }
      \newcommand{\T}[1]{ \var{T}{#1} }
      \newcommand{\m}[1]{ \var{m}{#1} }
      \newcommand{\ms}[1]{ \var{m^{*}}{#1} }
      \newcommand{\psw}{p_{\text{ocean}}}
      \newcommand{\pice}{p_{\text{ice}}}
      \newcommand{\pmelange}{p_{\text{melange}}}
      \newcommand{\n}{\mathbf{n}}
      \newcommand{\nx}{\n_{x}}
      \newcommand{\ny}{\n_{y}}
      \newcommand{\phimin}{\phi_{\mathrm{min}}}
      \newcommand{\phimax}{\phi_{\mathrm{max}}}
      \newcommand{\bmin}{b_{\mathrm{min}}}
      \newcommand{\bmax}{b_{\mathrm{max}}}
      \newcommand{\bq}{\mathbf{q}}

.. raw:: latex

   % We use \providecommand here so that these can be repeated several times.

   % generic
   \providecommand{\Diff}[2]{ \frac{\mathrm{d}#1}{\mathrm{d}#2} }
   \providecommand{\diff}[2]{ \frac{\partial #1}{\partial #2} }

   % elevation-dependent surface model
   \providecommand{\var}[2]{ {#1}_{\text{#2}} }
   \providecommand{\h}[1]{ \var{h}{#1} }
   \providecommand{\T}[1]{ \var{T}{#1} }
   \providecommand{\m}[1]{ \var{m}{#1} }
   \providecommand{\ms}[1]{ \var{m^{*}}{#1} }

   % Melange
   \providecommand{\psw}{p_{\text{ocean}}}
   \providecommand{\pice}{p_{\text{ice}}}
   \providecommand{\pmelange}{p_{\text{melange}}}
   \providecommand{\n}{\mathbf{n}}
   \providecommand{\nx}{\n_{x}}
   \providecommand{\ny}{\n_{y}}

   % Basal strength
   \providecommand{\phimin}{\phi_{\mathrm{min}}}
   \providecommand{\phimax}{\phi_{\mathrm{max}}}
   \providecommand{\bmin}{b_{\mathrm{min}}}
   \providecommand{\bmax}{b_{\mathrm{max}}}

   % hydrology
   \providecommand{\bq}{\mathbf{q}}
