-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreamble.tex
193 lines (165 loc) · 6.67 KB
/
preamble.tex
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
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{kpfonts}
\usepackage[euler]{textgreek}
\usepackage[final]{graphicx}
%% remove colorlinks when preparing for print
\usepackage[final,hyperindex,hyperfootnotes,bookmarksnumbered,colorlinks]{hyperref}
\usepackage{afterpage}
\newsubfloat{figure}
\usepackage{color} % to color background of generated values values
\usepackage{seqsplit} % used in the output automatically generated by scripts
\usepackage{url}
\usepackage[textsize=footnotesize]{todonotes}
%% new command for box about missing references
\newcommand{\addref}[1][]{\todo[color=red!40,size=\tiny]{Add reference: #1}}
\usepackage[sectionbib,square,comma,numbers]{natbib}
\bibliographystyle{agu}
\usepackage{etoolbox}
\usepackage{stringstrings}
\usepackage{fp}
\usepackage{intcalc}
\usepackage{capt-of}
\usepackage{xtab}
\usepackage[mode=text]{siunitx}
\DeclareSIUnit{\bp}{bp} % base pairs
\usepackage[english]{isodate}
\newfloat{supplement}{sup}{Supplementary}
\setfloatlocations{supplement}{h}
\renewcommand{\thesupplement}{S\arabic{supplement}}
%% Simple command for horizontal centering a single table cell
\newcommand{\centercell}[1]{\multicolumn{1}{c}{#1}}
\input{results/variables-configuration}
\input{results/variables-cluster_stats}
\input{results/variables-protein_stats}
\input{results/variables-utr}
\input{results/variables-histone_counts}
\input{results/variables-align_proteins_stats}
\input{results/variables-align_transcripts_stats}
%% We define a style here which will be used around all the values that
%% are copmuted automatically. The idea is to place them in a grey box
%% so that readers can really get the idea that the values in the text
%% are automatically generated. To do that, the scripts will put the
%% values inside a ScriptValue macro which we define here to control how
%% it really looks.
%%
%% By mixing a \strut with \fboxsep set to 0pt, we get an expanded
%% colorbox (not too tight), without changing the line height. It
%% also solves the issue of having different colorbox with different
%% heights (see https://tex.stackexchange.com/questions/7530/height-of-colorbox )
\newcommand{\ScriptValue}[1]{\setlength{\fboxsep}{0pt}\colorbox[gray]{0.8}{\strut #1}}
%% But then, we also want to make operations with those values in LaTeX
%% using FPeval but FPeval fails because ScriptValue gets expanded into
%% something non-numeric. So we use the following trick: we store the
%% original ScriptValue and FPeval macros, and then replace FPeval with
%% something that temporarily disables ScriptValue while we call the
%% original FPeval.
%% See https://tex.stackexchange.com/questions/159155/identify-pieces-of-text-automatically-generated-from-input-and-new-command
%% and https://tex.stackexchange.com/questions/283655/overloading-functions-of-the-fp-package
\let\RealScriptValue\ScriptValue
\let\RealFPeval\FPeval
\renewcommand{\FPeval}[2]{%
\renewcommand{\ScriptValue}[1]{##1}%
\RealFPeval{\UnmarkedResult}{#2}%
\edef#1{\noexpand\ScriptValue{\UnmarkedResult}}%
\renewcommand{\ScriptValue}{\RealScriptValue}%
}
\let\RealFPmin\FPmin
\renewcommand{\FPmin}[3]{%
\renewcommand{\ScriptValue}[1]{##1}%
\RealFPmin{\UnmarkedResult}{#2}{#3}%
\edef#1{\noexpand\ScriptValue{\UnmarkedResult}}%
\renewcommand{\ScriptValue}{\RealScriptValue}%
}
\let\RealFPround\FPround
\renewcommand{\FPround}[3]{%
\renewcommand{\ScriptValue}[1]{##1}%
\RealFPround{\UnmarkedResult}{#2}{#3}%
\edef#1{\noexpand\ScriptValue{\UnmarkedResult}}%
\renewcommand{\ScriptValue}{\RealScriptValue}%
}
\let\Realprintdate\printdate
\renewcommand{\printdate}[1]{%
\renewcommand{\ScriptValue}[1]{##1}%
\RealScriptValue{\Realprintdate{#1}}%
\renewcommand{\ScriptValue}{\RealScriptValue}%
}
%% When using \SI, sometimes we are doing with "normal" values, othertimes
%% they are \ScriptValue macros. In those cases, we will want to keep
%% ScriptValue box around the values, but we need to be careful to not
%% "promote" if not. So we check of #1 is a macro (and assume it's
%% \ScriptValue if true.
\let\RealSI\SI
\renewcommand{\SI}[2]{%
\ifdefmacro{#1}%
{%
\renewcommand{\ScriptValue}[1]{##1}%
\RealScriptValue{\RealSI{#1}{#2}}%
\renewcommand{\ScriptValue}{\RealScriptValue}%
}%
{%
\RealSI{#1}{#2}%
}%
}
\let\RealSIrange\SIrange
\renewcommand{\SIrange}[3]{%
\ifdefmacro{#1}%
{%
\renewcommand{\ScriptValue}[1]{##1}%
\RealScriptValue{\RealSIrange{#1}{#2}{#3}}%
\renewcommand{\ScriptValue}{\RealScriptValue}%
}%
{%
\RealSIrange{#1}{#2}{#3}%
}%
}
%% A function to automatically round a number using the "best" SI prefix.
%% The idea is to transform very long numbers into something more
%% reasonable. For example, instead of 1672945bp, say 1.67Mbp.
%% The first argument is the number, the second the length of the
%% decimal part, adn the third a SI unit (as defined by the siunitx package)
%% Examples:
%% \AutoSIPrefix{12345}{2}{\bp} => \SI{12.35}{\kilo\bp} % note rounding of 12.345
%% \AutoSIPrefix{123456}{1}{\bp} => \SI{123.5}{\kilo\bp}
%% \AutoSIPrefix{1234567}{0}{\bp} => \SI{1}{\mega\bp}
%%
%% As with the overloading of the FP* macros, we need to redefine \ScriptValue
\newcommand{\AutoSIPrefix}[3]{%
\renewcommand{\ScriptValue}[1]{##1}%
\stringlength[e]{#1}%
\numdef{\length}{\theresult}%
%
\numdef{\modulo}{\intcalcMod{\length}{3}}%
\numdef{\power}{\intcalcMul{\intcalcDiv{\length}{3}}{3}}%
%% If modulo is zero, then we use the prefix below
\ifnumequal{\modulo}{0}{\numdef{\modulo}{3} \numdef{\power}{\intcalcSub{\power}{3}}}{}%
%
\ifnumequal{\power}{24}{\def\prefix{\yotta}}{%
\ifnumequal{\power}{21}{\def\prefix{\zetta}}{%
\ifnumequal{\power}{18}{\def\prefix{\exa}}{%
\ifnumequal{\power}{15}{\def\prefix{\peta}}{%
\ifnumequal{\power}{12}{\def\prefix{\tera}}{%
\ifnumequal{\power}{9}{\def\prefix{\giga}}{%
\ifnumequal{\power}{6}{\def\prefix{\mega}}{%
\ifnumequal{\power}{3}{\def\prefix{\kilo}}{%
\def\prefix{}}}}}}}}}%
%% Compute the integer part
\substring[q]{#1}{1}{\modulo}%
\csedef{integer}{\thestring}%
%% Compute the fractional part
\numdef{\fractStart}{\intcalcAdd{\modulo}{1}}%
\substring[q]{#1}{\fractStart}{$}%
\csedef{fractional}{\thestring}%
%% Round and echo
\RealFPround{\rounded}{\integer.\fractional}{#2}%
\renewcommand{\ScriptValue}{\RealScriptValue}%
\ScriptValue{\SI{\rounded}{\prefix#3}}%
}
%%
%% Some computations fit better here in LaTeX than the scripts.
%%
%% Minimum overall PID of each histone type
\FPmin{\result}{\HTwoAPID}{\HTwoBPID}
\FPmin{\result}{\result}{\HThreePID}
\FPmin{\HallMinPID}{\result}{\HFourPID}
\FPeval{\PercentageGenesInHISTOne}{\CoreCodingGenesInHISTOne{}*100/\TotalCoreCodingGenes{}}