| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2016 by Christopher Granade <[email protected]> |
| 4 |
% --------------------------------------------------------------------------- |
| 5 |
% This work may be distributed and/or modified under the |
| 6 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 7 |
% of this license or (at your option) any later version. |
| 8 |
% The latest version of this license is in |
| 9 |
% http://www.latex-project.org/lppl.txt |
| 10 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 11 |
% version 2005/12/01 or later. |
| 12 |
% |
| 13 |
% This work has the LPPL maintenance status `maintained'. |
| 14 |
% |
| 15 |
% The Current Maintainer of this work is Christopher Granade ([email protected]). |
| 16 |
% |
| 17 |
% This work consists of the files revquantum.dtx and revquantum.ins |
| 18 |
% and the derived filebase revquantum.sty. |
| 19 |
% |
| 20 |
% \fi |
| 21 |
% |
| 22 |
% \iffalse |
| 23 |
%<*driver> |
| 24 |
\ProvidesFile{revquantum.dtx} |
| 25 |
%</driver> |
| 26 |
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 27 |
%<package>\ProvidesPackage{revquantum} |
| 28 |
%<*package> |
| 29 |
[2017/03/15 v0.11 Misc. fixes and improved installer.] |
| 30 |
%</package> |
| 31 |
% |
| 32 |
%<*driver> |
| 33 |
\documentclass{ltxdoc} |
| 34 |
\usepackage[pretty]{revquantum}[2015/12/29] |
| 35 |
\usepackage{xcolor} |
| 36 |
\EnableCrossrefs |
| 37 |
\CodelineIndex |
| 38 |
\RecordChanges |
| 39 |
\begin{document} |
| 40 |
\DocInput{revquantum.dtx} |
| 41 |
\PrintChanges |
| 42 |
\PrintIndex |
| 43 |
\end{document} |
| 44 |
%</driver> |
| 45 |
% \fi |
| 46 |
% |
| 47 |
% \CheckSum{0} |
| 48 |
% |
| 49 |
% \CharacterTable |
| 50 |
% {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 |
| 51 |
% 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 |
| 52 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 53 |
% Exclamation \! Double quote \" Hash (number) \# |
| 54 |
% Dollar \$ Percent \% Ampersand \& |
| 55 |
% Acute accent \' Left paren \( Right paren \) |
| 56 |
% Asterisk \* Plus \+ Comma \, |
| 57 |
% Minus \- Point \. Solidus \/ |
| 58 |
% Colon \: Semicolon \; Less than \< |
| 59 |
% Equals \= Greater than \> Question mark \? |
| 60 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 61 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 62 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 63 |
% Right brace \} Tilde \~} |
| 64 |
% |
| 65 |
% \changes{v0.10}{2016/09/21}{Build script fixes for CTAN submission.} |
| 66 |
% \changes{v0.09}{2016/09/20}{wlog fix, updates to affil database.} |
| 67 |
% \changes{v0.08}{2016/04/11}{Significant reworking to robustly configure colors and fonts in listings.} |
| 68 |
% \changes{v0.07}{2016/04/07}{Added citeneed macro, fixed TODO spacing.} |
| 69 |
% \changes{v0.06}{2016/04/04}{Fix for hyperref bug.} |
| 70 |
% \changes{v0.05}{2016/04/04}{BibTeX hack for missing babel languages.} |
| 71 |
% \changes{v0.04}{2015/12/30}{Added Color Universal Design color names, checks for incompatible packages.} |
| 72 |
% \changes{v0.03}{2015/11/26}{Integration of stmaryrd, better docs.} |
| 73 |
% \changes{v0.02}{2015/11/04}{Initial public version.} |
| 74 |
% |
| 75 |
% \DoNotIndex{\newcommand,\newenvironment} |
| 76 |
% |
| 77 |
% \providecommand*{\url}{\texttt} |
| 78 |
% \newcommand{\DescribeColor}[1]{% |
| 79 |
% \DescribeMacro{#1}% |
| 80 |
% {\color{#1} \textbullet} |
| 81 |
% |
| 82 |
% } |
| 83 |
% |
| 84 |
% \GetFileInfo{revquantum.dtx} |
| 85 |
% \title{The \textsf{revquantum} package} |
| 86 |
% \author{Christopher Granade \\ \url{[email protected]}} |
| 87 |
% \date{\fileversion~from \filedate} |
| 88 |
% |
| 89 |
% \maketitle |
| 90 |
% |
| 91 |
% \section{Introduction} |
| 92 |
% |
| 93 |
% The \textsf{revquantum} package provides a number of useful hacks to solve |
| 94 |
% common annoyances with the \textsf{revtex4-1} package, and to define notation |
| 95 |
% in common use within quantum information. In doing so, \textsf{revquantum} |
| 96 |
% imports and configures a number of commonly-available and used packages, and |
| 97 |
% where reasonable, provides fallbacks. |
| 98 |
% |
| 99 |
% The \textsf{revquantum} package also warns when users try to load packages which |
| 100 |
% are known to be incompatible with \textsf{revtex4-1}. In particular, loading the following |
| 101 |
% packages will cause warnings: |
| 102 |
% |
| 103 |
% \begin{itemize} |
| 104 |
% \item \textsf{subcaption} |
| 105 |
% \end{itemize} |
| 106 |
% |
| 107 |
% Yes, this is a short list. It will get longer. |
| 108 |
% |
| 109 |
% \section{Usage} |
| 110 |
% |
| 111 |
% \textbf{NB:} \textsf{revquantum} must be loaded first unless |nobibtexhacks| |
| 112 |
% is passed. |
| 113 |
% |
| 114 |
% \subsection{Package Options} |
| 115 |
% |
| 116 |
% The \textsf{revquantum} package provides several options to configure its behavior. |
| 117 |
% These can be used in the traditional way, as optional arguments to |\usepackage|. |
| 118 |
% For instance, this document was prepared using |\usepackage[pretty]{revquantum}|. |
| 119 |
% |
| 120 |
% \DescribeMacro{[final]} |
| 121 |
% |
| 122 |
% Removes support for TODO commands (see below), causing them to escalate from |
| 123 |
% warnings to errors. |
| 124 |
% |
| 125 |
% \DescribeMacro{[pretty]} |
| 126 |
% |
| 127 |
% Uses the \textsf{mathpazo} package to typeset the document |
| 128 |
% more nicely than the default for \textsf{revtex4-1} drafts. |
| 129 |
% |
| 130 |
% \DescribeMacro{[uselistings]} |
| 131 |
% |
| 132 |
% Includes the \textsf{listings} package and configures it for |
| 133 |
% literate and math-escape notation in Python, Mathematica and MATLAB. |
| 134 |
% |
| 135 |
% \DescribeMacro{[nobibtexhacks]} |
| 136 |
% |
| 137 |
% Prevents \textsf{revquantum} from patching the \BibTeX support provided |
| 138 |
% by \textsf{revtex4-1} to include titles. |
| 139 |
% |
| 140 |
% \DescribeMacro{[strict]} |
| 141 |
% |
| 142 |
% Causes package incompatibility warnings to become errors. |
| 143 |
% |
| 144 |
% \subsection{New Commands} |
| 145 |
% |
| 146 |
% \subsubsection{TODO Annotations} |
| 147 |
% |
| 148 |
% \DescribeMacro{\todo} \marg{annotation} |
| 149 |
% |
| 150 |
% Marks an incompleted task in a different color in the document, and raises |
| 151 |
% a warning in the LaTeX log. |
| 152 |
% |
| 153 |
% \DescribeMacro{\TODO} |
| 154 |
% \TODO |
| 155 |
% |
| 156 |
% \DescribeMacro{\todolist} \marg{contents} |
| 157 |
% |
| 158 |
% Typesets \emph{contents} as a TODO annotation, wrapped in an |{enumerate}| |
| 159 |
% environment. |
| 160 |
% |
| 161 |
% \subsubsection{Mathematical Notation} |
| 162 |
% |
| 163 |
% This package also provides commands for notation common in quantum information. |
| 164 |
% |
| 165 |
% \DescribeMacro{\ii} |
| 166 |
% \DescribeMacro{\dd} |
| 167 |
% |
| 168 |
% These commands typeset the imaginary unit $\ii$ and differential element $\dd$, |
| 169 |
% respectively, in math roman. |
| 170 |
% |
| 171 |
% \DescribeMacro{\defeq} |
| 172 |
% |
| 173 |
% This command uses |\mathrel| to properly format the colon-equals operator |
| 174 |
% as a relation operator. |
| 175 |
% |
| 176 |
% \DescribeMacro{\expect} |
| 177 |
% Typesets the expectation operator $\expect$. |
| 178 |
% |
| 179 |
% \DescribeMacro{\id} |
| 180 |
% |
| 181 |
% \todo{The current implementation of id is to call openone, provided by revtex4-1, |
| 182 |
% and thus not available when used from documentation.} |
| 183 |
% |
| 184 |
% \DescribeMacro{\llbracket} |
| 185 |
% \DescribeMacro{\rrbracket} |
| 186 |
% |
| 187 |
% Typesets the double-square brackets commonly used to denote stabilizer code |
| 188 |
% properties, as in $\llbracket n, k, d \rrbracket$. These commands are provided |
| 189 |
% by |{stmaryrd}|, and are given a reasonable fallback if that package is not |
| 190 |
% available. |
| 191 |
% |
| 192 |
% |
| 193 |
% |
| 194 |
% \subsubsection{Affiliation Database} |
| 195 |
% |
| 196 |
% The \textsf{revquantum} package provides commands for quickly typesetting |
| 197 |
% affiliations, with an eye towards reducing copy-paste errors when authors have |
| 198 |
% a nontrivial set of shared affiliations. |
| 199 |
% |
| 200 |
% \DescribeMacro{\newaffil} \marg{shorthand} \marg{description} |
| 201 |
% |
| 202 |
% The workhorse of the affiliation database is the |\newaffil| command, |
| 203 |
% which defines a new command that expands to call the \textsf{revtex4-1} |
| 204 |
% |\affiliation| command. For instance, |\newaffil{UFooBar}{Bar, UFoo}| |
| 205 |
% defines a new command |\affilUFooBar| that expands to |
| 206 |
% |\affiliation{Bar, UFoo}|. |
| 207 |
% |
| 208 |
% So far, the following affiliation commands are provided: |
| 209 |
% |
| 210 |
% \DescribeMacro{\affilTODO} Special, marks that an affiliation is not |
| 211 |
% provided. |
| 212 |
% |
| 213 |
% |
| 214 |
% \DescribeMacro{\affilEQuSUSyd} Centre for Engineered Quantum Systems, University of Sydney. |
| 215 |
% |
| 216 |
% \DescribeMacro{\affilEQuSMacq} Centre for Engineered Quantum Systems, Macquarie University. |
| 217 |
% |
| 218 |
% \DescribeMacro{\affilUSydPhys} School of Physics, University of Sydney. |
| 219 |
% |
| 220 |
% \DescribeMacro{\affilIQC} Institute for Quantum Computing, University of Waterloo. |
| 221 |
% |
| 222 |
% \DescribeMacro{\affilUWPhys} Department of Physics, University of Waterloo. |
| 223 |
% |
| 224 |
% \DescribeMacro{\affilUWAMath} Department of Applied Mathematics, University of Waterloo. |
| 225 |
% |
| 226 |
% \DescribeMacro{\affilUWChem} Department of Chemistry, University of Waterloo. |
| 227 |
% |
| 228 |
% \DescribeMacro{\affilPI} Perimeter Institute for Theoretical Physics. |
| 229 |
% |
| 230 |
% \DescribeMacro{\affilCIFAR} Canadian Institute for Advanced Research. |
| 231 |
% |
| 232 |
% \DescribeMacro{\affilCQuIC} Center for Quantum Information and Control, University of New Mexico. |
| 233 |
% |
| 234 |
% \DescribeMacro{\affilIBMTJW} IBM T. J. Watson Research Center. |
| 235 |
% |
| 236 |
% |
| 237 |
% \subsubsection{Internal-Use Commands} |
| 238 |
% |
| 239 |
% \DescribeMacro{\booloption} |
| 240 |
% \DescribeMacro{\newnew} |
| 241 |
% |
| 242 |
% These commands are used internally by \textsf{revquantum} to define |
| 243 |
% new boolean package options, and to declare new kinds of |\newcommand| |
| 244 |
% commands. For example, |\newnew| is used to define |\newoperator|, |
| 245 |
% which in turn defines new commands for named mathematical operators (e.g. $\Tr$). |
| 246 |
% |
| 247 |
% \DescribeMacro{\sectionautorefname} |
| 248 |
% \DescribeMacro{\algorithmautorefname} |
| 249 |
% \DescribeMacro{\equationautorefname} |
| 250 |
% \DescribeMacro{\lemmaautorefname} |
| 251 |
% |
| 252 |
% These commands configure \textsf{hyperref}'s \texttt{autoref} command |
| 253 |
% for use with \textsf{revtex4-1}, so that \texttt{autoref} correctly |
| 254 |
% describes Section, Algorithm, and Lemma, and also follows the standard |
| 255 |
% notation for equation references. |
| 256 |
% |
| 257 |
% \DescribeMacro{\boolean{@xetex}} |
| 258 |
% |
| 259 |
% This boolean variable uses \textsf{iftex} to check if XeTeX is installed. |
| 260 |
% If \textsf{iftex} is not available, then we assume plain LaTeX. |
| 261 |
% |
| 262 |
% \subsection{New Colors} |
| 263 |
% |
| 264 |
% The \textsf{revquantum} package also provides a color palette |
| 265 |
% that is safe for colorblind readers and for printing, the |
| 266 |
% \href{http://jfly.iam.u-tokyo.ac.jp/color/}{Color Universal |
| 267 |
% Design} palette of Okabe and Ito. |
| 268 |
% |
| 269 |
% \DescribeColor{cud-black} |
| 270 |
% \DescribeColor{cud-orange} |
| 271 |
% \DescribeColor{cud-sky-blue} |
| 272 |
% \DescribeColor{cud-bluish-green} |
| 273 |
% \DescribeColor{cud-yellow} |
| 274 |
% \DescribeColor{cud-blue} |
| 275 |
% \DescribeColor{cud-vermillion} |
| 276 |
% \DescribeColor{cud-reddish-purple} |
| 277 |
% |
| 278 |
% These colors are defined as \textsf{xcolor} color names, such that they |
| 279 |
% can be used in all packages which depend on \textsf{xcolor}. In particular, |
| 280 |
% CUD colors can be directly used from \textsf{tikz}. To use with \textsf{tikz}, |
| 281 |
% however, \textsf{revquantum} must be loaded \emph{after} \textsf{tikz}. |
| 282 |
% |
| 283 |
% \StopEventually{} |
| 284 |
% |
| 285 |
% \section{Implementation} |
| 286 |
% |
| 287 |
% \iffalse |
| 288 |
%<*package> |
| 289 |
% \fi |
| 290 |
% |
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
% \begin{macrocode} |
| 295 |
|
| 296 |
\usepackage{ifthen} |
| 297 |
|
| 298 |
% \end{macrocode} |
| 299 |
|
| 300 |
% \subsection{XeTeX Detection} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 301 |
|
| 302 |
% We make a new boolean variable to track if XeTeX is being used. |
| 303 |
|
| 304 |
% \begin{macrocode} |
| 305 |
|
| 306 |
\newboolean{@xetex} |
| 307 |
\setboolean{@xetex}{false} |
| 308 |
\IfFileExists{iftex.sty}{ |
| 309 |
\wlog{[INFO] iftex loaded} |
| 310 |
\usepackage{iftex} |
| 311 |
}{ |
| 312 |
\newif\ifXeTeX |
| 313 |
\XeTeXfalse |
| 314 |
} |
| 315 |
\ifXeTeX |
| 316 |
\wlog{[INFO] Using XeTeX} |
| 317 |
\setboolean{@xetex}{true} |
| 318 |
\else |
| 319 |
\setboolean{@xetex}{false} |
| 320 |
\fi |
| 321 |
|
| 322 |
% \end{macrocode} |
| 323 |
|
| 324 |
|
| 325 |
% \subsection{Notation} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 326 |
% |
| 327 |
% |
| 328 |
% \begin{macro}{\newnew} |
| 329 |
% \begin{macrocode} |
| 330 |
\newcommand{\newnew}[2]{ |
| 331 |
\expandafter\newcommand\csname new#1\endcsname[1]{ |
| 332 |
\expandafter\newcommand\csname ##1\endcsname{#2{##1}} |
| 333 |
} |
| 334 |
} |
| 335 |
% \end{macrocode} |
| 336 |
% \end{macro} |
| 337 |
% |
| 338 |
% \begin{macrocode} |
| 339 |
\newnew{operator}{\operatorname} |
| 340 |
\newnew{rm}{\mathrm} |
| 341 |
|
| 342 |
\newoperator{Tr} |
| 343 |
\newoperator{Cov} |
| 344 |
\newoperator{supp} |
| 345 |
\newoperator{diag} |
| 346 |
\newoperator{rank} |
| 347 |
|
| 348 |
% \end{macrocode} |
| 349 |
% |
| 350 |
% \begin{macro}{\ii} |
| 351 |
% \begin{macrocode} |
| 352 |
\newcommand{\ii}{\mathrm{i}} % Outside what newnew currently supports. |
| 353 |
% \end{macrocode} |
| 354 |
% \end{macro} |
| 355 |
% |
| 356 |
% |
| 357 |
% \begin{macro}{\dd} |
| 358 |
% \begin{macrocode} |
| 359 |
\newcommand{\dd}{\mathrm{d}} % Outside what newnew currently supports. |
| 360 |
% \end{macrocode} |
| 361 |
% \end{macro} |
| 362 |
% |
| 363 |
% \begin{macrocode} |
| 364 |
|
| 365 |
\newrm{e} |
| 366 |
\newrm{TVD} |
| 367 |
\newrm{T} |
| 368 |
|
| 369 |
% \end{macrocode} |
| 370 |
% |
| 371 |
% \begin{macro}{\defeq} |
| 372 |
% \begin{macrocode} |
| 373 |
\newcommand{\defeq}{\mathrel{:=}} |
| 374 |
% \end{macrocode} |
| 375 |
% \end{macro} |
| 376 |
% |
| 377 |
% |
| 378 |
% \begin{macro}{\expect} |
| 379 |
% \begin{macrocode} |
| 380 |
\newcommand{\expect}{\mathbb{E}} |
| 381 |
% \end{macrocode} |
| 382 |
% \end{macro} |
| 383 |
% |
| 384 |
% |
| 385 |
% \begin{macro}{\id} |
| 386 |
% \begin{macrocode} |
| 387 |
\newcommand{\id}{\openone} |
| 388 |
% \end{macrocode} |
| 389 |
% \end{macro} |
| 390 |
% |
| 391 |
% \begin{macrocode} |
| 392 |
|
| 393 |
% \end{macrocode} |
| 394 |
|
| 395 |
% We want to only conditionally use |{stmaryrd}| if it's available, and |
| 396 |
% otherwise, hack up a few commands from that package. |
| 397 |
% |
| 398 |
% \begin{macrocode} |
| 399 |
\IfFileExists{stmaryrd.sty}{ |
| 400 |
\RequirePackage{stmaryrd} |
| 401 |
}{ |
| 402 |
\PackageWarning{revquantum}{ |
| 403 |
The stmaryrd package is not available, |
| 404 |
so some commands (e.g.: double-brackets) will look wrong. |
| 405 |
} |
| 406 |
\newcommand{\llbracket}{[\!\!\hspace{1.5pt}[} |
| 407 |
\newcommand{\rrbracket}{]\!\!\hspace{1.5pt}]} |
| 408 |
} |
| 409 |
% \end{macrocode} |
| 410 |
|
| 411 |
|
| 412 |
% \subsection{Options Handling} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 413 |
|
| 414 |
% We will need to define a few options to make the package nicer to use. We do |
| 415 |
% so by making a new command, |\booloption| \marg{boolname} \marg{optionname} |
| 416 |
% \marg{default}. |
| 417 |
% \begin{macro}{\booloption} |
| 418 |
% \begin{macrocode} |
| 419 |
\newcommand{\booloption}[3]{ |
| 420 |
\newboolean{#1} |
| 421 |
\setboolean{#1}{#3} |
| 422 |
\ifthenelse{\equal{#3}{true}}{ |
| 423 |
% \end{macrocode} |
| 424 |
% Default is true, so we need a "no" option to |
| 425 |
% turn off the new boolean. |
| 426 |
% \begin{macrocode} |
| 427 |
\DeclareOption{no#2}{\setboolean{#1}{false}} |
| 428 |
}{ |
| 429 |
% \end{macrocode} |
| 430 |
% Default is false, so we need an option to turn |
| 431 |
% on the new boolean. |
| 432 |
% \begin{macrocode} |
| 433 |
\DeclareOption{#2}{\setboolean{#1}{true}} |
| 434 |
} |
| 435 |
} |
| 436 |
% \end{macrocode} |
| 437 |
% \end{macro} |
| 438 |
|
| 439 |
% We then use this new command to define the options for \textsf{revquantum}, |
| 440 |
% |final|, |pretty|, |uselistings|, |nobibtexhacks|, and |strict|. |
| 441 |
|
| 442 |
% \begin{macrocode} |
| 443 |
|
| 444 |
\booloption{@final}{final}{false} |
| 445 |
\booloption{@pretty}{pretty}{false} |
| 446 |
\booloption{@uselistings}{uselistings}{false} |
| 447 |
\booloption{@bibtexhacks}{bibtexhacks}{true} |
| 448 |
\booloption{@strict}{strict}{false} |
| 449 |
|
| 450 |
\ProcessOptions\relax |
| 451 |
|
| 452 |
% \end{macrocode} |
| 453 |
|
| 454 |
% For the |strict| option, we do one last thing and define a new macro that |
| 455 |
% either raises a warning or an option depending on whether |strict| has been |
| 456 |
% set as an option. |
| 457 |
|
| 458 |
% \begin{macro}{\rq@quasiwarn} |
| 459 |
% \begin{macrocode} |
| 460 |
\ifthenelse{\boolean{@strict}}{ |
| 461 |
\newcommand{\rq@quasiwarn}{ |
| 462 |
\PackageError{revquantum} |
| 463 |
} |
| 464 |
}{ |
| 465 |
\newcommand{\rq@quasiwarn}{ |
| 466 |
\PackageWarning{revquantum} |
| 467 |
} |
| 468 |
} |
| 469 |
% \end{macrocode} |
| 470 |
% \end{macro} |
| 471 |
|
| 472 |
% \subsection{Unforgivable BibTeX Hacks} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 473 |
|
| 474 |
% These hacks include the title of each reference in the BibTeX output by |
| 475 |
% redefining the part of \textsf{revtex4-1} on the fly which is responsible |
| 476 |
% for writing out the bibdata. Note that these hacks \emph{must} come before |
| 477 |
% importing packages, or else \textsf{revtex4-1} will have already written out |
| 478 |
% its control notes. |
| 479 |
|
| 480 |
% \begin{macrocode} |
| 481 |
|
| 482 |
\ifthenelse{\boolean{@bibtexhacks}}{\def\@bibdataout@aps{% |
| 483 |
\immediate\write\@bibdataout{% |
| 484 |
@CONTROL{% |
| 485 |
apsrev41Control,author="08",editor="1",pages="0",title="0",year="1",eprint="1"% |
| 486 |
}% |
| 487 |
}% |
| 488 |
\if@filesw |
| 489 |
\immediate\write\@auxout{\string\citation{apsrev41Control}}% |
| 490 |
\fi |
| 491 |
}}{} |
| 492 |
|
| 493 |
% \end{macrocode} |
| 494 |
|
| 495 |
% \subsection{Imports} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 496 |
|
| 497 |
% Here, we import a few other useful packages and configure them according to |
| 498 |
% the options passed by the user. In handling the fonts specified by |
| 499 |
% |[pretty]|, we must be careful to do so in a way that is supported by |
| 500 |
% XeTeX. |
| 501 |
% Note that we only load \textsf{color} if |
| 502 |
% neither \textsf{tikz} nor \textsf{xcolor} have already been imported, and if |
| 503 |
% we are not using \textsf{listings}. In the latter case, we will load |
| 504 |
% \textsf{xcolor} instead so that we can make \textsf{listings} play nicer with |
| 505 |
% our own custom palette. |
| 506 |
% Also of |
| 507 |
% note is that we do not import \textsf{hyperref} yet, as it must go last to avoid duplicating |
| 508 |
% reference names. |
| 509 |
|
| 510 |
% \begin{macrocode} |
| 511 |
|
| 512 |
\RequirePackage{amsmath} |
| 513 |
\RequirePackage{amsfonts} |
| 514 |
\RequirePackage{amsthm} |
| 515 |
\RequirePackage{amssymb} |
| 516 |
\RequirePackage{amsbsy} |
| 517 |
\@ifpackageloaded{tikz}{}{% |
| 518 |
\@ifpackageloaded{xcolor}{}{% |
| 519 |
\ifthenelse{\boolean{@uselistings}}{}{% |
| 520 |
\RequirePackage[usenames,dvipsnames]{color}% |
| 521 |
}% |
| 522 |
}% |
| 523 |
\AtBeginDocument{% |
| 524 |
\@ifpackageloaded{tikz}{% |
| 525 |
\rq@quasiwarn{tikz loaded, but after revquantum. This may not work.}% |
| 526 |
}% |
| 527 |
}% |
| 528 |
} |
| 529 |
\RequirePackage{braket} |
| 530 |
\RequirePackage{graphicx} |
| 531 |
\RequirePackage[english]{babel} |
| 532 |
\ifthenelse{\boolean{@pretty}}{ |
| 533 |
\ifthenelse{\boolean{@xetex}}{ |
| 534 |
% http://tex.stackexchange.com/a/50593 |
| 535 |
\usepackage{fontspec} |
| 536 |
\usepackage{mathpazo} |
| 537 |
\setmainfont |
| 538 |
[ BoldFont = texgyrepagella-bold.otf , |
| 539 |
ItalicFont = texgyrepagella-italic.otf , |
| 540 |
BoldItalicFont = texgyrepagella-bolditalic.otf ] |
| 541 |
{texgyrepagella-regular.otf} |
| 542 |
}{ |
| 543 |
\RequirePackage{mathpazo} |
| 544 |
} |
| 545 |
}{} |
| 546 |
\ifthenelse{\boolean{@uselistings}}{ |
| 547 |
\RequirePackage{xcolor} |
| 548 |
\RequirePackage{listings} |
| 549 |
\RequirePackage{textcomp} % Make sure we have a ` for writing Mathematica. |
| 550 |
}{} |
| 551 |
\ifthenelse{\boolean{@bibtexhacks}}{ |
| 552 |
\RequirePackage{letltxmacro} |
| 553 |
\RequirePackage{etoolbox} |
| 554 |
}{} |
| 555 |
% \end{macrocode} |
| 556 |
|
| 557 |
% \subsubsection{Theorem Environments} |
| 558 |
|
| 559 |
% \begin{macrocode} |
| 560 |
|
| 561 |
\newtheorem{theorem}{Theorem} |
| 562 |
\newtheorem{lemma}{Lemma} |
| 563 |
|
| 564 |
% \end{macrocode} |
| 565 |
|
| 566 |
% \subsubsection{\textsf{algorithm} and \textsf{algpseudocode} Setup} |
| 567 |
|
| 568 |
% \begin{macrocode} |
| 569 |
|
| 570 |
\RequirePackage{algorithm} |
| 571 |
\RequirePackage{algpseudocode} |
| 572 |
\renewcommand{\algorithmicrequire}{\textbf{Input:}} |
| 573 |
\renewcommand{\algorithmicensure}{\textbf{Output:}} |
| 574 |
\newcommand{\inlinecomment}[1]{\Comment {\footnotesize #1} \normalsize} |
| 575 |
\newcommand{\linecomment}[1]{\State \(\triangleright\) {\footnotesize #1} \normalsize} |
| 576 |
|
| 577 |
% \end{macrocode} |
| 578 |
|
| 579 |
% \subsubsection{\textsf{listings} Setup} |
| 580 |
|
| 581 |
% Here, we provide special support for scientific languages like Python and Mathematica, |
| 582 |
% as well as for legacy environments. This support consists of configuring escapes, |
| 583 |
% quoting, providing additional keywords, etc. |
| 584 |
|
| 585 |
% \begin{macrocode} |
| 586 |
|
| 587 |
\ifthenelse{\boolean{@uselistings}}{ |
| 588 |
\definecolor{comment-color}{gray}{0.5} |
| 589 |
|
| 590 |
\lstset{ |
| 591 |
basicstyle=\footnotesize, |
| 592 |
commentstyle=\color{comment-color}, |
| 593 |
frame=lines, |
| 594 |
gobble=4, |
| 595 |
numbers=left, |
| 596 |
numberstyle=\tiny, stepnumber=5, |
| 597 |
numbersep=5pt, |
| 598 |
keywordstyle=\color{cud-bluish-green!85!black}\bfseries, |
| 599 |
keywordstyle={[2]\color{cud-sky-blue!75!black}}, |
| 600 |
emphstyle=\color{cud-vermillion} |
| 601 |
} |
| 602 |
|
| 603 |
\ifthenelse{\boolean{@xetex}}{ |
| 604 |
\RequirePackage{sourcecodepro} |
| 605 |
\lstset{basicstyle=\footnotesize\sourcecodepro} |
| 606 |
}{} |
| 607 |
|
| 608 |
\lstdefinestyle{matlab}{ |
| 609 |
language=MATLAB, |
| 610 |
mathescape=true |
| 611 |
} |
| 612 |
|
| 613 |
\lstdefinestyle{python}{ |
| 614 |
language=Python, |
| 615 |
mathescape=true, |
| 616 |
showstringspaces=false, |
| 617 |
morekeywords={as,async,await} |
| 618 |
} |
| 619 |
|
| 620 |
\lstdefinestyle{mathematica}{ |
| 621 |
language=Mathematica, |
| 622 |
upquote=true, % Needed to deal with the context symbol `.' |
| 623 |
literate= |
| 624 |
{->}{$\to$}1 |
| 625 |
{!=}{$\neq$}1 |
| 626 |
{\\[DoubleStruckOne]}{${\id}$}1 |
| 627 |
{\\[Sigma]}{$\sigma$}1 |
| 628 |
{(x)}{$\otimes$}1 % CG: I have the distinct impression this will break. Badly. |
| 629 |
} |
| 630 |
}{} |
| 631 |
|
| 632 |
% \end{macrocode} |
| 633 |
|
| 634 |
% \subsection{Import Warnings} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 635 |
|
| 636 |
% The following command will cause a warning to be emitted if the package |
| 637 |
% named by its argument is loaded. To make robust against the order in which |
| 638 |
% packages are loaded, all such logic happens at |\begin{document}|. This |
| 639 |
% code is adapted from the solution provided by Martin Scharrer at |
| 640 |
% \url{http://tex.stackexchange.com/a/16200/615}. |
| 641 |
|
| 642 |
% \begin{macro}{\rq@warnpackage} |
| 643 |
% \begin{macrocode} |
| 644 |
\newcommand{\rq@warnpackage}[1]{ |
| 645 |
\AtBeginDocument{% |
| 646 |
\@ifpackageloaded{#1}{% |
| 647 |
\rq@quasiwarn{The #1 package is known to be incompatible with revtex4-1. You may encounter problems using this package.}% |
| 648 |
}{} |
| 649 |
} |
| 650 |
} |
| 651 |
% \end{macrocode} |
| 652 |
% \end{macro} |
| 653 |
|
| 654 |
% With this command in place, we can now issue specific warnings for individual |
| 655 |
% ``bad'' packages. |
| 656 |
|
| 657 |
% \begin{macrocode} |
| 658 |
\rq@warnpackage{subcaption} |
| 659 |
% \end{macrocode} |
| 660 |
|
| 661 |
|
| 662 |
% \subsection{Slightly More Forgivable BibTeX Hacks} %%%%%%%%%%%%%%%%%%%%%%%%% |
| 663 |
|
| 664 |
% Next, we include \href{http://tex.stackexchange.com/a/199299/615}{a solution |
| 665 |
% suggested by egreg} for a rather annoying |{revtex4-1}| bug. In particular, |
| 666 |
% we will set up |language={en}| as an alias for |language={english}|, so that |
| 667 |
% |{revtex4-1}| will no longer raise |{babel}| errors for the undefined language. |
| 668 |
% As with our unforgivable hacks, we will guard the forgivable hacks with |
| 669 |
% the |[nobibtexhacks]| option. |
| 670 |
|
| 671 |
% \begin{macro}{\ORIGselectlanguage} |
| 672 |
% \begin{macrocode} |
| 673 |
|
| 674 |
\ifthenelse{\boolean{@bibtexhacks}}{ |
| 675 |
\LetLtxMacro{\ORIGselectlanguage}{\selectlanguage} |
| 676 |
\DeclareRobustCommand{\selectlanguage}[1]{% |
| 677 |
\@ifundefined{alias@\string#1} |
| 678 |
{\ORIGselectlanguage{#1}} |
| 679 |
{\begingroup\edef\x{\endgroup |
| 680 |
\noexpand\ORIGselectlanguage{\@nameuse{alias@#1}}}\x}% |
| 681 |
} |
| 682 |
}{} |
| 683 |
|
| 684 |
% \end{macrocode} |
| 685 |
% \end{macro} |
| 686 |
|
| 687 |
% \begin{macro}{\definelanguagealias} |
| 688 |
% \begin{macrocode} |
| 689 |
|
| 690 |
\newcommand{\definelanguagealias}[2]{% |
| 691 |
\@namedef{alias@#1}{#2}% |
| 692 |
} |
| 693 |
|
| 694 |
% \end{macrocode} |
| 695 |
% \end{macro} |
| 696 |
|
| 697 |
% \begin{macrocode} |
| 698 |
|
| 699 |
\definelanguagealias{en}{english} |
| 700 |
\definelanguagealias{EN}{english} |
| 701 |
\definelanguagealias{English}{english} |
| 702 |
|
| 703 |
% \end{macrocode} |
| 704 |
|
| 705 |
% We will also redefine |\doibase| to eat any newlines following it, and to |
| 706 |
% prefer HTTPS to HTTP. This will fix a rather annoying bug where line breaks |
| 707 |
% in the *.bbl source can introduce extraneous spaces into the target of |
| 708 |
% each citation's |\href|. |
| 709 |
|
| 710 |
% \begin{macro}{\doibase} |
| 711 |
% \begin{macrocode} |
| 712 |
|
| 713 |
\ifthenelse{\boolean{@bibtexhacks}}{ |
| 714 |
% Ensure that the \doibase command is defined, just in case. |
| 715 |
\providecommand{\doibase}{} |
| 716 |
\renewcommand{\doibase}[1]{https://dx.doi.org/\ifdefempty{#1}{}{#1}} |
| 717 |
}{} |
| 718 |
|
| 719 |
% \end{macrocode} |
| 720 |
% \end{macro} |
| 721 |
|
| 722 |
|
| 723 |
% \subsection{TODO Support} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 724 |
|
| 725 |
% These commands provide a way of marking items as needing to be done before |
| 726 |
% the final version (denoted by the |final| package option). |
| 727 |
|
| 728 |
% \begin{macro}{\todo} |
| 729 |
% \begin{macrocode} |
| 730 |
|
| 731 |
\ifthenelse{\boolean{@final}}{ |
| 732 |
\newcommand{\todo}[1]{% |
| 733 |
\PackageError{revquantum}{Unaddressed TODO}% |
| 734 |
\rq@todo{#1}% |
| 735 |
} |
| 736 |
}{ |
| 737 |
\newcommand{\todo}[1]{% |
| 738 |
\PackageWarning{revquantum}{Unaddressed TODO}% |
| 739 |
\rq@todo{#1}% |
| 740 |
} |
| 741 |
} |
| 742 |
|
| 743 |
% \end{macrocode} |
| 744 |
% \end{macro} |
| 745 |
% |
| 746 |
% We also define a |\citeneed| command for the special case of a missing citation. |
| 747 |
% As per Steve Flammia's suggestion, this is formatted in analogy to the infamous |
| 748 |
% Wikipedia annotation. |
| 749 |
% |
| 750 |
% \begin{macro}{\citeneed} |
| 751 |
% \begin{macrocode} |
| 752 |
\ifthenelse{\boolean{@final}}{ |
| 753 |
\newcommand{\citeneed}{% |
| 754 |
\PackageError{revquantum}{citation needed}% |
| 755 |
\rq@todo{[citation needed]}% |
| 756 |
} |
| 757 |
}{ |
| 758 |
\newcommand{\citeneed}{% |
| 759 |
\PackageWarning{revquantum}{citation needed}% |
| 760 |
\rq@todo{[citation needed]}% |
| 761 |
} |
| 762 |
} |
| 763 |
% \end{macrocode} |
| 764 |
% \end{macro} |
| 765 |
% |
| 766 |
% Both of these macros are based on the |\rq@todo| macro, which performs the |
| 767 |
% formatting for TODOs. |
| 768 |
% |
| 769 |
% \begin{macro}{\rq@todo} |
| 770 |
% \begin{macrocode} |
| 771 |
\newcommand{\rq@todo}[1]{% |
| 772 |
{\color{magenta} #1}% |
| 773 |
} |
| 774 |
% \end{macrocode} |
| 775 |
% \end{macro} |
| 776 |
% |
| 777 |
% We also provide a few other special cases below. |
| 778 |
% |
| 779 |
% \begin{macro}{\TODO} |
| 780 |
% \begin{macrocode} |
| 781 |
\newcommand{\TODO}{\todo{TODO}} |
| 782 |
% \end{macrocode} |
| 783 |
% \end{macro} |
| 784 |
% |
| 785 |
% |
| 786 |
% \begin{macro}{\todolist} |
| 787 |
% \begin{macrocode} |
| 788 |
\newcommand{\todolist}[1]{\todo{ |
| 789 |
\begin{itemize} |
| 790 |
#1 |
| 791 |
\end{itemize} |
| 792 |
}} |
| 793 |
|
| 794 |
% \end{macrocode} |
| 795 |
% \end{macro} |
| 796 |
|
| 797 |
% \subsection{Color Universal Design} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 798 |
|
| 799 |
% \begin{macrocode} |
| 800 |
\definecolor{cud-black} {RGB}{0,0,0} |
| 801 |
\definecolor{cud-orange} {RGB}{230,159,0} |
| 802 |
\definecolor{cud-sky-blue} {RGB}{86,180,233} |
| 803 |
\definecolor{cud-bluish-green} {RGB}{0,158,115} |
| 804 |
\definecolor{cud-yellow} {RGB}{240,228,66} |
| 805 |
\definecolor{cud-blue} {RGB}{0,114,178} |
| 806 |
\definecolor{cud-vermillion} {RGB}{213,94,0} |
| 807 |
\definecolor{cud-reddish-purple}{RGB}{204,121,167} |
| 808 |
% \end{macrocode} |
| 809 |
|
| 810 |
% \subsection{Affiliation Database} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 811 |
% |
| 812 |
% \begin{macro}{\newaffil} |
| 813 |
% \begin{macrocode} |
| 814 |
\newcommand{\newaffil}[2]{ |
| 815 |
\expandafter\newcommand\csname affil#1\endcsname{ |
| 816 |
\affiliation{ |
| 817 |
#2 |
| 818 |
} |
| 819 |
} |
| 820 |
} |
| 821 |
% \end{macrocode} |
| 822 |
% \end{macro} |
| 823 |
% |
| 824 |
% \subsubsection{General Affiliations} |
| 825 |
% |
| 826 |
% \begin{macrocode} |
| 827 |
|
| 828 |
\newaffil{TODO}{\TODO} |
| 829 |
|
| 830 |
% \end{macrocode} |
| 831 |
% |
| 832 |
% \subsubsection{Australia} |
| 833 |
% |
| 834 |
% \begin{macrocode} |
| 835 |
|
| 836 |
\newaffil{EQuSUSyd}{ |
| 837 |
Centre for Engineered Quantum Systems, |
| 838 |
University of Sydney, |
| 839 |
Sydney, NSW, Australia |
| 840 |
} |
| 841 |
\newaffil{EQuSMacq}{ |
| 842 |
Centre for Engineered Quantum Systems, |
| 843 |
Macquarie University, |
| 844 |
Sydney, NSW, Australia |
| 845 |
} |
| 846 |
\newaffil{USydPhys}{ |
| 847 |
School of Physics, |
| 848 |
University of Sydney, |
| 849 |
Sydney, NSW, Australia |
| 850 |
} |
| 851 |
|
| 852 |
% \end{macrocode} |
| 853 |
% |
| 854 |
% \subsubsection{Canada} |
| 855 |
% |
| 856 |
% \begin{macrocode} |
| 857 |
|
| 858 |
\newaffil{IQC}{ |
| 859 |
Institute for Quantum Computing, |
| 860 |
University of Waterloo, |
| 861 |
Waterloo, ON, Canada |
| 862 |
} |
| 863 |
\newaffil{UWPhys}{ |
| 864 |
Department of Physics, |
| 865 |
University of Waterloo, |
| 866 |
Waterloo, ON, Canada |
| 867 |
} |
| 868 |
\newaffil{UWAMath}{ |
| 869 |
Department of Applied Mathematics, |
| 870 |
University of Waterloo, |
| 871 |
Waterloo, ON, Canada |
| 872 |
} |
| 873 |
\newaffil{UWChem}{ |
| 874 |
Department of Chemistry, |
| 875 |
University of Waterloo, |
| 876 |
Waterloo, ON, Canada |
| 877 |
} |
| 878 |
\newaffil{PI}{ |
| 879 |
Perimeter Institute for Theoretical Physics, |
| 880 |
31 Caroline St. N, |
| 881 |
Waterloo, Ontario, Canada N2L 2Y5 |
| 882 |
} |
| 883 |
\newaffil{CIFAR}{ |
| 884 |
Canadian Institute for Advanced Research, |
| 885 |
Toronto, ON, Canada |
| 886 |
} |
| 887 |
|
| 888 |
% \end{macrocode} |
| 889 |
% |
| 890 |
% \subsubsection{United States} |
| 891 |
% |
| 892 |
% \begin{macrocode} |
| 893 |
|
| 894 |
\newaffil{CQuIC}{ |
| 895 |
Center for Quantum Information and Control, |
| 896 |
University of New Mexico, |
| 897 |
Albuquerque, NM 87131-0001, USA |
| 898 |
} |
| 899 |
\newaffil{IBMTJW}{ |
| 900 |
IBM T. J. Watson Research Center, |
| 901 |
Yorktown Heights, New York 10598, USA |
| 902 |
} |
| 903 |
|
| 904 |
|
| 905 |
% \end{macrocode} |
| 906 |
|
| 907 |
|
| 908 |
% \subsection{\textsf{hyperref} Setup} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 909 |
|
| 910 |
% Finally, we load \textsf{hyperref} separately so that it can go last. |
| 911 |
|
| 912 |
% Get rid of \textsf{hyperref}'s ugly boxes. |
| 913 |
%From:http://tex.stackexchange.com/a/51349 |
| 914 |
% \begin{macrocode} |
| 915 |
|
| 916 |
\RequirePackage[breaklinks=true]{hyperref} |
| 917 |
|
| 918 |
\hypersetup{ |
| 919 |
colorlinks = true, %Colours links instead of ugly boxes |
| 920 |
urlcolor = blue, %Colour for external hyperlinks |
| 921 |
linkcolor = blue, %Colour of internal links |
| 922 |
citecolor = red %Colour of citations |
| 923 |
} |
| 924 |
|
| 925 |
% \end{macrocode} |
| 926 |
|
| 927 |
|
| 928 |
% \subsubsection{\textsf{autoref} Setup} |
| 929 |
% We must declare our \textsf{autoref} configuration at the beginning |
| 930 |
% of the document to keep other packages from clobbering it. |
| 931 |
|
| 932 |
% \begin{macro}{\sectionautorefname} |
| 933 |
% \begin{macrocode} |
| 934 |
\AtBeginDocument{% |
| 935 |
\def\sectionautorefname{Section}% |
| 936 |
} |
| 937 |
% \end{macrocode} |
| 938 |
% \end{macro} |
| 939 |
% |
| 940 |
% |
| 941 |
% \begin{macro}{\algorithmautorefname} |
| 942 |
% \begin{macrocode} |
| 943 |
\AtBeginDocument{% |
| 944 |
\def\algorithmautorefname{Algorithm}% |
| 945 |
} |
| 946 |
% \end{macrocode} |
| 947 |
% \end{macro} |
| 948 |
% |
| 949 |
% |
| 950 |
% \begin{macro}{\equationautorefname} |
| 951 |
% See http://tex.stackexchange.com/a/66150. |
| 952 |
% \begin{macrocode} |
| 953 |
\AtBeginDocument{% |
| 954 |
\def\equationautorefname~#1\null{(#1)\null}% |
| 955 |
} |
| 956 |
% \end{macrocode} |
| 957 |
% \end{macro} |
| 958 |
% |
| 959 |
% |
| 960 |
% \begin{macro}{\lemmaautorefname} |
| 961 |
% \begin{macrocode} |
| 962 |
\AtBeginDocument{% |
| 963 |
\newcommand{\lemmaautorefname}{Lemma}% |
| 964 |
} |
| 965 |
% \end{macrocode} |
| 966 |
% \end{macro} |
| 967 |
% |
| 968 |
% \iffalse |
| 969 |
%</package> |
| 970 |
% \fi |
| 971 |
% |
| 972 |
% \Finale |
| 973 |
\endinput |