Skip to content

Instantly share code, notes, and snippets.

@mandli
Created September 17, 2020 15:47
Show Gist options
  • Save mandli/240d982d5c5f0191f24b17fcff93f7e2 to your computer and use it in GitHub Desktop.
Save mandli/240d982d5c5f0191f24b17fcff93f7e2 to your computer and use it in GitHub Desktop.
Macros for Writing LaTeX
\newcommand{\eg}{{e.g.}\xspace}
% ==============================================================================
% Generic math macros
\renewcommand{\v}[1]{\boldsymbol{#1}}
\newcommand{\m}[1]{\text{\textsf#1}}
\newcommand{\pd}[2]{\ensuremath{\frac{\partial #1}{\partial #2}}} % partial
\newcommand{\dee}{\ensuremath{\mathrm{d}}} % d symbol
\newcommand{\diff}[2]{\ensuremath{\frac{\dee #1}{\dee #2}}} % Derivative d/dx
\newcommand{\grad}{\ensuremath{\nabla}} % Gradient symbol
\newcommand{\gradient}{\ensuremath{\textsf{grad}}} % Written gradient
\newcommand{\Div}{\ensuremath{\nabla \cdot}} % Divergence
\newcommand{\divergence}{\ensuremath{\textsf{div}}} % Written div
\newcommand{\del}{\ensuremath{\nabla}} % Same as gradient
\newcommand{\delsq}{\ensuremath{\nabla^2}} % Laplacian
\newcommand{\lap}{\ensuremath{\delsq}} % Laplacian
\newcommand{\dx}{\ensuremath{\Delta x}} % Delta x
\newcommand{\dy}{\ensuremath{\Delta y}} % Delta y
\newcommand{\dt}{\ensuremath{\Delta t}} % Delta t
\newcommand{\scinot}[2]{\ensuremath{#1\times10^{#2}}} % Scientific note
\newcommand{\bigO}[1]{\ensuremath{\mathcal{O}(#1)}} % Big O notation
\newcommand{\R}{\ensuremath{\mathbb{R}}} % Real field
\newcommand{\Z}{\ensuremath{\mathbb{Z}}} % Integer field
\newcommand{\half}{\ensuremath{\frac{1}{2}}} % 1/2 fraction
% Define theorems and definitions
% \newtheorem{theorem}{Theorem}[section]
% \newtheorem{definition}{Definition}[section]
% Markings
% \usepackage{color}
% \newcommand{\alert}[1]{\textbf{\color{red} #1}}
% \DeclareMathOperator{\erf}{erf}
% ==============================================================================
% Finite volume method symbols
\newcommand{\wave}{\ensuremath{\mathcal{W}}\xspace} % Wave
\newcommand{\fwave}{\ensuremath{\mathcal{Z}}\xspace} % F-Waves
\newcommand{\cell}{\ensuremath{\mathcal{C}}\xspace} % FV grid cell
\newcommand{\apdq}{\ensuremath{\mathcal{A}^+ \Delta Q}\xspace} % A+dq
\newcommand{\amdq}{\ensuremath{\mathcal{A}^- \Delta Q}\xspace} % A-dq
\newcommand{\apmdq}{\ensuremath{\mathcal{A}^{\pm} \Delta Q}\xspace} % A+-dq
% B+-A+-dq symbols
\newcommand{\BpApdq}{\ensuremath{\mathcal{B}^{+} \mathcal{A}^{+} \Delta Q}\xspace}
\newcommand{\BpAmdq}{\ensuremath{\mathcal{B}^{+} \mathcal{A}^{-} \Delta Q}\xspace}
\newcommand{\BmApdq}{\ensuremath{\mathcal{B}^{-} \mathcal{A}^{+} \Delta Q}\xspace}
\newcommand{\BmAmdq}{\ensuremath{\mathcal{B}^{-} \mathcal{A}^{-} \Delta Q}\xspace}
\newcommand{\BpmApmdq}{\ensuremath{\mathcal{B}^{\pm} \mathcal{A}^{\pm} \Delta Q}\xspace}
% ==============================================================================
% Fluids non-dimensional parameters
\newcommand{\Rey}{\ensuremath{\text{Re}}}
\newcommand{\Fr}{\ensuremath{\text{Fr}}}
\newcommand{\Ri}{\ensuremath{\text{Ri}}}
% ==============================================================================
% Special formatting for codes
\newcommand{\geoclaw}{{\sc GeoClaw}\xspace}
\newcommand{\clawpack}{{\sc Clawpack}\xspace}
\newcommand{\amrclaw}{{\sc AMRClaw}\xspace}
\newcommand{\pyclaw}{{\sc PyClaw}\xspace}
\newcommand{\forestclaw}{Forestclaw\xspace}
\newcommand{\pforest}{\texttt{p4est}\xspace}
\newcommand{\manyclaw}{Manyclaw\xspace}
\newcommand{\adcirc}{ADCIRC\xspace}
\newcommand{\striche}{\texttt{STRICHE}\xspace}
%\newcommand{\geostriche}{\geoclaw-\striche\xspace}
\newcommand{\geostriche}{\geoclaw-\striche}
% ==============================================================================
% Makes an abbreviated title, useful for notes and other less formal docs
\newcommand{\makesmalltitle}[3]
{
\noindent
\begin{minipage}{1.0\linewidth}
{\LARGE \bf
#1}\\[-1.5mm]
\noindent\rule{\linewidth}{1pt}\\
#2 \hfill \hbox{#3}
\\ %[8mm]
\end{minipage}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment