pyafm/stack.tex: Add detail to the fig:pyafm:stack caption
[thesis.git] / src / local_cmmds.tex
1 % String comparison for \fref
2 \makeatletter
3 \long\def\isequal#1#2{\pdf@strcmp{#1}{#2}}
4 \makeatother
5
6 % An reference index from an unspecified source
7 % usage: \iref{environment}{value}
8 % for example: \iref{equation}{75}
9 \newcommand{\iref}[2]{%
10   \switch%
11   \case{\isequal{#1}{equation}}%
12     ({#2})%
13   \otherwise%
14     {#2}%
15   \endswitch%
16 }
17
18 % A formatted reference from an unspecified source
19 % usage: \fref{environment}{value}
20 % for example: \fref{figure}{75}
21 \newcommand{\fref}[2]{%
22   \switch%
23   \case{\isequal{#1}{equation}}%
24     Eq.~\iref{#1}{#2}%
25   \case{\isequal{#1}{figure}}%
26     Fig.~\iref{#1}{#2}%
27   \case{\isequal{#1}{section}}%
28     Section~\iref{#1}{#2}%
29   \otherwise%
30     \PackageError{fref}{
31       \MessageBreak
32       environment value >#2< unknown \MessageBreak
33     }{possible values are: equation. \MessageBreak}%
34   \endswitch%
35 }
36
37 % References to external figures, equations, etc.
38 % usage: \xref{key}{environment}{value}
39 % for example: \xref{roman12}{figure}{75}
40 \newcommand{\xref}[3]{\citet{#1} \fref{#2}{#3}}
41
42 % Fourier Transform to angular momentum space
43 \newcommand{\Four}[1]{\ensuremath{{\mathcal F}\left\{ {#1} \right\}}}
44 % Fourier Transform to frequency space
45 \newcommand{\Fourf}[1]{\ensuremath{{\mathcal F}_f\left\{ {#1} \right\}}}
46
47 % Symbol denoting the Langevin function
48 \newcommand{\Langevin}{\ensuremath{\mathcal{L}}}
49 % Symbol denoting big-O order of #1
50 \newcommand{\order}[1]{\ensuremath{\mathcal{O}\p({#1})}}
51
52 % Integral from #1 to #2 of #4 with respect to #3
53 \newcommand{\integral}[4]{\ensuremath{\int_{#1}^{#2} {#4} \dd{#3}}}
54 % Integral from -infty to +infty of #2 with respect to #1
55 \newcommand{\iInfInf}[2]{\integral{-\infty}{\infty}{#1}{#2}}
56 % Integral from 0 to +infty of #2 with respect to #1
57 % note that the second char in the name is a capital o, not a 0
58 % because ?Latex doesn't allow digits in command names
59 \newcommand{\iOInf}[2]{\integral{0}{\infty}{#1}{#2}}
60 % #3 evaluated at #2 and #1
61 \newcommand{\evaluated}[3]{\ensuremath{\left.{#3}\right|_{#1}^{#2}}}
62 % #2 evaluated at #1
63 \newcommand{\eval}[2]{\ensuremath{\left.{#2}\right|_{#1}}}
64 % evaluated at infty and -infty
65 \newcommand{\eInfInf}[1]{\evaluated{-\infty}{\infty}{#1}}
66 % evaluated at infty and 0
67 \newcommand{\eOInf}[1]{\evaluated{0}{\infty}{#1}}
68
69 % we do a lot of lim t_T -> infty, so macro that out
70 % lim as #1 -> infty
71 \newcommand{\limInf}[1]{\ensuremath{\lim_{{#1}\rightarrow \infty}}}
72 \newcommand{\limT}{\limInf{t_T}}
73 \newcommand{\normLimT}{\limT \frac{1}{t_T}\ } % '\ ' for a normal space
74 % lim as t_T -> infty of integral from -t_T/2 to t_T/2 of #1 with respect to t
75 \newcommand{\iLimT}[1]{\normLimT \integral{-t_T/2}{t_T/2}{t}{#1}}
76
77 \newcommand{\magSq}[1]{\ensuremath{\left|{#1}\right|^2}}
78 \newcommand{\PSD}{\ensuremath{\operatorname{PSD}}}
79
80 % complex conjugate
81 \newcommand{\conj}[1]{\ensuremath{\overline{#1}}}
82
83 % Symbol denoting the contour C
84 \newcommand{\C}{\ensuremath{\mathcal{C}}}
85 % Integral about contour C of #1 with respect to z
86 \newcommand{\iC}[1]{\integral{\C}{}{z}{#1}}
87 \newcommand{\Reals}{\ensuremath{\mathds{R}}}
88 \newcommand{\Imags}{\ensuremath{\mathds{I}}}
89 \newcommand{\Real}{\ensuremath{\operatorname{Re}}}
90 \newcommand{\Imag}{\ensuremath{\operatorname{Im}}}
91 \newcommand{\ResX}[3]{\operatorname{Res}\left({{#1}={#2}},{#3}\right)}
92 \newcommand{\Res}[2]{\ResX{z}{#1}{#2}}
93 \newcommand{\limX}[2]{\lim_{{#1} \rightarrow {#2}}}
94 \newcommand{\limZ}[1]{\limX{z}{#1}}
95 \newcommand{\limZp}{\limZ{z_p}}
96 \newcommand{\CPV}{\ensuremath{\mathds{P}}}
97
98 \newcommand{\supScript}[1]{\ensuremath{^{\text{#1}}}}
99 \newcommand{\st}{\supScript{st}}
100 \newcommand{\nd}{\supScript{nd}}
101 \newcommand{\rd}{\supScript{rd}}
102 \newcommand{\sth}{\supScript{th}} % th, TH already taken
103
104 \newcommand{\colA}[1]{\textcolor{red}{#1}}
105 \newcommand{\colB}[1]{\textcolor{blue}{#1}}
106 \definecolor{purple}{rgb}{0.8, 0, 0.8}
107 \newcommand{\colAB}[1]{\textcolor{purple}{#1}}
108 \newcommand{\colC}[1]{\textcolor{green}{#1}}
109
110 \newcommand{\cf}{\emph{cf.}} % "confer" or "bring together" / "compare"
111 \newcommand{\ie}{\emph{i.e.}} % "id est" or "in other words"
112 \newcommand{\insilico}{\emph{in silico}} % quasi latin for "on a computer"
113 \newcommand{\invitro}{\emph{in vitro}}   % latin for "in glass"
114 \newcommand{\invivo}{\emph{in vivo}}     % latin for "in living organisms"
115
116 \newcommand{\ensuretext}[1]{\ensuremath{\text{#1}}}
117 % Hyeon and Thirumalai equation number #1
118 \newcommand{\HTeq}[1]{\ensuretext{\emph{H\&T eq.\ {#1}}}}
119 \newcommand{\kT}{\ensuremath{k_B T}}
120 \newcommand{\bt}{\ensuremath{\beta}}
121 \newcommand{\fs}{\ensuremath{f^*}}
122 \newcommand{\dx}{\ensuremath{\Delta x(\fs)}}
123 \newcommand{\dxs}[1]{\ensuremath{\Delta x_{#1}(\fs)}} % for subscripting
124 \newcommand{\FO}{\ensuremath{\Delta F_0^\ddagger(\fs)}}
125 \newcommand{\vD}{\ensuremath{\nu_D(\fs)}}
126 \newcommand{\vDs}[1]{\ensuremath{\nu_{D{#1}}(\fs)}}
127 \newcommand{\kexp}{\ensuremath{\vD e^{-\bt \FO}}}
128 \newcommand{\kexps}[1]{\ensuremath{\vDs{#1} e^{-\bt_{#1} \FO_{#1}}}}
129 \newcommand{\kf}{\ensuremath{k(\fs)}}
130 \newcommand{\kfs}[1]{\ensuremath{k_{#1}(\fs)}}
131 %\newcommand{\avg}[1]{\ensuremath{\left\langle {#1} \right\rangle}}
132 \newcommand{\abs}[1]{\ensuremath{\lvert {#1} \rvert}}
133 \newcommand{\logp}[1]{\ensuremath{\log\!\!\left( {#1} \right)}}
134 % \! is a negative thin space to get the paren closer to the log
135 %\renewcommand{\r}{\ensuremath{r_f}}
136 %\newcommand{\rs}[1]{\ensuremath{r_{f{#1}}}}% to avoid double-subscripting
137 \newcommand{\ep}{\varepsilon}
138
139 \newcommand{\species}[1]{\emph{#1}} % \species{Homo sapiens}
140
141 % Chemicals
142 \newcommand{\Ca}{Ca\textsuperscript{2+}}
143 \newcommand{\CaCl}{CaCl\textsubscript{2}}
144 \newcommand{\Na}{Na\textsuperscript{+}}
145 \newcommand{\NaCl}{NaCl}
146 \newcommand{\diNaHPO}{Na\textsubscript{2}HPO\textsubscript{4}}
147 \newcommand{\NadiHPO}{NaH\textsubscript{2}PO\textsubscript{4}}
148
149 % Workaround for inline minted markup
150 %   http://code.google.com/p/minted/issues/detail?id=15
151 % usage: \imint{language}|value|
152 \NewDocumentCommand\imint{mv}{\texttt{#2}}
153
154 % Aliases for citations
155 \defcitealias{calibcant}{calibcant}
156 \defcitealias{comedi}{Comedi}
157 \defcitealias{cygwin}{Cygwin}
158 \defcitealias{cython}{Cython}
159 \defcitealias{epics}{EPICS}
160 \defcitealias{force-robot}{ForceRobot}
161 \defcitealias{gentoo}{Gentoo}
162 \defcitealias{h5config}{h5config}
163 \defcitealias{hdf5}{HDF5}
164 \defcitealias{interix}{Interix}
165 \defcitealias{king10}{sawsim}
166 \defcitealias{labview}{LabVIEW}
167 \defcitealias{picoforce}{PicoForce}
168 \defcitealias{prefix}{Gentoo Prefix}
169 \defcitealias{punias}{PUNIAS}
170 \defcitealias{pyafm}{pyafm}
171 \defcitealias{pycomedi}{pycomedi}
172 \defcitealias{pymodbus}{pymodbus}
173 \defcitealias{pymol}{PyMol}
174 \defcitealias{pypid}{pypid}
175 \defcitealias{pypiezo}{pypiezo}
176 \defcitealias{python}{Python}
177 \defcitealias{sandal09}{Hooke}
178 \defcitealias{stepper}{stepper}
179 \defcitealias{beazley96}{SWIG}
180 \defcitealias{unfold-protein}{unfold-protein}
181 \defcitealias{wavemetrics-igor}{IGOR Pro}
182 \defcitealias{xcode}{Xcode}
183 \defcitealias{yaml}{YAML}
184
185 \newcommand{\Comedi}{\citetalias{comedi}}
186 \newcommand{\Hooke}{\citetalias{sandal09}}
187 \newcommand{\calibcant}{\citetalias{calibcant}}
188 \newcommand{\hFconfig}{\citetalias{h5config}}
189 \newcommand{\pyafm}{\citetalias{pyafm}}
190 \newcommand{\pypid}{\citetalias{pypid}}
191 \newcommand{\pypiezo}{\citetalias{pypiezo}}
192 \newcommand{\pycomedi}{\citetalias{pycomedi}}
193 \newcommand{\pysawsim}{\texttt{pysawsim}}
194 \newcommand{\sawsim}{\citetalias{king10}}
195 \newcommand{\stepper}{\citetalias{stepper}}
196 \newcommand{\unfoldprotein}{\citetalias{unfold-protein}}
197
198 % draw a line TikZ (useful for captions explaining figures)
199 % usage: \tikzline{style}
200 \DeclareRobustCommand{\tikzline}[1]{%
201   \protect\tikz \draw[#1] (0,0) -- (14pt,6pt);}
202
203 % draw a thermometer in TikZ
204 % usage: \thermometer{bulb-location}
205 \newcommand{\thermometer}[1]{
206   \draw[blue!20, line width=4pt, cap=round] #1 -- +(0, 12pt);
207   \fill[blue!20] #1 circle (5pt);
208   \draw[red, line width=2pt, cap=butt] #1 -- +(0, 8pt);
209   \fill[red] #1 circle (4pt);
210 }
211
212 % shared figure between pyafm and calibcant
213 % usage: \tikzstack{unfold-protein-color}{calibcant-color}
214 \newcommand{\tikzstack}[2]{%
215   \begin{tikzpicture}[decoration={
216       markings,%  switch on markings
217       mark=%  add a mark for screw threading
218         between positions 0 and 1 step 1pt
219         with
220         {
221           \draw (0, 2pt) -- (1pt, -2pt);
222         }
223       }
224       ]
225     \tikzstyle{every node}=[text depth=0pt, rounded rectangle,
226       draw=blue!50, very thick, minimum height=1.7em]
227     % hardware nodes and coordinates
228     \node[shape=rectangle,draw=none,inner sep=0]
229       (image) at (0,0) {
230       \asyinclude{figures/schematic/afm}};
231     \node[shape=rectangle,draw=black, semithick]
232       (daq) at ($(image.south west) + (-0.25, -1)$) {DAQ card};
233     \node[shape=rectangle,draw=black, semithick]
234       (motor) at ($(image.south) + (0, -1)$) {motor};
235     \coordinate (thermocouple) at ($(image.west) + (1.4, -4pt)$);
236     \thermometer{(thermocouple)}
237     \coordinate (photodiode) at ($(image.west) + (1, 26pt)$);
238     \coordinate (piezo) at ($(image.south) + (-6pt, 0)$);
239     \draw[black!20,dashed] ($(daq.south west) + (-10pt, 0)$) -- +(0, 4);
240     % software nodes
241     \node (pycomedi) at ($(daq) + (-6,0)$) {pycomedi};
242     \node (pypiezo) at ($(pycomedi) + (0,1)$) {pypiezo};
243     \node (pyafm) at ($(pypiezo) + (0,1)$) {pyafm};
244     \node[#1] (unfold-protein) at ($(pyafm) + (0,1)$) {unfold-protein};
245     \node (stepper) at ($(pycomedi) + (2,1)$) {stepper};
246     \node (pypid) at ($(stepper) + (2,0)$) {pypid};
247     \node (h5config) at ($(pycomedi) + (-3,0)$) {h5config};
248     \node[#2] (calibcant) at ($(unfold-protein) + (-3,0)$) {calibcant};
249     % software connections
250     \draw (pypiezo) -- (pyafm);
251     \draw (stepper) -- (pyafm);
252     \draw (pypid) -- (pyafm);
253     \draw[#1] (pyafm) -- (unfold-protein);
254     \draw (h5config) -- (pypiezo);
255     \draw (h5config) -- (pyafm);
256     \ifthenelse{\equal{#1}{}}{%  draw unfold-protein in black (the default)
257       \draw[#2] (pyafm) -- (calibcant);
258       \draw[#1] (h5config) -- (unfold-protein);%  default path on top
259       }{%
260       \draw[#1] (h5config) -- (unfold-protein);
261       \draw[#2] (pyafm) -- (calibcant);%  default path on top
262       }
263     \draw[#2] (h5config) -- (calibcant);
264     % hardware connections
265     \begin{pgfonlayer}{background}
266       \draw[purple, ->] (thermocouple) -- (pypid);
267     \end{pgfonlayer}
268     % begin motor screw
269     \draw[black!20, line width=4pt]
270       (motor) -- (image.south);   % shaft with decoration threads
271     \draw[black, decorate, ultra thin]
272       (motor) -- (image.south);   % shaft with decoration threads
273     % end motor screw
274     \draw[red, <->] (pypiezo) -- (pycomedi);
275     \draw[red, <->, line width=2pt] (pycomedi) -- (daq);
276     \draw[red, ->] (daq) -- (piezo);
277     \begin{pgfonlayer}{background}
278       \draw[red, ->, out=180, in=90] (photodiode) to (daq.north);
279     \end{pgfonlayer}
280     \draw[blue, ->] (stepper) -- (pycomedi);
281     \draw[blue, ->] (pycomedi) -- (daq);
282     \draw[blue, ->] (daq) -- (motor);
283   \end{tikzpicture}
284 }