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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
|
% \iffalse meta-comment
%
% Copyright (c) 2013 Christian Dietrich
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% 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
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Christian Dietrich
%
% This work consists of the files dataref.dtx and dataref.ins
% and the derived file dataref.sty.
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{dataref.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{dataref}
%<package> [2015/09/17 v0.5 dataref]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage[usagereport]{dataref}[2015/09/17]
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\usepackage{listings}
\usepackage{pdfcomment}
\usepackage{filecontents}
\begin{filecontents}{datapoints.tex}
\drefset{/control group/mice race}{Black Six}
\drefset{/control group/mice count}{32}
\drefset{/control group/dead after 24h}{3}
\drefset{/control group/dead after 48h}{7}
\drefset{/control group/recovered}{6}
\drefset{/med A/mice race}{Black Six}
\drefset{/med A/mice count}{32}
\drefset{/med A/dead after 24h}{6}
\drefset{/med A/dead after 48h}{1}
\drefset{/med A/recovered}{9}
\drefsethelp{.*/mice race}{The mice race used for experiments heavily
influences the outcome of the results}
\drefsethelp{.*/(dead after|recovered)}{Of all infected mice, a
certain number died within a specified period of time. A certain
recovered from the infection. Each mouse is in exactly one category.}
\end{filecontents}
\input{datapoints}
% \OnlyDescription
\begin{document}
\DocInput{dataref.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
%
% \changes{v0.4}{2015/04/21}{Remove Spurious Whitespaces}
% \changes{v0.1}{2013/12/06}{Initial version}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
% \providecommand*{\url}{\texttt}
% \GetFileInfo{dataref.sty}
% \title{The \textsf{dataref} package}
% \author{Christian Dietrich 2013-2014\\ \url{stettberger@dokucode.de}\\
% \url{https://github.com/stettberger/dataref}}
% \date{\filedate~\fileversion}
%
% \maketitle
%
% \section{Introduction}
%
% Writing scientific texts is a craft. It is the craft of communicating your results to your
% colleagues and to the curious world public. Often your conclusions are based upon facts and
% numbers that you gathered during your research for the specific topic. You might have done many
% experiments and produced lot of data. The craft of writing is to guide your reader through a
% narrative that is based upon that data. But there may be many versions of that data. Perhaps you
% found a problem in your experiment, while already writing, that forces you back into the
% laboratory. After a while, the moon has done its circle many times, you return from that dark
% place and your methodology has improved as significantly as your data has. But now you have to
% rewrite that parts of the data that reference the old data points.
%
% The \textsf{dataref} is here to help you with managing your data points. It provides you with
% macro style keys that represent symbolic names for your data points. You can reference those
% symbolic names with \cmd{\dref}, use them in calculations to have always up-to-date percentage
% values, define projections between sets of data points and document them. \textsf{dataref} also
% introduces the notion of assertions (\cmd{\drefassert}) for your results to ensure that your prosa
% text references fit the underlying data.
%
% \section{Usage}
%
% The \textsf{dataref} package heavily uses \textsf{pgfkeys} and \textsf{pgfmath} to perform storage
% and operations upon data points. See \texttt{texdoc pgfmanual} for further information about those
% topics.
%
% \DescribeMacro{\drefset\{\meta{name}\}\{\meta{value}\}}
%
% The \cmd{\drefset} command is used to define the symbolic data points. The first argument is the
% symbolic name, the second argument is the value. The value can be a number, but it can also be
% arbitrary text. The key may contain virtually all characters, including spaces and slashes. It is
% good practice to use a hierarchy to structure you data point names.
%
% \lstinputlisting[language=tex, firstline=5, lastline=15,basicstyle=\footnotesize,frame=single]{datapoints.tex}
%
% The code snippet, which is best stored in an external file, and which might be auto-generated, is
% best read with \cmd{\input}. It defines 10 symbolic names, that are partitioned into two
% "directories" (\texttt{control group} and \texttt{medicament A}).
%
% \DescribeMacro{\dref*\{\meta{name}\}}
% \DescribeMacro{\dref[\meta{format}]\{\meta{name}\}}
%
% This macro is used to reference a single symbolic data point. The value stored in that datapoint
% is inserted into the text. \cmd{\dref} additionally marks the data point as used. It will then
% appear in the dref usage report. For undefined keys the default behaviour is to abort the
% compilation. But the package option \texttt{ignoremissing} just outputs a warning. All
% referenced/missing/found datapoints are noted in the aux file.
%
% \vspace{1em}\noindent\begin{tabular}{ll}\toprule
% Macro & Expansion \\
% \midrule
% \cmd{\dref*\{/control group/mice race\}} & \dref*{/control group/mice race} \\
% \cmd{\dref*\{/control group/mice count\}} & \dref*{/control group/mice count} \\
% \cmd{\dref[sci,precision=2,zerofill=true]\{/med A/recovered\}} & \dref[sci,precision=2,zerofill=true]{/med A/recovered} \\ \bottomrule
% \end{tabular}\vspace{1em}
%
% \cmd{\dref} additionally takes an optional argument. This argument is interpreted as
% \texttt{/pgf/number format/} argument. See the pgf/tikz manual for more information. Only in the
% unstarred version this macro parses the value as a number. Be aware that
% \cmd{\dref} is \textbf{not} expandable.
%
% \DescribeMacro{\drefvalueof\{\meta{name}\}}
%
% Since \cmd{\dref} is not expandable, this macro can be used to get the bare value of a symbolic data point. But use it with caution, since it bypasses all internal book keeping.
% \begin{quote}
% \verb|\drefvalueof{/med A/mice race}|
% \end{quote}
%
% \DescribeMacro{\drefref\{\meta{name}\}}
%
% This is complement of \cmd{\drefvalueof}, it does \emph{only} the book keeping for a key (marking it as referenced etc.) So it might be used to compensate the usage of its bad sibling.
% \begin{quote}
% \verb|\drefref{/med A/mice race}|
% \end{quote}
%
% \DescribeMacro{[ignoremissing]}
% \DescribeMacro{[defaultvalue=1.0]}
% These two package options influence the behaviour regarding unknown
% keys. With \verb|ignoremissing| each missing symbolic datapoint is replaced by the defaultvalue. This behaviour might be useful when you use the .aux file, where the unknown keys are noted to extract data points from a third source (e.g. database, wikidata, etc). In the future a secondary tool will be provided to resolve those references.
%
% \DescribeMacro{\drefsethelp\{\meta{pattern}\}\{\meta{text}\}}
% \DescribeMacro{\drefhelp\{\meta{name}\}}
%
% \textsf{dataref} comes with a simple method for defining documentation for data points. This help can for example be used to communicate what is the concrete semantics of the data point. This is of special interest when writter and data gatherer are not the same person. \cmd{\drefsethelp} takes two arguments: first a regular expression that matches the symbolic data point, second the help text.
%
% \lstinputlisting[language=tex, firstline=17, lastline=18,basicstyle=\footnotesize,frame=single]{datapoints.tex}
%
% The helptext for a key is obtained by using the \cmd{\drefhelp} macro. It checks all defined helps (in linear order, first defined, first matched), and prints the first matching help text.
%
% For \textbf{LuaTeX}: When using this \TeX{} engine, only Lua (string.find)
% regular expressions are supported as patterns.
% \begin{quote}
% \verb|\drefhelp{/med A/mice race}|
% \end{quote}
%
% \DescribeMacro{\drefcalc[\meta{format}]\{\meta{expr}\}}
% \DescribeMacro{data("\meta{key}")}
% \DescribeMacro{d(\meta{key})}
%
% The \cmd{\drefcalc} command is the core function of calculating with data points. It is based on
% the pgfmath engine. It uses the required argument as a mathematical expression, but has additional
% features, that can be used.
%
% \begin{quote}
% \verb|\drefcalc{(4+7)/12 * 100}| $\Rightarrow$ \drefcalc{(4+7)/12 * 100}
% \end{quote}
%
% \noindent It adds support for the \texttt{data} function within pgfmath, which
% references symbolic data points. The keyname has to be in double
% quotes to indicate a string, but you can easily define an appropriate
% macro that abstracts from \verb|data("")|. As a quote-free
% alternative to the data command, \cmd{\drefcalc} provides also \verb|d(<key>|).
%
%
% \begin{quote}
% \verb|\drefcalc{data("/med A/mice count") * 100}| $\Rightarrow$ \drefcalc{data("/med A/mice count") * 100}
% \verb|\drefcalc{d(/med A/mice count) * 100}| $\Rightarrow$ \drefcalc{d(/med A/mice count) * 100}
% \end{quote}
%
% \noindent The optional argument lets you give a number format, which is used for printing the
% result number (\verb|/pgf/number format|).
%
% \begin{quote}
% \verb|\drefcalc[precision=5,fixed]{1/3}| $\Rightarrow$ \drefcalc[fixed,precision=5]{1/3}
% \end{quote}
%
% \cmd{\drefcalc} works as well in a \textbf{/pgf/fpu} environment or a normal one. The FPU feature of
% pgfmath is used to handle large numbers, which may occur often when handling experiment data
% points.
%
% \begin{quote}
%
% \end{quote}
% \dreflet{A=123456789,B=987654321, a=12, b=98}
%
% \begin{tabular}{lrr}
% \multicolumn{3}{l}{\cmd{\dreflet\{A=123456789, B=987654321, a=12, b=98\}}} \\
%\toprule
% Macro & Inserted Text & \cmd{\drefresult} \\\midrule
% \verb|\drefcalc[/pgf/fpu]{A/B}| & \drefcalc[/pgf/fpu]{A/B} & \drefresult\\
% \verb|\drefcalc{a/b}| & \drefcalc[]{a/b} & \drefresult \\
% \verb|\drefcalc*[/pgf/fpu]{A/B}| & \drefcalc*[/pgf/fpu]{A/B} & \drefresult\\
% \verb|\drefcalc*{a/b}| & \drefcalc*[]{a/b} & \drefresult \\
% \bottomrule
% \end{tabular}
%
%
% \DescribeMacro{\drefcalc*}
% \DescribeMacro{\drefresult}
% \DescribeMacro{\drefformat\{\meta{number}\}}
%
% \begin{quote}
% \verb|\drefcalc*{1/3} ABC: \drefresult| $\Rightarrow$ \drefcalc*{1/3} ABC: \drefresult\\
% \verb|\drefformat[fixed,precision=1]{\drefresult}|$\Rightarrow$ \drefformat[fixed,precision=1]{\drefresult}\\
% \verb|\drefformat[sci]{100000}| $\Rightarrow$ \drefformat[sci]{100000}
% \end{quote}
%
% \DescribeMacro{/dref/let=\{\meta{lets}\}}
% \DescribeMacro{\dreflet\{\meta{lets}\}}
%
% Since symbolic key names can get long, dataref has the possibility to define variables for use
% within mathematical expression from other expressions. These "let"-bindings can either be defined
% locally for a \cmd{\drefcalc} commando with a pgf key or globally with \cmd{\dreflet}.
%
% \begin{quote}
% \verb|\drefcalc[/dref/let{A=12*20,B=\cg{recovered}}]{A/B}| $\Rightarrow$ \drefcalc[/dref/let={B=data("/control group/recovered"),A=12*20}]{A/B}\\
% \verb|\drefcalc[/dref/let={X=100}]{30/X}| $\Rightarrow$ \drefcalc[/dref/let={X=100}]{30/X}
% \end{quote}
%
% The bindings for \cmd{\drefcalc} are only local to that macro
% call. Defining a binding for the current group can be done with
% \cmd{\dreflet}.
%
% \begin{quote}
% \verb|\newcommand{\cg}[1]{data("/control group/#1")}|\newcommand{\cg}[1]{data("/control group/#1")}\\
% \verb|\dreflet{percent=data("/med A/mice count")/100}|\dreflet{percent=data("/med A/mice count")/100}\\
%
% The result clearly shows that a lorem ipsum kills\\
% \verb|\drefcalc{\cg{dead after 24h}/percent}| percent within 24
% and \verb|\drefcalc{\cg{dead after 28h}/percent}| percent within 48 hours.
%
% The result cleary shows that a lorem ipsum kills
% \drefcalc{\cg{dead after 24h}/percent} percent within 24
% and \drefcalc{\cg{dead after 48h}/percent} percent within 48 hours.
% \end{quote}
%
% \DescribeMacro{\drefrel*[\meta{opts}]\{\meta{key}\}}
% \DescribeMacro{\drefrel[\meta{opts}]\{\meta{key}\}}
%
% The \cmd{\drefrel} macro is used to calculate relations between a base value and a concrete key. A
% prominent example of such a relation is the percent relation. \cmd{\drefrel} allows you to write
% down intentionally what relation you want to express without thinking about a concrete
% formula. The starred version of this macro does not print anything, but sets only
% \cmd{\drefresult}.
%
% \begin{quote}
% \noindent\verb|\drefrel[base=/med A/mice count,factor]{/med A/recovered}| \\
% \mbox{}\hspace{1cm} $\Rightarrow$ \drefrel[base=/med A/mice
% count,factor,percent]{/med A/recovered} \\
% \end{quote}
%
% The type of relation can be manipulated with various keys. Almost
% always the given argument key will be set in relation to a base
% value. The type of relation can be given as well as post-processing
% steps.
%
% Like \cmd{\drefcalc}, \cmd{\drefrel} sets the \cmd{\drefresult}
% macro accordingly.
%
% \DescribeMacro{/dref/base}
% \DescribeMacro{/dref/base plain}
% \DescribeMacro{/dref/value plain}
%
% This specifies the key that will be used as a base. Without the
% \textbf{base plain} option, the value will be interpreted as a symbolic
% datapoint. With the option, base contains the plain value. When
% \textbf{value plain} is given, the mandatory argument is interpreted as
% a number and not as a symbolic name.
%
% \verb|\drefrel[factor,base=50,base plain]{/med A/mice count}| $\Rightarrow$
% \drefrel[factor,base=50,base plain]{/med A/mice count}
%
% \verb|\drefrel[factor,base=50,base plain,value plain]{45}| $\Rightarrow$
% \drefrel[factor,base=50,base plain,value plain]{45}
%
% \DescribeMacro{/dref/factor}
%
% Is a base relation type, which cannot be mixed with other relation
% types. It simply divides the given value by the base value.
%
% \[\cmd{\drefresult} = \frac{\texttt{value}}{\texttt{base}}\]
%
% \DescribeMacro{/dref/increase}
% \DescribeMacro{/dref/overhead}
%
% Is a base relation type. It calculates the overhead factor a value
% show toward the base value. \texttt{increase} and \texttt{overhead}
% are synonyms.
%
% \[\cmd{\drefresult} = \frac{\texttt{value} -
% \texttt{base}}{\texttt{base}}\]
%
% \verb|\drefrel[overhead,base=50,base plain,value plain]{45}| $\Rightarrow$
% \drefrel[overhead,base=50,base plain,value plain]{45}
%
%
% \DescribeMacro{/dref/delta}
%
% Is a base relation type. It calculates the difference between value
% and base.
%
% \[\cmd{\drefresult} = \texttt{value} - \texttt{base}\]
%
% \verb|\drefrel[delta,base=50,base plain,value plain]{45}| $\Rightarrow$
% \drefrel[delta,base=50,base plain,value plain]{45}
%
% \DescribeMacro{/dref/scale}
% \DescribeMacro{/dref/product}
%
% Is a base-relation type. It calculates the product of value and base.
%
% \[\cmd{\drefresult} = \texttt{value} \cdot \texttt{base}\]
%
% \verb|\drefrel[scale,base=50,base plain,value plain]{45}| $\Rightarrow$
% \drefrel[scale,base=100,base plain,value plain]{0.45}
%
% % \DescribeMacro{/dref/percent}
%
% Is a post-processing type. It calculates the percent value from a fraction.
%
% \[\cmd{\drefresult} = \cmd{\drefresult} \cdot 100.0 \]
%
% \noindent\verb|\drefrel[factor,percent,base=/med A/mice count]{/med A/recovered}| \\
% \mbox{}\hspace{1cm}$\Rightarrow$ \drefrel[factor,percent,base=/med A/mice count]{/med A/recovered}
%
% % \DescribeMacro{/dref/abs}
%
% Is a post-processing type. It takes the absolute value.
%
% \[\cmd{\drefresult} = \mid \cmd{\drefresult} \mid \]
% \verb|\drefrel[overhead,abs,base=50,base plain,value plain]{45}| $\Rightarrow$
% \drefrel[overhead,abs,base=50,base plain,value plain]{45}
%
% % \DescribeMacro{/dref/negate}
%
% Is a post-processing type. It negates the value.
%
% \[\cmd{\drefresult} = \cmd{\drefresult} \cdot -1.0 \]
%
% \noindent\verb|\drefrel[factor,negate,base=/med A/mice count]{/med A/recovered}| \\
% \mbox{}\hspace{1cm}$\Rightarrow$ \drefrel[factor,negate,base=/med A/mice count]{/med A/recovered}
%
% \DescribeMacro{/dref/divide}
%
% Is a post-processing type. Divides the result by a contant
% factor. The argument must be a plain number.
%
% \[\cmd{\drefresult} = \cmd{\drefresult} \cdot \{divide\} \]
%
% \noindent\verb|\drefrel[value plain,divide=1e6]{1453342654}|
% $\Rightarrow$
% \drefrel[value plain,divide=1e6]{1453342654}
%
%
% \DescribeMacro{\drefprojection\{\meta{from}\}\{\meta{to}\}\{\meta{projection}\}}
%
% Sometimes one or multiple sets of data have to be projected/mixed into a
% new set of data that is fully dependent on those values. This is
% achieved with \cmd{\drefprojection}. It projects one data set (subdirectoy) into
% another one. Tithin the projection three different operations are
% possible: \cmd{\id}, \cmd{\rename} and \cmd{\calc}.
%
% \drefprojection{/control group}{/projection}{
% \id{mice race} % identity function
% \rename{mice count}{count} % renaming of points
% \calc{data("/dead after 24h")+data("/dead after 48h")}{died}
% }
%
% \begin{quote}
% \begin{verbatim}\drefprojection{/control group}{/projection}{
% \id{mice race} % identity function
% \rename{mice count}{count} % renaming of points
% \calc{data("/dead after 24h")+data("/dead after 48h")}{died}
% }\end{verbatim}
%
% \verb|\dref*{/projection/died}| $\Rightarrow$ \dref*{/projection/died}\\
% \verb|\dref*{/projection/mice race}| $\Rightarrow$ \dref*{/projection/mice race}\\
% \verb|\dref{/projection/count}| $\Rightarrow$ \dref{/projection/count}
% \end{quote}
%
% \DescribeMacro{\drefrow\{\meta{list}\}\{\meta{macro}\}}
% \DescribeMacro{\drefrow*}
%
%
% Often different columns in a table have to be obtained from your data
% points. Often those rows and columns are similar. Generating parts of
% tables within \LaTeX is very tricky, so \textsf{dataref} provides you
% with \cmd{\drefrow}. This macro iterates over a comma-separated list
% of values and fills out a macro which is interpreted as a symbolic
% data point. The entries are seperated with \& and printed. In the
% starred variant the resulting text is not interpreted as symbolic
% name, but as a macro. The symbolic name is expanded with \cmd{\drefvalueof}.
%
% The second argument is the macro, and can have two macro
% replacements. The first replacement \verb|#1| is the value of the list
% item, the second \verb|#2| is the index in the list.
%
% \begin{verbatim}\begin{tabular}{lccc}
% Group & $<$ 24h & $<$48h & recovered\\ \hline
% Control Group & \drefrow{dead after 24h,dead after 48h,recovered}%
% {/control group/#1}\\
% Medicament A & \drefrow{dead after 24h,dead after 48h,recovered}%
% {/med A/#1}\\
% Starred Variant & \drefrow*{B,C,D}{\#1=#1,\#2=#2}\\
% \end{tabular}
% \end{verbatim}
%
%
% \vspace{1em}\begin{tabular}{lccc}
% Group & $<$ 24h & $<$48h & recovered\\ \hline
% Control Group & \drefrow{dead after 24h,dead after 48h,recovered}%
% {/control group/#1}\\
% Medicament A & \drefrow{dead after 24h,dead after 48h,recovered}%
% {/med A/#1}\\\hline
% Starred Variant & \drefrow*{B,C,D}{\#1=#1,\#2=#2}\\
% \end{tabular}\vspace{1em}
%
% \DescribeMacro{\drefassert\{\meta{expr}\}}
% \DescribeMacro{[noassert]}
%
% Sometimes the underlying data changes while you are writing. But what
% if your prose text relies on certain characteristics of the data. \cmd{\drefassert} uses a pgfmath
% expression that evaluates to \verb|true| or \verb|false|. When the
% assertion holds (\verb|true|) nothing happens, only a terminal message
% is printed. When it does not hold (\verb|false|) the compilation is aborted.
%
% \begin{verbatim}\drefassert{data("/control group/mice count") > 30}
% Of the more than thirty infected mice...
% \end{verbatim}
% \drefassert{data("/control group/mice count") > 30}
% \begingroup \pgfset{/pgf/fpu} \drefassert{data("/control group/mice
% count") > 30} \endgroup
%
% The \textbf{noassert} package options disables the latex abortion. In
% that case only a warning message is printed on the terminal.
%
% \DescribeMacro{[annotate=none]}
% \DescribeMacro{[annotate=footnote]}
% \DescribeMacro{[annotate=pdfcomment]}
% \DescribeMacro{\drefannotate\{\meta{style}\}}
%
%
% While writing a document it is desirable to know, what key is used,
% while writing the text and generating the document. Therefore
% \textsf{dataref} provides the possibility to annotate values. The
% default package option \textbf{none} disables this kind of
% annotation. The \textbf{pdfcomment} option uses pdf
% annotations. Be aware that those annotations work properlyy only on a few
% selected PDF readers\footnote{In doubt use Acrobat}. \cmd{\drefannotate} sets the annoation
% style for the current group.
%
% \begin{quote}
% \verb|\drefannotate{none}|\drefannotate{none}\\
% \dref*{/control group/mice race}, \dref{/control group/mice count}, \drefcalc{100/3}
% \end{quote}
%
% \begin{quote}
% \verb|\drefannotate{footnote}|\drefannotate{footnote}\\
% \dref*{/control group/mice race}, \dref{/control group/mice count}, \drefcalc{100/3}
% \end{quote}
%
% \begin{quote}
% \verb|\drefannotate{pdfcomment}|\drefannotate{pdfcomment}\\
% \dref*{/control group/mice race}, \dref{/control group/mice count}, \drefcalc{100/3}
% \end{quote}
%
% \DescribeMacro{\drefusagereport}
% \DescribeMacro{[usagereport]}
% \DescribeMacro{[refall]}
%
% With the \textbf{usagereport} package option enabled,
% \cmd{\drefusagereport} generates a usagereport of all referenced
% keys. The usage report groups the keys by the help texts. If the
% refall package option is given, all keys are marked as referenced.
%
% \section*{Datagraphy}
% \drefusagereport
% \pagebreak
% \StopEventually{}
%
% \section{Implementation}
%
% \iffalse
%<*package>
% \fi
%
% Guard against reading twice
% \begin{macrocode}
\ifx\drefloaded\undefined
\let\drefloaded=\relax
\else
\expandafter\endinput
\fi
\ifx\PackageError\undefined
\def\dref@error#1{\immediate\write-1{Package dref: Error! #1.}}%
\else
\def\dref@error#1{\PackageError{dref}{#1}{}}%
\fi
% \end{macrocode}
%
% \begin{macrocode}
\RequirePackage{pgf}
\RequirePackage{iftex}
\RequirePackage{kvoptions}
\usepgflibrary{fpu}
\usepackage{etoolbox}
\RequirePackage{xcolor}
% \end{macrocode}
% \begin{macrocode}
\SetupKeyvalOptions{
family=dref,
prefix=dref@
}
\DeclareStringOption[/data]{datapath}
\DeclareStringOption[1]{defaultvalue}
\DeclareStringOption[none]{annotate}
\DeclareBoolOption{usagereport}
\DeclareBoolOption{refall}
\DeclareBoolOption{ignoremissing}
\DeclareBoolOption{noassert}
\ProcessKeyvalOptions*
% \end{macrocode}
%
% \begin{macro}{\dref@set}
% \begin{macrocode}
\def\dref@set#1#2{%
\edef\dref@set@tmp{#2}%
\expandafter\pgfkeys@temptoks\expandafter{\dref@set@tmp}%
\expandafter\xdef\csname
pgfk@\dref@datapath#1\endcsname{\the\pgfkeys@temptoks}%
\ifdref@refall%
\expandafter\dref@found\expandafter{\dref@datapath#1}{0}
\expandafter\dref@referenced\expandafter{\dref@datapath#1}{0}%
\fi%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\drefset}
% \begin{macrocode}
\def\drefset#1#2{\dref@set{#1}{#2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dref@expandable}
% \begin{macrocode}
\def\dref@expandable#1{%
\pgfkeysifdefined{\dref@datapath\csuse{dref@prefix}#1}{%
\pgfkeysvalueof{\dref@datapath\csuse{dref@prefix}#1}%
}{%
\ifdref@ignoremissing%
\dref@defaultvalue%
\else%
\typeout{Dref error: undefined key `#1'}\QUIT%
\fi%
}%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\dref@unexpandable}
% \begin{macrocode}
\def\dref@unexpandable#1{%
\def\drefcurrentkey{\dref@datapath\csuse{dref@prefix}#1}%
\pgfkeysifdefined{\drefcurrentkey}{%
\edef\dref@thepage{\arabic{page}}%
\immediate\write\@auxout{\noexpand\dref@found{\drefcurrentkey}{\dref@thepage}}%
}{%
\immediate\write\@auxout{\noexpand\dref@notfound{\drefcurrentkey}{\dref@thepage}}%
}%
\immediate\write\@auxout{\noexpand\dref@referenced{\drefcurrentkey}{\dref@thepage}}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\drefifdefined}
% \begin{macrocode}
\newcommand{\drefifdefined}[3]{
\def\drefcurrentkey{\dref@datapath\csuse{dref@prefix}#1}%
\pgfkeysifdefined{\drefcurrentkey}{#2}{#3}%
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\dref}
% \begin{macrocode}
\def\dref{\@ifstar\@@dref\@dref}
\newcommand{\@dref}[2][]{% Unstarred
\edef\dref@argument{#2}%
\expandafter\dref@unexpandable\expandafter{\dref@argument}%
\pgfmathparse{\dref@expandable{#2}}%
\dref@format[#1]{\pgfmathresult}%
\dref@mkannotate{\textbackslash dref\{#2\}}%
}
\newcommand{\@@dref}[2][]{% Starred
\edef\dref@argument{#2}%
\expandafter\dref@unexpandable\expandafter{\dref@argument}%
\expandafter\gdef\expandafter\dref@dref@output\expandafter{\expandafter\dref@expandable\expandafter{\dref@argument}}%
\dref@dref@output%
\dref@mkannotate{\textbackslash dref*\{#2\}}%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\drefvalueof}
% \begin{macrocode}
\def\drefvalueof#1{%
\dref@expandable{#1}%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\drefref}
% \begin{macrocode}
\def\drefref#1{%
\dref@unexpandable{#1}%
}
% \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\dref@help@match}
% \begin{macrocode}
%% dref@ifstrmatch is copied from etextools, but etextools is
%% incompatible with etoolbox
%% \ifstrmatch{ pattern }{ string }{ true }{ false }
\ifPDFTeX%
\let\dref@strmatch\pdfmatch
\fi
\ifLuaTeX%
\newcommand{\dref@strmatch}[2]{%
\directlua{%
local match = string.find("\luaescapestring{#2}", "\luaescapestring{#1}");%
if match then
tex.print("1");
else
tex.print("0");
end
}%
}
\fi
\long\def\dref@firstoftwo#1#2{\z@#1} %% for romannumeral
\long\def\dref@secondoftwo#1#2{\z@#2}%% for romannumeral
\newcommand{\dref@ifstrmatch}[2]{%
\romannumeral\csname dref@%
\ifnum\dref@strmatch{#1}{#2}=1 first\else second\fi oftwo\endcsname%
}
\newcommand{\dref@help@match}[2]{%
\dref@ifstrmatch{#1}{#2}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dref@help}
% \begin{macrocode}
\newcommand{\dref@help}[2][]{%
\pgfkeysifdefined{#2/help}{%
\pgfkeysvalueof{#2/help}%
}{#1}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\drefsethelp}
% \begin{macrocode}
\csdef{dref@helps}{}
\newcommand{\drefsethelp}[2]{
\csdef{dref@help@#1}{#2}%
\listcsadd{dref@helps}{#1}%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\drefhelp}
% \begin{macrocode}
\newcommand{\drefhelp}[1]{
\renewcommand{\do}[1]{%
\dref@help@match{##1}{#1}{%
\csuse{dref@help@##1}%
\listbreak}{}%
}%
\ifcsvoid{dref@helps}{}{%
\dolistcsloop{dref@helps}%
}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dref@referenced}
% \begin{macrocode}
\def\dref@notfound#1#2{
\ifdref@usagereport%
\dref@usagereport@notfound{#1}{#2}%
\else\relax\fi%
}
\def\dref@found#1#2{
\ifdref@usagereport%
\dref@usagereport@found{#1}{#2}%
\else\relax\fi%
}
\def\dref@referenced#1#2{
\ifdref@usagereport%
\dref@usagereport@referenced{#1}{#2}%
\else\relax\fi%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dref@let}
% \begin{macrocode}
\def\dref@let#1{%
\def\@tmp##1=##2;{\pgfmathdeclarefunction*{##1}{0}{\pgfmathparse{##2}}}%
\renewcommand*{\do}[1]{\@tmp##1;}%
\ifstrempty{#1}{}{%
\docsvlist{#1}%
}%
}
% \end{macro}
%
%
% \begin{macro}{\dreflet}
% \begin{macrocode}
\def\dreflet#1{%
\dref@let{#1}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\drefcalc}
% \begin{macrocode}
\def\dref@parser#1#2{%
\edef\@tempa{#1}%
\csdef{dref@parser@result}{}%
\csdef{dref@parser@state}{}%
\expandafter\dref@parser@parse\@tempa\@nnil%
\xdef#2{\csuse{dref@parser@result}}%
}
\def\dref@parser@parse#1#2\@nnil{%
%\typeout{#1 State: \csuse{dref@parser@state}}%
\ifblank{#1#2}{%
\csxdef{dref@parser@result}{\csuse{dref@parser@result}\csuse{dref@parser@state}}%
}{%
\ifcsdef{dref@parser@\csuse{dref@parser@state}@#1}{%
\csuse{dref@parser@\csuse{dref@parser@state}@#1}#2\@nnil%
}{%
\csxdef{dref@parser@result}{\csuse{dref@parser@result}\csuse{dref@parser@state}#1}%
\csdef{dref@parser@state}{}%
\ifblank{#2}{}{%
\dref@parser@parse#2\@nnil%
}%
}%
}%
}
\csdef{dref@parser@@d}{\csdef{dref@parser@state}{d}\dref@parser@parse}
\csdef{dref@parser@d@a}{\csdef{dref@parser@state}{da}\dref@parser@parse}
\csdef{dref@parser@da@t}{\csdef{dref@parser@state}{dat}\dref@parser@parse}
\csdef{dref@parser@dat@a}{\csdef{dref@parser@state}{data}\dref@parser@parse}
\csdef{dref@parser@data@(}{\csdef{dref@parser@state}{data(}\dref@parser@parse}
\csdef{dref@parser@data(@"}{\dref@parser@tillquote}
\csdef{dref@parser@d@(}{\dref@parser@tillparen}
\def\dref@parser@tillquote#1")#2\@nnil{%
\drefref{\dref@data@math@prefix #1}%
\csxdef{dref@parser@result}{\csuse{dref@parser@result}(\drefvalueof{\dref@data@math@prefix #1})}%
\csdef{dref@parser@state}{}%
\ifblank{#2}{}{\dref@parser@parse#2\@nnil}}
\def\dref@parser@tillparen#1)#2\@nnil{%
\drefref{\dref@data@math@prefix #1}%
\csxdef{dref@parser@result}{\csuse{dref@parser@result}(\drefvalueof{\dref@data@math@prefix #1})}%
\csdef{dref@parser@state}{}%
\ifblank{#2}{}{\dref@parser@parse#2\@nnil}}%
\def\dref@parser@end#1#2\@nnil{}
\csdef{dref@parser@@}{\typeout{end}\dref@parser@end}
\newcommand{\dref@calc}[1]{%
%\typeout{Before: '#1'}%
\dref@parser{#1}{\dref@calc@@argA}%
%\typeout{After: \dref@calc@@argA}%
\pgfmathparse{\dref@calc@@argA}%
}
\pgfset{/dref/let/.code={\dref@let{#1}}}
\pgfset{/dref/prefix/.code={\csdef{dref@prefix}{#1}}}
\def\drefprefix#1{\csdef{dref@prefix}{#1}}
\def\drefresult{0}
\def\drefcalc{\@ifstar\@@drefcalc\@drefcalc}
\newcommand{\@drefcalc}[2][]{% Unstarred
\begingroup%
\pgfset{/pgf/number format/.cd, #1}%
\dref@calc{#2}%
\pgfmathprintnumberto[fixed,assume math mode=true,precision=10,1000 sep={}]{\pgfmathresult}{\drefresult}%
\xdef\drefresult{\drefresult}%
\dref@format{\pgfmathresult}%
\dref@mkannotate{\textbackslash drefcalc\{#2\}}%
\endgroup%
}
\newcommand{\@@drefcalc}[2][]{ % Starred
\begingroup%
\pgfset{/pgf/number format/.cd, #1}%
\dref@calc{#2}%
\pgfmathprintnumberto[fixed,assume math mode=true,precision=10,1000 sep={}]{\pgfmathresult}{\drefresult}%
\xdef\drefresult{\drefresult}%
\endgroup%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\drefformat}
% \begin{macrocode}
\newcommand{\dref@format}[2][]{%
\pgfmathprintnumber[#1]{#2}%
}
\newcommand{\drefformat}[2][]{\dref@format[#1]{#2}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{data()}
% \begin{macrocode}
\gdef\dref@data@math@prefix{}
\pgfmathdeclarefunction{data}{1}{%
\begingroup%
\dref@unexpandable{\dref@data@math@prefix#1}%
\pgfmathparse{\dref@expandable{\dref@data@math@prefix#1}}%
\pgfmath@smuggleone\pgfmathresult%
\endgroup%
}
\long\def\drefprojection#1#2#3{%
\begingroup%
\def\dref@data@math@prefix{#1}%
\def\rename##1##2{\dref@unexpandable{#1/##1}\drefset{#2/##2}{\dref@expandable{#1/##1}}}%
\def\id##1{\rename{##1}{##1}}%
\def\calc##1##2{%
\begingroup%
\drefcalc{##1}%
\xdef\dref@project@result{\drefresult}
\endgroup%
\drefset{#2/##2}{\dref@project@result}%
}%
#3%
\endgroup%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dref@makerow}
% \begin{macrocode}
\newtoks\dref@toks
\newcount\drefcellcount
\newcommand{\dref@makerow}[2]{%
{\global\dref@toks={}%
\drefcellcount=\z@%
\def\do##1{%
\advance\drefcellcount\@ne%
\def\@tempa{\doX{##1}}%
\expandafter\@tempa\expandafter{\the\drefcellcount}%
}%
\def\doX##1##2{%
\csxdef{@cell\the\drefcellcount}{\detokenize{%
#2%
}}%
}%
\expandafter\def\expandafter\arglist\expandafter{#1}%
\expandafter\docsvlist\expandafter{\arglist}%
\@tempcntb=0\relax
{\loop\ifnum\@tempcntb<\drefcellcount
\advance\@tempcntb by 1\relax%
\ifnum \@tempcntb = 1%
\edef\@@next{\csuse{@cell\the\@tempcntb}}%
\else%
\edef\@@next{&\csuse{@cell\the\@tempcntb}}%
\fi%
\global%
\dref@toks%
\expandafter=%
\expandafter{%
\the%
\expandafter\dref@toks%
\@@next}%
\repeat}%
}%
\typeout{LINE: \the\dref@toks}%
\expandafter\scantokens\expandafter{\the\dref@toks}}
\long\def\drefrow{\@ifstar\@@drefrow\@drefrow}
\def\@drefrow#1#2{\dref@makerow{#1}{\dref{#2}}} % Unstarred
\def\@@drefrow#1#2{\dref@makerow{#1}{#2}} % Starred
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dref@mkannotate}
% \begin{macrocode}
\expandafter\ifstrequal\expandafter{\dref@annotate}{pdfcomment}{
\RequirePackage{pdfcomment}
}
\def\dref@mkannotate@none#1{\relax}
\def\dref@mkannotate@footnote#1{\footnote{\texttt{#1}}}
\def\dref@mkannotate@pdfcomment#1{\pdfcomment[opacity=0.4,voffset=2ex]{#1}}
\newcommand{\dref@mkannotate}[1]{%
\ifcsdef{dref@mkannotate@\dref@annotate}{%
\csuse{dref@mkannotate@\dref@annotate}{#1}%
}{%
\dref@error{Value for annotate not supported: '\dref@annotate'}%
}%
}
\newcommand{\drefannotate}[1]{%
\renewcommand{\dref@annotate}{#1}%
}
% \end{macrocode}
% \end{macro}
%
%% Usagereport
% \begin{macrocode}
\ifdref@usagereport
\RequirePackage{xtab}
\RequirePackage{booktabs}
\fi
% \end{macrocode}
%
% \begin{macro}{\dref@usagereport@referenced}
% \begin{macrocode}
\newcommand{\dref@usagereport@notfound}[2]{}
\newcommand{\dref@usagereport@found}[2]{}
\csdef{pgfdat@usagereport@keys}{}
\csdef{pgfdat@usagereport@matchedkeys}{}
\newcommand{\dref@usagereport@referenced}[2]{
\ifinlistcs{#2}{dref@usagereport@referenced@#1}{}{
\listcsgadd{dref@usagereport@referenced@#1}{#2}
}
\ifinlistcs{#1}{dref@usagereport@keys}{}{
\listcsgadd{dref@usagereport@keys}{#1}
}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dref@usagereport@strippath}
% \begin{macrocode}
\expandafter\def\expandafter\dref@usagereport@strippath@\dref@datapath#1\blanktest{#1}
\newcommand{\dref@usagereport@strippath}[1]{%
\expandafter\dref@ifstrmatch\expandafter{\expandafter^\dref@datapath.*$}{#1}%
{\dref@usagereport@strippath@#1\blanktest}%
{#1}%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\dref@usagereport@formatreferencelist}
% \begin{macrocode}
\newcommand{\dref@usagereport@formatreferencelist}[1]{%
\begingroup%
\def\sep{}%
\renewcommand{\do}[1]{\sep\ifdef{\hyperlink}{\hyperlink{page.##1}{##1}}{##1}\def\sep{, }}%
\dolistcsloop{dref@usagereport@referenced@#1}%
\endgroup%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\dref@usagereport@keyheader}
% \begin{macrocode}
\newif\ifdref@usagereport@keyheader@first
\dref@usagereport@keyheader@firsttrue
\newcommand{\dref@usagereport@keyheader}[1]{%
\ifdref@usagereport@keyheader@first%
\global\dref@usagereport@keyheader@firstfalse%
\else%
\\%
\fi%
\textbf{\ifdef{\hypertarget}%
{\hypertarget{#1}{\dref@usagereport@strippath{#1}}}%
{\dref@usagereport@strippath{#1}}}%
& \dref@usagereport@formatreferencelist{#1}%
& \pgfkeysifdefined{#1}{\pgfkeysvalueof{#1}}{\textbf{\color{red}undefined}}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\drefusagereportaftergroup}
% \begin{macrocode}
\def\drefusagereportaftergroup{}
\def\drefusagereportbeforerow{}
\def\drefusagereportbeforetitle{}
\def\drefusagereportaftertitle{}
\def\drefusagereportbeforedescription{}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\dref@usagereport@forhelp}
% \begin{macrocode}
\newif\ifdref@withhelp
\errorcontextlines=23
\newlength{\dreflinewidth}%
\newcommand{\dref@usagereport@forhelp}[1]{%
\begingroup%
\dref@withhelpfalse%
\renewcommand{\do}[1]{%
\dref@help@match{#1}{##1}{%
\dref@withhelptrue%
}{}%
}%
\dolistcsloop{dref@usagereport@keys}%
\dref@usagereport@keyheader@firsttrue%
\renewcommand{\do}[1]{%
\dref@help@match{#1}{##1}{%
\drefusagereportbeforerow%
\dref@usagereport@keyheader{##1}%
\ifinlistcs{##1}{dref@usagereport@matchedkeys}{}{%
\listcsgadd{dref@usagereport@matchedkeys}{##1}%
}%
}{}%
}%
\ifdref@withhelp
\tablehead{\drefusagereportbeforetitle%
\hline & Page & Value %
\drefusagereportaftertitle\\\hline%
}%
\setlength\tabcolsep{3pt}%
\dreflinewidth=\linewidth%
\advance\dreflinewidth by -4\tabcolsep%
\advance\dreflinewidth by -2\arrayrulewidth%
\begin{xtabular}{|p{0.7\dreflinewidth}|p{0.15\dreflinewidth}|p{0.15\dreflinewidth}|}%
\dolistcsloop{dref@usagereport@keys}\\\hline
\drefusagereportbeforedescription%
\multicolumn{3}{|p{\linewidth}|}{\csuse{dref@help@#1}}\\\hline
\end{xtabular}%
\fi%
\drefusagereportaftergroup%
\endgroup%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\dref@usagereport@withouthelp}
% \begin{macrocode}
\newif\ifdref@withouthelp
\newcommand{\dref@usagereport@withouthelp}{%
\begingroup%
\dref@withouthelpfalse%
\renewcommand{\do}[1]{%
\ifinlistcs{##1}{dref@usagereport@matchedkeys}{}{%
\dref@withouthelptrue%
}%
}%
\dolistcsloop{dref@usagereport@keys}%
\dref@usagereport@keyheader@firsttrue%
\renewcommand{\do}[1]{%
\ifinlistcs{##1}{dref@usagereport@matchedkeys}{}{%
\drefusagereportbeforerow%
\dref@usagereport@keyheader{##1}%
}%
}%
\ifdref@withouthelp%
\tablehead{\drefusagereportbeforetitle%
\hline Keys without Description & Page & Value %
\drefusagereportaftertitle\\\hline%
}%
\setlength\tabcolsep{3pt}%
\dreflinewidth=\linewidth%
\advance\dreflinewidth by -4\tabcolsep%
\advance\dreflinewidth by -2\arrayrulewidth%
\begin{xtabular}{|p{0.7\dreflinewidth}|p{0.15\dreflinewidth}|p{0.15\dreflinewidth}|}%
\dolistcsloop{dref@usagereport@keys}\\\hline
\drefusagereportbeforedescription%
\multicolumn{3}{|p{\linewidth}|}{%
\emph{For these keys, no description was given}}\\\hline
\end{xtabular}%
\fi%
\endgroup%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\drefusagereport}
% \begin{macrocode}
\newcommand{\drefusagereport}{%
\ifdref@usagereport%
\ifcsvoid{dref@usagereport@keys}{\typeout{EMPTY}}{%
\begingroup%
\renewcommand{\do}[1]{%
\ifinlistcs{##1}{dref@usagereport@matchedkeys}{}{%
\dref@usagereport@forhelp{##1}%
}%
}%
\dolistcsloop{dref@helps} % For all help text
\dref@usagereport@withouthelp\relax
\endgroup%
}% csempty @keys
\fi%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\drefassert}
% \begin{macrocode}
\newcommand{\drefassert}[1]{%
\begingroup%
\drefcalc*{#1}%
\expandafter\ifstrequal\expandafter{\drefresult}{1}{%
\typeout{Assertion holds: #1}%
}{%
\ifdref@noassert%
\typeout{Assertion failed: #1}%
\else%
\dref@error{Assertion failed: #1}%
\fi%
}%
\endgroup%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\drefrel}
% \begin{macrocode}
\newif\if@dref@valuemustderef%
\newif\if@dref@basemustderef%
\newif\if@dref@increase%
\newif\if@dref@product%
\newif\if@dref@factor%
\newif\if@dref@delta%
\newif\if@dref@percent%
\newif\if@dref@abs%
\newif\if@dref@neg%
\pgfkeys{%
\dref@datapath/.DUMMY/.initial=1
}
\pgfkeys{%
/dref/.cd,%
value/.initial = /.DUMMY,%
base/.initial = /.DUMMY,%
divide/.initial = 1,%
value plain/.is if=@dref@valuemustderef,%
value plain/.default=false,%
value plain=true,%
base plain/.is if=@dref@basemustderef,%
base plain/.default=false,%
base plain=true,%
factor/.is if=@dref@factor,%
factor/.default=true,%
factor=false,%
delta/.is if=@dref@delta,%
delta/.default=true,%
delta=false,%
scale/.is if=@dref@product,%
scale/.default=true,%
scale=false,%
product/.is if=@dref@product,%
product/.default=true,%
product=false,%
increase/.is if=@dref@increase,%
increase/.default=true,%
increase=false,%
overhead/.is if=@dref@increase,%
overhead/.default=true,%
overhead=false,%
percent/.is if=@dref@percent,%
percent/.default=true,%
percent=false,%
abs/.is if=@dref@abs,%
abs/.default=true,%
abs=false,%
negate/.is if=@dref@neg,%
negate/.default=true,%
negate=false,%
}
\def\drefrel{\@ifstar\@@drefrel\@drefrel}
\newcommand{\@drefrel}[2][]{%
\@@drefrel[#1]{#2}%
\@@drefrel@result%
\dref@mkannotate{\textbackslash{}drefrel[#1]\{#2\}}%
}
\newcommand{\@@drefrel}[2][]{%
\begingroup%
\pgfkeys{/pgf/fpu}%
\pgfkeys{/dref/.cd,#1}%
\pgfkeys{/dref/value=#2}%
\if@dref@valuemustderef%
\drefref{\pgfkeysvalueof{/dref/value}}%
\edef\drefvalue{\drefvalueof{\pgfkeysvalueof{/dref/value}}}%
\else%
\def\drefvalue{\pgfkeysvalueof{/dref/value}}%
\fi%
\if@dref@basemustderef%
\drefref{\pgfkeysvalueof{/dref/base}}%
\def\drefbase{\drefvalueof{\pgfkeysvalueof{/dref/base}}}%
\else%
\def\drefbase{\pgfkeysvalueof{/dref/base}}%
\fi%
\xdef\drefresult{\drefvalue}%
\if@dref@increase%
\pgfmathparse{((\drefvalue) - (\drefbase)) / (\drefbase)}%
\def\drefresult{\pgfmathresult}%
\else%
\if@dref@factor%
\pgfmathparse{(\drefvalue) / (\drefbase)}%
\def\drefresult{\pgfmathresult}%
\else%
\if@dref@delta%
\pgfmathparse{(\drefvalue) - (\drefbase)}%
\def\drefresult{\pgfmathresult}%
\else%
\if@dref@product%
\pgfmathparse{(\drefvalue) * (\drefbase)}%
\def\drefresult{\pgfmathresult}%
\else
\def\drefresult{\drefvalue}%
\fi
\fi%
\fi%
\fi%
% Percent
\if@dref@percent%
\pgfmathparse{(\drefresult)*100.0}%
\def\drefresult{\pgfmathresult}%
\fi%
% Absolute Value
\if@dref@abs%
\pgfmathparse{abs(\drefresult)}%
\def\drefresult{\pgfmathresult}%
\fi%
% Negative Value
\if@dref@neg%
\pgfmathparse{-1.0*(\drefresult)}%
\def\drefresult{\pgfmathresult}%
\fi%
\pgfmathparse{\drefresult/\pgfkeysvalueof{/dref/divide}}%
\pgfmathprintnumberto[fixed,assume math mode=true,precision=10,1000 sep={}]{\pgfmathresult}{\drefresult}%
\pgfmathprintnumberto{\pgfmathresult}{\@@drefrel@result}%
\xdef\drefresult{\drefresult}%
\xdef\@@drefrel@result{\@@drefrel@result}%
\endgroup%
}
%
% \end{macrocode}
% \end{macro}
%
% \iffalse
%</package>
% \fi
%
% \Finale
\endinput
|