summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/revquantum
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/revquantum
Initial commit
Diffstat (limited to 'macros/latex/contrib/revquantum')
-rw-r--r--macros/latex/contrib/revquantum/Install.ps122
-rw-r--r--macros/latex/contrib/revquantum/README.md83
-rw-r--r--macros/latex/contrib/revquantum/example.pdfbin0 -> 83056 bytes
-rw-r--r--macros/latex/contrib/revquantum/example.tex52
-rw-r--r--macros/latex/contrib/revquantum/revquantum.dtx973
-rw-r--r--macros/latex/contrib/revquantum/revquantum.ins55
-rw-r--r--macros/latex/contrib/revquantum/revquantum.pdfbin0 -> 167886 bytes
7 files changed, 1185 insertions, 0 deletions
diff --git a/macros/latex/contrib/revquantum/Install.ps1 b/macros/latex/contrib/revquantum/Install.ps1
new file mode 100644
index 0000000000..eac3910e6f
--- /dev/null
+++ b/macros/latex/contrib/revquantum/Install.ps1
@@ -0,0 +1,22 @@
+param(
+ [switch] $CTAN
+)
+
+#region Bootstrap PoShTeX
+if (!(Get-Module -ListAvailable -Name posh-tex -ErrorAction SilentlyContinue)) {
+ Install-Module posh-tex -Scope CurrentUser
+}
+Import-Module posh-tex
+#endregion
+
+Out-TeXStyle revquantum
+Out-TeXStyleDocumentation revquantum
+
+Install-TeXUserResource tex/latex/revquantum revquantum.sty, revquantum.pdf
+
+Install-PandocUserResource templates pandoc/templates/revquantum.latex -ErrorAction Continue
+
+if ($CTAN) {
+ Invoke-TeXBuildEngine example.tex
+ Export-CTANArchive -ArchiveLayout Simple revquantum.ins, revquantum.pdf, README.md, example.tex, example.pdf, Install.ps1
+} \ No newline at end of file
diff --git a/macros/latex/contrib/revquantum/README.md b/macros/latex/contrib/revquantum/README.md
new file mode 100644
index 0000000000..8cce7cfa93
--- /dev/null
+++ b/macros/latex/contrib/revquantum/README.md
@@ -0,0 +1,83 @@
+# revquantum #
+
+This package attempts to solve, or at least mitigate, standard problems with
+writing quantum information papers in ``{revtex4-1}``. In particular:
+
+- Includes titles in BibTeX.
+- Allows for use of nicer-looking fonts via ``{mathpazo}``.
+- Configures ``{hyperref}`` to make nicer-looking links and to correctly use ``\autoref``.
+- Sets up ``{listings}`` for common scientific languages and legacy environments (Python, Mathematica and MATLAB).
+- Provides notation for quantum information and makes defining new notation easier.
+- Reduces boilerplate for author affiliations by providing a (rudimentary) database for a few departments.
+
+A major goal of this package is to reduce the amount of useless crap that needs to be copied and pasted between documents. In particular, a complete document can be written in just a few lines:
+
+```latex
+\documentclass[pra,aps,twocolumn,superscriptaddress,10pt]{revtex4-1}
+\usepackage[pretty,uselistings]{revquantum}
+
+\begin{document}
+
+\title{Example \textsf{revquantum} Document}
+
+\author{Christopher Granade}
+\email{cgranade@cgranade.com}
+\affilUSydPhys \affilEQUS
+
+\date{\today}
+
+\begin{abstract}
+ \TODO
+\end{abstract}
+
+\maketitle
+
+\bibliography{example}
+\appendix
+
+\end{document}
+```
+
+## Installing ##
+
+### Install With PowerShell ###
+
+In an attempt to cut down on the pain of LaTeX package installation, ``{revquantum}`` uses [PoShTeX](https://github.com/cgranade/posh-tex/) to automate installation. If you're running PowerShell already, just run ``Install.ps1``:
+
+```powershell
+PS> Unblock-File Install.ps1 # Mark the installer as safe to run.
+PS> ./Install.ps1
+```
+
+PowerShell itself is easy to install on many macOS and Linux systems using the [provided packages](https://github.com/PowerShell/PowerShell#get-powershell).
+
+### Manual Installation ###
+
+I think the following works on Unix-like systems. If not, let me know or pull request with better instructions.
+
+```bash
+$ latex revquantum.ins # Makes the actual .sty from the .dtx file.
+$ pdflatex revquantum.dtx # Makes documentation, such as it is.
+$ mkdir texdir/tex/latex/revquantum # Replace texdir with where you actually installed TeX (e.g. ~/texmf).
+$ cp revquantum.sty texdir/tex/latex/revquantum # As with above, replace texdir.
+$ texhash
+```
+
+Directions for Windows/MikTeX can be found thanks to [this useful StackOverflow answer](http://tex.stackexchange.com/questions/2063/how-can-i-manually-install-a-package-on-miktex-windows).
+
+## Using ##
+
+I'll write more complete documentation later (hopefully), but for now:
+
+- ``{braket}`` is automatically imported, defining ``\ket``, ``\bra`` and ``\braket``.
+- The notation commands ``\ii`` and ``\dd`` typeset roman "i" and "d" characters, respectively. More generally, ``\newrm{foo}`` creates a new command ``\foo`` that typesets ``foo`` in math-roman. ``{revquantum}`` comes with ``\e``, ``\TVD`` and ``\T`` predefined using ``\newrm``.
+- Similarly, ``\newoperator`` defines new commands which typeset using ``\operatorname``. By default, this is used to define ``\Tr``, ``\Cov``, ``\supp``, ``\diag`` and ``\rank``.
+- The commands ``\defeq``, ``\expect`` and ``\id`` define the common notation ``:=``, double-struck E and double-struck 1 (respectively).
+- ``\newaffil{NAME}{DESCRIPTION}`` defines a new affiliation command ``\affilNAME``.
+- The ``\todo`` command typesets its argument in purple and raises a warning when built. If ``{revquantum}`` is loaded with the ``[final]`` option, this warning is escalated to an error. Similarly, ``\TODO`` takes no argument but inserts the placeholder "TODO" and ``\todolist`` typesets an ``{itemize}`` environment in ``\todo``.
+
+## Known Issues ##
+
+- The BibTeX thing is an unforgivable hack. Thankfully, I'm not asking for anyone's forgiveness.
+- ``\autoref`` chokes on appendices, giving nonsense like "Section A". This should be fixable, though.
+- The use of the "UW" prefix for the University of Waterloo was probably a bad idea, and will likely change so as to not preclude other universities whose names start with "W".
diff --git a/macros/latex/contrib/revquantum/example.pdf b/macros/latex/contrib/revquantum/example.pdf
new file mode 100644
index 0000000000..269e1b7110
--- /dev/null
+++ b/macros/latex/contrib/revquantum/example.pdf
Binary files differ
diff --git a/macros/latex/contrib/revquantum/example.tex b/macros/latex/contrib/revquantum/example.tex
new file mode 100644
index 0000000000..d94c1e4a43
--- /dev/null
+++ b/macros/latex/contrib/revquantum/example.tex
@@ -0,0 +1,52 @@
+\documentclass[pra,aps,twocolumn,superscriptaddress,10pt]{revtex4-1}
+\usepackage[pretty,uselistings]{revquantum}
+
+%=============================================================================
+% FRONT MATTER
+%=============================================================================
+
+\begin{document}
+
+\title{Example \textsf{revquantum} Document}
+
+\author{Christopher Granade}
+\email{cgranade@cgranade.com}
+\affilUSydPhys
+\affilEQuSUSyd
+
+\date{\today}
+
+\begin{abstract}
+ \TODO
+\end{abstract}
+
+\maketitle
+
+%=============================================================================
+% MAIN DOCUMENT
+%=============================================================================
+
+Lorum ipsum is kind of dated by now, but whatever. At least we can $\Tr$ its
+history.
+
+\todo{an example of a TODO, which will cause errors if present in the
+\texttt{final} version.}
+
+\bibliography{example}
+
+%=============================================================================
+% APPENDICES
+%=============================================================================
+
+\appendix
+
+%=============================================================================
+\section{Source Code}
+\label{apx:code}
+%=============================================================================
+
+\begin{lstlisting}[style=python,gobble=4,caption={Quick example of importing \cite{johansson_qutip_2013}.}]
+ >>> import qutip as qt
+\end{lstlisting}
+
+\end{document} \ No newline at end of file
diff --git a/macros/latex/contrib/revquantum/revquantum.dtx b/macros/latex/contrib/revquantum/revquantum.dtx
new file mode 100644
index 0000000000..103ea3b0bf
--- /dev/null
+++ b/macros/latex/contrib/revquantum/revquantum.dtx
@@ -0,0 +1,973 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2016 by Christopher Granade <cgranade@cgranade.com>
+% ---------------------------------------------------------------------------
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Christopher Granade (cgranade@cgranade.com).
+%
+% This work consists of the files revquantum.dtx and revquantum.ins
+% and the derived filebase revquantum.sty.
+%
+% \fi
+%
+% \iffalse
+%<*driver>
+\ProvidesFile{revquantum.dtx}
+%</driver>
+%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+%<package>\ProvidesPackage{revquantum}
+%<*package>
+ [2017/03/15 v0.11 Misc. fixes and improved installer.]
+%</package>
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage[pretty]{revquantum}[2015/12/29]
+\usepackage{xcolor}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+ \DocInput{revquantum.dtx}
+ \PrintChanges
+ \PrintIndex
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{0}
+%
+% \CharacterTable
+% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+% \changes{v0.10}{2016/09/21}{Build script fixes for CTAN submission.}
+% \changes{v0.09}{2016/09/20}{wlog fix, updates to affil database.}
+% \changes{v0.08}{2016/04/11}{Significant reworking to robustly configure colors and fonts in listings.}
+% \changes{v0.07}{2016/04/07}{Added citeneed macro, fixed TODO spacing.}
+% \changes{v0.06}{2016/04/04}{Fix for hyperref bug.}
+% \changes{v0.05}{2016/04/04}{BibTeX hack for missing babel languages.}
+% \changes{v0.04}{2015/12/30}{Added Color Universal Design color names, checks for incompatible packages.}
+% \changes{v0.03}{2015/11/26}{Integration of stmaryrd, better docs.}
+% \changes{v0.02}{2015/11/04}{Initial public version.}
+%
+% \DoNotIndex{\newcommand,\newenvironment}
+%
+% \providecommand*{\url}{\texttt}
+% \newcommand{\DescribeColor}[1]{%
+% \DescribeMacro{#1}%
+% {\color{#1} \textbullet}
+%
+% }
+%
+% \GetFileInfo{revquantum.dtx}
+% \title{The \textsf{revquantum} package}
+% \author{Christopher Granade \\ \url{cgranade@cgranade.com}}
+% \date{\fileversion~from \filedate}
+%
+% \maketitle
+%
+% \section{Introduction}
+%
+% The \textsf{revquantum} package provides a number of useful hacks to solve
+% common annoyances with the \textsf{revtex4-1} package, and to define notation
+% in common use within quantum information. In doing so, \textsf{revquantum}
+% imports and configures a number of commonly-available and used packages, and
+% where reasonable, provides fallbacks.
+%
+% The \textsf{revquantum} package also warns when users try to load packages which
+% are known to be incompatible with \textsf{revtex4-1}. In particular, loading the following
+% packages will cause warnings:
+%
+% \begin{itemize}
+% \item \textsf{subcaption}
+% \end{itemize}
+%
+% Yes, this is a short list. It will get longer.
+%
+% \section{Usage}
+%
+% \textbf{NB:} \textsf{revquantum} must be loaded first unless |nobibtexhacks|
+% is passed.
+%
+% \subsection{Package Options}
+%
+% The \textsf{revquantum} package provides several options to configure its behavior.
+% These can be used in the traditional way, as optional arguments to |\usepackage|.
+% For instance, this document was prepared using |\usepackage[pretty]{revquantum}|.
+%
+% \DescribeMacro{[final]}
+%
+% Removes support for TODO commands (see below), causing them to escalate from
+% warnings to errors.
+%
+% \DescribeMacro{[pretty]}
+%
+% Uses the \textsf{mathpazo} package to typeset the document
+% more nicely than the default for \textsf{revtex4-1} drafts.
+%
+% \DescribeMacro{[uselistings]}
+%
+% Includes the \textsf{listings} package and configures it for
+% literate and math-escape notation in Python, Mathematica and MATLAB.
+%
+% \DescribeMacro{[nobibtexhacks]}
+%
+% Prevents \textsf{revquantum} from patching the \BibTeX support provided
+% by \textsf{revtex4-1} to include titles.
+%
+% \DescribeMacro{[strict]}
+%
+% Causes package incompatibility warnings to become errors.
+%
+% \subsection{New Commands}
+%
+% \subsubsection{TODO Annotations}
+%
+% \DescribeMacro{\todo} \marg{annotation}
+%
+% Marks an incompleted task in a different color in the document, and raises
+% a warning in the LaTeX log.
+%
+% \DescribeMacro{\TODO}
+% \TODO
+%
+% \DescribeMacro{\todolist} \marg{contents}
+%
+% Typesets \emph{contents} as a TODO annotation, wrapped in an |{enumerate}|
+% environment.
+%
+% \subsubsection{Mathematical Notation}
+%
+% This package also provides commands for notation common in quantum information.
+%
+% \DescribeMacro{\ii}
+% \DescribeMacro{\dd}
+%
+% These commands typeset the imaginary unit $\ii$ and differential element $\dd$,
+% respectively, in math roman.
+%
+% \DescribeMacro{\defeq}
+%
+% This command uses |\mathrel| to properly format the colon-equals operator
+% as a relation operator.
+%
+% \DescribeMacro{\expect}
+% Typesets the expectation operator $\expect$.
+%
+% \DescribeMacro{\id}
+%
+% \todo{The current implementation of id is to call openone, provided by revtex4-1,
+% and thus not available when used from documentation.}
+%
+% \DescribeMacro{\llbracket}
+% \DescribeMacro{\rrbracket}
+%
+% Typesets the double-square brackets commonly used to denote stabilizer code
+% properties, as in $\llbracket n, k, d \rrbracket$. These commands are provided
+% by |{stmaryrd}|, and are given a reasonable fallback if that package is not
+% available.
+%
+%
+%
+% \subsubsection{Affiliation Database}
+%
+% The \textsf{revquantum} package provides commands for quickly typesetting
+% affiliations, with an eye towards reducing copy-paste errors when authors have
+% a nontrivial set of shared affiliations.
+%
+% \DescribeMacro{\newaffil} \marg{shorthand} \marg{description}
+%
+% The workhorse of the affiliation database is the |\newaffil| command,
+% which defines a new command that expands to call the \textsf{revtex4-1}
+% |\affiliation| command. For instance, |\newaffil{UFooBar}{Bar, UFoo}|
+% defines a new command |\affilUFooBar| that expands to
+% |\affiliation{Bar, UFoo}|.
+%
+% So far, the following affiliation commands are provided:
+%
+% \DescribeMacro{\affilTODO} Special, marks that an affiliation is not
+% provided.
+%
+%
+% \DescribeMacro{\affilEQuSUSyd} Centre for Engineered Quantum Systems, University of Sydney.
+%
+% \DescribeMacro{\affilEQuSMacq} Centre for Engineered Quantum Systems, Macquarie University.
+%
+% \DescribeMacro{\affilUSydPhys} School of Physics, University of Sydney.
+%
+% \DescribeMacro{\affilIQC} Institute for Quantum Computing, University of Waterloo.
+%
+% \DescribeMacro{\affilUWPhys} Department of Physics, University of Waterloo.
+%
+% \DescribeMacro{\affilUWAMath} Department of Applied Mathematics, University of Waterloo.
+%
+% \DescribeMacro{\affilUWChem} Department of Chemistry, University of Waterloo.
+%
+% \DescribeMacro{\affilPI} Perimeter Institute for Theoretical Physics.
+%
+% \DescribeMacro{\affilCIFAR} Canadian Institute for Advanced Research.
+%
+% \DescribeMacro{\affilCQuIC} Center for Quantum Information and Control, University of New Mexico.
+%
+% \DescribeMacro{\affilIBMTJW} IBM T. J. Watson Research Center.
+%
+%
+% \subsubsection{Internal-Use Commands}
+%
+% \DescribeMacro{\booloption}
+% \DescribeMacro{\newnew}
+%
+% These commands are used internally by \textsf{revquantum} to define
+% new boolean package options, and to declare new kinds of |\newcommand|
+% commands. For example, |\newnew| is used to define |\newoperator|,
+% which in turn defines new commands for named mathematical operators (e.g. $\Tr$).
+%
+% \DescribeMacro{\sectionautorefname}
+% \DescribeMacro{\algorithmautorefname}
+% \DescribeMacro{\equationautorefname}
+% \DescribeMacro{\lemmaautorefname}
+%
+% These commands configure \textsf{hyperref}'s \texttt{autoref} command
+% for use with \textsf{revtex4-1}, so that \texttt{autoref} correctly
+% describes Section, Algorithm, and Lemma, and also follows the standard
+% notation for equation references.
+%
+% \DescribeMacro{\boolean{@xetex}}
+%
+% This boolean variable uses \textsf{iftex} to check if XeTeX is installed.
+% If \textsf{iftex} is not available, then we assume plain LaTeX.
+%
+% \subsection{New Colors}
+%
+% The \textsf{revquantum} package also provides a color palette
+% that is safe for colorblind readers and for printing, the
+% \href{http://jfly.iam.u-tokyo.ac.jp/color/}{Color Universal
+% Design} palette of Okabe and Ito.
+%
+% \DescribeColor{cud-black}
+% \DescribeColor{cud-orange}
+% \DescribeColor{cud-sky-blue}
+% \DescribeColor{cud-bluish-green}
+% \DescribeColor{cud-yellow}
+% \DescribeColor{cud-blue}
+% \DescribeColor{cud-vermillion}
+% \DescribeColor{cud-reddish-purple}
+%
+% These colors are defined as \textsf{xcolor} color names, such that they
+% can be used in all packages which depend on \textsf{xcolor}. In particular,
+% CUD colors can be directly used from \textsf{tikz}. To use with \textsf{tikz},
+% however, \textsf{revquantum} must be loaded \emph{after} \textsf{tikz}.
+%
+% \StopEventually{}
+%
+% \section{Implementation}
+%
+% \iffalse
+%<*package>
+% \fi
+%
+
+
+
+% \begin{macrocode}
+
+\usepackage{ifthen}
+
+% \end{macrocode}
+
+% \subsection{XeTeX Detection} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% We make a new boolean variable to track if XeTeX is being used.
+
+% \begin{macrocode}
+
+\newboolean{@xetex}
+\setboolean{@xetex}{false}
+\IfFileExists{iftex.sty}{
+ \wlog{[INFO] iftex loaded}
+ \usepackage{iftex}
+}{
+ \newif\ifXeTeX
+ \XeTeXfalse
+}
+\ifXeTeX
+ \wlog{[INFO] Using XeTeX}
+ \setboolean{@xetex}{true}
+\else
+ \setboolean{@xetex}{false}
+\fi
+
+% \end{macrocode}
+
+
+% \subsection{Notation} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%
+% \begin{macro}{\newnew}
+% \begin{macrocode}
+\newcommand{\newnew}[2]{
+ \expandafter\newcommand\csname new#1\endcsname[1]{
+ \expandafter\newcommand\csname ##1\endcsname{#2{##1}}
+ }
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\newnew{operator}{\operatorname}
+\newnew{rm}{\mathrm}
+
+\newoperator{Tr}
+\newoperator{Cov}
+\newoperator{supp}
+\newoperator{diag}
+\newoperator{rank}
+
+% \end{macrocode}
+%
+% \begin{macro}{\ii}
+% \begin{macrocode}
+\newcommand{\ii}{\mathrm{i}} % Outside what newnew currently supports.
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\dd}
+% \begin{macrocode}
+\newcommand{\dd}{\mathrm{d}} % Outside what newnew currently supports.
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+
+\newrm{e}
+\newrm{TVD}
+\newrm{T}
+
+% \end{macrocode}
+%
+% \begin{macro}{\defeq}
+% \begin{macrocode}
+\newcommand{\defeq}{\mathrel{:=}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\expect}
+% \begin{macrocode}
+\newcommand{\expect}{\mathbb{E}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\id}
+% \begin{macrocode}
+\newcommand{\id}{\openone}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+
+% \end{macrocode}
+
+% We want to only conditionally use |{stmaryrd}| if it's available, and
+% otherwise, hack up a few commands from that package.
+%
+% \begin{macrocode}
+ \IfFileExists{stmaryrd.sty}{
+ \RequirePackage{stmaryrd}
+ }{
+ \PackageWarning{revquantum}{
+ The stmaryrd package is not available,
+ so some commands (e.g.: double-brackets) will look wrong.
+ }
+ \newcommand{\llbracket}{[\!\!\hspace{1.5pt}[}
+ \newcommand{\rrbracket}{]\!\!\hspace{1.5pt}]}
+ }
+% \end{macrocode}
+
+
+% \subsection{Options Handling} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% We will need to define a few options to make the package nicer to use. We do
+% so by making a new command, |\booloption| \marg{boolname} \marg{optionname}
+% \marg{default}.
+% \begin{macro}{\booloption}
+% \begin{macrocode}
+\newcommand{\booloption}[3]{
+ \newboolean{#1}
+ \setboolean{#1}{#3}
+ \ifthenelse{\equal{#3}{true}}{
+% \end{macrocode}
+% Default is true, so we need a "no" option to
+% turn off the new boolean.
+% \begin{macrocode}
+ \DeclareOption{no#2}{\setboolean{#1}{false}}
+ }{
+% \end{macrocode}
+% Default is false, so we need an option to turn
+% on the new boolean.
+% \begin{macrocode}
+ \DeclareOption{#2}{\setboolean{#1}{true}}
+ }
+}
+% \end{macrocode}
+% \end{macro}
+
+% We then use this new command to define the options for \textsf{revquantum},
+% |final|, |pretty|, |uselistings|, |nobibtexhacks|, and |strict|.
+
+% \begin{macrocode}
+
+\booloption{@final}{final}{false}
+\booloption{@pretty}{pretty}{false}
+\booloption{@uselistings}{uselistings}{false}
+\booloption{@bibtexhacks}{bibtexhacks}{true}
+\booloption{@strict}{strict}{false}
+
+\ProcessOptions\relax
+
+% \end{macrocode}
+
+% For the |strict| option, we do one last thing and define a new macro that
+% either raises a warning or an option depending on whether |strict| has been
+% set as an option.
+
+% \begin{macro}{\rq@quasiwarn}
+% \begin{macrocode}
+\ifthenelse{\boolean{@strict}}{
+ \newcommand{\rq@quasiwarn}{
+ \PackageError{revquantum}
+ }
+}{
+ \newcommand{\rq@quasiwarn}{
+ \PackageWarning{revquantum}
+ }
+}
+% \end{macrocode}
+% \end{macro}
+
+% \subsection{Unforgivable BibTeX Hacks} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% These hacks include the title of each reference in the BibTeX output by
+% redefining the part of \textsf{revtex4-1} on the fly which is responsible
+% for writing out the bibdata. Note that these hacks \emph{must} come before
+% importing packages, or else \textsf{revtex4-1} will have already written out
+% its control notes.
+
+% \begin{macrocode}
+
+\ifthenelse{\boolean{@bibtexhacks}}{\def\@bibdataout@aps{%
+ \immediate\write\@bibdataout{%
+ @CONTROL{%
+ apsrev41Control,author="08",editor="1",pages="0",title="0",year="1",eprint="1"%
+ }%
+ }%
+ \if@filesw
+ \immediate\write\@auxout{\string\citation{apsrev41Control}}%
+ \fi
+}}{}
+
+% \end{macrocode}
+
+% \subsection{Imports} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Here, we import a few other useful packages and configure them according to
+% the options passed by the user. In handling the fonts specified by
+% |[pretty]|, we must be careful to do so in a way that is supported by
+% XeTeX.
+% Note that we only load \textsf{color} if
+% neither \textsf{tikz} nor \textsf{xcolor} have already been imported, and if
+% we are not using \textsf{listings}. In the latter case, we will load
+% \textsf{xcolor} instead so that we can make \textsf{listings} play nicer with
+% our own custom palette.
+% Also of
+% note is that we do not import \textsf{hyperref} yet, as it must go last to avoid duplicating
+% reference names.
+
+% \begin{macrocode}
+
+\RequirePackage{amsmath}
+\RequirePackage{amsfonts}
+\RequirePackage{amsthm}
+\RequirePackage{amssymb}
+\RequirePackage{amsbsy}
+\@ifpackageloaded{tikz}{}{%
+ \@ifpackageloaded{xcolor}{}{%
+ \ifthenelse{\boolean{@uselistings}}{}{%
+ \RequirePackage[usenames,dvipsnames]{color}%
+ }%
+ }%
+ \AtBeginDocument{%
+ \@ifpackageloaded{tikz}{%
+ \rq@quasiwarn{tikz loaded, but after revquantum. This may not work.}%
+ }%
+ }%
+}
+\RequirePackage{braket}
+\RequirePackage{graphicx}
+\RequirePackage[english]{babel}
+\ifthenelse{\boolean{@pretty}}{
+ \ifthenelse{\boolean{@xetex}}{
+ % http://tex.stackexchange.com/a/50593
+ \usepackage{fontspec}
+ \usepackage{mathpazo}
+ \setmainfont
+ [ BoldFont = texgyrepagella-bold.otf ,
+ ItalicFont = texgyrepagella-italic.otf ,
+ BoldItalicFont = texgyrepagella-bolditalic.otf ]
+ {texgyrepagella-regular.otf}
+ }{
+ \RequirePackage{mathpazo}
+ }
+}{}
+\ifthenelse{\boolean{@uselistings}}{
+ \RequirePackage{xcolor}
+ \RequirePackage{listings}
+ \RequirePackage{textcomp} % Make sure we have a ` for writing Mathematica.
+}{}
+\ifthenelse{\boolean{@bibtexhacks}}{
+ \RequirePackage{letltxmacro}
+ \RequirePackage{etoolbox}
+}{}
+% \end{macrocode}
+
+% \subsubsection{Theorem Environments}
+
+% \begin{macrocode}
+
+\newtheorem{theorem}{Theorem}
+\newtheorem{lemma}{Lemma}
+
+% \end{macrocode}
+
+% \subsubsection{\textsf{algorithm} and \textsf{algpseudocode} Setup}
+
+% \begin{macrocode}
+
+\RequirePackage{algorithm}
+\RequirePackage{algpseudocode}
+ \renewcommand{\algorithmicrequire}{\textbf{Input:}}
+ \renewcommand{\algorithmicensure}{\textbf{Output:}}
+ \newcommand{\inlinecomment}[1]{\Comment {\footnotesize #1} \normalsize}
+ \newcommand{\linecomment}[1]{\State \(\triangleright\) {\footnotesize #1} \normalsize}
+
+% \end{macrocode}
+
+% \subsubsection{\textsf{listings} Setup}
+
+% Here, we provide special support for scientific languages like Python and Mathematica,
+% as well as for legacy environments. This support consists of configuring escapes,
+% quoting, providing additional keywords, etc.
+
+% \begin{macrocode}
+
+\ifthenelse{\boolean{@uselistings}}{
+ \definecolor{comment-color}{gray}{0.5}
+
+ \lstset{
+ basicstyle=\footnotesize,
+ commentstyle=\color{comment-color},
+ frame=lines,
+ gobble=4,
+ numbers=left,
+ numberstyle=\tiny, stepnumber=5,
+ numbersep=5pt,
+ keywordstyle=\color{cud-bluish-green!85!black}\bfseries,
+ keywordstyle={[2]\color{cud-sky-blue!75!black}},
+ emphstyle=\color{cud-vermillion}
+ }
+
+ \ifthenelse{\boolean{@xetex}}{
+ \RequirePackage{sourcecodepro}
+ \lstset{basicstyle=\footnotesize\sourcecodepro}
+ }{}
+
+ \lstdefinestyle{matlab}{
+ language=MATLAB,
+ mathescape=true
+ }
+
+ \lstdefinestyle{python}{
+ language=Python,
+ mathescape=true,
+ showstringspaces=false,
+ morekeywords={as,async,await}
+ }
+
+ \lstdefinestyle{mathematica}{
+ language=Mathematica,
+ upquote=true, % Needed to deal with the context symbol `.'
+ literate=
+ {->}{$\to$}1
+ {!=}{$\neq$}1
+ {\\[DoubleStruckOne]}{${\id}$}1
+ {\\[Sigma]}{$\sigma$}1
+ {(x)}{$\otimes$}1 % CG: I have the distinct impression this will break. Badly.
+ }
+}{}
+
+% \end{macrocode}
+
+% \subsection{Import Warnings} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% The following command will cause a warning to be emitted if the package
+% named by its argument is loaded. To make robust against the order in which
+% packages are loaded, all such logic happens at |\begin{document}|. This
+% code is adapted from the solution provided by Martin Scharrer at
+% \url{http://tex.stackexchange.com/a/16200/615}.
+
+% \begin{macro}{\rq@warnpackage}
+% \begin{macrocode}
+\newcommand{\rq@warnpackage}[1]{
+ \AtBeginDocument{%
+ \@ifpackageloaded{#1}{%
+ \rq@quasiwarn{The #1 package is known to be incompatible with revtex4-1. You may encounter problems using this package.}%
+ }{}
+ }
+}
+% \end{macrocode}
+% \end{macro}
+
+% With this command in place, we can now issue specific warnings for individual
+% ``bad'' packages.
+
+% \begin{macrocode}
+\rq@warnpackage{subcaption}
+% \end{macrocode}
+
+
+% \subsection{Slightly More Forgivable BibTeX Hacks} %%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Next, we include \href{http://tex.stackexchange.com/a/199299/615}{a solution
+% suggested by egreg} for a rather annoying |{revtex4-1}| bug. In particular,
+% we will set up |language={en}| as an alias for |language={english}|, so that
+% |{revtex4-1}| will no longer raise |{babel}| errors for the undefined language.
+% As with our unforgivable hacks, we will guard the forgivable hacks with
+% the |[nobibtexhacks]| option.
+
+% \begin{macro}{\ORIGselectlanguage}
+% \begin{macrocode}
+
+\ifthenelse{\boolean{@bibtexhacks}}{
+ \LetLtxMacro{\ORIGselectlanguage}{\selectlanguage}
+ \DeclareRobustCommand{\selectlanguage}[1]{%
+ \@ifundefined{alias@\string#1}
+ {\ORIGselectlanguage{#1}}
+ {\begingroup\edef\x{\endgroup
+ \noexpand\ORIGselectlanguage{\@nameuse{alias@#1}}}\x}%
+ }
+}{}
+
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\definelanguagealias}
+% \begin{macrocode}
+
+\newcommand{\definelanguagealias}[2]{%
+ \@namedef{alias@#1}{#2}%
+}
+
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macrocode}
+
+\definelanguagealias{en}{english}
+\definelanguagealias{EN}{english}
+\definelanguagealias{English}{english}
+
+% \end{macrocode}
+
+% We will also redefine |\doibase| to eat any newlines following it, and to
+% prefer HTTPS to HTTP. This will fix a rather annoying bug where line breaks
+% in the *.bbl source can introduce extraneous spaces into the target of
+% each citation's |\href|.
+
+% \begin{macro}{\doibase}
+% \begin{macrocode}
+
+\ifthenelse{\boolean{@bibtexhacks}}{
+ % Ensure that the \doibase command is defined, just in case.
+ \providecommand{\doibase}{}
+ \renewcommand{\doibase}[1]{https://dx.doi.org/\ifdefempty{#1}{}{#1}}
+}{}
+
+% \end{macrocode}
+% \end{macro}
+
+
+% \subsection{TODO Support} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% These commands provide a way of marking items as needing to be done before
+% the final version (denoted by the |final| package option).
+
+% \begin{macro}{\todo}
+% \begin{macrocode}
+
+\ifthenelse{\boolean{@final}}{
+ \newcommand{\todo}[1]{%
+ \PackageError{revquantum}{Unaddressed TODO}%
+ \rq@todo{#1}%
+ }
+}{
+ \newcommand{\todo}[1]{%
+ \PackageWarning{revquantum}{Unaddressed TODO}%
+ \rq@todo{#1}%
+ }
+}
+
+% \end{macrocode}
+% \end{macro}
+%
+% We also define a |\citeneed| command for the special case of a missing citation.
+% As per Steve Flammia's suggestion, this is formatted in analogy to the infamous
+% Wikipedia annotation.
+%
+% \begin{macro}{\citeneed}
+% \begin{macrocode}
+\ifthenelse{\boolean{@final}}{
+ \newcommand{\citeneed}{%
+ \PackageError{revquantum}{citation needed}%
+ \rq@todo{[citation needed]}%
+ }
+}{
+ \newcommand{\citeneed}{%
+ \PackageWarning{revquantum}{citation needed}%
+ \rq@todo{[citation needed]}%
+ }
+}
+% \end{macrocode}
+% \end{macro}
+%
+% Both of these macros are based on the |\rq@todo| macro, which performs the
+% formatting for TODOs.
+%
+% \begin{macro}{\rq@todo}
+% \begin{macrocode}
+\newcommand{\rq@todo}[1]{%
+ {\color{magenta} #1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% We also provide a few other special cases below.
+%
+% \begin{macro}{\TODO}
+% \begin{macrocode}
+\newcommand{\TODO}{\todo{TODO}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\todolist}
+% \begin{macrocode}
+\newcommand{\todolist}[1]{\todo{
+ \begin{itemize}
+ #1
+ \end{itemize}
+}}
+
+% \end{macrocode}
+% \end{macro}
+
+% \subsection{Color Universal Design} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% \begin{macrocode}
+\definecolor{cud-black} {RGB}{0,0,0}
+\definecolor{cud-orange} {RGB}{230,159,0}
+\definecolor{cud-sky-blue} {RGB}{86,180,233}
+\definecolor{cud-bluish-green} {RGB}{0,158,115}
+\definecolor{cud-yellow} {RGB}{240,228,66}
+\definecolor{cud-blue} {RGB}{0,114,178}
+\definecolor{cud-vermillion} {RGB}{213,94,0}
+\definecolor{cud-reddish-purple}{RGB}{204,121,167}
+% \end{macrocode}
+
+% \subsection{Affiliation Database} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% \begin{macro}{\newaffil}
+% \begin{macrocode}
+\newcommand{\newaffil}[2]{
+ \expandafter\newcommand\csname affil#1\endcsname{
+ \affiliation{
+ #2
+ }
+ }
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{General Affiliations}
+%
+% \begin{macrocode}
+
+\newaffil{TODO}{\TODO}
+
+% \end{macrocode}
+%
+% \subsubsection{Australia}
+%
+% \begin{macrocode}
+
+\newaffil{EQuSUSyd}{
+ Centre for Engineered Quantum Systems,
+ University of Sydney,
+ Sydney, NSW, Australia
+}
+\newaffil{EQuSMacq}{
+ Centre for Engineered Quantum Systems,
+ Macquarie University,
+ Sydney, NSW, Australia
+}
+\newaffil{USydPhys}{
+ School of Physics,
+ University of Sydney,
+ Sydney, NSW, Australia
+}
+
+% \end{macrocode}
+%
+% \subsubsection{Canada}
+%
+% \begin{macrocode}
+
+\newaffil{IQC}{
+ Institute for Quantum Computing,
+ University of Waterloo,
+ Waterloo, ON, Canada
+}
+\newaffil{UWPhys}{
+ Department of Physics,
+ University of Waterloo,
+ Waterloo, ON, Canada
+}
+\newaffil{UWAMath}{
+ Department of Applied Mathematics,
+ University of Waterloo,
+ Waterloo, ON, Canada
+}
+\newaffil{UWChem}{
+ Department of Chemistry,
+ University of Waterloo,
+ Waterloo, ON, Canada
+}
+\newaffil{PI}{
+ Perimeter Institute for Theoretical Physics,
+ 31 Caroline St. N,
+ Waterloo, Ontario, Canada N2L 2Y5
+}
+\newaffil{CIFAR}{
+ Canadian Institute for Advanced Research,
+ Toronto, ON, Canada
+}
+
+% \end{macrocode}
+%
+% \subsubsection{United States}
+%
+% \begin{macrocode}
+
+\newaffil{CQuIC}{
+ Center for Quantum Information and Control,
+ University of New Mexico,
+ Albuquerque, NM 87131-0001, USA
+}
+\newaffil{IBMTJW}{
+ IBM T. J. Watson Research Center,
+ Yorktown Heights, New York 10598, USA
+}
+
+
+% \end{macrocode}
+
+
+% \subsection{\textsf{hyperref} Setup} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Finally, we load \textsf{hyperref} separately so that it can go last.
+
+% Get rid of \textsf{hyperref}'s ugly boxes.
+%From:http://tex.stackexchange.com/a/51349
+% \begin{macrocode}
+
+\RequirePackage[breaklinks=true]{hyperref}
+
+\hypersetup{
+ colorlinks = true, %Colours links instead of ugly boxes
+ urlcolor = blue, %Colour for external hyperlinks
+ linkcolor = blue, %Colour of internal links
+ citecolor = red %Colour of citations
+}
+
+% \end{macrocode}
+
+
+% \subsubsection{\textsf{autoref} Setup}
+% We must declare our \textsf{autoref} configuration at the beginning
+% of the document to keep other packages from clobbering it.
+
+% \begin{macro}{\sectionautorefname}
+% \begin{macrocode}
+\AtBeginDocument{%
+ \def\sectionautorefname{Section}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\algorithmautorefname}
+% \begin{macrocode}
+\AtBeginDocument{%
+ \def\algorithmautorefname{Algorithm}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\equationautorefname}
+% See http://tex.stackexchange.com/a/66150.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \def\equationautorefname~#1\null{(#1)\null}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\lemmaautorefname}
+% \begin{macrocode}
+\AtBeginDocument{%
+ \newcommand{\lemmaautorefname}{Lemma}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \iffalse
+%</package>
+% \fi
+%
+% \Finale
+\endinput
diff --git a/macros/latex/contrib/revquantum/revquantum.ins b/macros/latex/contrib/revquantum/revquantum.ins
new file mode 100644
index 0000000000..3e69d1772b
--- /dev/null
+++ b/macros/latex/contrib/revquantum/revquantum.ins
@@ -0,0 +1,55 @@
+%%
+%% Copyright (C) 2015 by Christopher Granade <cgranade@cgranade.com>.
+%%
+%% This file may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License, either version 1.3 of this license
+%% or (at your option) any later version. The latest version of this
+%% license is in:
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% and version 1.3 or later is part of all distributions of LaTeX version
+%% 2005/12/01 or later.
+%%
+
+\input docstrip.tex
+\keepsilent
+
+\usedir{tex/latex/revquantum}
+
+\preamble
+
+This is a generated file.
+
+Copyright (C) 2015 by Christopher Granade <cgranade@cgranade.com>.
+
+This file may be distributed and/or modified under the conditions of
+the LaTeX Project Public License, either version 1.3 of this license
+or (at your option) any later version. The latest version of this
+license is in:
+
+ http://www.latex-project.org/lppl.txt
+
+and version 1.3 or later is part of all distributions of LaTeX version
+2005/12/01 or later.
+
+\endpreamble
+
+\generate{\file{revquantum.sty}{\from{revquantum.dtx}{package}}}
+
+\obeyspaces
+\Msg{*************************************************************}
+\Msg{* *}
+\Msg{* To finish the installation you have to move the following *}
+\Msg{* file into a directory searched by TeX: *}
+\Msg{* *}
+\Msg{* revquantum.sty *}
+\Msg{* *}
+\Msg{* To produce the documentation run the file revquantum.dtx *}
+\Msg{* through LaTeX. *}
+\Msg{* *}
+\Msg{* Happy TeXing! *}
+\Msg{* *}
+\Msg{*************************************************************}
+
+\endbatchfile
diff --git a/macros/latex/contrib/revquantum/revquantum.pdf b/macros/latex/contrib/revquantum/revquantum.pdf
new file mode 100644
index 0000000000..07dfd1a324
--- /dev/null
+++ b/macros/latex/contrib/revquantum/revquantum.pdf
Binary files differ