From: Michael Orlitzky Date: Sun, 15 Sep 2019 20:16:08 +0000 (-0400) Subject: Wrap all mjotex files in conditionals to prevent double-loading. X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mjotex.git;a=commitdiff_plain;h=fc7cfa7f3d02715cb09eae2e1c6bc501dc2d8d50 Wrap all mjotex files in conditionals to prevent double-loading. I plan to start putting glossary entries in mjo-common, and that reveals a problem: some files (i.e. mjo-common.tex) get loaded more than once. And there's not always a way to ignore the duplicate definitions. So, finally, after avoiding it for as long as possible, I've wrapped everything in "ifx" tests that check the value of a macro I define (just like #ifdef HAVE_FOO in C). The \ifx test was chosen over of \ifdefined (which is an e-TeX primitive) because it makes the conditional simpler; we don't need to have an empty "if" block. Of course, testing against \undefined only works if \undefined is... undefined. But theoretically someone could probably redefine \ifdefined, too. Whatever. I can change it if it ever causes a problem. --- diff --git a/mjo-algebra.tex b/mjo-algebra.tex index 010ab05..8852345 100644 --- a/mjo-algebra.tex +++ b/mjo-algebra.tex @@ -1,6 +1,9 @@ % % Abstract algebraic structures. % +\ifx\havemjoalgebra\undefined +\def\havemjoalgebra{1} + % Needed for \operatorname. \usepackage{amsopn} @@ -15,3 +18,6 @@ % coefficients is the first argument and whose indeterminates (a % comma-separated list) are the second argumnt. \newcommand*{\polyring}[2]{{#1}\left[{#2}\right]} + + +\fi diff --git a/mjo-algorithm.tex b/mjo-algorithm.tex index 25b396c..cef0e89 100644 --- a/mjo-algorithm.tex +++ b/mjo-algorithm.tex @@ -1,6 +1,9 @@ % % Good looking algorithm environments. % +\ifx\havemjoalgorithm\undefined +\def\havemjoalgorithm{1} + % algorithmicx, for the, uh, algorithms. \usepackage{algpseudocode} @@ -14,3 +17,6 @@ \usepackage{algorithm} \algrenewcommand{\algorithmiccomment}[1]{/\!/ {#1}} + + +\fi diff --git a/mjo-arrow.tex b/mjo-arrow.tex index 8b44ded..4dd5f88 100644 --- a/mjo-arrow.tex +++ b/mjo-arrow.tex @@ -1,6 +1,9 @@ % % Things dealing with arrows in a category. Or functions, basically. % +\ifx\havemjoarrow\undefined +\def\havemjoarrow{1} + \input{mjo-common} @@ -16,3 +19,6 @@ % The preimage of the second argument (a set) under the first (a function). \newcommand*{\preimage}[2]{ #1^{-1}\of{#2} } + + +\fi diff --git a/mjo-calculus.tex b/mjo-calculus.tex index c162d34..fbc9bfe 100644 --- a/mjo-calculus.tex +++ b/mjo-calculus.tex @@ -1,3 +1,10 @@ +\ifx\havemjocalculus\undefined +\def\havemjocalculus{1} + + % The gradient of its argument, which should be a function from R^n to % R (or maybe some other field). \newcommand*{\gradient}[1]{ \nabla{{#1}} } + + +\fi diff --git a/mjo-common.tex b/mjo-common.tex index 7b6280b..8ead123 100644 --- a/mjo-common.tex +++ b/mjo-common.tex @@ -1,6 +1,9 @@ % % Only the most commonly-used macros. Needed by everything else. % +\ifx\havemjocommon\undefined +\def\havemjocommon{1} + % Needed for \mathbb. \usepackage{amsfonts} @@ -132,3 +135,6 @@ \providecommand*{\intervaloc}[2]{ \left({#1},{#2}\right] } % open-closed \providecommand*{\intervalco}[2]{ \left[{#1},{#2}\right) } % closed-open \providecommand*{\intervalcc}[2]{ \left[{#1},{#2}\right] } % closed-closed + + +\fi diff --git a/mjo-complex.tex b/mjo-complex.tex index 23d440f..25c6872 100644 --- a/mjo-complex.tex +++ b/mjo-complex.tex @@ -1,4 +1,10 @@ % Operations used when dealing with complex numbers. +\ifx\havemjocomplex\undefined +\def\havemjocomplex{1} + % The complex conjugate of its argument. \providecommand*{\compconj}[1]{ \overline{#1} } + + +\fi diff --git a/mjo-cone.tex b/mjo-cone.tex index dad432e..35edc8e 100644 --- a/mjo-cone.tex +++ b/mjo-cone.tex @@ -4,6 +4,9 @@ % The operator families Z(K), LL(K), etc. can technically be defined on % sets other than cones, but nobody cares. % +\ifx\havemjocone\undefined +\def\havemjocone{1} + \usepackage{amssymb} % \succcurlyeq and friends @@ -67,3 +70,6 @@ \newcommand*{\gtcone}{\succ} \newcommand*{\lecone}{\preccurlyeq} \newcommand*{\ltcone}{\prec} + + +\fi diff --git a/mjo-convex.tex b/mjo-convex.tex index a51011f..dfc2822 100644 --- a/mjo-convex.tex +++ b/mjo-convex.tex @@ -1,6 +1,9 @@ % % Operations that usually appear in convex optimization. % +\ifx\havemjoconvex\undefined +\def\havemjoconvex{1} + % Needed for \operatorname. \usepackage{amsopn} @@ -28,3 +31,6 @@ % The "is a face of" and "is a proper face of" relations. \newcommand*{\faceof}{ \trianglelefteq } \newcommand*{\properfaceof}{ \triangleleft } + + +\fi diff --git a/mjo-eja.tex b/mjo-eja.tex index 0408bea..b6974be 100644 --- a/mjo-eja.tex +++ b/mjo-eja.tex @@ -1,6 +1,9 @@ % % Euclidean Jordan algebras. % +\ifx\havemjoeja\undefined +\def\havemjoeja{1} + % The jordan product of its two arguments. % @@ -18,3 +21,6 @@ % into its own LaTeX file; we probably wouldn't want to use \circ as % a (bilinear) algebra multiplication in any other context. \newcommand*{\jp}[2]{{#1} \circ {#2}} + + +\fi diff --git a/mjo-font.tex b/mjo-font.tex index fda3c08..c6675f3 100644 --- a/mjo-font.tex +++ b/mjo-font.tex @@ -1,6 +1,9 @@ % % Font handling that you probably want to use everywhere. % +\ifx\havemjofont\undefined +\def\havemjofont{1} + % Allow arbitrary font sizes (prevents pdflatex warnings). \usepackage{lmodern} @@ -11,3 +14,6 @@ % Grab the AMS fonts, too, for things like \mathbb. \usepackage{amsfonts} + + +\fi diff --git a/mjo-linear_algebra.tex b/mjo-linear_algebra.tex index 5c3f715..d423a43 100644 --- a/mjo-linear_algebra.tex +++ b/mjo-linear_algebra.tex @@ -1,6 +1,9 @@ % % Standard operations from linear algebra. % +\ifx\havemjolinearalgebra\undefined +\def\havemjolinearalgebra{1} + % Needed for \lvert, \rVert, etc. and \operatorname. \usepackage{amsmath} @@ -99,3 +102,6 @@ % Now declare an orthogonal direct sum in terms of \oplusperp. \newcommand*{\directsumperp}[2]{ {#1}\oplusperp{#2} } + + +\fi diff --git a/mjo-listing.tex b/mjo-listing.tex index f733be6..f898aba 100644 --- a/mjo-listing.tex +++ b/mjo-listing.tex @@ -10,6 +10,10 @@ % x % \end{tcblisting} % +\ifx\havemjolisting\undefined +\def\havemjolisting{1} + + \usepackage{listings} \usepackage{tcolorbox} @@ -52,3 +56,6 @@ left=2em,% listing options={language=sage,style=sage},% listing file=sage_listings/#1.listing}} + + +\fi diff --git a/mjo-misc.tex b/mjo-misc.tex index 3d8a406..f73fe14 100644 --- a/mjo-misc.tex +++ b/mjo-misc.tex @@ -1,6 +1,9 @@ % % Things that fit absolutely nowhere else. % +\ifx\havemjomisc\undefined +\def\havemjomisc{1} + \usepackage{amsmath} @@ -8,3 +11,6 @@ % absolute value, and the meaning of card(X) is clear at once, so we % prefer the latter. \newcommand*{\card}[1]{ \operatorname{card} \of{{#1}} } + + +\fi diff --git a/mjo-proof_by_cases.tex b/mjo-proof_by_cases.tex index ae4b0fc..247d280 100644 --- a/mjo-proof_by_cases.tex +++ b/mjo-proof_by_cases.tex @@ -8,6 +8,9 @@ % % Case 2 (x < 0): derp. % +\ifx\havemjoproofbycases\undefined +\def\havemjoproofbycases{1} + % Used below to define pcases. The ``loadonly'' parameter prevents % a very bad interaction with the beamer document class. @@ -59,3 +62,6 @@ \def\thiscase{#1}% \item \hfill\par\vspace{\singleblskip} } + + +\fi diff --git a/mjo-theorem-star.tex b/mjo-theorem-star.tex index 7fd06e1..7a3ceba 100644 --- a/mjo-theorem-star.tex +++ b/mjo-theorem-star.tex @@ -1,6 +1,9 @@ % % Unnumbered versions of the mjo-theorem environments. % +\ifx\havemjotheoremstar\undefined +\def\havemjotheoremstar{1} + \usepackage{amsthm} @@ -17,3 +20,6 @@ \theoremstyle{remark} \newtheorem*{remark*}{Remark} + + +\fi diff --git a/mjo-theorem.tex b/mjo-theorem.tex index c11d56f..dc67f45 100644 --- a/mjo-theorem.tex +++ b/mjo-theorem.tex @@ -2,6 +2,9 @@ % The standard corollary, definition, theorem, etc. that we all define % in every single paper. % +\ifx\havemjotheorem\undefined +\def\havemjotheorem{1} + \usepackage{amsthm} @@ -18,3 +21,6 @@ \theoremstyle{remark} \newtheorem{remark}{Remark} + + +\fi diff --git a/mjo-topology.tex b/mjo-topology.tex index 885f339..c7f5037 100644 --- a/mjo-topology.tex +++ b/mjo-topology.tex @@ -1,6 +1,9 @@ % % Standard topological operations. % +\ifx\havemjotopology\undefined +\def\havemjotopology{1} + % Needed for \operatorname. \usepackage{amsopn} @@ -15,3 +18,6 @@ % And the ``boundary of'' operator. \newcommand*{\boundary}[1]{ \operatorname{bdy}\of{{#1}} } + + +\fi