summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/simpler-wick/simpler-wick.tex
blob: 02bdfe895fcb656df231cd5182feb18c770836ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Simpler-Wick
% Simpler Wick contractions in LaTeX
% Copyright (C) 2015  Joshua Ellis
%
%
% This LaTeX file is free: you can redistribute it and/or modify it under the
% terms of the GNU General Public License as published by the Free Software
% Foundation, either version 3 of the License, or (at your option) any later
% version.
%
% This is distributed in the hope that it will be useful, but WITHOUT ANY
% WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
% A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% HEADER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\pgfautoxrefs{1}
\documentclass[a4paper,final]{ltxdoc}

\usepackage{etex}

%% Formatting
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage[vmargin=4cm, hmargin=3cm]{geometry}  % Customize text width, page height, margins, etc.
% \usepackage{multicol}  % {multicols}{n} environment
% \usepackage{pdflscape} % {landscape} environment

%\usepackage{setspace} % Line spacing
%\singlespacing        % 1-spacing (default)
%\onehalfspacing       % 1,5-spacing
%\doublespacing        % 2-spacing

\usepackage{fontspec}  % Allows other fonts to be specified
\setmainfont{EB Garamond}[
  Contextuals={Alternate},
  Numbers=OldStyle,
]
\setmonofont{Inconsolata-g}[
  Scale=MatchLowercase,
]
\newfontface\swshape{EB Garamond 12 Italic}[Style=Swash]

\usepackage{microtype}   % Fine small typographical details
\usepackage{titlesec}    % Change section heading font
\titleformat*{\section}{\huge\scshape}
\titleformat*{\subsection}{\Large\scshape}
\titleformat*{\subsubsection}{\large\scshape}
\titleformat*{\paragraph}{\scshape}

\usepackage[symbol*,perpage]{footmisc}
\usepackage{enumitem}    % Easily customize lists
\setlist[description]{font=\normalfont\scshape}

%% Change the Table of Contents fonts
\usepackage{tocloft}
\renewcommand{\cftsecfont}{\normalfont\scshape}
\setlength\cftbeforesecskip{0pt}
\setcounter{tocdepth}{2}

%% Language
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage[UKenglish]{babel} % Set up the language
\usepackage{csquotes}
\usepackage{siunitx}          % Provides \SI{1}{\metre}, also \ang{90}.
\usepackage{textcomp}

%% Graphics & Figure
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{graphicx}   % Allow graphics to be included
\usepackage{xcolor}     % Define and use colours
% \usepackage{subcaption} % Subfigures inside a figure

% Keep all pictures in the './img/' sub-directory.
\graphicspath{{./img/}}

%% Math Packages
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{amsmath}   % The core math package
\usepackage{amssymb}   % Defines additional math fonts
\usepackage{mathtools} % Various extra maths functions
% \usepackage{cancel}    % Show cancellations with \cancel{}
% \usepackage{autonum}   % Only number referenced equations (must be loaded after cleverref)
\usepackage{dsfont}
\usepackage{simpler-wick}

\usepackage[cmintegrals,varg]{newtxmath} % Nice math with Garamond

%% Define \withnumber which forces the line to have number
\newcommand{\withnumber}{\refstepcounter{equation}\tag{\theequation}}

%% Allows page breaks in math (1 = avoid if possible, 4 = whenever)
%% Page breaks can be avoided at particular places by using \\*
\allowdisplaybreaks[2]

%% Tables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{array}     % New column types, including >{}x<{}
\usepackage{booktabs}  % Provides nicer horizontal lines
\usepackage{multirow}  % Allows cells to span multiple rows
%\usepackage{longtable} % Allows for tables to span multiple pages

%% Define the maths version of clr columns.
\newcolumntype{C}{>{\(}c<{\)}}
\newcolumntype{L}{>{\(}l<{\)}}
\newcolumntype{R}{>{\(}r<{\)}}

%% Other Packages
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{listings}    % Code listings
\usepackage{minted}      % Use Pygments
\usepackage{fp}          % Floating point arithmetics
\usepackage{makeidx}     % Index creation
\usepackage{xr}          % Cross-referencing

\usepackage{hyperref}    % Automatically inserts hyperlinks.
\usepackage{cleveref}    % Use `\cref{}` to reference anything

\usepackage{autonum}

%% Other modifications
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Modify the skip after each paragraph
\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}
\setlength{\parindent}{0pt}

\providecommand\href[2]{\texttt{#1}}
\providecommand\hypertarget[2]{\texttt{#1}}
\providecommand\hyperlink[2]{\texttt{#1}}

\newenvironment{example}
  {\VerbatimEnvironment
   \begin{VerbatimOut}{example.out}}
  {\end{VerbatimOut}%
   \vspace{1ex}%
   \setlength{\parindent}{0pt}%
   \fbox{\begin{minipage}{0.5\linewidth}%
     \inputminted[resetmargins]{latex}{example.out}%
   \end{minipage}%
   \hspace{0.05\linewidth}%
   \begin{minipage}{0.43\linewidth}%
     \input{example.out}%
   \end{minipage}%
   \vspace{1ex}}}

\let\origtexttt=\texttt
\def\texttt#1{{\def\textunderscore{\char`\_}\def\textbraceleft{\char`\{}\def\textbraceright{\char`\}}\origtexttt{#1}}}
\def\exclamationmarktext{!}
\def\atmarktext{@}

{
  \catcode`\|=12
  \gdef\pgfmanualnormalbar{|}
  \catcode`\|=13
  \AtBeginDocument{\gdef|{\ifmmode\pgfmanualnormalbar\else\expandafter\verb\expandafter|\fi}}
}

\makeatother

\makeindex

%% Define some slightly nicer colors
\definecolor{link-color}{RGB}{96 0 0}
\definecolor{cite-color}{RGB}{0 96 0}
\definecolor{file-color}{RGB}{0 0 96}
\definecolor{url-color}{RGB}{0 0 96}
\definecolor{link-border-color}{RGB}{255 159 159}
\definecolor{cite-border-color}{RGB}{159 255 159}
\definecolor{file-border-color}{RGB}{159 159 255}
\definecolor{url-border-color}{RGB}{159 159 255}

\hypersetup{
  pdfborder=0 0 0,
}

%% Document Information
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\makeatletter
\newcommand{\@keywords}{}
\newcommand{\keywords}[1]{\renewcommand{\@keywords}{#1}}

\newcommand{\@version}{}
\newcommand{\version}[1]{\renewcommand{\@version}{#1}}

\AtBeginDocument{
  \hypersetup{
    pdftitle={\@title},
    pdfauthor={\@author},
    pdfkeywords={\@keywords},
  }
}
\makeatother

\title{Simpler-Wick}
\version{1.0.0}
\author{Joshua \textsc{Ellis}}
\keywords{Wick contractions; TeX; LaTeX; TikZ; Simpler-Wick}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%     DOCUMENT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\begin{titlepage}
  \makeatletter
  \begin{center}
    \vspace*{1em}
    \tikz\node[scale=1.5]{%
      \color{gray}\Huge\ttfamily \char`\{\textcolor{red!75!black}{\@title}\char`\}};

    \vspace{0.5em}
    {\Large\bfseries Simpler Wick Contractions}

    \vspace{0.7em}
    {Version \@version \qquad \today}

    \vspace{1.3em}
    {by  \@author}
  \end{center}
  \makeatother

  \vfill

\begin{VerbatimOut}{example.out}
\(\wick{\c1Simp\c2le\c3r\ \c2Wick\ \c3Contractio\c1n}\)
\end{VerbatimOut}

  \begin{center}
    \tikzexternaldisable
    \tikz\node[scale=2]{\input{example.out}};
    \tikzexternalenable

    \begin{minipage}{0.65\linewidth}
      \inputminted{latex}{example.out}
    \end{minipage}
  \end{center}

  \vfill

  \tableofcontents
\end{titlepage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% CONTENT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
\section{Introduction}
\label{sec:introduction}

This package provides simple way of inserting Wick contractions.

If you have any suggestions or have found any bugs, please feel free to create a
new issue or pull request on the Github page:
\href{https://www.github.com/JP-Ellis/simpler-wick}{|https://www.github.com/JP-Ellis/simpler-wick|}.

\subsection{Installation}
\label{subsec:installation}

In order to use this as it is, simply download |simpler-wick.sty| and place it
in the same directory as your \TeX~file and include it using the usual
|\usepackage{simpler-wick}|.  Alternatively, it is also possible to install
|simpler-wick| system-wide by placing it inside \TeX's search path (which will
vary based on your operating system).  This package is also available through
\href{https:/ctan.org}{\textsc{ctan}}.


\section{Usage}
\label{sec:usage}

The package is imported by adding |\usepackage{simpler-wick}| to your preamble.
In your math environment, you can now use the |\wick| command in combination
with |\c|:

\begin{example}
  \begin{equation}
    \wick{\c\phi A \c\phi}
  \end{equation}
\end{example}

If you wish to have multiple contractions, then follow |\c| with a number
between 1 and 9;  the first occurrence of |\cN| will start the Wick contraction,
and the second occurrence of |\cN| will end it.  After you have ended a
contraction, |\cN| start another contraction.

\begin{example}
  \begin{equation}
    \wick{
      \c1 a \c2 b \c3 c \c1 a \c4 d \c1 e
      \c1 e \c1 a \c2 b \c3 c \c1 a
    }
  \end{equation}
\end{example}

The package has two options: |sep| and |offset|.  |sep| is
the distance separating each level and |offset| is the base offset.  By default,
|\sep=3pt| and |\offset=1em|, but they can be changed globally by specifying
them as package variables:

\begin{minted}{latex}
\usepackage[sep=5pt, offset=1.5em]{simpler-wick}
\end{minted}

Or you can specify them as optional argument to |\wick|.  This is particularly
useful if you have some tall symbols within your Wick contraction:

\begin{example}
  \begin{equation}
    \wick[offset=2em]{\c\phi \int \frac{dx}{x} \c\phi}
  \end{equation}
\end{example}

\end{document}

%%% Local Variables:
%%% TeX-master: t
%%% End: