diff options
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/dataref/README.md (renamed from Master/texmf-dist/doc/latex/dataref/README) | 12 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/dataref/dataref-doc.pdf | bin | 0 -> 238060 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/dataref/dataref-doc.tex | 735 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/dataref/dataref.pdf | bin | 250799 -> 0 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/dataref/dataref.dtx | 1333 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/dataref/dataref.ins | 29 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/dataref/dataref.sty | 872 | ||||
-rwxr-xr-x | Master/tlpkg/libexec/ctan2tds | 1 |
8 files changed, 1331 insertions, 1651 deletions
diff --git a/Master/texmf-dist/doc/latex/dataref/README b/Master/texmf-dist/doc/latex/dataref/README.md index 7c2e73022d0..bcd6362daf5 100644 --- a/Master/texmf-dist/doc/latex/dataref/README +++ b/Master/texmf-dist/doc/latex/dataref/README.md @@ -25,12 +25,12 @@ Building the documentation With latexmk installed: make - + or - make dataref.sty; pdflatex dataref.dtx; pdflatex dataref.dtx; pdflatex dataref.dtx - - + pdflatex dataref.tex; pdflatex dataref.tex; pdflatex dataref.tex + + Examples ======== @@ -38,7 +38,7 @@ Setting symbolic data points \drefset{/count}{42} \drefset{/abc}{23} - + Referencing them with \dref, \drefcalc, \drefassert \dref{/count} => 42 @@ -48,4 +48,4 @@ Referencing them with \dref, \drefcalc, \drefassert Getting the latest version ========================== -dataref is hosted at github: https://github.com/stettberger/dataref
\ No newline at end of file +dataref is hosted at github: https://github.com/stettberger/dataref diff --git a/Master/texmf-dist/doc/latex/dataref/dataref-doc.pdf b/Master/texmf-dist/doc/latex/dataref/dataref-doc.pdf Binary files differnew file mode 100644 index 00000000000..ec64e4c97a6 --- /dev/null +++ b/Master/texmf-dist/doc/latex/dataref/dataref-doc.pdf diff --git a/Master/texmf-dist/doc/latex/dataref/dataref-doc.tex b/Master/texmf-dist/doc/latex/dataref/dataref-doc.tex new file mode 100644 index 00000000000..d50200f57a6 --- /dev/null +++ b/Master/texmf-dist/doc/latex/dataref/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/Master/texmf-dist/doc/latex/dataref/dataref.pdf b/Master/texmf-dist/doc/latex/dataref/dataref.pdf Binary files differdeleted file mode 100644 index 0a0b2b6f332..00000000000 --- a/Master/texmf-dist/doc/latex/dataref/dataref.pdf +++ /dev/null diff --git a/Master/texmf-dist/source/latex/dataref/dataref.dtx b/Master/texmf-dist/source/latex/dataref/dataref.dtx deleted file mode 100644 index 50fcb2dac9c..00000000000 --- a/Master/texmf-dist/source/latex/dataref/dataref.dtx +++ /dev/null @@ -1,1333 +0,0 @@ -% \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 diff --git a/Master/texmf-dist/source/latex/dataref/dataref.ins b/Master/texmf-dist/source/latex/dataref/dataref.ins deleted file mode 100644 index e3509b32cb0..00000000000 --- a/Master/texmf-dist/source/latex/dataref/dataref.ins +++ /dev/null @@ -1,29 +0,0 @@ -%% LaTeX2e file `pgfdata.ins' -%% generated by the `filecontents' environment -%% from source `pgfdata' on 2013/12/06. -%% -\def\batchfile{dataref.ins} -\input docstrip.tex -\askforoverwritefalse -\preamble -dataref.dtx - Copyright 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. -\endpreamble -\keepsilent -\generate{\file{dataref.sty}{\from{dataref.dtx}{package}}} -\endbatchfile diff --git a/Master/texmf-dist/tex/latex/dataref/dataref.sty b/Master/texmf-dist/tex/latex/dataref/dataref.sty index 381d57469af..bb6f013032a 100644 --- a/Master/texmf-dist/tex/latex/dataref/dataref.sty +++ b/Master/texmf-dist/tex/latex/dataref/dataref.sty @@ -1,13 +1,5 @@ +%% Copyright 2013-2017 Christian Dietrich %% -%% This is file `dataref.sty', -%% generated with the docstrip utility. -%% -%% The original source files were: -%% -%% dataref.dtx (with options: `package') -%% dataref.dtx -%% Copyright 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. @@ -15,33 +7,32 @@ %% 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} - [2015/09/17 v0.5 dataref] +\ProvidesPackage{dataref}[2017/01/06 v0.6 dataref] \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 + +\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} -\usepgflibrary{fpu} -\usepackage{etoolbox} -\RequirePackage{xcolor} +\RequirePackage{etoolbox} \SetupKeyvalOptions{ family=dref, @@ -55,72 +46,297 @@ \DeclareBoolOption{ignoremissing} \DeclareBoolOption{noassert} \ProcessKeyvalOptions* -\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}% + +% 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@datapath#1}{0} - \expandafter\dref@referenced\expandafter{\dref@datapath#1}{0}% + \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\drefset#1#2{\dref@set{#1}{#2}} -\def\dref@expandable#1{% - \pgfkeysifdefined{\dref@datapath\csuse{dref@prefix}#1}{% - \pgfkeysvalueof{\dref@datapath\csuse{dref@prefix}#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{}% + }% }{% - \ifdref@ignoremissing% - \dref@defaultvalue% - \else% - \typeout{Dref error: undefined key `#1'}\QUIT% - \fi% + \edef#2{\dref@defaultvalue}% + \def#3{}% }% } -\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}}% + +\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}% }{% - \immediate\write\@auxout{\noexpand\dref@notfound{\drefcurrentkey}{\dref@thepage}}% + \dref@set{#1}{#2}{#3}% }% - \immediate\write\@auxout{\noexpand\dref@referenced{\drefcurrentkey}{\dref@thepage}}% -} -\newcommand{\drefifdefined}[3]{ - \def\drefcurrentkey{\dref@datapath\csuse{dref@prefix}#1}% - \pgfkeysifdefined{\drefcurrentkey}{#2}{#3}% -} -\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\}}% } -\def\drefvalueof#1{% - \dref@expandable{#1}% + +\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% } -\def\drefref#1{% - \dref@unexpandable{#1}% + +\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 + \let\dref@strmatch\pdfmatch \fi \ifLuaTeX% -\newcommand{\dref@strmatch}[2]{% + \newcommand{\dref@strmatch}[2]{% \directlua{% local match = string.find("\luaescapestring{#2}", "\luaescapestring{#1}");% if match then @@ -160,6 +376,20 @@ \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}% @@ -175,18 +405,9 @@ \dref@usagereport@referenced{#1}{#2}% \else\relax\fi% } -\def\dref@let#1{% - \def\@tmp##1=##2;{\pgfmathdeclarefunction*{##1}{0}{\pgfmathparse{##2}}}% - \renewcommand*{\do}[1]{\@tmp##1;}% - \ifstrempty{#1}{}{% - \docsvlist{#1}% - }% -} -\def\dreflet#1{% - \dref@let{#1}% -} +% The data("") || d() Parser \def\dref@parser#1#2{% \edef\@tempa{#1}% \csdef{dref@parser@result}{}% @@ -221,77 +442,67 @@ \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})}% + \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{% - \drefref{\dref@data@math@prefix #1}% - \csxdef{dref@parser@result}{\csuse{dref@parser@result}(\drefvalueof{\dref@data@math@prefix #1})}% + \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@@}{\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}% +\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}% + } + } } -\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% +\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}[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% -} -\newcommand{\dref@format}[2][]{% - \pgfmathprintnumber[#1]{#2}% +\newcommand{\drefcalc@starred}[2][]{ % Starred + \drefkeys{@[,@init, @calc pgf={#2}, #1, @calc, @set,% + @annotate={\textbackslash \drefcalc*[#1]\{#2\}},@]% + }% } -\newcommand{\drefformat}[2][]{\dref@format[#1]{#2}} -\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% +\newcommand{\drefformat}[2][]{% + \drefkeys{@[,@init, print=default, value={#2}, #1, @calc, @print, @]}% } + \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% + \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% } @@ -313,8 +524,8 @@ }% \expandafter\def\expandafter\arglist\expandafter{#1}% \expandafter\docsvlist\expandafter{\arglist}% - \@tempcntb=0\relax - {\loop\ifnum\@tempcntb<\drefcellcount + \@tempcntb=0\relax% + {\loop\ifnum\@tempcntb<\drefcellcount% \advance\@tempcntb by 1\relax% \ifnum \@tempcntb = 1% \edef\@@next{\csuse{@cell\the\@tempcntb}}% @@ -330,31 +541,25 @@ \@@next}% \repeat}% }% - \typeout{LINE: \the\dref@toks}% - \expandafter\scantokens\expandafter{\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 +\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} } -\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}% +\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 @@ -379,7 +584,7 @@ \expandafter\def\expandafter\dref@usagereport@strippath@\dref@datapath#1\blanktest{#1} \newcommand{\dref@usagereport@strippath}[1]{% - \expandafter\dref@ifstrmatch\expandafter{\expandafter^\dref@datapath.*$}{#1}% + \expandafter\dref@ifstrmatch\expandafter{\expandafter^\dref@datapath.*$}{#1}%$ {\dref@usagereport@strippath@#1\blanktest}% {#1}% } @@ -402,7 +607,7 @@ {\hypertarget{#1}{\dref@usagereport@strippath{#1}}}% {\dref@usagereport@strippath{#1}}}% & \dref@usagereport@formatreferencelist{#1}% - & \pgfkeysifdefined{#1}{\pgfkeysvalueof{#1}}{\textbf{\color{red}undefined}}% + & \drefifdefined{#1}{\dref*[@reference key/.code={}]{#1}}{\textbf{undefined}}% } \def\drefusagereportaftergroup{} @@ -492,7 +697,7 @@ } \newcommand{\drefusagereport}{% \ifdref@usagereport% - \ifcsvoid{dref@usagereport@keys}{\typeout{EMPTY}}{% + \ifcsvoid{dref@usagereport@keys}{}{% \begingroup% \renewcommand{\do}[1]{% \ifinlistcs{##1}{dref@usagereport@matchedkeys}{}{% @@ -505,142 +710,243 @@ }% csempty @keys \fi% } +\drefkeys{ + noassert/.is if=dref@noassert +} \newcommand{\drefassert}[1]{% \begingroup% \drefcalc*{#1}% - \expandafter\ifstrequal\expandafter{\drefresult}{1}{% - \typeout{Assertion holds: #1}% - }{% + \ifdim\drefresult pt = 0pt% \ifdref@noassert% - \typeout{Assertion failed: #1}% + \dref@warning{Assertion failed: #1}% \else% \dref@error{Assertion failed: #1}% - \fi% - }% + \fi% + \else + \dref@warning{Assertion holds: #1}% + \fi% \endgroup% } -\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 +\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% - % 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% + \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'. diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index 784c3d04bd1..335c7128dfd 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -334,6 +334,7 @@ chomp ($Build = `cd $Master/../Build/source && pwd`); 'cwpuzzle', "die 'skipping, in crossword package'", 'cyklop', "&MAKEcopy", 'dantelogo', "&MAKEflatten", + 'dataref', "&MAKEflatten", 'datatooltk', "die 'skipping, Java installation'", 'datepicker-pro', "die 'skipping, per author (dpstory) request'", 'datetime2-contrib', "die 'skipping, use its subdirectories'", |