-
Notifications
You must be signed in to change notification settings - Fork 0
LaTeX Macros
(Another draft for a post)
Contents
Sometimes the document class (e.g., amsart
) contains \email{}
and \address{}
macros, other times (e.g. article
) it doesn't. But I'd like to have the information be present.
\usepackage[hidelinks]{hyperref}
\makeatletter
\@ifundefined{email}
\usepackage[12hr,us]{datetime}
\author{Alex Nelson%
\footnote{This is a page from \url{http://code.google.com/p/notebk/}\hfil\break%
\indent\;\, Compiled:\enspace\today\ at \currenttime\ (PST)}\\%
\texttt{Email:\enspace\href{mailto:pqnelson@gmail.com}{pqnelson@gmail.com}}}
\else
\author{Alex Nelson}
\email{pqnelson@gmail.com}
\urladdr{http://notebk.googlecode.com}
\fi
\makeatother
I always like using bold sans serif for my sections (it's what Knuth uses in The Art of Computer Programming).
\usepackage{titlesec}
\titleformat*{\section}{\Large\bfseries\sffamily}
\titleformat*{\subsection}{\large\bfseries\sffamily}
\titleformat*{\subsubsection}{\bfseries\sffamily}
I like to write notes with an outline in mind. I usually have self-contained "chunks", usually numbered and sometimes with a summary in bold.
\makeatletter
\@ifundefined{@addpunct}{
\def\@addpunct#1{\ifnum\spacefactor>\@m \else#1\fi}
}{}
\newcounter{chunk@ctr}
\newcommand\M{\medbreak\noindent%
\refstepcounter{chunk@ctr}%
\textbf{\thechunk@ctr\@addpunct{.}}\quad\ignorespaces}
% deprecated macro:
% \newcommand\N[1]{\M\textbf{#1\@addpunct{.}}\quad\ignorespaces}
% superior implementation:
\def\N{\@ifstar
\NStar%
\NNoStar%
}
\def\NStar#1{\medbreak\noindent\textbf{#1\@addpunct{.}\quad}\ignorespaces}
\def\NNoStar#1{\M\textbf{#1\@addpunct{.}\quad}\ignorespaces}
% permits writing \N*{Un-numbered chunk} for a chunk
% without a numeric label!
\makeatother
When I cite an article, I'd like to cite ArXiv as \arXiv{category/number}
for older papers and \arXiv[category]{number}
for newer articles.
\makeatletter
\@ifundefined{href}
\usepackage[hidelinks]{hyperref}
\fi
\def\arXiv{\@ifnextchar[{\@arXivWith}{\@arXivWithout}}
\def\@arXivWith[#1]#2{\texttt{\href{http://arxiv.org/abs/#2}{arXiv:#2} [#1]}}
\def\@arXivWithout#1{\texttt{\href{http://arxiv.org/abs/#1}{arXiv:#1}}}
\makeatother
A variation on Bourbaki's Dangerous Bend symbol. I make the font-size smaller, and have some extra whitespace padding the "dangerous thinking".
\def\dbend{{\manual\char127}} % dangerous bend sign
% Danger, Will Robinson!
\newenvironment{danger}{\medbreak\noindent\hangindent=2pc\hangafter=-2%
\clubpenalty=10000%
\hbox to0pt{\hskip-\hangindent\dbend\hfill}\small\ignorespaces}%
{\medbreak\par}
% Danger! Danger!
\newenvironment{ddanger}{\medbreak\noindent\hangindent=3pc\hangafter=-2%
\clubpenalty=10000%
\hbox to0pt{\hskip-\hangindent\dbend\kern2pt\dbend\hfill}\small\ignorespaces}%
{\medbreak\par}
I use some variety of pdflatex
when compiling, which throws errors when I use Metapost generated graphics. The workaround this:
\usepackage{ifpdf}
\usepackage[final]{graphicx}
\ifpdf
\DeclareGraphicsRule{*}{mps}{*}{}
\fi
I standardize my notation using macros.
I stole these from Springer-Verlag's monograph document class.
% special signs and characters
\newcommand{\D}{\mathrm{d}}
\newcommand{\E}{\mathrm{e}}
\let\eul=\E
\newcommand{\I}{{\rm i}}
\let\imag=\I
Also note for integrals, we should write:
F(x) = \int f(x)\,\D x
To simplify some set theory related notation, we write:
%% Frequently used set theory notation
\let\logic\texttt
\newcommand\powerset[1]{\mathcal{P}(#1)}
\newcommand\CC{\mathbb{C}}
\newcommand\FF{\mathbb{F}}
\newcommand\NN{\mathbb{N}}
\newcommand\OO{\mathbb{O}}
\newcommand\QQ{\mathbb{Q}}
\newcommand\RR{\mathbb{R}}
\newcommand\ZZ{\mathbb{Z}}
\let\oldsetminus\setminus
\def\setminus{-}
\newcommand\universe{\mathcal{U}}
\newcommand\domain{\mathop{\mathrm{dom}}\nolimits}
\newcommand\codomain{\mathop{\mathrm{cod}}\nolimits}
\let\propersubset\subset
\let\propersupset\supset
\let\oldsubset\subset
\let\oldsupset\supset
\let\subset\subseteq
\let\supset\supseteq
\let\oldemptyset\emptyset
\let\varemptyset\varnothing
There are some idiosyncratic notations used in physics, which I keep abstracted as macros for my own sanity.
\def\normOrd#1{\mathop{:}\nolimits\!#1\!\mathop{:}\nolimits}