-
Notifications
You must be signed in to change notification settings - Fork 0
/
enzrcp.sty
199 lines (170 loc) · 5.99 KB
/
enzrcp.sty
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
% -----------------------------------------------------------------
% The enzrcp package.
% Typeset recipes for enzyme reactions.
%
% Copyright 2013 Davide Liessi <davide dot liessi at gmail dot com>
% -----------------------------------------------------------------
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any
% later version. The latest version of this license is in
% http://www.latex-project.org/lppl.txt
%
% This work has the LPPL maintenance status `maintained'.
% The Current Maintainer of this work is Davide Liessi.
%
% This work consists of the file enzrcp.sty.
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{enzrcp}[2013/09/16 v0.5 Typeset recipes for enzyme reactions]
\RequirePackage{float}[2001/11/08]
\RequirePackage{booktabs}[2005/04/14]
\RequirePackage{siunitx}[2012/12/29]
\RequirePackage{schemata}[2013/03/10]
\RequirePackage{kvoptions}[2011/06/30]
\RequirePackage{ifthen}[2001/05/26]
\RequirePackage{calc}[2007/08/22]
\RequirePackage{caption}[2011/11/02]
\RequirePackage{etoolbox}[2011/01/03]
\SetupKeyvalOptions{
family=enzrcp,
prefix=enzrcp@
}
\DeclareStringOption[0.9]{recipewidthratio}
\DeclareStringOption[0.5]{ingredwidthratio}
\DeclareStringOption[0.05]{ingredmarginratio}
\DeclareStringOption[plaintop]{floatstyle}
\DeclareBoolOption[true]{bflabel}
\DeclareBoolOption[true]{sfcaption}
\DeclareBoolOption[true]{sfrecipe}
\ProcessKeyvalOptions*
\newlength{\enzrcp@privaterecipewidth}
\edef\enzrcp@privateingredwidthratio{\enzrcp@ingredwidthratio}
\edef\enzrcp@privateingredmarginratio{\enzrcp@ingredmarginratio}
\newlength{\enzrcp@privateingredwidth}
\newlength{\enzrcp@privateinstrwidth}
\newcommand{\enzrcp@setrecipewidth}[1]{%
\setlength{\enzrcp@privaterecipewidth}{#1}%
}
\newcommand{\enzrcp@setinnerwidths}[2]{%
\edef\enzrcp@privateingredwidthratio{#1}
\edef\enzrcp@privateingredmarginratio{#2}
\setlength{\enzrcp@privateingredwidth}{\enzrcp@privaterecipewidth*\real{#1}}%
\setlength{\enzrcp@privateinstrwidth}{\enzrcp@privaterecipewidth-\enzrcp@privaterecipewidth*\real{#2}-\enzrcp@privateingredwidth}%
}
\newcommand{\enzrcpspacing}[2]{%
\ifthenelse{\equal{recipewidthratio}{#1}}{%
\ifthenelse{\equal{initial}{#2}}{%
\enzrcp@setrecipewidth{\enzrcp@recipewidthratio\textwidth}%
}{%
\enzrcp@setrecipewidth{#2\textwidth}%
}%
}{%
\ifthenelse{\equal{ingredwidthratio}{#1}}{%
\ifthenelse{\equal{initial}{#2}}{%
\enzrcp@setinnerwidths{\enzrcp@ingredwidthratio}{\enzrcp@privateingredmarginratio}%
}{%
\enzrcp@setinnerwidths{#2}{\enzrcp@privateingredmarginratio}%
}%
}{%
\ifthenelse{\equal{ingredmarginratio}{#1}}{%
\ifthenelse{\equal{initial}{#2}}{%
\enzrcp@setinnerwidths{\enzrcp@privateingredwidthratio}{\enzrcp@ingredmarginratio}%
}{%
\enzrcp@setinnerwidths{\enzrcp@privateingredwidthratio}{#2}%
}%
}{%
\ifthenelse{\equal{all}{#1}}{%
\ifthenelse{\equal{initial}{#2}}{%
\enzrcp@setrecipewidth{\enzrcp@recipewidthratio\textwidth}%
\enzrcp@setinnerwidths{\enzrcp@ingredwidthratio}{\enzrcp@ingredmarginratio}%
}{%
\PackageError{enzrcp}%
{Invalid arguments to \string\enzrcpspacing}%
{The second argument should be 'initial' if the first is 'all'.}%
}%
}{%
\PackageError{enzrcp}%
{Invalid arguments to \string\enzrcpspacing}%
{The first argument must be one of the following:\MessageBreak
recipewidthratio, ingredwidthratio, ingredmarginratio, all.}%
}%
}%
}%
}%
}
\AtBeginDocument{\enzrcpspacing{all}{initial}}
\ifenzrcp@bflabel\captionsetup[\enzrcp@floatstyle]{labelfont=bf}\fi
\ifenzrcp@sfcaption\captionsetup[\enzrcp@floatstyle]{font+=sf}\fi
\floatstyle{\enzrcp@floatstyle}
\newfloat{Recipe}{tbp}{rcp}
\sisetup{detect-family}
\newcommand{\NB}{\textbf{N.B.} }
\newcommand{\ingred}[3]{#1&\si{#3}\\}
\newcommand{\recipe}[6][]{%
\begin{Recipe}[H]
\caption{#3}
\label{rcp:#2}
\medskip
\centering
\begin{minipage}[t]{\enzrcp@privaterecipewidth}
\ifenzrcp@sfrecipe\sffamily\fi
\begin{minipage}[c]{\enzrcp@privateingredwidth}
\begin{tabular}{lS[table-format=#4]s}
\toprule
#5
\bottomrule
\end{tabular}
\end{minipage}
\hfill
\begin{minipage}[c]{\enzrcp@privateinstrwidth}
\flushleft\hangindent=1em\hangafter=1
#6
\end{minipage}
\smallskip
\if\relax\detokenize{#1}\relax\else\par\smallskip\NB#1\fi
\end{minipage}
\end{Recipe}}
\newcommand{\enzrcp}[7][]{%
\recipe[#1]{#2}{#3}{#4}{#5}{%
\if\relax\detokenize{#6}\relax\else\textbf{Incubation:} #6\fi
\smallskip
\if\relax\detokenize{#7}\relax\else\textbf{Inactivation:} #7\fi}}
\newcommand{\enzrcpTemp}[1]{\SI{#1}{\degreeCelsius}}
\newcommand{\enzrcpTime}[2]{\if\relax\detokenize{#1}\relax\else\SI{#1}{\arcminute}\fi%
\if\relax\detokenize{#2}\relax\else\SI{#2}{\arcsecond}\fi}
\newcommand{\enzrcpTimeTemp}[3]{\enzrcpTime{#1}{#2}~@~\enzrcpTemp{#3}}
\newcommand{\PCR}[9][]{%
\def\enzrcpNB{#1}%\if\relax\detokenize{#1}\relax\else\par\smallskip\NB#1\fi}%
\def\enzrcpID{#2}%
\def\enzrcpCaption{#3}%
\def\enzrcpTableFormat{#4}
\def\enzrcpIngred{#5}%
\def\enzrcpMeltingInitial{#6}%
\def\enzrcpCycle{#7 $\times$}
\def\enzrcpMeltingCycle{#8}%
\def\enzrcpAnnealing{#9}%
\PCRcontinuedA%
}
\newcommand{\PCRcontinuedA}[3]{%
\def\enzrcpElongationCycle{#1}%
\def\enzrcpElongationFinal{#2}%
\def\enzrcpStorage{\enzrcpTemp{#3}~$\infty$}%
\ifdefempty{\enzrcpNB}{%
\recipe{\enzrcpID}{\enzrcpCaption}{\enzrcpTableFormat}{\enzrcpIngred}{%
\textbf{Melting:} \enzrcpMeltingInitial
\schema{\schemabox{\enzrcpCycle}}{\schemabox{%
\textbf{Melting:} \enzrcpMeltingCycle\\
\textbf{Annealing:} \enzrcpAnnealing\\
\textbf{Elongation:} \enzrcpElongationCycle}}
\textbf{Elongation:} \enzrcpElongationFinal
\textbf{Storage:} \enzrcpStorage}}{%
\recipe[\enzrcpNB]{\enzrcpID}{\enzrcpCaption}{\enzrcpTableFormat}{\enzrcpIngred}{%
\textbf{Melting:} \enzrcpMeltingInitial
\schema{\schemabox{\enzrcpCycle}}{\schemabox{%
\textbf{Melting:} \enzrcpMeltingCycle\\
\textbf{Annealing:} \enzrcpAnnealing\\
\textbf{Elongation:} \enzrcpElongationCycle}}
\textbf{Elongation:} \enzrcpElongationFinal
\textbf{Storage:} \enzrcpStorage}}}