summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/dataref
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/dataref
Initial commit
Diffstat (limited to 'macros/latex/contrib/dataref')
-rw-r--r--macros/latex/contrib/dataref/README.md51
-rw-r--r--macros/latex/contrib/dataref/doc/dataref-doc.pdfbin0 -> 238060 bytes
-rw-r--r--macros/latex/contrib/dataref/doc/dataref-doc.tex735
-rw-r--r--macros/latex/contrib/dataref/tex/dataref.sty952
4 files changed, 1738 insertions, 0 deletions
diff --git a/macros/latex/contrib/dataref/README.md b/macros/latex/contrib/dataref/README.md
new file mode 100644
index 0000000000..bcd6362daf
--- /dev/null
+++ b/macros/latex/contrib/dataref/README.md
@@ -0,0 +1,51 @@
+dataref
+=======
+
+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 dataref is here to help you with managing your data points. It provides
+you with macro style keys, that represent symbolic names for your datapints.
+You can reference those symbolic names with \dref, use them in calculations
+to have always up-to-date percentage values, define projections between sets of
+data points and document them. dataref also introduces the notion of assertions
+(\drefassert) for your results to ensure that your prosa text references fit the
+underlying data.
+
+Building the documentation
+==========================
+With latexmk installed:
+
+ make
+
+or
+
+ pdflatex dataref.tex; pdflatex dataref.tex; pdflatex dataref.tex
+
+
+Examples
+========
+
+Setting symbolic data points
+
+ \drefset{/count}{42}
+ \drefset{/abc}{23}
+
+Referencing them with \dref, \drefcalc, \drefassert
+
+ \dref{/count} => 42
+ \drefcalc{data("/abc") / data("/count")} => 0.55
+ \drefassert{data("/abc") < data("/count")}
+
+Getting the latest version
+==========================
+
+dataref is hosted at github: https://github.com/stettberger/dataref
diff --git a/macros/latex/contrib/dataref/doc/dataref-doc.pdf b/macros/latex/contrib/dataref/doc/dataref-doc.pdf
new file mode 100644
index 0000000000..ec64e4c97a
--- /dev/null
+++ b/macros/latex/contrib/dataref/doc/dataref-doc.pdf
Binary files differ
diff --git a/macros/latex/contrib/dataref/doc/dataref-doc.tex b/macros/latex/contrib/dataref/doc/dataref-doc.tex
new file mode 100644
index 0000000000..d50200f57a
--- /dev/null
+++ b/macros/latex/contrib/dataref/doc/dataref-doc.tex
@@ -0,0 +1,735 @@
+% Copyright (c) 2013-2017 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.tex and dataref.sty
+
+\documentclass{ltxdoc}
+\usepackage[usagereport]{dataref}[2017/01/06]
+
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+
+\usepackage{verbatim}
+\usepackage{listings}
+\usepackage{pdfcomment}
+\usepackage{siunitx}
+\usepackage{xspace}
+\usepackage{pgffor}
+\usepackage{filecontents}
+\usepackage{tikz}
+\usetikzlibrary{positioning, arrows}
+
+\begin{filecontents}{datapoints.tex}
+\drefset{/control group/mice race}{Black Six}
+\drefset{/control group/mice count}{32}
+\drefset{/control group/dead after 24h}{4}
+\drefset{/control group/dead after 48h}{7}
+\drefset{/control group/recovered}{21}
+
+\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}{12}
+\drefset{/med A/recovered}{20}
+
+\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. The dead categories are cumulative and
+include all dead mice before.}
+\end{filecontents}
+\input{datapoints}
+% \OnlyDescription
+\drefkeys{prefix=/foo,value=123,save=/foo}
+\drefset{/override test}{2}
+\begin{document}
+\drefsave{/override test}{4}
+\drefkeys{prefix=}
+
+\parskip=1ex
+\parindent=0pt
+
+\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.6}{2016/11/15}{Units, Unit Scaling, general overhaul}
+ \changes{v0.4}{2015/04/21}{Remove Spurious Whitespaces}
+ \changes{v0.1}{2013/12/06}{Initial version}
+
+ \DoNotIndex{\newcommand,\newenvironment}
+
+ \makeatletter
+ \def\colorfirsttoken#1#2{\bgroup\expandafter\color{#1}\cmd{#2}\egroup}
+ \def\Macro@Name#1#2\@nnil{\string#1}
+
+\renewcommand{\meta}[1]{\bgroup\color{green!40!black}$\langle$\textit{#1}$\rangle$\egroup}
+\newcommand{\Macro}[2][]{%
+ \noindent\hspace{-\marginparwidth}%
+ \hypertarget{\Macro@Name#2\@nnil}{%
+ \mbox{\colorfirsttoken{blue!50!black}#2}} \hfill\mbox{#1}\par}
+ \newcommand{\Option}[2][]{%
+ \noindent\hspace{-\marginparwidth}%
+ \mbox{\color{red!50!black}#2} \hfill\mbox{#1}\par}
+
+ \newcommand{\option}[1]{%
+ \bgroup\color{red!50!black}#1\egroup\xspace
+ }
+
+ \renewcommand{\macro}[1]{%
+ \hyperlink{\Macro@Name#1\@nnil}{\bgroup\color{blue!50!black}\cmd#1\egroup}\xspace
+ }
+ \makeatother
+
+ \colorlet{examplefill}{yellow!80!black}
+ \definecolor{codebackground}{rgb}{0.9,0.9,1}
+ \newdimen\examplewidth
+ \newsavebox{\codebox}
+ \newenvironment{example}[1][\marginparwidth-12pt]
+ {\begin{lrbox}{\codebox}\begin{minipage}{#1-2\fboxsep}}
+ {\end{minipage}\end{lrbox}%
+ \examplewidth=\wd\codebox%
+ \addtolength{\examplewidth}{-\marginparwidth+15pt}%
+ \global\examplewidth=\examplewidth%
+ \noindent\hspace{-\marginparwidth}\colorbox{examplefill}{\usebox{\codebox}}\hspace{12pt}}
+
+ \newenvironment{codeexample}
+ {\begin{lrbox}{\codebox}\begin{minipage}{\textwidth-\examplewidth-2\fboxsep}}
+{\end{minipage}\end{lrbox}\noindent\colorbox{codebackground}{\usebox{\codebox}}\global\examplewidth=0pt%
+\par\vspace{1em}}%
+
+
+ \newcommand{\dataref}{\textsc{dataref}\xspace}
+ \providecommand*{\url}{\texttt}
+ \GetFileInfo{dataref.sty}
+ \title{The \textsf{dataref} package}
+ \author{Christian Dietrich 2013-2016\\ \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 \macro{\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 (\macro{\drefassert}) for your results to ensure that your prosa
+ text references fit the underlying data.
+
+ \section{Usage (or \dref*{/control group/mice count} mice)}
+
+ \begin{example}
+ From the \dref{/med A/mice count} mice in the experiment, \drefcalc[prefix=/med A]{d(/mice
+ count)-d(/recovered)} died.
+ \end{example}
+ \begin{codeexample}
+ \verb|\drefset{/med A/mice count}{32}|\\
+ \verb|\drefset{/med A/recovered}{20}|\\
+ \verb|From the \dref{/med A/mice count} mice in the experiment, |\\
+ \verb|\drefcalc[prefix=/med A]{d(/mice count)-d(/recovered)} died.|
+ \end{codeexample}
+
+ \subsection{Design Principles}
+
+ Before we jump into the description of \dataref, let us look a little bit into the design principles of \dataref. By
+ understanding the principles, you will be more productive and embedding data into your document will become easier.
+
+ First of all, \dataref is built on top of \textsf{pgfkeys} and \textsf{pgfmath} from the PGF/TiKZ macro packages. While
+ the former provides a usable user interface to provide options to \dataref, the later is used to perform computation on
+ your datapoints. If you are interested into these two excellent \TeX{} packages, please look at \texttt{texdoc
+ pgfmanual} for further information.
+
+ There are two aspects of \dataref: setting datapoints and referencing datapoints. While setting datapoints is kind of
+ boring, we have a wide variety of options when it comes to referencing. The expansion of datapoints is done in
+ multiples phases (see Figure~\ref{fig:pipeline}).
+
+
+ \begin{figure}[t]
+ \begin{tikzpicture}[node distance=0.5cm]
+ \tikzstyle{phase}=[draw,minimum width=1.5cm, fill=green!20!white];
+ \tikzstyle{desc}=[align=left, text width=3cm,anchor=#1,draw];
+
+
+ \node[phase](@init){@init};
+ \node[phase,right=of @init](@options){@options};
+ \node[phase,right=of @options](@get){@get};
+ \node[phase,right=of @get](@calc){@calc};
+ \node[phase,right=of @calc](@print){@print};
+ \node[phase,right=of @print](@set){@set};
+
+ \draw[>=latex']
+ (@init) edge[->] (@options)
+ (@options) edge[->] (@get)
+ (@get) edge[->] (@calc)
+ (@calc) edge[->] (@print)
+ (@print) edge[->] (@set);
+
+ \draw[ultra thin,shorten <=2pt] (@init) -- ++(75:1cm)
+ node[desc=south] {Set up a clean working environment.};
+
+ \draw[ultra thin,shorten <=2pt] (@options) -- ++(-140:1.5cm)
+ node[desc=north] {Parse the user-defined options and fill up all subsequent phases.};
+
+ \draw[ultra thin,shorten <=2pt] (@get) -- ++(95:1cm)
+ node[desc=south] {Load the main datapoint into \macro{\drefresult} and reference it.};
+
+ \draw[ultra thin,shorten <=2pt] (@calc) -- ++(-140:1.5cm)
+ node[desc=north] {Perform calculations on the main datapoint, including unit scaling.};
+
+ \draw[ultra thin,shorten <=2pt] (@print) -- ++(95:1.5cm)
+ node[desc=south] {Format and insert the result into the document body.};
+
+ \draw[ultra thin,shorten <=2pt] (@set) -- ++(-140:1.5cm)
+ node[desc=north] {Save the result as a datapoint or macro.};
+
+ \end{tikzpicture}
+ \caption{The \dataref Pipeline}\label{fig:pipeline}
+ \end{figure}
+
+ The \dataref macros are different regarding the phases they include or omit and in their default settings. In the
+ following, we will discuss all options and macros you can use to reference your datapoints. By default, the
+ \macro{\drefresult} is always set to the result of the pipeline.
+
+ \subsection{Setting Datapoints}
+
+
+
+ \Macro[(@set)]{\drefset\oarg{options}\{\meta{name}\}\{\meta{value}\}}
+
+
+\begin{codeexample}
+\begin{verbatim}
+\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}
+\end{verbatim}
+\end{codeexample}
+
+
+ The \macro{\drefset} command is used to define the symbolic datapoints. The name of a datapoint may contain virtually all
+ characters, including spaces and slashes. It is good practice to use a hierarchy to structure your data point names.
+ The value might be any string, while the focus of \dataref is on numerical datapoints. The \macro{\drefset} command works
+ outside the pipeline model (Figure \ref{fig:pipeline}) for performance reasons. It virtually consists only of the
+ @options and @set stage.
+
+ \Macro[(@set)]{\drefsave[\meta{options}]\{\meta{name}\}\{\meta{value}\}}
+
+ Besides setting the datapoint, \macro{\drefsave} writes it to the \textsc{aux} file and, therefore, makes it available in
+ the next \LaTeX{} run from the very beginning. The \option{ignoremissing} option is useful to reference the saved keys
+ at an earlier place in the document.
+
+\Option[(no default)]{/dref/set=\meta{key}}
+
+Inserts a \macro{\drefset} to the @set that captures the current result and saves it to the given datapoint.
+
+\Option[(no default)]{/dref/save=\meta{key}}
+
+Inserts a \macro{\drefsave} to the @set that captures the current result and saves it to the given datapoint. Since
+\macro{\drefsave} is used the result is available from the beginning of the document.
+
+\Option[(no default)]{/dref/to macro=\meta{macro}}
+
+The current result is saved to the given macro.
+
+\begin{example}[2cm]
+ \dref[set=/foo]{/med A/mice count} \dref{/foo}\\
+ \dref[ignoremissing]{/bar} \dref[save=/bar]{/med A/mice count}\\
+ \drefcalc*[to macro=\myresult]{3+2} \myresult
+\end{example}
+\begin{codeexample}
+\begin{verbatim}
+\dref[set=/foo]{/med A/mice count} \dref{/foo}\\
+\dref[ignoremissing]{/bar} \dref[save=/bar]{/med A/mice count}\\
+\drefcalc*[to macro=\myresult]{3+2} \myresult
+\end{verbatim}
+\end{codeexample}
+
+
+\Option[(no default, initially "")]{/dref/prefix=\meta{key prefix}}
+
+On every key retrieval or setting of a datapoint this prefix is added.
+It is a value-typed PGF key, so operations like
+\texttt{prefix/.append} are possible.
+
+\Macro{\drefinput[\meta{prefix}]\{\meta{filename}\}}
+
+Uses \cmd{\input} to read the file. During the processing of this file
+\option{prefix} is set to the given value. This is useful to include
+several files that resulted from different experiments but include
+equal datapoint keys.
+
+
+\subsection{Referencing Datapoints}
+
+
+ \Macro[(@options=\{print=default\}, @get, @calc, @print, @set)]{\dref*[\meta{options}]\{\meta{name}\}}
+ \Macro[(@options=\{print=raw\}, @get, @calc, @print, @set)]{\dref[\meta{options}]\{\meta{name}\}}
+
+ This macro is used to reference a single symbolic data point. The value stored in that datapoint is inserted into the
+ text. \macro{\dref} additionally marks the data point as used; it will appear in the datagraphy (see
+ Section~\ref{sec:datagraphy}). The starred variant does not attempt to parse the datapoint as a numerical value, but
+ outputs the saved string.
+
+\begin{example}
+\dref*{/control group/mice race}\\
+\dref*{/control group/mice count}\\
+\dref[sci,precision=2,zerofill=true]{/med A/recovered}
+\end{example}
+\begin{codeexample}
+\begin{verbatim}
+\dref*{/control group/mice race}\\
+\dref*{/control group/mice count}\\
+\dref[sci,precision=2,zerofill=true]{/med A/recovered}
+\end{verbatim}
+\end{codeexample}
+
+\Macro[(@get, @print)]{\drefvalueof\{\meta{name}\}}
+\Macro[(@get)]{\drefref\{\meta{name}\}}
+\vspace{1em}
+
+\begin{example}
+\drefvalueof{/med A/mice race}
+\end{example}\begin{codeexample}
+\begin{verbatim}
+\drefvalueof{/med A/mice race}
+\end{verbatim}
+\end{codeexample}
+
+ Since \macro{\dref} is not expandable, it cannot be used in all circumstances. Therefore, \macro{\drefvalueof} bypasses
+ all internal bookkeeping and provides access to the raw datapoint value. \macro{\drefref} can be used to mark the
+ datapoint as used to let it appear in the datagraphy.
+
+\Option[(default \textbf{true}, initially \textbf{false})]{/dref/ignoremissing=\meta{true-or-false}}
+\Option[(no default, initially \textbf{1.0})]{/dref/defaultvalue=\meta{value}}
+
+By default, \dataref produces an error if the referenced datapoint is undefined. If ignoremissing is given, the
+defaultvalue is used. This key is useful in combination with \macro{\drefsave}. Furthermore, it is possible to extract the
+missing keys from the \textsc{aux} file and to retrieve it from a secondary source (e.g. database, wikidata, etc).
+
+\begin{example}
+\dref*[ignoremissing,defaultvalue=undefined]{blah}
+\end{example}\begin{codeexample}
+\begin{verbatim}
+\dref*[ignoremissing,defaultvalue=undefined]{blah}
+\end{verbatim}
+\end{codeexample}
+
+\Macro{\drefsethelp\{\meta{pattern}\}\{\meta{text}\}}
+\Macro{\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. \macro{\drefsethelp} takes two arguments: first a regular expression that matches the symbolic data point, second the help text.
+
+\begin{codeexample}
+\begin{verbatim}
+\drefsethelp{.*/mice race}{The mice race used for experiments
+ heavily influences the outcome of the results}
+\end{verbatim}
+\end{codeexample}
+
+The documentation for a datapoint is obtained by using the \macro{\drefhelp} macro. It checks all defined documentation
+strings (in linear order, first defined, first matched), and prints the first matching help text. With \textbf{LuaTeX}:
+only Lua (string.find) regular expressions are supported as patterns.
+
+ \begin{example}
+ \drefhelp{/med A/mice race}
+ \end{example}\begin{codeexample}
+\begin{verbatim}
+\drefhelp{/med A/mice race}
+\end{verbatim}
+ \end{codeexample}
+
+
+\Macro{\drefresult}
+
+Is set in the @set phase to the result of the currently executed pipeline.
+
+
+\subsection{Calculations and Math Tools}
+
+\Macro[(@calc, @print, @set)]{\drefcalc[\meta{options}]\{\meta{expression}\}}
+\Macro[(@calc, @set)]{\drefcalc*[\meta{options}]\{\meta{expression}\}}
+\Macro[(@print)]{\drefformat*[\meta{options}]\{\meta{number}\}}
+
+The \macro{\drefcalc} is the core function of calculating with data points. It is based on the pgfmath engine, but allows
+also the usage of symbolic datapoints within mathematical expressions. Datapoints can either are inserted into the
+calculations with the \cmd{d(\meta{path})} or the \cmd{data("\meta{path}")} notation. The starred variant of
+\macro{\drefcalc} does not print the result, but only sets the result macros.
+
+It is important to note, that \macro{\drefcalc} always uses the \textbf{/pgf/fpu} environment. The FPU feature of pgfmath
+is used to handle large numbers, which may occur often when handling experiment data points.
+
+\begin{example}
+ \drefcalc{(4+7)/12 * 100}\\
+ \drefcalc{d(/med A/mice count) * 100}\\
+ \drefcalc{data("/med A/mice count") * 100}\\
+ \drefcalc*{1+3}\\
+ \drefresult
+\end{example}\begin{codeexample}
+\begin{verbatim}
+\drefcalc{(4+7)/12 * 100}\\
+\drefcalc{d(/med A/mice count) * 100}\\
+\drefcalc{data("/med A/mice count") * 100}\\
+\drefcalc*{1+3}\\
+\drefresult
+\end{verbatim}
+\end{codeexample}
+
+Since the default printing mechanism of \dataref utilizes PGF, all options from \texttt{/pgf/number format} can be
+directly used in the options. \macro{\drefformat} does only the printing. For documentation on the available options,
+please consult the PGF manual.
+
+\begin{example}
+ \drefcalc[precision=4]{1/3}\\
+ \drefcalc[sci]{123456789}\\
+ \drefcalc[prefix=/med A/,frac]{d(recovered)/d(mice count)}\\
+ \drefformat[fixed zerofill, precision=2]{\drefresult}
+\end{example}\begin{codeexample}
+\begin{verbatim}
+\drefcalc[precision=4]{1/3}\\
+\drefcalc[sci]{123456789}\\
+\drefcalc[prefix=/med A/,frac]{d(recovered)/d(mice count)}\\
+\drefformat[fixed zerofill, precision=2]{\drefresult}
+\end{verbatim}
+\end{codeexample}
+
+\subsection{Units and Unit Scaling}
+
+\dataref allows to give the unit of a datapoint and enforces the correct combination of units when using them in
+calculations. \dataref units can be arbitrary combinations of macros and strings, which allows the combination with the
+\textsc{SIUnitX} package.
+
+\Option[(no default)]{/dref/unit=\meta{unit}}
+
+The unit of a datapoint is loaded in the @get phase, and stored in the @set phase of the \dataref pipeline.
+
+\drefset[unit=\joule]{/power}{1234}
+\drefset[unit=ms]{/duration}{5555}
+\begin{codeexample}
+\begin{verbatim}
+\drefset[unit=ms]{/duration}{5555}
+\drefset[unit=\joule]{/power}{1234}
+\end{verbatim}
+\end{codeexample}
+
+\Option[(no default, choice)]{/dref/unit/format=\meta{formatting style}}
+\Option[(initially \textbf{plain})]{/dref/unit/format default=\meta{formatting style}}
+
+
+If a datapoint with unit is referenced, the unit is printed after the value. The formatting mechanism can be exchanged,
+in order to omit the unit, or to use \textsc{SIUnitX} for properly print it. By default, the \texttt{unit/format
+ default} is set in the @init phase. If you are using \textsc{SIUnitX} in your document, it is safe to set the default
+value accordingly. Currently, the values \texttt{false}, \texttt{plain}, and \texttt{siunitx} are valid formatting
+styles.
+
+\drefkeys{unit/format default=siunitx}
+\begin{example}
+ \dref[unit/format=false]{/duration}; \dref{/duration};
+ \typeout{\pgfkeysvalueof{/dref/unit/format default}}
+ \dref{/power}
+\end{example}\begin{codeexample}
+\begin{verbatim}
+\drefkeys{unit/format default=siunitx}
+\dref[unit/format=false]{/duration}; \dref{/duration};
+\dref{/power}
+\end{verbatim}
+\end{codeexample}
+
+\Option[(no default)]{/dref/unit/new scala=\meta{scala}}
+
+\dataref allows to define scaled units and conversion between the members of the scala. A scala definition is a list of
+units with scaling factors between them.
+
+
+\drefkeys{
+ unit/new scala={
+ 1/y, 365/d, 24/h, 60/m, 60/s, 1000/ms, 1000/us, 1000/ns
+ },
+ unit/new scala={
+ 1/\kilo\joule, 1000/\joule, 1000/\milli\joule,
+ 1000/\micro\joule, 1000/\nano\joule
+ }
+}
+
+\begin{codeexample}
+\begin{verbatim}
+\drefkeys{
+ unit/new scala={
+ 1/y, 365/d, 24/h, 60/m, 60/s, 1000/ms, 1000/us, 1000/ns
+ },
+ unit/new scala={
+ 1/\kilo\joule, 1000/\joule, 1000/\milli\joule,
+ 1000/\micro\joule, 1000/\nano\joule
+ }
+}
+\end{verbatim}
+\end{codeexample}
+
+\Option[(no default)]{/dref/unit/scale to=\meta{unit}}
+
+With a defined scala, you can scale to any unit on that scala automatically. In the example, we use unit to set the unit
+of plain value to nano joule, and scale everything to milli joule.
+
+\begin{example}
+\foreach \a in {1234, 4135413, 213516513245, 24} {%
+ \drefformat[unit=\nano\joule, unit/scale to=\milli\joule]{\a}\\
+}
+\end{example}\begin{codeexample}
+\begin{verbatim}
+\foreach \x in {1234, 4135413, 213516513245, 24} {%
+ \drefformat[
+ unit=\nano\joule,
+ unit/scale to=\milli\joule]{\x}\\
+}
+\end{verbatim}
+\end{codeexample}
+
+\Option[(default \textbf 50)]{/dref/unit/scale to auto=\meta{optimum number}}
+
+With \texttt{scale to auto}, the appropriate unit is chosen automatically. The algorithm tries every unit on the scala
+and chooses the unit, where the numerical value after scaling is nearest to the \meta{optimum number}. So with a optimum
+number of 50, 5000 seconds are scaled to \drefformat[unit=s, unit/scale to auto]{5000} instead of \drefformat[unit=s,
+unit/scale to=h]{5000}.
+
+
+\begin{example}
+\foreach \a in {1234, 4135413, 213516513245, 24} {%
+ \drefformat[unit=ms, unit/scale to auto]{\a}\\
+}
+\end{example}\begin{codeexample}
+\begin{verbatim}
+\foreach \x in {1234, 4135413, 213516513245, 24} {%
+ \drefformat[unit=ms, unit/scale to auto]{\x}\\
+}
+\end{verbatim}
+\end{codeexample}
+
+
+\subsection{Relating Datapoints}
+
+\Macro[(@calc, @set)]{\drefrel*[\meta{options}]\{\meta{key or value}\}}
+\Macro[(@calc, @print, @set)]{\drefrel[\meta{options}]\{\meta{key or value}\}}
+
+Often, datapoints are set in relation to each other. This can either be done with \macro{\drefcalc} or, more explictily,
+with \macro{\drefrel}. The different options that come along \macro{\drefrel}, add steps to the @calc phase and can,
+therefore, be combinated with any other dref macro that includes the @calc phase.
+
+All operations operate on the current result, which is initially the given key or value from the mandatory argument.
+
+\begin{example}
+ \drefrel[percent of=123]{40}
+\end{example}\begin{codeexample}
+\begin{verbatim}
+ \drefrel[percent of=123]{40}
+\end{verbatim}
+\end{codeexample}
+
+The different relation operations try to have a speaking name, such that the \TeX{} code is easily understandable by the
+writer. This explicit notation aims to prevent common mistakes, like confusing denominator and numerator.
+
+The starred version of \macro\drefrel does not print any number, but only saves the result in \macro\drefresult. Instead of
+only taking datapoint keys, \macro\drefrel, as well as the relating operations, take either a key or a bare number as you can
+see from the example.
+
+\Option[(no default)]{/dref/scale by=\meta{key or value}}
+
+Scales the current value by the given factor, which must be unit less. The resulting unit is untouched.
+
+\Option[(no default)]{/dref/percent}
+
+Scales the current value by 100. The unit is not changed.
+
+\Option[(no default)]{/dref/negate}
+
+Scales the current value by -1. The resulting unit is untouched.
+
+\Option[(no default)]{/dref/divide by=\meta{key or value}}
+
+Divides the current value by the given factor, which must be unit less. The resulting unit is untouched.
+
+
+\Option[(no default)]{/dref/abs}
+
+Calculate the absolute value.
+
+\Option[(no default)]{/dref/factor of=\meta{key or value}}
+\Option[(no default)]{/dref/percent of=\meta{key or value}}
+
+The \textbf{factor of} operation gives the portion the current value in relation to the given base value. In easy words:
+a division. This macro ensures, that base and current vale have the same unit or are unit less. The result of this
+operation is unit less. The \textbf{percent of} operation, furthermore, scales the result with 100 to get a percentage.
+
+\Option[(no default)]{/dref/increase from=\meta{key or value}}
+\Option[(no default)]{/dref/decrease from=\meta{key or value}}
+\Option[(no default)]{/dref/increase factor from=\meta{key or value}}
+\Option[(no default)]{/dref/decrease factor from=\meta{key or value}}
+\Option[(no default)]{/dref/increase percent from=\meta{key or value}}
+\Option[(no default)]{/dref/decrease percent from=\meta{key or value}}
+
+In a situation, where a datapoint is the result of a changed experiment setup, the value normally shows an increased or decrease
+numerical value. This family of operations calculates this delta, assuming it is an increase or decrease. The factor
+operations scale the result to the base value, and the percent operations give this scaled value as a percentage.
+
+\begin{example}
+ \drefrel[increase from=500]{525}\\
+ \drefrel[increase factor from=500,fixed]{525}\\
+ \drefrel[increase percent from=500]{525}\,\%
+\end{example}
+\begin{codeexample}
+\begin{verbatim}
+ \drefrel[increase from=500]{525}\\
+ \drefrel[increase factor from=500,fixed]{525}\\
+ \drefrel[increase percent from=500]{525}\,\%
+\end{verbatim}
+\end{codeexample}
+
+\subsection{Helper Utilities}
+
+\Macro{\drefrow[\meta{options}]\{\meta{comma-separated list}\}\{\meta{key template}\}}
+\Macro{\drefrow*\{\meta{comma-separated list}\}\{\meta{template}\}}
+
+ 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 \dataref provides you
+ with \macro{\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.
+
+ Both, unstarred and starred variant take a template (a macro body) that is expanded once for every item in the given
+ list. The first replacement \verb|#1| is list item and the second \verb|#2| is the current index starting from 0. The
+ unstarred variant interprets the expanded result as a datapoint key and uses \macro\dref to expand it; the optional
+ parameter is passed through to every invocation of \macro\dref.
+ The starred variant does not wrap the result into \macro\dref, and, therefore, is more flexible.
+
+ \begin{example}
+ \begin{tabular}{|c|c|c|}\hline
+ \drefrow{dead after 24h,dead after 48h,recovered}%
+ {/control group/#1}\\\hline
+ \drefrow{dead after 24h,dead after 48h,recovered}%
+ {/med A/#1}\\\hline
+ \end{tabular}
+ \end{example}
+ \begin{codeexample}
+\begin{verbatim}
+\begin{tabular}{|c|c|c|}\hline
+ \drefrow{dead after 24h,dead after 48h,recovered}
+ {/control group/#1}\\\hline
+ \drefrow{dead after 24h,dead after 48h,recovered}%
+ {/med A/#1}\\\hline
+\end{tabular}
+\end{verbatim}
+ \end{codeexample}
+
+
+ \Macro[(@calc)]{\drefassert\{\meta{expr}\}}
+
+ Sometimes the underlying data changes while you are writing. But what
+ if your prose text relies on certain characteristics of the data. \macro{\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{example}
+\drefassert{data("/control group/mice count") > 30}
+Of the more than thirty infected mice...
+\end{example}\begin{codeexample}
+\begin{verbatim}
+\drefassert{data("/control group/mice count") > 30}
+Of the more than thirty infected mice...
+\end{verbatim}
+\end{codeexample}
+
+ \Option[(default \textbf{true})]{/dref/noassert=\meta{true or false}}
+
+ The \textbf{noassert} deescalates all assertion errors to mere warnings. This option can also be given at the
+ \cmd{\usepackage} invication.
+
+\Option[(no default, initially \textbf{none}, choice)]{/dref/annotate=\meta{annotation type}}
+\Option[(choice item)]{/dref/annotate=none}
+\Option[(choice item)]{/dref/annotate=footnote}
+\Option[(choice item)]{/dref/annotate=pdfcomment}
+\Option[(choice item)]{/dref/annotate=typeout}
+
+While writing a document it is desirable to know, what key is used, while writing the text and generating the document.
+Therefore \dataref provides the possibility to annotate values. The default 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}.
+
+\begin{example}[6cm]
+ \drefkeys{annotate=footnote}
+ \dref*{/control group/mice race}
+ \dref{/control group/mice count}
+ \drefcalc[annotate=pdfcomment]{100/3}
+\end{example}\begin{codeexample}
+\begin{verbatim}
+\drefkeys{annotate=footnote}
+\dref*{/control group/mice race}
+\dref{/control group/mice count}
+\drefcalc[annotate=pdfcomment]{100/3}
+\end{verbatim}
+\end{codeexample}
+
+
+ \subsection{Datagraphy}\label{sec:datagraphy}
+
+ \Macro{\drefusagereport}
+ \Option{[usagereport]}
+ \Option{[refall]}
+
+ With the \textbf{usagereport} package option enabled, \macro{\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
+
+\end{document}
+
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End:
diff --git a/macros/latex/contrib/dataref/tex/dataref.sty b/macros/latex/contrib/dataref/tex/dataref.sty
new file mode 100644
index 0000000000..bb6f013032
--- /dev/null
+++ b/macros/latex/contrib/dataref/tex/dataref.sty
@@ -0,0 +1,952 @@
+%% Copyright 2013-2017 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.
+\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+\ProvidesPackage{dataref}[2017/01/06 v0.6 dataref]
+
+\ifx\drefloaded\undefined
+ \let\drefloaded=\relax
+\else
+ \expandafter\endinput
+\fi
+
+\def\drefutil@packageerror#1#2#3{\errhelp{#3}\errmessage{Package #1 Error: #2}}
+\def\drefutil@packagewarning#1#2{\immediate\write17{Package #1: Warning! #2.}}
+\def\dref@error#1{\drefutil@packageerror{dref}{#1}{}}
+\def\dref@warning#1{\drefutil@packagewarning{dref}{#1}}
+
+\RequirePackage{pgf}
+\usepgflibrary{fpu}
+\RequirePackage{iftex}
+\RequirePackage{kvoptions}
+\RequirePackage{etoolbox}
+
+\SetupKeyvalOptions{
+ family=dref,
+ prefix=dref@
+}
+\DeclareStringOption[/data]{datapath}
+\DeclareStringOption[1]{defaultvalue}
+\DeclareStringOption[none]{annotate}
+\DeclareBoolOption{usagereport}
+\DeclareBoolOption{refall}
+\DeclareBoolOption{ignoremissing}
+\DeclareBoolOption{noassert}
+\ProcessKeyvalOptions*
+
+% Load & Store Layer
+
+\def\dref@set#1#2#3{%
+ \edef\dref@set@path{#3}%
+ \edef\dref@set@value{#2}%
+ \expandafter\pgfkeys@temptoks\expandafter{\dref@set@value}%
+ \expandafter\xdef%
+ \csname pgfk@\dref@datapath\dref@set@path\endcsname%
+ {\the\pgfkeys@temptoks}%
+ % Setting the Unit is a little bit more tricky
+ %% Unit Path Assembly
+ \expandafter\def%
+ \expandafter\dref@set@unitpath%
+ \expandafter{%
+ \csname pgfk@\dref@datapath\dref@set@path @unit\endcsname}%
+ \expandafter\gdef\dref@set@unitpath{#1}%
+ \ifdref@refall%
+ \expandafter\dref@found\expandafter{\dref@set@path}{0}
+ \expandafter\dref@referenced\expandafter{\dref@set@path}{0}%
+ \fi%
+ \dref@debug{\dref@set@path = \dref@set@value (\detokenize{#1})}%
+}
+
+\def\dref@load#1#2#3{%
+ \edef\dref@load@path{#1}%
+ \pgfkeysifdefined{\dref@datapath\dref@load@path}{%
+ \pgfkeysgetvalue{\dref@datapath\dref@load@path}{#2}%
+ \pgfkeysifdefined{\dref@datapath\dref@load@path @unit}{%
+ \pgfkeysgetvalue{\dref@datapath\dref@load@path @unit}{#3}%
+ }{%
+ \def#3{}%
+ }%
+ }{%
+ \edef#2{\dref@defaultvalue}%
+ \def#3{}%
+ }%
+}
+
+\def\drefifdefined#1{%
+ \pgfkeysifdefined{\dref@datapath\drefprefix #1}%{then}{else}
+}
+
+\def\dref@set@fromaux#1#2#3{%
+ \drefifdefined{#2}{%
+ \dref@warning{"\drefprefix #2" set before beginning of document, \string\drefsave{} is ignore}%
+ }{%
+ \dref@set{#1}{#2}{#3}%
+ }%
+}
+
+\def\drefkeys#1{\pgfkeys{/dref/.cd,#1}}
+\def\drefprefix{\pgfkeysvalueof{/dref/prefix}}
+\newif\ifdref@debug
+\def\dref@debug#1{\ifdref@debug \immediate\write17{Package dref: Debug: #1.}\fi}
+
+\drefkeys{
+ .is family,
+ .search also={/pgf/number format},
+ % The @init action is used to initialize all other actions
+ @[/.code={\begingroup%
+ \pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}% No more dimensions too large
+ \def\drefunit{}% At first we are unitless
+ \aftergroup\edef%
+ \aftergroup\drefresult%
+ \aftergroup{%
+ \aftergroup\drefresult@smuggle%
+ \aftergroup}%
+ \aftergroup\expandafter%
+ \aftergroup\def%
+ \aftergroup\expandafter%
+ \aftergroup\drefunit%
+ \aftergroup\expandafter%
+ \aftergroup{%
+ \aftergroup\drefunit@smuggle%
+ \aftergroup}
+ },
+ @]/.code={% We smuggle \drefresult after the current group
+ \xdef\drefresult@smuggle{\drefresult}%
+ \xdef\drefunit@smuggle{\expandonce\drefunit}%
+ \endgroup%
+ },
+ @init/.style={},
+ % The \drefresult macro holds the current value,
+ % it can be set by value=
+ prefix/.initial={},
+ value/.code={\edef\drefresult{#1}\def\drefunit{}},
+ value=0,
+ path/.estore in={\drefcurrentpath},
+ @init/.append style={},
+ % \drefresult can be set by the @load action
+ @load key to/.code n args={3}{%
+ \dref@load{\drefprefix #1}{#2}{#3}%
+ },
+ @get key to/.style n args={3}{
+ @check key={#1},
+ @reference key={#1},
+ @load key to={#1}{#2}{#3},
+ },
+ @get/.style={%
+ @get key to={\drefcurrentpath}{\drefresult}{\drefunit},
+ unit/@format enable,
+ },
+ % For most commands, we want to check whether a key exists.
+ @check key/.code={%
+ \drefifdefined{#1}{}{%
+ \ifdref@ignoremissing%
+ \dref@warning{undefined key `\drefprefix #1'}%
+ \else%
+ \dref@error{undefined key `\drefprefix #1'}%
+ \fi%
+ }%
+ },
+ % The @set action is used to pipe out \drefresult, before we can
+ % print it. For example, we can use it to save the result to a new
+ % key.
+ @init/.append style={
+ @set/.code={},
+ },
+ set/.style={
+ @set/.append code={%
+ \expandafter\dref@set\expandafter{\drefunit}{\drefresult}{\drefprefix #1}%
+ }
+ },
+ save/.style={
+ set={#1},
+ @set/.append code={%
+ \immediate\write\@auxout{%
+ \noexpand\dref@set@fromaux{\expandonce\drefunit}{\drefresult}{\drefprefix #1}%
+ }%
+ }
+ },
+ to macro/.style={
+ @set/.append code={%
+ \aftergroup\edef%
+ \aftergroup#1%
+ \aftergroup{%
+ \aftergroup\drefresult%
+ \aftergroup}}
+ },
+ %
+ debug/.is if=dref@debug,
+ ignoremissing/.is if=dref@ignoremissing,
+ defaultvalue/.store in=\dref@defaultvalue,
+}
+
+\csdef{dref@ifnum@0}{}
+\csdef{dref@ifnum@1}{}
+\csdef{dref@ifnum@2}{}
+\csdef{dref@ifnum@3}{}
+\csdef{dref@ifnum@4}{}
+\csdef{dref@ifnum@5}{}
+\csdef{dref@ifnum@6}{}
+\csdef{dref@ifnum@7}{}
+\csdef{dref@ifnum@8}{}
+\csdef{dref@ifnum@9}{}
+\csdef{dref@ifnum@-}{}
+\csdef{dref@ifnum@.}{}
+\def\dref@load@ifkey@firstchar#1#2\@nnil{#1}
+\drefkeys{%
+ @get key or value to/.code n args={3}{%
+ \edef\dref@load@path{#1}%
+ \edef\dref@firstchar{\expandafter\dref@load@ifkey@firstchar \dref@load@path\@nnil}%
+ \ifcsdef{dref@ifnum@\dref@firstchar}{%
+ \edef#2{\dref@load@path}%
+ }{%
+ \drefkeys{@get key to={#1}{#2}{#3}}%
+ }%
+ },
+ @get key or value/.style={
+ @get key or value to={\drefcurrentpath}{\drefresult}{\drefunit},
+ unit/@format enable,
+ },
+}
+
+
+% Print layer
+\drefkeys{
+ @init/.append style={
+ @print result/.code={},
+ @print unit/.code={}
+ },
+ @print/.style={@print result, @print unit},
+ print default/.initial={pgf},
+ print/.is choice,
+ print/no/.style={
+ @print result/.code={},
+ @print unit/.code={}
+ },
+ print/default/.style={%
+ print default/.get=\dref@print@format,%
+ print/.expand once=\dref@print@format,
+ },
+ print/raw/.style={
+ @print result/.code={\drefresult}
+ },
+ print/typeout/.style={
+ @print result/.code={\typeout{#1\drefresult}},
+ @print unit/.code={\typeout{\expandonce\drefunit}},
+ },
+ print/show/.style={
+ @print result/.append code={\show\drefresult},
+ },
+ print/pgf/.style={
+ @print result/.code={%
+ \pgfmathprintnumber{\drefresult}%
+ }
+ },
+ print/siunitx/.style={
+ @print result/.code={%
+ \num{\drefresult}%
+ }
+ },
+}
+
+% Compatibility with underscore package
+\def\dref@normalunderscore{_}
+\edef\dref@catcode@underscore{\the\catcode`_}
+\catcode`_=13
+\def\dref@catcode@setup{%
+ \edef _{\dref@normalunderscore}%
+}
+\catcode`_=\dref@catcode@underscore
+
+
+\AtBeginDocument{%
+ \ifdim 13pt = \the\catcode`_pt%
+ % _ is an active character
+ \drefkeys{@[/.append code={%
+ \dref@catcode@setup%
+ }%
+ }%
+ \fi%
+}
+
+\newcommand{\drefset}[3][]{%
+ % I put this version here, since it
+ % provides a sped up mass setting of keys
+ \begingroup%
+ \ifdim 13pt = \the\catcode`_pt%
+ \dref@catcode@setup%
+ \fi%
+ \edef\drefresult{#3}%
+ \def\drefunit{}%
+ \drefkeys{#1}%
+ \expandafter\dref@set\expandafter{\drefunit}%
+ {\drefresult}{\drefprefix #2}%
+ \endgroup%
+}
+
+\newcommand{\drefsave}[3][]{%
+ \drefkeys{@[, @init, value={#3}, #1, save={#2}, @set, @]}%
+}
+
+\newcommand{\drefinput}[2][]{%
+ \begingroup
+ \drefkeys{prefix/.append={#1}}
+ \input{data/#2}
+ \endgroup
+}
+
+
+\def\drefref#1{\drefkeys{@reference key={#1}}}
+
+% From here on, everything should be implemented using pgfkeys
+\protected\def\dref{\@ifstar\dref@starred\dref@unstarred}
+\newcommand{\dref@unstarred}[2][]{%
+ \drefkeys{@[, @init, print=default, path={#2}, #1, @get, @calc, @print, @set,%
+ @annotate={\textbackslash dref[#1]\{#2\}}, @]%
+ }%
+}
+\newcommand{\dref@starred}[2][]{%
+ \drefkeys{@[, @init, print=raw, path={#2}, #1, @get, @calc, @print, @set,%
+ @annotate={\textbackslash dref*[#1]\{#2\}}, @]%
+ }%
+}
+\def\drefgetvalue#1#2{%
+ \drefkeys{@[,@init, path={#1}, to macro={#2}, @get, @set, @]}%
+}
+\def\drefvalueof#1{%
+ \pgfkeysvalueof{\dref@datapath \drefprefix #1}%
+}
+
+%% 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}%
+}
+\newcommand{\dref@help}[2][]{%
+ \pgfkeysifdefined{#2/help}{%
+ \pgfkeysvalueof{#2/help}%
+ }{#1}%
+}
+\csdef{dref@helps}{}
+\newcommand{\drefsethelp}[2]{
+ \csdef{dref@help@#1}{#2}%
+ \listcsadd{dref@helps}{#1}%
+}
+\newcommand{\drefhelp}[1]{
+ \renewcommand{\do}[1]{%
+ \dref@help@match{##1}{#1}{%
+ \csuse{dref@help@##1}%
+ \listbreak}{}%
+ }%
+ \ifcsvoid{dref@helps}{}{%
+ \dolistcsloop{dref@helps}%
+ }%
+}
+\drefkeys{
+ @reference key/.code={%
+ \edef\dref@thepage{\arabic{page}}%
+ \drefifdefined{#1}{%
+ \immediate\write\@auxout{%
+ \noexpand\dref@found{\drefprefix #1}{\dref@thepage}}%
+ }{%
+ \immediate\write\@auxout{%
+ \noexpand\dref@notfound{\drefprefix #1}{\dref@thepage}}%
+ }%
+ \immediate\write\@auxout{%
+ \noexpand\dref@referenced{\drefprefix #1}{\dref@thepage}}%
+ }
+}
+\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%
+}
+
+
+% The data("") || d() Parser
+\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{%
+ \drefkeys{
+ @get key to={#1}{\dref@math@value}{\dref@math@unit},
+ unit/@combine=\dref@math@unit,
+ }%
+ \csxdef{dref@parser@result}{\csuse{dref@parser@result}(\dref@math@value)}%
+ \csdef{dref@parser@state}{}%
+ \ifblank{#2}{}{\dref@parser@parse#2\@nnil}}
+
+\def\dref@parser@tillparen#1)#2\@nnil{%
+ \drefkeys{@get key to={#1}{\dref@math@value}{\dref@math@unit},
+ unit/@combine=\dref@math@unit}%
+ \csxdef{dref@parser@result}{\csuse{dref@parser@result}(\dref@math@value)}%
+ \csdef{dref@parser@state}{}%
+ \ifblank{#2}{}{\dref@parser@parse#2\@nnil}}%
+
+\def\dref@parser@end#1#2\@nnil{}
+\csdef{dref@parser@@}{\dref@parser@end}
+
+\drefkeys{
+ @init/.append style={%
+ @calc/.code={},%
+ },
+ @calc pgf/.style={
+ @calc/.append code={%
+ \dref@parser{#1}{\dref@calc@@ready}%
+ \pgfmathparse{\dref@calc@@ready}%
+ \dref@debug{#1 -> \dref@calc@@ready = \pgfmathresult}%
+ \edef\drefresult{\pgfmathresult}%
+ }
+ }
+}
+
+\protected\def\drefcalc{\@ifstar\drefcalc@starred\drefcalc@unstarred}
+\newcommand{\drefcalc@unstarred}[2][]{% Unstarred
+ \drefkeys{@[,@init, print=default, @calc pgf={#2}, #1, @calc, @print, @set,%
+ @annotate={\textbackslash drefcalc[#1]\{#2\}},@]}%
+}
+\newcommand{\drefcalc@starred}[2][]{ % Starred
+ \drefkeys{@[,@init, @calc pgf={#2}, #1, @calc, @set,%
+ @annotate={\textbackslash \drefcalc*[#1]\{#2\}},@]%
+ }%
+}
+
+\newcommand{\drefformat}[2][]{%
+ \drefkeys{@[,@init, print=default, value={#2}, #1, @calc, @print, @]}%
+}
+
+\long\def\drefprojection#1#2#3{%
+ \begingroup%
+ \def\rename##1##2{%
+ \drefkeys{@init, path={#1/##1}, set={#2/##2}, @get, @set}%
+ }%
+ \def\id##1{\rename{##1}{##1}}%
+ \def\calc##1##2{%
+ \edef\drefprojection@prefix{\drefprefix}%
+ \drefcalc[prefix={#1}]{##1}%
+ \edef\drefprefix{\drefprojection@prefix}%
+ \drefset{#2/##2}{\drefresult}%
+ }%
+ #3%
+ \endgroup%
+}
+
+
+\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}%
+ }%
+ \expandafter\scantokens\expandafter{\the\dref@toks}%
+}
+
+\long\def\drefrow{\@ifstar{\drefrow@starred}{\drefrow@unstarred}}
+\newcommand{\drefrow@unstarred}[3][]{\dref@makerow{#2}{\dref[#1]{#3}}\ignorespaces}
+\def\drefrow@starred#1#2{\dref@makerow{#1}{#2}\ignorespaces}
+
+\expandafter\ifstrequal\expandafter{\dref@annotate}{pdfcomment}{
+ \RequirePackage{pdfcomment}
+}
+
+
+\drefkeys{
+ annotate/.is choice,
+ annotate/none/.style={@annotate/.code={\relax}},
+ annotate/footnote/.style={@annotate/.code={\footnote{\texttt{##1}}}},
+ annotate/pdfcomment/.style={@annotate/.code={\pdfcomment[opacity=0.4,voffset=2ex]{##1}}},
+ annotate/typeout/.style={@annotate/.code={\typeout{##1}}},
+ annotate=\dref@annotate,
+}
+
+%% Usagereport
+\ifdref@usagereport
+ \RequirePackage{xtab}
+ \RequirePackage{booktabs}
+\fi
+\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}
+ }
+}
+\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}%
+}
+\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%
+}
+\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}%
+ & \drefifdefined{#1}{\dref*[@reference key/.code={}]{#1}}{\textbf{undefined}}%
+}
+
+\def\drefusagereportaftergroup{}
+
+\def\drefusagereportbeforerow{}
+\def\drefusagereportbeforetitle{}
+\def\drefusagereportaftertitle{}
+
+\def\drefusagereportbeforedescription{}
+
+
+\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%
+}
+\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%
+}
+\newcommand{\drefusagereport}{%
+ \ifdref@usagereport%
+ \ifcsvoid{dref@usagereport@keys}{}{%
+ \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%
+}
+\drefkeys{
+ noassert/.is if=dref@noassert
+}
+\newcommand{\drefassert}[1]{%
+ \begingroup%
+ \drefcalc*{#1}%
+ \ifdim\drefresult pt = 0pt%
+ \ifdref@noassert%
+ \dref@warning{Assertion failed: #1}%
+ \else%
+ \dref@error{Assertion failed: #1}%
+ \fi%
+ \else
+ \dref@warning{Assertion holds: #1}%
+ \fi%
+ \endgroup%
+}
+\drefkeys{%
+ factor of/.style={%
+ @get key or value to={#1}{\drefrel@tmp}{\drefrel@tmpunit},
+ unit/@assert compatible=\drefrel@tmpunit,
+ @calc pgf/.expanded={(\noexpand\drefresult)/(\drefrel@tmp)},
+ @calc/.append code={\def\drefunit{}},
+ },
+ percent/.style={
+ @calc pgf={100 * (\drefresult)},
+ },
+ percent of/.style={
+ factor of=#1, percent,
+ @calc/.append code={\def\drefunit{}},
+ },
+ scale by/.style={
+ @get key or value to={#1}{\drefrel@tmp}{\drefrel@tmpunit},%
+ unit/@assert unitless=\drefrel@tmpunit,
+ @calc pgf/.expanded={(\drefrel@tmp) * (\noexpand\drefresult)},
+ },
+ product/.style={scale by={#1}},
+ divide by/.style={
+ @get key or value to={#1}{\drefrel@tmp}{\drefrel@tmpunit},%
+ unit/@assert unitless=\drefrel@tmpunit,
+ @calc pgf/.expanded={(\noexpand\drefresult) / (\drefrel@tmp)},
+ },
+ divide/.style={divide by},
+ product/.style={scale by={#1}},
+ increase factor from/.style={
+ @get key or value to={#1}{\drefrel@tmp}{\drefrel@tmpunit},
+ unit/@assert compatible=\drefrel@tmpunit,
+ @calc pgf/.expanded={((\noexpand\drefresult)-(\drefrel@tmp))/(\drefrel@tmp)},
+ @calc/.append code={\def\drefunit{}},
+ },
+ increase percent from/.style={increase factor from={#1}, percent},
+ decrease factor from/.style={increase factor from={#1}, negate},
+ decrease percent from/.style={increase factor from={#1}, negate, percent},
+ increase from/.style={
+ @get key or value to={#1}{\drefrel@tmp}{\drefrel@tmpunit},%
+ unit/@assert compatible=\drefrel@tmpunit,
+ @calc pgf/.expanded={((\noexpand\drefresult)-(\drefrel@tmp))},
+ },
+ decrease from/.style={increase from={#1}, negate},
+ abs/.style={
+ @calc pgf={abs(\drefresult)}
+ },
+ negate/.style={
+ @calc pgf={-1 * (\drefresult)}
+ },
+}
+
+\def\drefrel{\@ifstar\drefrel@starred\drefrel@unstarred}
+
+\newcommand{\drefrel@unstarred}[2][]{%
+ \drefkeys{@[,
+ @init,
+ path={#2}, print=default, #1,
+ @get key or value, @calc, @print, @set,
+ @],
+ @annotate={\textbackslash drefrel[#1]\{#2\}}}%
+}
+
+\newcommand{\drefrel@starred}[2][]{%
+ \drefkeys{
+ @[, @init,
+ path={#2}, #1,
+ @get key or value, @calc, @set,
+ @],
+ @annotate={\textbackslash drefrel[#1]\{#2\}},
+ }%
+}
+
+% Unit scaling
+
+\def\dref@unit@key#1#2{%
+ dref@unit@\expandafter\detokenize\expandafter{#1}@\expandafter\detokenize\expandafter{#2}}
+
+\def\dref@unit@new#1{%
+ \def\dref@unit@scala{}%
+ \def\dref@unit@new@outer##1/##2,##3\@nnil{%
+ \def\dref@outer{\dref@unit@new@outer##3\@nnil}%
+ \listadd{\dref@unit@scala}{##2}%
+ \ifx##3&&%
+ \def\dref@outer{}%
+ \fi%
+ \dref@outer%
+ }%
+ \dref@unit@new@outer#1,\@nnil%
+ \def\dref@unit@new@outer##1/##2,##3\@nnil{%
+ \def\dref@outer{\dref@unit@new@outer##3\@nnil}%
+ \pgfkeys{/dref/units/\detokenize{##2} to \detokenize{##2}/.initial={* 1},%
+ /dref/units/scala \detokenize{##2}/.initial/.expand once={\dref@unit@scala}}%
+ \ifx##3&&%
+ \def\dref@outer{}%
+ \else%
+ \def\dref@unit@factor{}%
+ \dref@unit@new@inner{##2}##3\@stop%
+ \fi%
+ \dref@outer%
+ }
+ \def\dref@unit@new@inner##1##2/##3,##4\@stop{%
+ \def\dref@inner{\dref@unit@new@inner{##1}##4\@stop}%
+ \ifx##4&&\def\dref@inner{}\else\fi%
+ \edef\dref@unit@factor{\dref@unit@factor * ##2}%
+ \pgfkeys{/dref/units/\detokenize{##1} to \detokenize{##3}/.initial/.expanded={* (1 \dref@unit@factor)},%
+ /dref/units/\detokenize{##3} to \detokenize{##1}/.initial/.expanded={/ (1 \dref@unit@factor)},%
+ }%
+ \dref@inner%
+ }%
+ \dref@unit@new@outer#1,\@nnil%
+}
+
+\drefkeys{
+ unit/new scala/.code={%
+ \dref@unit@new{#1}%
+ },
+ unit/.style={
+ unit/@load={#1},
+ unit/@format enable,
+ @get/.append style={unit/@load={#1}}, % Override Unit from loads
+ },
+ unit/@load/.code={% #1 Is plain unit
+ \def\drefunit{#1}%
+ },
+ unit/@try override/.code={% #1 must be unit holding macro
+ \ifx#1\empty#1\else%
+ \expandafter\def\expandafter\drefunit\expandafter{#1}%
+ \fi%
+ },
+ unit/@format enable/.code={%
+ \ifx\drefunit\empty\drefunit\else%
+ \drefkeys{unit/format=default}%
+ \fi%
+ },
+ unit/@assert unitless/.code={%
+ \ifx\drefunit\empty\drefunit\else% We are unit less: good
+ \ifx#1\empty#1\else% Other has no unit, also good
+ \dref@error{At least one should be unitless:
+ \expandafter\detokenize\expandafter{\drefunit},
+ \expandafter\detokenize\expandafter{#1}}
+ % There is some unit here. That is BAD
+ \fi\fi%
+ },
+ unit/@assert compatible/.code={%
+ \ifx\drefunit\empty\drefunit\else% We are unit less: good
+ \ifx#1\empty#1\else% Other has no unit, also good
+ \ifx\drefunit#1\else% Bot equal: also good
+ \dref@error{Incompatible Units:
+ \expandafter\detokenize\expandafter{\drefunit}
+ != \expandafter\detokenize\expandafter{#1}}
+ \fi%
+ \fi%
+ \fi%
+ },
+ unit/@combine/.style={
+ unit/@assert compatible={#1}, unit/@try override={#1}, unit/@format enable
+ },
+ unit/scale to/.code={%
+ \edef\dref@unit@key{/dref/units/\expandafter\detokenize\expandafter{\drefunit} to \detokenize{#1}}%
+ \drefkeys{%
+ \dref@unit@key/.get=\dref@unit@factor,%
+ @calc pgf/.expanded={((\noexpand\drefresult) \dref@unit@factor)},%
+ unit=#1%
+ }%
+ },
+ unit/scale to auto/.default=50,
+ unit/scale to auto/.style={% #1 is the optimal value
+ @calc/.append code={
+ \dref@ifunit{%Only do the scaling, if there is a unit
+ \edef\dref@unit@key{/dref/units/scala \expandafter\detokenize\expandafter{\drefunit}}%
+ % Get all other units in the same scala
+ \drefkeys{\dref@unit@key/.get=\dref@unit@scala}%
+ \expandafter\def\expandafter\drefunit@best\expandafter{\drefunit}%
+ \def\drefunit@bestvalue{\drefresult}%
+ \def\@@score####1{1 / ( abs(#1) - abs(####1))}%
+ \def\do####1{%
+ \edef\dref@unit@key{/dref/units/\expandafter\detokenize\expandafter{\drefunit} to \detokenize{####1}}%
+ \pgfkeys{\dref@unit@key/.get=\dref@unit@factor}%
+ \pgfmathparse{\@@score{\drefunit@bestvalue} < \@@score{\drefresult \dref@unit@factor}}%
+ %\typeout{\drefunit \pgfmathresult \detokenize{####1}}%
+ \ifdim\pgfmathresult pt=1.0 pt%
+ \pgfmathparse{(\drefresult) \dref@unit@factor}%
+ \edef\drefunit@bestvalue{\pgfmathresult}%
+ \def\drefunit@best{####1}%
+ %\typeout{\expandafter\detokenize\expandafter{\drefunit} to
+ % \detokenize{####1} : \drefunit@bestvalue}%
+ \fi%
+ }%
+ \dolistloop\dref@unit@scala%
+ \edef\drefresult{\drefunit@bestvalue}%
+ \edef\drefunit{\expandonce{\drefunit@best}}%
+ }{}% ! \drefunit=\empty
+ }
+ },
+ unit/format default/.initial={plain},
+ unit/format/.is choice,
+ unit/format/no/.style={unit/format default=no, @print unit/.code={}},
+ unit/format/false/.style={unit/format default=no, @print unit/.code={}},
+ unit/format/plain/.style={
+ unit/format default=plain,
+ @print unit/.code={\dref@ifunit{\,\drefunit}{}}
+ },
+ unit/format/typeout/.style={
+ unit/format default=typeout,
+ @print unit/.code={\dref@ifunit{\expandafter\typeout\expandafter{\drefunit}}{}}
+ },
+ unit/format/siunitx/.style={
+ unit/format default=siunitx,
+ @print unit/.code={\dref@ifunit{\,\expandafter\si\expandafter{\drefunit}}{}}
+ },
+ unit/format/default/.style={%
+ unit/format default/.get=\dref@unit@format,
+ unit/format/.expand once=\dref@unit@format
+ },
+}
+
+\def\dref@ifunit#1#2{%
+ \expandafter\ifblank\expandafter{\drefunit}{#2}{#1}%
+}
+
+
+\endinput
+%%
+%% End of file `dataref.sty'.