Skip to content

Instantly share code, notes, and snippets.

@ambuc
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ambuc/318c491d38e5d9d7b57f to your computer and use it in GitHub Desktop.
Save ambuc/318c491d38e5d9d7b57f to your computer and use it in GitHub Desktop.
useful custom macros for typesetting vector calculus in LaTeX
%typeset \sgn as an upright operator name, like \sin. ex: \sgn(x)
\DeclareMathOperator{\sgn}{sgn}
%rename built-in command \v to \vaccent, to make room for...
\let\vaccent=\v
% ...\v, which typesets a bold, upright vector. ex: \v a
\renewcommand{\v}[1]{\ensuremath{\mathbf{#1}}}
% ... and \gv, which does the same for greek letters. ex: \gv\alpha
\newcommand{\gv}[1]{\ensuremath{\mbox{\boldmath $ #1 $ }}}
%absolute value function with | brackets. ex: \abs{x}, \abs{\frac{1}{2}}
\newcommand{\abs}[1]{\left| #1 \right|}
% rename builtinin command \d to \underdot, to make room for...
\let\underdot=\d
% ...\d, which typesets a derivative. ex: \d{y}{x}, instead of \frac{dx}{dy}.
\renewcommand{\d}[2]{\frac{d #1}{d #2}}
% ...similar for double-derivatives. ex: \dd{y}{x}.
\newcommand{\dd}[2]{\frac{d^2 #1}{d #2^2}}
% ...similar for partial derivatives. ex: \pd{y}{x}.
\newcommand{\pd}[2]{\frac{\partial #1}{\partial #2}}
% ...similar for partial double derivatives. ex: \pdd{y}{x}.
\newcommand{\pdd}[2]{\frac{\partial^2 #1}{\partial #2^2}}
% a \degrees symbol. ex: 90\degrees.
\newcommand{\degrees}{\ensuremath{^\circ}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment