From d6a9f13f45fead88404ee02cb446db2f3047eee8 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 7 Mar 2016 22:32:19 -0500 Subject: [PATCH] Initial commit of a big mess that will eventually be a library of LaTeX code. --- README | 26 +++++++++++++++ makefile | 74 ++++++++++++++++++++++++++++++++++++++++++ mjo-algorithms.tex | 14 ++++++++ mjo-common.tex | 21 ++++++++++++ mjo-cone.tex | 37 +++++++++++++++++++++ mjo-convex.tex | 23 +++++++++++++ mjo-fonts.tex | 10 ++++++ mjo-linear_algebra.tex | 38 ++++++++++++++++++++++ mjo-pcases.tex | 27 +++++++++++++++ mjo-theorems.tex | 19 +++++++++++ mjo-topology.tex | 12 +++++++ 11 files changed, 301 insertions(+) create mode 100644 README create mode 100644 makefile create mode 100644 mjo-algorithms.tex create mode 100644 mjo-common.tex create mode 100644 mjo-cone.tex create mode 100644 mjo-convex.tex create mode 100644 mjo-fonts.tex create mode 100644 mjo-linear_algebra.tex create mode 100644 mjo-pcases.tex create mode 100644 mjo-theorems.tex create mode 100644 mjo-topology.tex diff --git a/README b/README new file mode 100644 index 0000000..9c76735 --- /dev/null +++ b/README @@ -0,0 +1,26 @@ +== What == + +My personal library of LaTeX functions, macros, operators, whatever. + +== How == + +In the makefile of your project, you should list out the pieces of +mjotex that you use. For example, + + MJOTEX = mjo-fonts mjo-theorems + +The absolute paths to those libraries, on your system, can be found +using "kpsewhich" from the kpathsea suite: + + MJOTEXPATHS = $(shell kpsewhich $(MJOTEX)) + +Now add those as dependencies of your document: + + example.pdf: example.tex example.bbl ... $(MJOTEXPATHS) + +If you're not planning on publishing your document, great, you're +done. If you are, you probably also want to create a "dist" target +that will bundle all of your nonstandard TeX libraries along with the +code for your document. + +A full makefile example is provided in the repository. diff --git a/makefile b/makefile new file mode 100644 index 0000000..9ae1aa8 --- /dev/null +++ b/makefile @@ -0,0 +1,74 @@ +# +# Example makefile using some of mjotex (fonts, theorems) and a BibTeX +# references database. +# + +# The latex compiler. +LATEX = pdflatex -file-line-error -halt-on-error + +# The name of this document. +PN := paper + +# A space-separated list of bib files. These must all belong to paths +# contained in your $BIBINPUTS environment variable. +BIBS = references.bib + +# A space-separated list of the mjotex files that you use. The path to +# mjotex must be contain in your $TEXINPUTS environment variable. +MJOTEX = mjo-fonts.tex mjo-theorems.tex + +# Use kpsewhich (from the kpathsea suite) to find the absolute paths +# of the bibtex/mjotex files listed in in $(BIBS)/$(MJOTEX). +BIBPATHS = $(shell kpsewhich $(BIBS)) +MJOTEXPATHS = $(shell kpsewhich $(MJOTEX)) + + +# The first target is the default, so put the PDF document first. +# +# The voodoo here is to avoid rebuilding the project when nothing has +# changed. Each compilation pass with pdflatex will produce a new aux +# file, even if nothing has changed. That cases Make to think that we +# need to regenerate the bbl file, which in turn means we need to +# rebuild the whole project... +# +# To avoid that, we save a copy of the current aux file and compare it +# to the new one afterwards. If the files are the same, great, put the +# old one (with the old timestamp) back. If not, we need to compile +# again, so we just invoke $(MAKE) again on this target. +# +# The process is kind of like finding a fixpoint of `make` with +# respect to the contents of the aux file. +# +$(PN).pdf: $(PN).tex $(PN).aux $(PN).bbl $(MJOTEXPATHS) + mv $(PN).aux $(PN).aux.bak + $(LATEX) $< && $(LATEX) $< + if cmp -s $(PN).aux $(PN).aux.bak; then \ + mv $(PN).aux.bak $(PN).aux; \ + else \ + $(MAKE) $@; \ + fi; + +$(PN).aux: $(PN).tex $(BIBPATHS) + $(LATEX) $< + +$(PN).bbl: $(PN).aux + bibtex $< + + +# Clean up leftover junk. +.PHONY: clean +clean: + rm -f *.{out,nav,snm,toc,aux,log,pdf,bcf,xml,bbl,blg,bib} + rm -rf dist/ + + + +# If this document will be published, the publisher isn't going to +# have your BibTeX database or your mjotex files. So, you need to +# package them up along with the code for your document. This target +# will create a "dist" directory and copy the necessary stuff there. +# +.PHONY: dist +dist: $(PN).bbl + mkdir -p dist + cp $(PN).tex $(PN).bbl $(BIBPATHS) $(MJOTEXPATHS) dist/ diff --git a/mjo-algorithms.tex b/mjo-algorithms.tex new file mode 100644 index 0000000..77dcdb6 --- /dev/null +++ b/mjo-algorithms.tex @@ -0,0 +1,14 @@ +% +% Good looking algorithm environments. +% + +% algorithmicx, for the, uh, algorithms. +\usepackage{algpseudocode} + +% Rename ``require'' and ``ensure'' to ``input'' and ``output'' +% respectively. +\renewcommand{\algorithmicrequire}{\textbf{Input:}} +\renewcommand{\algorithmicensure}{\textbf{Output:}} + +% This just gives us the floating ``algorithm'' environment. +\usepackage{algorithm} diff --git a/mjo-common.tex b/mjo-common.tex new file mode 100644 index 0000000..edb5428 --- /dev/null +++ b/mjo-common.tex @@ -0,0 +1,21 @@ +% +% Only the most commonly-used macros. Needed by everything else. +% + +% Place the argument in matching left/right parntheses. +\DeclarePairedDelimiter{\of}{ \lparen }{ \rparen } + +% Group terms using parentheses. +\newcommand*{\qty}[1]{ \left\lparen {#1} \right\rparen } + +% Create a set from the given elements +\DeclarePairedDelimiter{\set}{ \lbrace }{ \rbrace } + +% A set comprehension, where the ``such that...'' bar is added +% automatically. The bar was chosen over a colon to avoid ambiguity +% with the L : V -> V notation. We can't leverage \set here because \middle +% needs \left and \right present. +\newcommand*{\setc}[2]{ \left\lbrace {#1}\ \middle|\ {#2} \right\rbrace } + +% A pair of things. +\DeclarePairedDelimiterX{\pair}[2]{ \lparen }{ \rparen}{ {#1}, {#2} } diff --git a/mjo-cone.tex b/mjo-cone.tex new file mode 100644 index 0000000..3691695 --- /dev/null +++ b/mjo-cone.tex @@ -0,0 +1,37 @@ +% +% Cone stuff. +% +% The operator families Z(K), LL(K), etc. can technically be defined on +% sets other than cones, but nobody cares. +% + +% The set of all S-operators on its argument. +\newcommand*{\Sof}[1]{ \mathbf{S} \of{ {#1} } } + +% The cone of all Z-operators on its argument. +\newcommand*{\Zof}[1]{ \mathbf{Z} \of{ {#1} } } + +% The space of Lyapunov-like operators on its argument. +\newcommand*{\LL}[1]{ \mathbf{LL}\of{ {#1} } } + +% Display a ``Discrete Complementarity Set'' (DCS). The first argument +% is the name of the cone, the second argument is a generating set for +% that cone, and the third argument is a generating set for its dual. +\newcommand*{\DCS}[3]{ C\of{{#1}} \cap \qty{ {#2} \times {#3} } } + +% Cone inequality operators. +\newcommand*{\gek}{ \succcurlyeq } +\newcommand*{\gtk}{ \succ } +\newcommand*{\lek}{ \preccurlyeq } +\newcommand*{\ltk}{ \prec } + +% Starred versions of the cone inequality operators. +\newcommand*{\ineqkstar}[1]{ \mathrel{ \overset{ _{\ast} }{ #1 } } } +\newcommand*{\gekstar}{ \ineqkstar{\gek} } +\newcommand*{\gtkstar}{ \ineqkstar{\gtk} } +\newcommand*{\lekstar}{ \ineqkstar{\lek} } +\newcommand*{\ltkstar}{ \ineqkstar{\ltk} } + +% And negated versions of some of those... +\newcommand*{\ngeqkstar}{ \ineqkstar{\nsucceq} } +\newcommand*{\ngtrkstar}{ \ineqkstar{\nsucc} } diff --git a/mjo-convex.tex b/mjo-convex.tex new file mode 100644 index 0000000..f482f9f --- /dev/null +++ b/mjo-convex.tex @@ -0,0 +1,23 @@ +% +% Operations that usually appear in convex optimization. +% + +\input{mjo-common} + +% The ``conic combination'' operator. +\newcommand*{\cone}[1]{ \operatorname{cone} \of{{#1}} } + +% The ``convex hull'' operator. +\newcommand*{\conv}[1]{ \operatorname{conv} \of{{#1}} } + +% The ``affine hull'' operator. +\newcommand*{\aff}[1]{ \operatorname{aff} \of{{#1}} } + +% The ``lineality space'' operator. +\newcommand*{\linspace}[1]{ \operatorname{linspace} \of{{#1}} } + +% The ``lineality'' operator. +\newcommand*{\lin}[1]{ \operatorname{lin} \of{{#1}} } + +% The ``Exteme vectors'' operator. +\newcommand*{\Ext}[1]{ \operatorname{Ext} \of{{#1}} } diff --git a/mjo-fonts.tex b/mjo-fonts.tex new file mode 100644 index 0000000..a70b1c3 --- /dev/null +++ b/mjo-fonts.tex @@ -0,0 +1,10 @@ +% +% Font handling that you probably want to use everywhere. +% + +% Allow arbitrary font sizes (prevents pdflatex warnings). +\usepackage{lmodern} + +% Support utf8 in LaTeX code. This lets you enter names like +% Carathéodory and Güler directly, without the funny escape sequences. +\usepackage[utf8]{inputenc} diff --git a/mjo-linear_algebra.tex b/mjo-linear_algebra.tex new file mode 100644 index 0000000..0fce684 --- /dev/null +++ b/mjo-linear_algebra.tex @@ -0,0 +1,38 @@ +% +% Standard operations from linear algebra. +% + +\input{mjo-common} + +% The inner product between its two arguments. +\DeclarePairedDelimiterX{\ip}[2]{ \langle }{ \rangle}{ {#1}, {#2} } + +% The tensor product of its two arguments. +\newcommand*{\tp}[2]{ {#1} \otimes {#2} } + +% The ``span of'' operator. The name \span is already taken. +\newcommand*{\spanof}[1]{ \operatorname{span} \of{{#1}} } + +% The ``co-dimension of'' operator. +\newcommand*{\codim}{ \operatorname{codim} } + +% The trace of an operator. +\newcommand*{\trace}[1]{ \operatorname{trace} \of{{#1}} } + +% The orthogonal projection of its second argument onto the first. +\newcommand*{\proj}[2] { \operatorname{proj}\of{#1, #2} } + +% The ``Automorphism group of'' operator. +\newcommand*{\Aut}[1]{ \operatorname{Aut} \of{{#1}} } + +% The ``Lie algebra of'' operator. +\newcommand*{\Lie}[1]{ \operatorname{Lie} \of{{#1}} } + +% The ``write a matrix as a big vector'' operator. +\newcommand*{\vectorize}[1]{ \operatorname{vec} \of{{#1}} } + +% The ``write a big vector as a matrix'' operator. +\newcommand*{\matricize}[1]{ \operatorname{mat} \of{{#1}} } + +% The inverse of the adjoint of an operator (the argument). +\newcommand*{\adjinv}[1]{ \left( {#1}^{*} \right)^{-1} } diff --git a/mjo-pcases.tex b/mjo-pcases.tex new file mode 100644 index 0000000..7dbe91c --- /dev/null +++ b/mjo-pcases.tex @@ -0,0 +1,27 @@ +% +% A proof-by-cases environment. This gives you a nicely-indented list +% of cases for use in proofs. +% +% Example: +% +% Case 1 (x >= 0): herp. +% +% Case 2 (x < 0): derp. +% + +% Used below to define pcases. +\usepackage{enumitem} + +% Using the enumitem package, we define a new type of list, called +% ``pcases'' (proof by cases). +\newlist{pcases}{enumerate}{1} +\setlist[pcases]{ + label=\textbf{Case~\arabic*}~(\protect\thiscase)\textbf{:}, + ref=\arabic*, + align=left, + leftmargin=\parindent +} +\newcommand{\case}[1][]{ + \def\thiscase{#1}% + \item +} diff --git a/mjo-theorems.tex b/mjo-theorems.tex new file mode 100644 index 0000000..0b55300 --- /dev/null +++ b/mjo-theorems.tex @@ -0,0 +1,19 @@ +% +% The standard corollary, definition, theorem, etc. that we all define +% in every single paper. +% + +\usepackage{amsthm} + +\newtheorem{corollary}{Corollary} +\newtheorem{lemma}{Lemma} +\newtheorem{proposition}{Proposition} +\newtheorem{theorem}{Theorem} +\newtheorem*{theorem*}{Theorem} + +\theoremstyle{definition} +\newtheorem{definition}{Definition} +\newtheorem{example}{Example} + +\theoremstyle{remark} +\newtheorem{remark}{Remark} diff --git a/mjo-topology.tex b/mjo-topology.tex new file mode 100644 index 0000000..574506c --- /dev/null +++ b/mjo-topology.tex @@ -0,0 +1,12 @@ +% +% Standard topological operations. +% + +% The ``interior of'' operator. +\newcommand*{\interior}[1]{ \operatorname{int} \of{{#1}} } + +% The ``closure of'' operator. +\newcommand*{\closure}[1]{ \overline{{#1}} } + +% And the boundary operator. +\newcommand*{\boundary}[1]{ \partial \of{{#1}} } -- 2.44.2