Skip to content

Instantly share code, notes, and snippets.

@benkehoe
Last active August 29, 2015 14:06
Show Gist options
  • Save benkehoe/c46647134d4bbd514869 to your computer and use it in GitHub Desktop.
Save benkehoe/c46647134d4bbd514869 to your computer and use it in GitHub Desktop.
LaTeX package of handy macros
\ProvidesPackage{benktools}
% Usage:
% \usepackage{benktools}
% \benkhide <-- put this when you want to remove all
% the todos, notes, version info, etc.
% e.g., for the final version
% updates at https://gist.github.com/benkehoe/c46647134d4bbd514869
\def\@benktoolsversion{1}
\newcommand{\benkhide}[0]{\def \@benkhide{}}
% Usage: \benkhidable{something}
% The text inside will be hidden when \benkhide is given
\newcommand{\benkhidable}[1]{\@ifundefined{@benkhide}{#1}{}}
\usepackage{datetime}
\newdateformat{dashdate}{\THEYEAR-\twodigit{\THEMONTH}-\twodigit{\THEDAY}}
% Usage:
% \timestamp{} produces e.g. "2011-07-09 15:29", using the current date and time.
% This is NOT hidden by \benkhide
\newcommand{\timestamp}[0]{\dashdate{\today{}}~\xxivtime}
% Usage:
% \version{3} produces e.g., "v3 [2011-07-09 15:29]", using the current date and time.
% \versionline{3} will produce the same output, but on a new line.
% this is helpful for putting the version info in the title
% These macros are hidden with \benkhide
\newcommand{\version}[1]{\benkhidable{v#1~[\dashdate{\today{}}~\xxivtime]}}
\newcommand{\versionline}[1]{\benkhidable{\\v#1~[\dashdate{\today{}}~\xxivtime]}}
% Usage:
% \todo{something}
% \tocite{some paper}
% \figtodo{describe a figure you need to put in}
% \note{just a note}, \noteby{name}{just a note}
% These macros are hidden with \benkhide
\usepackage[usenames,dvipsnames]{color}
\newcommand{\todo}[1]{\benkhidable{{\large \color{red} \textsc{{[todo:~#1]}}}}}
\newcommand{\tocite}[1]{\benkhidable{{\large \color{red} \textsc{{[to~cite:~#1]}}}}}
\newcommand{\figtodo}[1]{\benkhidable{{\large \color{blue} \textsc{{[figure:~#1]}}}}}
\newcommand{\note}[1]{\benkhidable{{\large \color{Orange} \textsc{{[note~#1]}}}}}
\newcommand{\noteby}[2]{\benkhidable{{\large \color{Orange} \textsc{{[#1:~#2]}}}}}
% The following macros help to create and reference specific
% types of labels, using the usual conventions.
% The reference macros put in the appropriate name and use
% non-breaking spaces. They can be changed as needed
% e.g., to use Fig. 1 instead of Figure 1
% Usage:
% \figlabel{myfigure} creates \label{fig:myfigure}
% \figref{myfigure} references it
\newcommand{\figlabel}[1]{\label{fig:#1}}
\newcommand{\figref}[1]{Figure~\ref{fig:#1}}
% Usage:
% \tablabel{mytable} creates \label{tab:mytable}
% \tabref{mytable} references it
\newcommand{\tablabel}[1]{\label{tab:#1}}
\newcommand{\tabref}[1]{Table~\ref{tab:#1}}
% Usage:
% \eqnlabel{myeqn} creates \label{eq:myeqn}
% \eqnref{myeqn} references it
\newcommand{\eqnlabel}[1]{\label{eq:#1}}
\newcommand{\eqnref}[1]{Equation~\ref{eq:#1}}
% Usage:
% \seclabel{mysection} creates \label{sec:mysection}
% \secref{mysection} references it
\newcommand{\seclabel}[1]{\label{sec:#1}}
\newcommand{\secref}[1]{Section~\ref{sec:#1}}
% Usage:
% \chaplabel{mychapter} creates \label{chap:mychapter}
% \chapref{mychapter} references it
\newcommand{\chaplabel}[1]{\label{chap:#1}}
\newcommand{\chapref}[1]{Chapter~\ref{chap:#1}}
% \vectornorm{x} creates ||x||, properly formatted
\newcommand{\vectornorm}[1]{\left|\left|#1\right|\right|}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment