From 9adf8e355a84312cf403250df2e41e11b893e687 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 21 Aug 2012 22:32:05 +0000 Subject: new latex package endiagram (21aug12) git-svn-id: svn://tug.org/texlive/trunk@27489 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/endiagram/README | 31 + .../doc/latex/endiagram/endiagram_en.pdf | Bin 0 -> 1041464 bytes .../doc/latex/endiagram/endiagram_en.tex | 1223 ++++++++++++++++ .../texmf-dist/tex/latex/endiagram/endiagram.sty | 1540 ++++++++++++++++++++ 4 files changed, 2794 insertions(+) create mode 100644 Master/texmf-dist/doc/latex/endiagram/README create mode 100644 Master/texmf-dist/doc/latex/endiagram/endiagram_en.pdf create mode 100644 Master/texmf-dist/doc/latex/endiagram/endiagram_en.tex create mode 100644 Master/texmf-dist/tex/latex/endiagram/endiagram.sty (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/endiagram/README b/Master/texmf-dist/doc/latex/endiagram/README new file mode 100644 index 00000000000..4a856fe0aeb --- /dev/null +++ b/Master/texmf-dist/doc/latex/endiagram/README @@ -0,0 +1,31 @@ +-------------------------------------------------------------------------- +the ENdiagram package v0.1a + + easy creation of potential energy curve diagrams + +2012/08/20 +-------------------------------------------------------------------------- +Clemens Niederberger +Web: https://www.bitbucket.org/cgnieder/endiagram +E-Mail: contact@mychemistry.eu +-------------------------------------------------------------------------- +If you have any ideas, questions, suggestions or bugs to report, please +feel free to contact me. +-------------------------------------------------------------------------- +Copyright 2012 Clemens Niederberger + +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 Clemens Niederberger. + +This work consists of the files endiagram.sty, endiagram_en.tex, +README and the derived file endiagram_en.pdf. +-------------------------------------------------------------------------- \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/endiagram/endiagram_en.pdf b/Master/texmf-dist/doc/latex/endiagram/endiagram_en.pdf new file mode 100644 index 00000000000..c141d30e4f8 Binary files /dev/null and b/Master/texmf-dist/doc/latex/endiagram/endiagram_en.pdf differ diff --git a/Master/texmf-dist/doc/latex/endiagram/endiagram_en.tex b/Master/texmf-dist/doc/latex/endiagram/endiagram_en.tex new file mode 100644 index 00000000000..fe739d5c81a --- /dev/null +++ b/Master/texmf-dist/doc/latex/endiagram/endiagram_en.tex @@ -0,0 +1,1223 @@ +% arara: pdflatex +% arara: makeindex: { sort: true , style: endiagram_en.ist } +% arara: biber +% arara: pdflatex +% arara: pdflatex +% -------------------------------------------------------------------------- +% the ENdiagram package +% +% easy creation of potential energy curve diagrams +% +% -------------------------------------------------------------------------- +% Clemens Niederberger +% Web: https://www.bitbucket.org/cgnieder/endiagram +% E-Mail: contact@mychemistry.eu +% -------------------------------------------------------------------------- +% If you have any ideas, questions, suggestions or bugs to report, please +% feel free to contact me. +% -------------------------------------------------------------------------- +% Copyright 2012 Clemens Niederberger +% +% 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 Clemens Niederberger. +% +% This work consists of the files endiagram.sty, endiagram_en.tex, +% README and the derived file endiagram_en.pdf. +% -------------------------------------------------------------------------- +% if you want to compile this documentation you'll need the document class +% `cnpkgdoc' which you can get here: +% https://bitbucket.org/cgnieder/cnpkgdoc/ +% the class is licensed LPPL 1.3 or later +\documentclass[DIV10,toc=index,toc=bib]{cnpkgdoc} +\docsetup{ + language = en , + title = ENdiagram , + subtitle = {Easy creation of potential energy curve diagrams.} , + name = ENdiagram , + info = {Easy creation of potential energy curve diagrams} , + date = 2012/08/20 , + version = 0.1a , + keywords = {energy diagrams,tikz,LaTeX}, + modules = true , + code-box = { + backgroundcolor = gray!2!white , + skipbelow = .6\baselineskip plus .5ex minus .5ex , + skipabove = .6\baselineskip plus .5ex minus .5ex , + roundcorner = 3pt + } +} +\usepackage[osf]{libertine} +\cnpkgcolors{ + main => cnpkgred , + key => yellow!40!brown , + module => cnpkgblue , + link => black!90 +} + +\renewcommand*\othersectionlevelsformat[3]{% + \textcolor{main}{#3\autodot}\enskip} +\renewcommand*\partformat{% + \textcolor{main}{\partname~\thepart\autodot}} + +\addcmds{ + AddAxisLabel, + arrow, + calory, + ch, + chemfig, + chemsetup, + color, + command, + DeclareChemIUPAC, + draw, + ENcurve, + ENsetup, + fontfamily, + iso, + joule, + kilo, + lewis, + MakeOrigin, + mole, + node, + per, + schemestart, + schemestop, + selectfont, + setatomsep, + ShowEa, + ShowGain, + ShowNiveaus, + sisetup, + tert, + tikz, + transitionstatesymbol +} +\usepackage{endiagram,chemmacros,chemfig,ragged2e,fnpct} + +\usepackage{acro} +\acsetup{short-format=\scshape} +\DeclareAcronym{su}{su}{standard unit} +\DeclareAcronym{CTAN}{ctan}{Comprehensive \TeX\ Archive Network} +\DeclareAcronym{MWE}{mwe}{minimal working example} + +\begin{filecontents}{\jobname.ist} + heading_prefix "{\\bfseries " + heading_suffix "\\hfil}\\nopagebreak\n" + headings_flag 1 + delim_0 "\\dotfill " + delim_1 "\\dotfill " + delim_2 "\\dotfill " + delim_r "\\nohyperpage{\\textendash}" + suffix_2p "\\nohyperpage{\\,f.}" + suffix_3p "\\nohyperpage{\\,ff.}" +\end{filecontents} + +\begin{filecontents}{\jobname.bib} +@book{brueckner, + author = {Reinhard Br\"uckner}, + title = {Reaktionsmechanismen}, + publisher = {Springer-Verlag Berlin Heidelberg}, + edition = {3.\,Auflage, 2.\,korrigierter Nachdruck}, + year = {2009}, + isbn = {978-3-8274-1579-0} +} +@online{tikz, + author = {Till Tantau}, + title = {Ti\textbf{\textit{k}}Z/pgf}, + url = {http://sourceforge.net/projects/pgf/}, + urldate = {2012-01-31} +} +\end{filecontents} + +\usepackage[backend=biber,style=alphabetic]{biblatex} +\addbibresource{\jobname.bib} + +\setlength{\marginparwidth}{1.5\marginparwidth} + +\ExplSyntaxOn +\NewDocumentCommand \Default {g} + { + \hfill\llap + { + \IfNoValueTF { #1 } + {(initially~empty)} + {Default:~\code{#1}} + } + \newline + } +\NewDocumentCommand \NoDefault {} + { \hfill \newline } +\ExplSyntaxOff + +\makeindex +\begin{document} + +\section{Licence and Requirements} +Permission is granted to copy, distribute and/or modify this software under the +terms of the LaTeX Project Public License, version 1.3 or later +(\url{http://www.latex-project.org/lppl.txt}). This package has the status +``maintained.'' + +\ENdiagram needs the \paket{l3kernel} and the package \paket{xparse}. \paket{xparse} +is part of the \paket{l3packages} bundle. \ENdiagram also needs \paket[pgf]{\TIKZ} +and \paket{siunitx}. + +Basic knowledge of \TikZ/pgf \cite{tikz} is recommended. + +\section{Caveat} +This package is in an experimental state. There is lots of code to clean up and +there are many loose ends to be tied together until I'll be satisfied to publish +this package as stable. However, as the unofficial release on my blog has gotten +quite some interest\footnote{$\ge 400$ downloads} I decided to publish this +experimental version on the \ac{CTAN} nonetheless. + +If you detect any bugs -- and I guess you will -- please write me a short email +with a \ac{MWE} showing the undesired behaviour or report on issue on +\url{https://www.bitbucket.org/cgnieder/endiagram}. + +\section{Before We Start} +This document presents commands and options in a consistent way: +\begin{beschreibung} + \Umg{environment}[]{...} + \Befehl{command}[]{} + \option{option}{\default{default}|value} choice option with a \default{default value} + that will be used, if the option is set without value. + \option{option}{} option that needs an input of a certain type. + \option[command]{option}{} option that belongs to the module + \textcolor{module}{\code{command}}. +\end{beschreibung} +Options can be used in the \oa{} arguments. There are two kinds of +options: choice options where you can choose one of the values separated with +\code{|}; an underlined value is a default value that is used, if no value is +given. The others need a value of a certain type like a number (\code{}), +arbitrary input (\code{}), \TikZ\ options (\code{}) \etc. + +As a rule commands are only defined inside the \env{endiagram}{} environment. + +Options can also be set up with this command: +\begin{beschreibung} + \Befehl{ENsetup}[]{} +\end{beschreibung} + +\begin{beispiel}[code only] + \ENsetup{option1 = value1, option2 = value2} + \ENsetup{module/option = value} + \ENsetup[module]{option = value} +\end{beispiel} + +Options that belong to a module are specific to a command. The command +\cmd{command} they belong to can \emph{only} have the options marked with +\textcolor{module}{\code{command}} in his argument \oa{}. + +All other options can also be set globally as package options. These are options +which do \emph{not} belong to a module like for example the \key{draft} option +(see page~\pageref{key:debug}): +\begin{beispiel}[code only] + \usepackage[draft]{endiagram} +\end{beispiel} + +\section{The Curve -- \cmd{ENcurve}}\secidx{curve} +The potential energy curves are drawn inside the \env{endiagram}{\ldots} +environment using the command \cmd{ENcurve}. +\begin{beschreibung} + \Umg{endiagram}[]{} + \Befehl{ENcurve}[]{,,} +\end{beschreibung} +The command needs a comma separated list of relative energy levels. +\cmd{ENcurve}{1,4,0} means the maximum is four times higher above the end level +than the starting level. +\begin{beispiel} +\begin{endiagram} + \ENcurve{1,4,0} +\end{endiagram} +\end{beispiel} + +\cmd{ENcurve} can read any number of values but needs \emph{at least three}. +Less values will cause an error. +\begin{beispiel}[below] +\begin{endiagram} + \ENcurve{1,5,2.5,4,0} +\end{endiagram} +\quad +\begin{endiagram}[scale=.7] + \ENcurve{1,7,2.5,6,3,4,0} +\end{endiagram} +\end{beispiel} + +\subsection{Properties} +\subsubsection{Scaling}\secidx[scaling]{curve} +Values given to \cmd{ENcurve} are multiples of \ENdiagram's \ac{su}. As a default +it is set to \SI{.5}{cm} but can be changed using an option. There are other ways +to influence the size of the diagram, too. +\begin{beschreibung} + \Option{unit}{}\Default{.5cm} The standard unit for \cmd{ENcurve} and + some other commands. This document refers to it with \ac{su}. + \Option{scale}{}\Default{1} +\end{beschreibung} + +A changed \ac{su}: +\begin{beispiel} +\begin{endiagram}[unit=2em] + \ENcurve{1,4,0} +\end{endiagram} +\end{beispiel} + +Scaled by the factor \code{1.5}: +\begin{beispiel} +\begin{endiagram}[scale=1.5] + \ENcurve{1,4,0} +\end{endiagram} +\end{beispiel} + +\subsubsection{Influencing the position relative to the axes}\secidx[position]{curve} +The \code{offset} options control the length and position of the horizontal axis +relative to the curve. +\begin{beschreibung} + \Option{offset}{}\Default{0} \code{} is a multiple of the \ac{su} (see + page~\pageref{key:unit}). + \Option{r-offset}{}\Default{0} \code{} is a multiple of the \ac{su}. + \Option{l-offset}{}\Default{0} \code{} is a multiple of the \ac{su}. +\end{beschreibung} + +The default behaviour for comparison: +\begin{beispiel} +\begin{endiagram} + \ENcurve{1,4,0} +\end{endiagram} +\end{beispiel} + +\key{l-offset} controls the distance of the start of the $x$ axis to the start +of the curve: +\begin{beispiel} +closer to the $y$ axis:\\ +\begin{endiagram}[l-offset=-1] + \ENcurve{1,4,0} +\end{endiagram} +\end{beispiel} + +\key{r-offset} controls the ``protruding'' of the $x$ axis after the curve: +\begin{beispiel} +$x$ axis extended to the right:\\ +\begin{endiagram}[r-offset=1] + \ENcurve{1,4,0} +\end{endiagram} +\end{beispiel} + +\key{offset} changes both values equally: +\begin{beispiel} +$x$ extended to the left and the right:\\ +\begin{endiagram}[offset=1] + \ENcurve{1,4,0} +\end{endiagram} +\end{beispiel} + +\subsubsection{Increment between the levels}\secidx[increment]{curve} +With the option +\begin{beschreibung} + \Option[ENcurve]{step}{}\Default{2} \code{} is a multiple of the \ac{su} + (see page~\pageref{key:unit}). +\end{beschreibung} +the default increment between the levels can be changed. +\begin{beispiel}[below] +\begin{endiagram} + \ENcurve{1,4,0} +\end{endiagram} +\quad +\begin{endiagram} + \ENcurve[step=3]{1,4,0} +\end{endiagram} +\end{beispiel} + +Sometimes a certain level should be shifted against the others. This is possible +using an optional argument to the value of that level: +\begin{beschreibung} + \Befehl{ENcurve}{[],...}\NoDefault + \oa{} is a multiple of the \ac{su} (see page~\pageref{key:unit}) and is set + to \code{0} as default. The level will be shifted to the right (positive values) + or left (negative values). +\end{beschreibung} +\begin{beispiel}[below] +\begin{endiagram} + \ENcurve{1,4,0} +\end{endiagram} +\quad +\begin{endiagram} + \ENcurve{1,4[.5],0} +\end{endiagram} +\quad +\begin{endiagram} + \ENcurve{1,4[-.5],0} +\end{endiagram} +\end{beispiel} + +\subsubsection{The shape}\secidx[shape]{curve} +The option +\begin{beschreibung} + \Option[ENcurve]{looseness}{}\Default{.5} should be a number between + \code{0} and \code{1}. +\end{beschreibung} +changes the shape of the curve. +\begin{beispiel}[below] +\begin{endiagram} + \ENcurve[looseness=0]{0,3,1} +\end{endiagram} +\quad +\begin{endiagram} + \ENcurve{0,3,1}% corresponds looseness=.5 +\end{endiagram} +\quad +\begin{endiagram} + \ENcurve[looseness=1]{0,3,1} +\end{endiagram} +\end{beispiel} + +\subsubsection{Ending minima}\secidx[minima]{curve} +Sometimes potential energy curves are drawn with local minima at the start and +the end of the cuve. The option +\begin{beschreibung} + \Option[ENcurve]{minima}{\default{true}|false}\Default{false} +\end{beschreibung} +en- or disables them: +\begin{beispiel} +\begin{endiagram} + \ENcurve[minima]{1,4,0} +\end{endiagram} +\end{beispiel} + +\subsubsection{\TIKZ\ style}\secidx[style]{curve} +The style of the curve can be changed using \TikZ\ options: +\begin{beschreibung} + \Option[ENcurve]{tikz}{}\Default Valid are options that can be used with + \verb=\draw=. +\end{beschreibung} +\begin{beispiel} +\begin{endiagram} + \ENcurve[tikz={red,dotted}]{0,3,1} +\end{endiagram} +\end{beispiel} + +\subsection{The Axes}\secidx[axes]{curve}\secidx{axes} +There are also possibilities to customize the axes. +\begin{beschreibung} + \Option{axes}{xy|y|y-l|y-r|x|all|false}\Default{xy} Number and type of axes. + \Option{x-axis}{}\Default \TikZ options to the $x$ axis. + \Option{y-axis}{}\Default \TikZ options to the $y$ axis. + \Option{x-label}{below|right}\Default{below} Position of the $x$ axis label. + \Option{y-label}{above|left}\Default{left} Position of the $y$ axis label. + \Option{x-label-pos}{}\Default{.5} Position of the $x$ axis label when + \key{x-label}{below} is set. + \Option{y-label-pos}{}\Default{.5} Position of the $y$ axis label when + \key{y-label}{left} is set. + \Option{x-label-offset}{}\Default{0pt} Distance between label and $x$ + axis. + \Option{y-label-offset}{}\Default{0pt} Distance between label and $y$ + axis. + \Option{x-label-angle}{}\Default{0} Angle which rotates the $x$ axis + label counter clockwise. + \Option{y-label-angle}{}\Default{0} Angle which rotates the $y$ axis + label counter clockwise. + \Option{x-label-text}{}\Default{\$\cmd{xi}\$} $x$ axis label. + \Option{y-label-text}{}\Default{\$E\$} $y$ axis label. +\end{beschreibung} + +No axes: +\begin{beispiel} +\begin{endiagram}[axes=false] + \ENcurve{1,4,0} +\end{endiagram} +\end{beispiel} + +All axes: +\begin{beispiel} +\begin{endiagram}[axes=all] + \ENcurve{1,4,0} +\end{endiagram} +\end{beispiel} + +Only the $x$ axis: +\begin{beispiel} +\begin{endiagram}[axes=x] + \ENcurve{1,4,0} +\end{endiagram} +\end{beispiel} + +Changed labels: +\begin{beispiel} +\begin{endiagram}[x-label-text=\footnotesize reaction coordinate] + \ENcurve{1,4,0} +\end{endiagram} +\end{beispiel} + +Different positions of the labels: +\begin{beispiel}[below] +\begin{endiagram}[ + x-label=right, + y-label=above] + \ENcurve{1,4,0} +\end{endiagram} +\quad +\begin{endiagram}[ + x-label-pos=.7, + y-label-pos=.7, + y-label-angle=-90, + y-label-offset=5pt] + \ENcurve{1,4,0} +\end{endiagram} +\end{beispiel} + +Crazy setup: +\begin{beispiel} +\begin{endiagram}[x-axis={draw=blue,dashed,font=\color{green}}] + \ENcurve{1,4,0} +\end{endiagram} +\end{beispiel} +\secidx*{axes} + +\subsection{Debugging Information}\secidx[debugging]{curve}\index{debugging} +For precise adjustments of details -- particularly with the options and commands +described in the next sections -- some information is useful that is hidden +normally. These options enable access: +\begin{beschreibung} + \Option{debug}{\default{true}|false}\Default{false} + \Option{draft}{\default{true}|false}\Default{false} An Alias to \key{debug}. + \Option{final}{\default{true}|false}\Default{true} The opposite of \key{draft}. +\end{beschreibung} +\begin{beispiel}[below] +\begin{endiagram}[debug] + \ENcurve{1,4,0} +\end{endiagram} +\quad +\begin{endiagram}[debug,unit=2em] + \ENcurve[step=3,minima]{1,4,0} +\end{endiagram} +\end{beispiel} +Shown are a grid, the origin and the coordinates and names of the levels. +Depending on the commands you're using you get more information.It is described +with the commands they belong to. +\secidx*{curve} + +\section{The Levels}\secidx{levels} +\subsection{The \cmd{ShowNiveaus} Command} +The command +\begin{beschreibung} + \Befehl{ShowNiveaus}[] +\end{beschreibung} +draws horizontal lines to the levels: +\begin{beispiel} +\begin{endiagram} + \ENcurve{3,4,0} + \ShowNiveaus +\end{endiagram} +\end{beispiel} + +\subsection{Customization} +A number of options allow fine-tuning: +\begin{beschreibung} + \Option[ShowNiveaus]{length}{}\Default{1} The length of the lines. + \code{} is a multiple of the \ac{su} (see page~\pageref{key:unit}). + \Option[ShowNiveaus]{shift}{}\Default{0} Shift to the right (positive + values) or the left (negative values). \code{} is a multiple of the \ac{su}. + \Option[ShowNiveaus]{tikz}{}\Default \TikZ options to modify the style + of the lines. +\end{beschreibung} + +Longer lines: +\begin{beispiel} +\begin{endiagram} + \ENcurve{3,4,0} + \ShowNiveaus[length=2] +\end{endiagram} +\end{beispiel} + +Without \key{shift} are centered to the extrema , \ie they protrude by half of +the value specified with \key{length}. +\begin{beispiel}[below] +\begin{endiagram} + \ENcurve{3,4,0} + \ShowNiveaus[shift=.5] +\end{endiagram} +\quad +\begin{endiagram} + \ENcurve{3,4,0} + \ShowNiveaus[length=2,shift=1] +\end{endiagram} +\end{beispiel} +Maybe the examples in the next section will make it more clear why \key{shift} +can be useful. + +\subsection{Choose Levels Explicitly} +If you don't want to draw a line to every level you can use this option: +\begin{beschreibung} + \Option[ShowNiveaus]{niveau}{,}\NoDefault + The \code{} is the name of the level as shown by the \key{debug} option, + see page~\pageref{key:debug}. +\end{beschreibung} + +The debug information helps in choosing the right level. The names of the levels +follow the scheme \code{N--}. +\begin{beispiel}[below] +\begin{endiagram}[debug] + \ENcurve{3,4,0} +\end{endiagram} +\quad +\begin{endiagram} + \ENcurve{3,4,0} + \ShowNiveaus[niveau=N1-2] +\end{endiagram} +\end{beispiel} + +Every level can have a different color, length and shift: +\begin{beispiel} +\begin{endiagram} + \ENcurve{3,4,0} + \ShowNiveaus[length=2,tikz=red,niveau=N1-2] + \ShowNiveaus[niveau=N1-1,shift=-.5] + \ShowNiveaus[niveau=N1-3,shift=.5] +\end{endiagram} +\end{beispiel} +\secidx*{Niveaus} + +\section{The Energy Gain}\secidx{energy gain} +\subsection{The \cmd{ShowGain} Command} +The command +\begin{beschreibung} + \Befehl{ShowGain}[] +\end{beschreibung} +enables you the show the energy gain or loss of the reaction. It is always the +difference between the first and the last level. +\begin{beispiel} +\begin{endiagram} + \ENcurve{3,4,0} + \ShowGain +\end{endiagram} +\end{beispiel} + +\subsection{Customization} +The command has options to modify the appearance. +\begin{beschreibung} + %% + \Option[ShowGain]{tikz}{}\Default{<->} \TikZ options for the vertical line. + %% + \Option[ShowGain]{connect}{}\Default{dashed,help lines} \TikZ options for + the connecting line. + %% + \Option[ShowGain]{connect-from-line}{\default{true}|false}\Default{false} The + connecting line starts either at the maximum/minimum or at the line drawn by + \cmd{ShowNiveaus}. This option works with the default values but otherwise can + lead to unwanted results. To avoid that you can either set \cmd{ShowGain} + \emph{before} \cmd{ShowNiveaus} or you need to choose another way. + %% + \Option[ShowGain]{offset}{}\Default{0} Shifts the vertical line to the + right (positive value) or the left (negative value). \code{} is a multiple + of \ac{su} (see page~\pageref{key:unit}). + %% + \Option[ShowGain]{label}{\default{true}|false|}\Default{false} Use the + default label (\code{true}) or an own label (\code{}).\label{key:showgain_label} + %% + \Option[ShowGain]{label-side}{right|left}\Default{right} The side of the vertical + line on which the label should be placed. + %% + \Option[ShowGain]{label-pos}{}\Default{.5} Position at the line. \code{0} + means at the height of $H_1$, \ie the starting level, \code{1} means at the + height of $H_2$, \ie the ending level. + %% + \Option[ShowGain]{label-tikz}{}\Default \TikZ options for the label. +\end{beschreibung} + +\begin{beispiel} +\begin{endiagram} + \ENcurve{3,4,0} + \ShowGain[connect={dotted,red},offset=2] +\end{endiagram} +\end{beispiel} + +Using the \key{label} option: +\begin{beispiel}[below] +\begin{endiagram} + \ENcurve{3,4,0} + \ShowGain[label] +\end{endiagram} +\begin{endiagram} + \ENcurve{0,4,3} + \ShowGain[label] +\end{endiagram} +\begin{endiagram} + \ENcurve{3,4,0} + \ShowGain[label=exothermic] +\end{endiagram} +\end{beispiel} + +Connecting lines and levels are overlapping: +\begin{beispiel} +\begin{endiagram} + \ENcurve{3,4,0} + \ShowNiveaus + \ShowGain[connect=red] +\end{endiagram} +\end{beispiel} + +A possible solution: +\begin{beispiel} +\begin{endiagram} + \ENcurve{3,4,0} + \ShowNiveaus + \ShowGain[connect-from-line,connect=red] +\end{endiagram} +\end{beispiel} + +Better would be to set \cmd{ShowNiveaus} \emph{after} \cmd{ShowGain}, particularly +if you're not using the default settings. +\begin{beispiel} +\begin{endiagram} + \ENcurve{3,4,0} + \ShowNiveaus[niveau=N1-1] + \ShowGain[connect={red,dotted}] +\end{endiagram} +\begin{endiagram} + \ENcurve{3,4,0} + \ShowGain[connect={red,dotted}] + \ShowNiveaus[niveau=N1-1] +\end{endiagram} +\end{beispiel} + +\subsection{Debugging Information}\index{debugging}\secidx[debugging]{energy gain} +Using the \key{debug} option (see page~\pageref{key:debug}) gives you further +information: +\begin{beispiel} +\begin{endiagram}[debug] + \ENcurve{3,4,0} + \ShowGain +\end{endiagram} +\end{beispiel} +\secidx*{energy gain} + +\section{The Activation Energy}\secidx{activation energy} +\subsection{The \cmd{ShowEa} Command} +This command is similar to the commands \cmd{ShowNiveaus} and \cmd{ShowGain}. +\begin{beschreibung} + \Befehl{ShowEa}[] +\end{beschreibung} +It enables to show the activation energy: +\begin{beispiel} +\begin{endiagram} + \ENcurve{2,4,0} + \ShowEa +\end{endiagram} +\end{beispiel} + +The default behaviour shows the difference between the \emph{first} maximum +after a \emph{previous} minimum to that minimum: +\begin{beispiel} +\begin{endiagram} + \ENcurve{2,0,4} + \ShowEa +\end{endiagram} +\end{beispiel} + +This also holds if there is more than one maximum. How you choose a different +one is described in the next section. +\begin{beispiel} +\begin{endiagram} + \ENcurve{1,5,2.5,4,0} + \ShowEa +\end{endiagram} +\end{beispiel} + +\subsection{Choose Level Explicitly} +The default behaviour is all right if there is only one maximum. If there are +more one might want to choose a different one. The following options allow that. +\begin{beschreibung} + \Option[ShowEa]{max}{first|all}\Default{first} + Show the difference to the first maximum or to all maxima. + \Option[ShowEa]{from}{\{()to()\}}\NoDefault + Specify the coordinates that should be connected. You can either use the + coordinates \code{(,)} or the name \code{()} of the node. +\end{beschreibung} + +Using \key[ShowEa]{max}{all}: +\begin{beispiel} +\begin{endiagram} + \ENcurve{1,5,2.5,4,0} + \ShowEa[max=all] +\end{endiagram} +\end{beispiel} + + +Since in most cases this won't be what you want you can specify the coordinates +yourself. The option \key{debug} (see page~\pageref{key:debug}) may help. +\begin{beispiel}[below] +\begin{endiagram}[debug] + \ENcurve{1,5,2.5,4,0} + \ShowEa +\end{endiagram} +\quad +\begin{endiagram} + \ENcurve{1,5,2.5,4,0} + \ShowEa[from={(0,1) to (6,4)}] +\end{endiagram} + +\begin{endiagram} + \ENcurve{1,5,2.5,4,0} + \ShowEa[from={(N1-1) to (N1-3)}] +\end{endiagram} +\quad +\begin{endiagram} + \ENcurve{1,5,2.5,4,0} + \ShowEa[from={(N1-5) to (N1-4)}] +\end{endiagram} +\end{beispiel} +In every case the position of the vertical line is determined by the \emph{first} +coordinate. + +\subsection{Customization} +Again there are a number of options to customize the appearance. +\begin{beschreibung} + \Option[ShowEa]{tikz}{}\Default{<->} \TikZ options for the vertical line. + \Option[ShowEa]{connect}{}\Default{dashed,help lines} \TikZ options for + the horizontal line. + \Option[ShowEa]{label}{\default{true}|false|}\Default{false} Use the + default label ($E_{\mathrm{a}}$) or an own label.\label{key:showea_label} + \Option[ShowEa]{label-side}{right|left}\Default{right} The side of the vertical + line where the label should appear. + \Option[ShowEa]{label-pos}{}\Default{.5} Determines the vertical position + of the label relative to the vertical line. \code{0} means at the lower end, + \code{1} means at the upper end. + \Option[ShowEa]{label-tikz}{}\Default \TikZ options for the label. +\end{beschreibung} + +\begin{beispiel} +\begin{endiagram} + \ENcurve[step=4]{1,6,0} + \ShowEa[label,label-pos=.3] +\end{endiagram} +\end{beispiel} + +\begin{beispiel} +\begin{endiagram} + \ENcurve{1,5,2.5,4,0} + \ShowEa[ + from = {(N1-1) to (N1-3)}, + connect = {draw=none}, + label = endoth.] + \ShowEa[ + from = (N1-3) to (N1-5), + label = exoth., + label-pos = .7] + \ShowGain[label=exoth.] +\end{endiagram} +\end{beispiel} + +\subsection{Debugging Information}\index{debugging}\secidx[debugging]{activation energy} +The \key{debug} option gives you further information. +\begin{beispiel}[below] +\begin{endiagram}[debug] + \ENcurve{1,5,2,3,0} + \ShowEa[max=all] +\end{endiagram} +\quad +\begin{endiagram}[debug] + \ENcurve{1,5,2,3,0} + \ShowEa[from={(0,1) to (6,3)}] +\end{endiagram} +\end{beispiel} +\secidx*{activation energy} + +\section{Several Curves in one Diagram}\secidx{several curves} +It's easy to draw several curves. You only need to use \cmd{ENcurve} more than +once. +\begin{beispiel} +\begin{endiagram} + \ENcurve[tikz=blue]{1,4,0} + \ENcurve[tikz=red]{1,2.5,0} + \draw[blue] (5,5) -- ++(1,0) node[black,right] {with enzyme}; + \draw[red] (5,4) -- ++(1,0) node[black,right] {without enzyme}; +\end{endiagram} +\end{beispiel} + +The commands \cmd{ShowNiveaus}, \cmd{ShowGain} and \cmd{ShowEa} always relate to +the curve set at last. This means you can use them selectively. +\begin{beispiel} +\begin{endiagram} + \ENcurve[tikz=blue]{1,4,0} + \ShowEa[tikz={blue,<->}] + \ENcurve[tikz=red]{1,2.5,0} +\end{endiagram} + +\begin{endiagram} + \ENcurve[tikz=blue]{1,4,0} + \ENcurve[tikz=red]{1,2.5,0} + \ShowEa[tikz={red,<->}] +\end{endiagram} +\end{beispiel} + +Using more than one curves explains the multiple numbering of the level names: +\begin{beispiel} +% the names of the levels (N1-1) +% and (N1-3) are hidden behind +% (N2-1) and (N2-3), resp. +\begin{endiagram}[debug] + \ENcurve{1,4,0} + \ENcurve{1,2.5,0} +\end{endiagram} + +\begin{endiagram} + \ENcurve[tikz=blue]{1,4,0} + \ENcurve[tikz=red]{1,2.5,0} + \draw[<->] (N1-2) -- (N2-2) ; +\end{endiagram} +\end{beispiel} + +Of course it's possible to choose different options for different curves. This +means you can use curves with a different number of maxima. +\begin{beispiel} +\begin{endiagram} + \ENcurve[step=4]{1,6,0} + \ENcurve[ + tikz={densely dotted}] + {1,4[1],2.5,3[-1],0} +\end{endiagram} +\end{beispiel} +\secidx*{several curves} + +\section{Usage of Ti\textit{k}Z}\index{TikZ@\TIKZ} +Since the \env{endiagram}{\ldots} environment only is a \code{tikzpicture} +environment (well, more or less) you can use \TikZ commands inside it. This +means you can easily add additional information to the diagram. +\begin{beispiel} +% needs the package `chemmacros' +\begin{endiagram} + \ENcurve{1,5,2,3,0} + \ShowNiveaus[length=2,niveau={N1-2,N1-3,N1-4}] + \node[above,xshift=4pt] at (N1-2) {[\"UZ1]$^{\transitionstatesymbol}$} ; + \node[below] at (N1-3) {ZZ} ; + \node[above,xshift=4pt] at (N1-4) {[\"UZ2]$^{\transitionstatesymbol}$} ; +\end{endiagram} +\quad +\begin{endiagram} + \ENcurve{2,3,0} + \draw[<-,red] (N1-2) -- ++(2,1) node[right] {transition state} ; +\end{endiagram} +\end{beispiel} + +\subsection{The Origin}\index{origin} +The nodes \code{(origin-l)} and \code{(origin-r)} are set at the end of the +environment. This means they are \emph{not} available inside the +\env{endiagram}{\ldots} environment. If you want to use them you either need to +look up their coordinates using the \key{debug} option (see +page~\pageref{key:debug}) \ldots +\begin{beispiel} +\begin{endiagram}[y-label=above] + \ENcurve{1,3[.5],0} + \draw[dashed,help lines] + (N1-2) -- (N1-2 -| -1.5,-1) + node[left,black] {max} ; +\end{endiagram} +\end{beispiel} +\ldots\ or use this option: +\begin{beschreibung} + \Option{tikz}{}\Default \TikZ options for the \env{endiagram}{\ldots} + environment. +\end{beschreibung} +With it you can pass arbitrary \TikZ options to the internal \code{tikzpicture} +environment. +\begin{beispiel} +\begin{endiagram}[ + y-label = above, + tikz = {remember picture}] + \ENcurve{1,3[.5],0} +\end{endiagram} +\tikz[remember picture,overlay]{ + \draw[dashed,help lines] + (N1-2) -- (N1-2 -| origin-l) + node[left,black] {max} ; +} +\end{beispiel} + +There is an easier way, though: you can use the following command \emph{after} +drawing all curves: +\begin{beschreibung} + \Befehl{MakeOrigin}\label{cmd:makeorigin} +\end{beschreibung} + +\begin{beispiel} +\begin{endiagram}[y-label = above] + \ENcurve{1,3[.5],0} + \MakeOrigin + \draw[dashed,help lines] + (N1-2) -- (N1-2 -| origin-l) + node[left,black] {max} ; +\end{endiagram} +\end{beispiel} + +\section{Axes Ticks and Labels}\secidx{axes ticks and labels} +\subsection{Automatic Ticks}\ENsetup{AddAxisLabel/font=\fontfamily{fxlf}\selectfont} +The $y$ axes can get ticks automatically. +\begin{beschreibung} + \Option{ticks}{y|\default{y-l}|y-r|none}\Default{none} Adds ticks to the + specified axes. + \Option{ticks-step}{}\Default{1} \code{} is a multiple of the \ac{su}. + \key{ticks-step}{2} means that only every second tick is added. +\end{beschreibung} +\begin{beispiel} +\ENsetup{ticks,y-label=above} +\begin{endiagram} + \ENcurve{1,5,2.5,4,0} +\end{endiagram} +\begin{endiagram}[ticks-step=2] + \ENcurve{1,5,2.5,4,0} +\end{endiagram} +\end{beispiel} +These ticks obey the \key{energy-unit} option, see section~\ref{sec:reale_werte}. + +\subsection{The \cmd{AddAxisLabel} Command} +% TODO auf Unterschied zwischen den Ticks produziert durch AddAxisLabel und Option ticks hinweisen +To be able to add labels to the ticks there is the command +\begin{beschreibung} + \Befehl{AddAxisLabel}[]{()[];();...} + \Befehl{AddAxisLabel}*[]{[];;...} +\end{beschreibung} +As you can see there are two variants. The first one awaits a list of coordinates +in the \TikZ sense. The second awaits $y$ values. Every of these values has an +optional argument with which you can specify the label. + +The first variant also draws lines between the points specifiad and the $y$ axis. +Internally this command calls \cmd{MakeOrigin}, see p.\,\pageref{cmd:makeorigin}, +which means it should be used \emph{after} drawing all curves. + +Example for the second variant: +\begin{beispiel} +\begin{endiagram}[y-label=above] + \ENcurve{1,3,2} + \AddAxisLabel*{1;2;3} +\end{endiagram} +\begin{endiagram}[y-label=above] + \ENcurve{1,3,2} + \AddAxisLabel*{1[10];2[20];3[30]} +\end{endiagram} +\end{beispiel} + +Example for the first variant: +\begin{beispiel} +\begin{endiagram}[y-label=above] + \ENcurve{1,3,2} + \AddAxisLabel{(N1-1)[$H_1$];(N1-3)[$H_2$]} +\end{endiagram} +\end{beispiel} + +The optional arguments can also get \TikZ options. The description should read: +\begin{beschreibung} + \Befehl{AddAxisLabel}{()[,]} + \Befehl{AddAxisLabel}*{[,]} +\end{beschreibung} + +\begin{beispiel} +\begin{endiagram}[y-label=above] + \ENcurve{1,3,2} + \AddAxisLabel*{1[10];2[20,{draw,fill=green!15}];3[30]} +\end{endiagram} +\begin{endiagram}[y-label=above] + \ENcurve{1,3,2} + \AddAxisLabel{(N1-1)[$H_1$];(N1-3)[$H_2$,{draw,font=\color{red},fill=green!15}]} +\end{endiagram} +\end{beispiel} + +\subsection{Customization} +You have several options to customize the labels: +\begin{beschreibung} + \Option[AddAxisLabel]{axis}{y-l|y-r|x}\Default{y-l} Choose which axis gets the + labels. + \Option[AddAxisLabel]{connect}{}\Default{dashed,help lines} Change the + style of the lines. + \Option[AddAxisLabel]{font}{}\Default You can add commands like + \verb=\footnotesize= and/or \verb=\color{red}= to format the label text. +\end{beschreibung} + +\begin{beispiel}[below] +\begin{endiagram}[y-label=above] + \ENcurve{1,3,2} + \AddAxisLabel{(2,3)[\"UZ]} +\end{endiagram} +\begin{endiagram}[y-label=above,x-label=right] + \ENcurve{1,3,2} + \AddAxisLabel[axis=x,connect=dotted]{(2,3)[\"UZ]} +\end{endiagram} +\begin{endiagram}[axes=all,y-label=above] + \ENcurve{1,3,2} + \AddAxisLabel[axis=y-r,connect=red]{(2,3)[\"UZ]} +\end{endiagram} +\end{beispiel} +\secidx*{axes ticks and labels} + +\section{Actual Values}\secidx{actual values}\label{sec:reale_werte} +\subsection{The Basics} +If you want to have a more quantitative diagram or use actual values for the +energies you can use these options: +\begin{beschreibung} + \Option{energy-unit}{}\Default The unit of the energy scale. A unit in + the \paket{siunitx} sense. + \Option{energy-step}{}\Default{1} Determines which increment on the energy + scale corresponds to the \ac{su}. + \Option{energy-zero}{}\Default{0} Shifts the origin of the energy scale by + \code{} in multiples of the energy scale. + \Option{energy-unit-separator}{}\Default{/} Separates the $y$ axes + label from the unit. + \Option{energy-round}{}\Default{3} Rounds the value to this number of figures. + \Option{energy-round-places}{\default{true}|false}\Default{false} Switch rounding + mode to places. +\end{beschreibung} +Choosing a unit will add ticks and labels to the $y$ axis automatically and has +an impact on the commands \cmd{ShowGain} and \cmd{ShowEa}, see section~\ref{ssec:real_einfluss}. + +\begin{beispiel} +\begin{endiagram}[ticks,y-label=above,energy-step=10] + \ENcurve{1,3,2} +\end{endiagram} +\begin{endiagram}[y-label=above,energy-step=10,energy-zero=30] + \ENcurve{1,3,2} + \AddAxisLabel*{1;2;3} +\end{endiagram} +\end{beispiel} + +\begin{beispiel} +\begin{endiagram}[y-label=above,energy-step=15,energy-zero=30,energy-unit=\kilo\joule] + \ENcurve{1,3,2} + \AddAxisLabel*{1;2;3} +\end{endiagram} +\begin{endiagram}[y-label=above,energy-step=10,energy-unit=\kilo\joule,energy-unit-separator={ in }] + \ENcurve{1,3,2} + \AddAxisLabel*{1;2;3} +\end{endiagram} +\end{beispiel} + +\begin{beispiel} +\ENsetup{energy-unit=kJ,energy-step=10,energy-zero=.613,y-label-offset=20pt} +\begin{endiagram} + \ENcurve{1.0613,4.3465,2.9876} + \ShowGain[label] +\end{endiagram} + +\begin{endiagram}[energy-round-places] + \ENcurve{1.0613,4.3465,2.9876} + \ShowGain[label] +\end{endiagram} +\end{beispiel} + +\subsection{Impact on Other Commands}\label{ssec:real_einfluss} +Using the option \key{energy-unit} changes the default labels of \cmd{ShowGain} +and \cmd{ShowEa}. Now an actual value is shown: +\begin{beispiel}[below] + % uses \DeclareSIUnit{\calory}{cal} +\sisetup{per-mode = fraction} +\ENsetup{ + energy-step = 100, + energy-unit = \kilo\calory\per\mole, + energy-unit-separator = { in }, + y-label = above, + AddAxisLabel/font = \fontfamily{fxlf}\selectfont\footnotesize +} +\begin{endiagram}[scale=1.5] + \ENcurve{2.232,4.174,.308} + \AddAxisLabel*{0;1;2;3;4} + \ShowEa[label,connect={draw=none}] + \ShowGain[label] +\end{endiagram} +\end{beispiel} + +This behaviour can be switched off, though: +\begin{beschreibung} + \Option{calculate}{\default{true}|false}\Default{true} +\end{beschreibung} +\begin{beispiel} + % uses \DeclareSIUnit{\calory}{cal} +\sisetup{per-mode = fraction} +\ENsetup{ + energy-step = 100, + energy-unit = \kilo\calory\per\mole, + energy-unit-separator = { in }, + y-label = above, + AddAxisLabel/font = \footnotesize, +} +\begin{endiagram}[scale=1.5,calculate=false] + \ENcurve{2.232,4.174,.308} + \AddAxisLabel*{0;1;2;3;4} + \ShowEa[label,connect={draw=none}] + \ShowGain[label] +\end{endiagram} +\end{beispiel} +\secidx*{Actual values} + +\section{Example} +The illustration of the Bell-Evans-Polanyi principle (figure~\ref{fig:bell-evans-polanyi}) +serves as an example for a more complex usage. One reaction is coloured as it +an exception to the principle. The figure is a reproduction of a similar figure +in~\cite{brueckner}. +\begin{beispiel}[code and float] +% uses the packages `chemmacros', `chemfig' and `libertine' +\begin{figure}[h] +\centering +\setatomsep{1.5em} +\DeclareChemIUPAC\iso{\textit{i}} +\chemsetup[chemformula]{font-family=fxl} +\ENsetup{ + ENcurve/minima, + AddAxisLabel/font=\fontfamily{fxlf}\selectfont\footnotesize +} +\begin{endiagram}[ + tikz = {yscale=1.5}, scale = 1.7, + y-label = above, y-label-text = $\Delta H$, + x-label = right, x-label-text = RK, + energy-step = 10] + \ENcurve{0,3.5,1} + \ENcurve[tikz=red]{0,3.7,.4} + \ENcurve{0,4.3[.2],2.4} + \ENcurve{0,4.7[.3],2.7} + \ENcurve{0,4.9[.35],2.9} + \ENcurve{0,5.2[.4],3.3} + \AddAxisLabel*{1;2;3;4;6} + \AddAxisLabel{(N1-1)[0];(N1-2)[35];(N2-2)[37];(N3-2)[43];(N4-2)[47];(N5-2)[49];(N6-2)[52]} + \draw[right] (N1-3) ++ (1,0) node {\small \ch{2 "\chemfig{=_[:30]-[::-60]\lewis{0.,}}~" + N2} } ; + \draw[right,red] (N2-3) ++ (1,-.3) node {\small \ch{2 "\chemfig{[:-60]*6(=-=-(-\lewis{0.,})=-)}~" + N2} } ; + \draw[right] (N3-3) ++ (1,-.2) node {\small \ch{2 "\tert-\lewis{0.,Bu}~" + N2} } ; + \draw[right] (N4-3) ++ (1,-.1) node {\small \ch{2 "\iso-\lewis{0.,Pr}~" + N2} } ; + \draw[right] (N5-3) ++ (1,0) node {\small \ch{2 "\lewis{0.,Et}~" + N2} } ; + \draw[right] (N6-3) ++ (1,0) node {\small \ch{2 "\lewis{0.,Me}~" + N2} } ; + \draw[above,font=\fontfamily{fxlf}\selectfont\footnotesize] + (N1-3) node {10} (N2-3) node[red] {4} + (N3-3) node {24} (N4-3) node {27} + (N5-3) node {29} (N6-3) node {33} ; +\end{endiagram} + +\setatomsep{2em} +\schemestart + \chemfig{R-[:30]N=N-[:30]R} + \arrow{->[$\Delta$]}[,2.1] + \ch{2 "\lewis{0.,R}~" + N2} +\schemestop +\caption{\label{fig:bell-evans-polanyi}Enthalpie-Entwicklung entlang +der Reaktionskoordinate bei einer Serie von Thermolysen aliphatischer +Azoverbindungen. Alle Thermolysen dieser Serie -- mit Ausnahme der +farbig hervorgehobenen -- folgen dem Bell-Evans-Polanyi-Prinzip~\cite{brueckner}.} +\end{figure} +\end{beispiel} + +\clearpage +{\RaggedRight +\printbibliography} + +\setindexpreamble{Section titles are indicated \textbf{bold}, packages +\textsf{sans serif}, commands \code{\textbackslash\textcolor{code}{brown}}, + options \textcolor{key}{\code{yellow}} and modules \textcolor{module}{\code{blue}}. + \par\bigskip} +\printindex + +\end{document} \ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/endiagram/endiagram.sty b/Master/texmf-dist/tex/latex/endiagram/endiagram.sty new file mode 100644 index 00000000000..bea29774539 --- /dev/null +++ b/Master/texmf-dist/tex/latex/endiagram/endiagram.sty @@ -0,0 +1,1540 @@ +% -------------------------------------------------------------------------- +% the ENdiagram package +% +% easy creation of potential energy curve diagrams +% +% -------------------------------------------------------------------------- +% Clemens Niederberger +% Web: https://www.bitbucket.org/cgnieder/endiagram +% E-Mail: contact@mychemistry.eu +% -------------------------------------------------------------------------- +% If you have any ideas, questions, suggestions or bugs to report, please +% feel free to contact me. +% -------------------------------------------------------------------------- +% Copyright 2012 Clemens Niederberger +% +% 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 Clemens Niederberger. +% +% This work consists of the files endiagram.sty, endiagram_en.tex, +% README and the derived file endiagram_en.pdf. +% -------------------------------------------------------------------------- +\RequirePackage{ expl3 , xparse , l3keys2e , tikz , siunitx } +\usetikzlibrary{calc} +\ProvidesExplPackage + {endiagram} + {2012/08/20} + {0.1a} + {Easy creation of potential energy curve diagrams} + +% --------------------------------------------------------------------------- % +% error and warning messages +\msg_set:nnnn { ENdiagram } { points-missing } + { + You~need~at~least~three~values~for~drawing~the~energy~curve~ + \msg_line_context: + } + { + You~need~at~least~three~values~for~drawing~the~energy~curve~ + \msg_line_context: + } + +\msg_set:nnnn { ENdiagram } { ShowEa } + { Wrong~argument~syntax.~ \msg_line_context: } + { Wrong~argument~syntax.~ \msg_line_context: } + +\msg_set:nnnn { ENdiagram } { MakeOrigin } + { + You~can't~use~\token_to_str:N \ENcurve \c_space_tl after~ + \token_to_str:N \MakeOrigin \c_space_tl \msg_line_context: + } + { + You~can't~use~\token_to_str:N \ENcurve \c_space_tl after~ + \token_to_str:N \MakeOrigin \c_space_tl \msg_line_context: + } + +% --------------------------------------------------------------------------- % +% tikz helper functions +\cs_new_nopar:Npn \ENdiagram_node:n #1 + { \node [ #1 ] } +\cs_generate_variant:Nn \ENdiagram_node:n { o,f,x } + +\cs_new_nopar:Npn \ENdiagram_draw:n #1 + { \draw [ #1 ] } +\cs_generate_variant:Nn \ENdiagram_draw:n { o,f,x } + +\cs_new_nopar:Npn \ENdiagram_draw:nn #1#2 + { \draw [ #1 ] #2 ; } +\cs_generate_variant:Nn \ENdiagram_draw:nn + { no,nf,nx,oo,of,ox,fn,fo,ff,fx,xn,xo,xf,xx } + +\cs_new_nopar:Npn \ENdiagram_tikz:n #1 + { \tikz [ #1 ] } +\cs_generate_variant:Nn \ENdiagram_tikz:n { o,f,x } + +\cs_new_nopar:Npn \ENdiagram_tikz:nn #1#2 + { \tikz [ #1 ] { #2 } } +\cs_generate_variant:Nn \ENdiagram_tikz:nn + { no,nf,nx,oo,of,ox,fn,fo,ff,fx,xn,xo,xf,xx } + +\cs_new_nopar:Npn \ENdiagram_start_tikzpicture:n #1 + { \tikzpicture [ #1 ] } +\cs_generate_variant:Nn \ENdiagram_start_tikzpicture:n { o,f,x } + +\cs_new_eq:NN \ENdiagram_end_tikzpicture: \endtikzpicture + +% --------------------------------------------------------------------------- % +\cs_if_exist:NF \l_tmpa_fp { \fp_new:N \l_tmpa_fp } +\cs_if_exist:NF \l_tmpb_fp { \fp_new:N \l_tmpb_fp } +\cs_if_exist:NF \l_tmpc_fp { \fp_new:N \l_tmpc_fp } +\cs_if_exist:NF \g_tmpa_fp { \fp_new:N \g_tmpa_fp } + +% --------------------------------------------------------------------------- % +% draw the curve +\clist_new:N \l_ENdiagram_points_clist +\prop_new:N \l_ENdiagram_points_prop +\int_new:N \l_ENdiagram_points_int +\int_zero:N \l_ENdiagram_points_int + +\int_new:N \g_ENdiagram_curve_int +\int_gzero:N \g_ENdiagram_curve_int + +\int_new:N \g_ENdiagram_points_max_int + +\int_new:N \l_ENdiagram_points_counter_int +\int_set:Nn \l_ENdiagram_points_counter_int { 1 } + +\tl_new:N \l_ENdiagram_draw_curve_tl +\tl_new:N \l_ENdiagram_curve_tikz_tl + +\tl_new:N \l_ENdiagram_curve_looseness_tl +\tl_set:Nn \l_ENdiagram_curve_looseness_tl { .5 } + +\tl_new:N \l_ENdiagram_points_step_tl +\tl_set:Nn \l_ENdiagram_points_step_tl { 2 } +\tl_new:N \l_ENdiagram_points_step_default_tl +\tl_set_eq:NN \l_ENdiagram_points_step_default_tl \l_ENdiagram_points_step_tl + +\fp_new:N \g_ENdiagram_y_min_fp +\fp_gzero:N \g_ENdiagram_y_min_fp +\fp_new:N \g_ENdiagram_y_max_fp +\fp_gzero:N \g_ENdiagram_y_max_fp + +\fp_new:N \g_ENdiagram_x_min_fp +\fp_gzero:N \g_ENdiagram_x_min_fp +\fp_new:N \g_ENdiagram_x_max_fp +\fp_gzero:N \g_ENdiagram_x_max_fp + +\bool_new:N \l_ENdiagram_debug_bool +\bool_new:N \l_ENdiagram_curve_minima_bool + +\keys_define:nn { ENdiagram / ENcurve } + { + step .tl_set:N = \l_ENdiagram_points_step_tl , + looseness .tl_set:N = \l_ENdiagram_curve_looseness_tl , + tikz .tl_set:N = \l_ENdiagram_curve_tikz_tl , + minima .bool_set:N = \l_ENdiagram_curve_minima_bool + } + +\cs_new_nopar:Npn \ENdiagram_determine_yaxis_length:n #1 + { + \fp_compare:nNnT { #1 } < { \g_ENdiagram_y_min_fp } + { \fp_gset:Nn \g_ENdiagram_y_min_fp { #1 } } + \fp_compare:nNnT { #1 } > { \g_ENdiagram_y_max_fp } + { \fp_gset:Nn \g_ENdiagram_y_max_fp { #1 } } + } + +\cs_new_nopar:Npn \ENdiagram_determine_xaxis_length: + { + \fp_gset:Nn \g_ENdiagram_x_max_fp { \int_to_arabic:n { \g_ENdiagram_points_max_int } } + \fp_gsub:Nn \g_ENdiagram_x_max_fp { 1 } + \exp_args:NNo \fp_gmul:Nn \g_ENdiagram_x_max_fp { \l_ENdiagram_points_step_tl } + } + +\NewDocumentCommand \ENdiagram_curve:w { o m } + { + \bool_if:NT \l_ENdiagram_origin_made_bool + { \msg_error:nn { ENdiagram } { MakeOrigin } } + \int_gincr:N \g_ENdiagram_curve_int + \tl_set_eq:NN \l_ENdiagram_points_step_tl \l_ENdiagram_points_step_default_tl + \IfNoValueF { #1 } { \keys_set:nn { ENdiagram / ENcurve } { #1 } } + \clist_clear:N \l_ENdiagram_points_clist + \tl_clear:N \l_ENdiagram_draw_curve_tl + \int_set:Nn \l_ENdiagram_points_counter_int { 1 } + \clist_map_inline:nn { #2 } + { + \fp_set:Nn \l_tmpa_tl { \int_to_arabic:n { \l_ENdiagram_points_int } } + \fp_mul:Nn \l_tmpa_tl { \l_ENdiagram_points_step_tl } + \tl_if_in:nnTF { ##1 } { [ } + { + \exp_args:Nfx \ENdiagram_save_points:nnnn + { \int_use:N \l_ENdiagram_points_int } + { \fp_to_tl:N \l_tmpa_tl } ##1 + } + { + \exp_args:Nfx \ENdiagram_save_points:nnnn + { \int_use:N \l_ENdiagram_points_int } + { \fp_to_tl:N \l_tmpa_tl } { ##1 } [ 0 ] + } + } + \int_zero:N \l_ENdiagram_points_int + \int_gset:Nn \g_ENdiagram_points_max_int + { \clist_length:N \l_ENdiagram_points_clist } + \int_compare:nT { \g_ENdiagram_points_max_int < 3 } + { \msg_error:nn { ENdiagram } { points-missing } } + \clist_map_inline:Nn \l_ENdiagram_points_clist + { + \int_compare:nT { \l_ENdiagram_points_counter_int = 1 } + { + \fp_gset:Nn \g_ENdiagram_y_min_fp { ##1 } + \bool_if:NT \l_ENdiagram_curve_minima_bool + { + \tl_put_right:Nn \l_ENdiagram_draw_curve_tl + { ($(-.5,##1)+(0,.2)$) to [bend~right] } + } + } + \ENdiagram_determine_yaxis_length:n { ##1 } + \ENdiagram_determine_xaxis_length: + \fp_set:Nn \l_tmpa_tl { \int_to_arabic:n { \l_ENdiagram_points_counter_int } } + \fp_sub:Nn \l_tmpa_tl { 1 } + \exp_args:NNx \prop_get:NnN \l_ENdiagram_points_prop + { \fp_to_tl:N \l_tmpa_tl } \l_tmpb_tl + \tl_put_right:Nx \l_ENdiagram_draw_curve_tl + { + ($ + { + \l_tmpb_tl + } + *(1,0)+(0,##1) + $) + node[inner~sep=0] + ( + N \int_to_arabic:n { \g_ENdiagram_curve_int } - + \int_to_arabic:n { \l_ENdiagram_points_counter_int } + ) {} + } + \bool_if:NT \l_ENdiagram_debug_bool + { + \tl_put_right:Nx \l_ENdiagram_draw_curve_tl + { + node[anchor=north~west,font={\exp_not:N \tiny},inner~sep=0,color=black,fill=yellow!20] + { + N \int_to_arabic:n { \g_ENdiagram_curve_int } - + \int_to_arabic:n { \l_ENdiagram_points_counter_int } + } + node[inner~sep=0,above,color=red,font={\exp_not:N \tiny}] + {(\l_tmpb_tl,##1)} + } + } + \int_compare:nT { \l_ENdiagram_points_counter_int < \g_ENdiagram_points_max_int } + { + \tl_put_right:Nn \l_ENdiagram_draw_curve_tl { to } + } + \int_compare:nT { \l_ENdiagram_points_counter_int = \g_ENdiagram_points_max_int } + { + \bool_if:NT \l_ENdiagram_curve_minima_bool + { + \tl_put_right:Nx \l_ENdiagram_draw_curve_tl + { + to [bend~right] + ($ + { + \l_ENdiagram_points_step_tl * + (\int_to_arabic:n { \l_ENdiagram_points_counter_int } - 1 ) + } + *(1,0)+(0,##1)+(.5,.2) + $) + } + } + } + \int_incr:N \l_ENdiagram_points_counter_int + } + + \ENdiagram_draw:xo + { + \l_ENdiagram_curve_tikz_tl, + out=0,in=180, + looseness=\l_ENdiagram_curve_looseness_tl + } + { \l_ENdiagram_draw_curve_tl } + \tl_clear:N \l_ENdiagram_curve_tikz_tl + } +\cs_generate_variant:Nn \tl_put_right:Nn { Nx } + +\cs_new_nopar:Npn \ENdiagram_save_points:nnnn #1#2#3[#4] + { + \fp_set:Nn \l_tmpa_tl { #2 } + \fp_add:Nn \l_tmpa_tl { #4 } + \clist_put_right:Nn \l_ENdiagram_points_clist { #3 } + \exp_args:NNox \prop_put:Nnn \l_ENdiagram_points_prop { #1 } { \fp_to_tl:N \l_tmpa_tl } + \int_incr:N \l_ENdiagram_points_int + } + +% --------------------------------------------------------------------------- % +% show the energy levels +\int_new:N \l_ENdiagram_niveau_counter_int +\int_set:Nn \l_ENdiagram_niveau_counter_int { 1 } + +\tl_new:N \l_ENdiagram_niveau_tikz_tl + +\tl_new:N \l_ENdiagram_niveau_length_tl +\tl_set:Nn \l_ENdiagram_niveau_length_tl { 1 } + +\tl_new:N \l_ENdiagram_niveau_shift_tl +\tl_set:Nn \l_ENdiagram_niveau_shift_tl { 0 } + +\bool_new:N \l_ENdiagram_niveau_pick_bool +\clist_new:N \l_ENdiagram_niveau_clist + +\keys_define:nn { ENdiagram / ShowNiveaus } + { + tikz .tl_set:N = \l_ENdiagram_niveau_tikz_tl , + length .tl_set:N = \l_ENdiagram_niveau_length_tl , + shift .tl_set:N = \l_ENdiagram_niveau_shift_tl , + niveau .code:n = + { + \bool_set_true:N \l_ENdiagram_niveau_pick_bool + \clist_clear:N \l_ENdiagram_niveau_clist + \clist_set:Nn \l_ENdiagram_niveau_clist { #1 } + } + } + +\NewDocumentCommand \ENdiagram_show_niveaus:w { o } + { + \group_begin: + \IfNoValueF { #1 } { \keys_set:nn { ENdiagram / ShowNiveaus } { #1 } } + \bool_if:NTF \l_ENdiagram_niveau_pick_bool + { + \clist_map_inline:Nn \l_ENdiagram_niveau_clist + { + \ENdiagram_draw:xn { \l_ENdiagram_niveau_tikz_tl } + { + (##1) ++ (\l_ENdiagram_niveau_shift_tl,0) + ++(-.5*\l_ENdiagram_niveau_length_tl,0) -- ++(\l_ENdiagram_niveau_length_tl,0) + } + } + } + { + \int_do_until:nn { \l_ENdiagram_niveau_counter_int > \g_ENdiagram_points_max_int } + { + \ENdiagram_draw:xn { \l_ENdiagram_niveau_tikz_tl } + { + ( + N + \int_to_arabic:n { \g_ENdiagram_curve_int } + - + \int_to_arabic:n { \l_ENdiagram_niveau_counter_int } + ) + ++ (\l_ENdiagram_niveau_shift_tl,0) + ++(-.5*\l_ENdiagram_niveau_length_tl,0) -- ++(\l_ENdiagram_niveau_length_tl,0) + } + \int_incr:N \l_ENdiagram_niveau_counter_int + } + } + \group_end: + } + +% --------------------------------------------------------------------------- % +% show the energy gain +\bool_new:N \l_ENdiagram_show_gain_right_bool +\bool_set_false:N \l_ENdiagram_show_gain_right_bool +\bool_new:N \l_ENdiagram_gain_label_bool +\bool_set_false:N \l_ENdiagram_gain_label_bool +\bool_new:N \l_ENdiagram_gain_own_label_bool +\bool_set_false:N \l_ENdiagram_gain_own_label_bool +\bool_new:N \l_ENdiagram_gain_connect_from_niveau_bool +\bool_set_false:N \l_ENdiagram_gain_connect_from_niveau_bool + +\tl_new:N \l_ENdiagram_gain_label_text_tl +\tl_new:N \l_ENdiagram_gain_label_side_tl +\tl_set:Nn \l_ENdiagram_gain_label_side_tl { right } +\tl_new:N \l_ENdiagram_gain_label_pos_tl +\tl_set:Nn \l_ENdiagram_gain_label_pos_tl { .5 } +\tl_new:N \l_ENdiagram_gain_label_tikz_tl +\tl_new:N \l_ENdiagram_gain_tikz_tl +\tl_set:Nn \l_ENdiagram_gain_tikz_tl { <-> } +\tl_new:N \l_ENdiagram_gain_connect_tikz_tl +\tl_set:Nn \l_ENdiagram_gain_connect_tikz_tl { dashed,help~lines } +\tl_new:N \l_ENdiagram_gain_x_value_tl +\tl_new:N \l_ENdiagram_gain_offset_tl +\tl_set:Nn \l_ENdiagram_gain_offset_tl { 0 } +\tl_new:N \g_ENdiagram_gain_offset_tl +\tl_gset:Nn \g_ENdiagram_gain_offset_tl { 0 } +\tl_new:N \l_ENdiagram_gain_value_tl + +\keys_define:nn { ENdiagram / ShowGain } + { + tikz .tl_set:N = \l_ENdiagram_gain_tikz_tl , + connect .tl_set:N = \l_ENdiagram_gain_connect_tikz_tl , + connect-from-line .bool_set:N = \l_ENdiagram_gain_connect_from_niveau_bool , + connect-from-line .default:n = true , + offset .tl_set:N = \l_ENdiagram_gain_offset_tl , + label .code:n = + { + \tl_if_eq:nnTF { true } { #1 } + { \bool_set_true:N \l_ENdiagram_gain_label_bool } + { + \tl_if_eq:nnF { false } { #1 } + { + \bool_set_true:N \l_ENdiagram_gain_label_bool + \bool_set_true:N \l_ENdiagram_gain_own_label_bool + \tl_set:Nn \l_ENdiagram_gain_label_text_tl { #1 } + } + } + } , + label .default:n = true , + label-side .choice: , + label-side / right .code:n = + { \tl_set:Nn \l_ENdiagram_gain_label_side_tl { right } } , + label-side / left .code:n = + { \tl_set:Nn \l_ENdiagram_gain_label_side_tl { left } } , + label-pos .tl_set:N = \l_ENdiagram_gain_label_pos_tl , + label-tikz .tl_set:N = \l_ENdiagram_gain_label_tikz_tl + } + +\NewDocumentCommand \ENdiagram_show_gain:w { o } + { + \bool_set_true:N \l_ENdiagram_show_gain_right_bool + \group_begin: + \IfNoValueF { #1 } { \keys_set:nn { ENdiagram / ShowGain } { #1 } } + \fp_compare:nNnT { \g_ENdiagram_gain_offset_tl } < { \l_ENdiagram_gain_offset_tl } + { \tl_gset_eq:NN \g_ENdiagram_gain_offset_tl \l_ENdiagram_gain_offset_tl } + \tl_set:Nx \l_ENdiagram_gain_x_value_tl + { \int_to_arabic:n { \int_eval:n { \g_ENdiagram_points_max_int - 1} } } + \ENdiagram_draw:xn { \l_ENdiagram_gain_tikz_tl } + { + let \p1 = (N\int_to_arabic:n { \g_ENdiagram_curve_int }-1) , + \p2 = (N\int_to_arabic:n { \g_ENdiagram_curve_int }-\int_to_arabic:n { \g_ENdiagram_points_max_int }) + in + ($\l_ENdiagram_points_step_tl*(\l_ENdiagram_gain_x_value_tl,0)+(\l_ENdiagram_gain_offset_tl+1,\y1)$) + -- + ($\l_ENdiagram_points_step_tl*(\l_ENdiagram_gain_x_value_tl,0)+(\l_ENdiagram_gain_offset_tl+1,\y2)$) + node[pos=0,inner~sep=0] (gain-start\int_to_arabic:n { \g_ENdiagram_curve_int }) {} + node[pos=1,inner~sep=0] (gain-end\int_to_arabic:n { \g_ENdiagram_curve_int }) {} + } + \fp_set:Nn \l_tmpa_tl + { \clist_item:Nn \l_ENdiagram_points_clist { 1 } } + \fp_set:Nn \l_tmpb_tl + { \clist_item:Nn \l_ENdiagram_points_clist { \g_ENdiagram_points_max_int } } +% \fp_sub:Nn \l_tmpb_tl { 1 } + \fp_set:Nn \l_tmpc_tl + { + \l_ENdiagram_gain_x_value_tl * \l_ENdiagram_points_step_tl + + \l_ENdiagram_gain_offset_tl + 1 + } + \bool_if:NT \l_ENdiagram_debug_bool + { + \ENdiagram_draw:nn {font=\tiny,inner~sep=0} + { + let \p1 = ( gain-start\int_to_arabic:n { \g_ENdiagram_curve_int } ) , + \p2 = ( gain-end\int_to_arabic:n { \g_ENdiagram_curve_int } ) + in + node[right=2pt,fill=yellow!10] + at ( \p1 ) + { gain-start\int_to_arabic:n { \g_ENdiagram_curve_int } } + node[right=2pt,fill=yellow!10] + at ( \p2 ) + { gain-end\int_to_arabic:n { \g_ENdiagram_curve_int } } + node[above~right,red] at (\p1) {(\fp_to_tl:N \l_tmpc_tl,\fp_to_tl:N \l_tmpa_tl)} + node[above~right,red] at (\p2) {(\fp_to_tl:N \l_tmpc_tl,\fp_to_tl:N \l_tmpb_tl)} + } + } + \bool_if:NT \l_ENdiagram_gain_label_bool + { + \bool_if:NF \l_ENdiagram_gain_own_label_bool + { + \bool_if:nTF + { \l_ENdiagram_energy_unit_bool && \l_ENdiagram_calculate_bool } + { + \fp_set:Nn \l_tmpb_fp { (\l_tmpb_tl - \l_tmpa_tl) * \l_ENdiagram_energy_step_tl } + \bool_if:NTF \l_ENdiagram_energy_round_places_bool + { + \fp_round_places:Nn \l_tmpb_fp + { \l_ENdiagram_energy_round_tl } + } + { + \fp_round_figures:Nn \l_tmpb_fp + { \l_ENdiagram_energy_round_tl } + } + \tl_set:Nn \l_ENdiagram_gain_value_tl + { + = \exp_args:Noo \SI + { \fp_to_tl:N \l_tmpb_fp } + { \l_ENdiagram_energy_unit_tl } + } + } + { + \fp_compare:nNnTF { \l_tmpa_tl } > { \l_tmpb_tl } + { \tl_set:Nn \l_ENdiagram_gain_value_tl { < 0 } } + { \tl_set:Nn \l_ENdiagram_gain_value_tl { > 0 } } + } + \tl_set:Nn \l_ENdiagram_gain_label_text_tl { $\Delta H \l_ENdiagram_gain_value_tl$ } + } + \ENdiagram_draw:nx {} + { + ($ + (gain-end\int_to_arabic:n { \g_ENdiagram_curve_int }) + !\l_ENdiagram_gain_label_pos_tl! + (gain-start\int_to_arabic:n { \g_ENdiagram_curve_int })$) + node[\l_ENdiagram_gain_label_side_tl,\l_ENdiagram_gain_label_tikz_tl] + { \exp_not:N \l_ENdiagram_gain_label_text_tl } + } + } + \bool_if:NTF \l_ENdiagram_gain_connect_from_niveau_bool + { + \ENdiagram_draw:xf { \l_ENdiagram_gain_connect_tikz_tl } + { + let \p1 = (N\int_to_arabic:n { \g_ENdiagram_curve_int }-1) , + \p2 = (N\int_to_arabic:n { \g_ENdiagram_curve_int }-\int_to_arabic:n { \g_ENdiagram_points_max_int }) + in + (gain-end\int_to_arabic:n { \g_ENdiagram_curve_int }) ++ (.5,0) -- ($(\p2)+(.5*\l_ENdiagram_niveau_length_tl,0)$) + (gain-start\int_to_arabic:n { \g_ENdiagram_curve_int }) ++ (.5,0) -- ($(\p1)+(.5*\l_ENdiagram_niveau_length_tl,0)$) + } + } + { + \ENdiagram_draw:xf { \l_ENdiagram_gain_connect_tikz_tl } + { + let \p1 = (N\int_to_arabic:n { \g_ENdiagram_curve_int }-1) , + \p2 = (N\int_to_arabic:n { \g_ENdiagram_curve_int }-\int_to_arabic:n { \g_ENdiagram_points_max_int }) + in + (gain-end\int_to_arabic:n { \g_ENdiagram_curve_int }) ++ (.5,0) -- (\p2) + (gain-start\int_to_arabic:n { \g_ENdiagram_curve_int }) ++ (.5,0) -- (\p1) + } + } + \group_end: + } + +% --------------------------------------------------------------------------- % +% show the activation energy +\bool_new:N \l_ENdiagram_ea_all_bool +\bool_new:N \l_ENdiagram_ea_coordinates_bool +\bool_new:N \l_ENdiagram_ea_coordinates_points_bool +\bool_new:N \l_ENdiagram_ea_label_bool +\bool_new:N \l_ENdiagram_ea_own_label_bool + +\int_new:N \g_ENdiagram_ea_int +\int_gzero:N \g_ENdiagram_ea_int +\int_new:N \l_ENdiagram_ea_count_int +\int_zero:N \l_ENdiagram_ea_count_int + +\tl_new:N \l_ENdiagram_ea_tikz_tl +\tl_set:Nn \l_ENdiagram_ea_tikz_tl { <-> } +\tl_new:N \l_ENdiagram_ea_connect_tikz_tl +\tl_set:Nn \l_ENdiagram_ea_connect_tikz_tl { dashed, help~lines } +\tl_new:N \l_ENdiagram_ea_label_text_tl +\tl_set_rescan:Nnn \l_ENdiagram_ea_label_text_tl + { \char_set_catcode_math_subscript:N \_ } { $E_{\mathrm{a}}$ } +\tl_new:N \l_ENdiagram_ea_value_tl +\tl_new:N \l_ENdiagram_ea_label_tikz_tl +\tl_new:N \l_ENdiagram_ea_label_side_tl +\tl_set:Nn \l_ENdiagram_ea_label_side_tl { right } +\tl_new:N \l_ENdiagram_ea_label_pos_tl +\tl_set:Nn \l_ENdiagram_ea_label_pos_tl { .5} +\tl_new:N \l_ENdiagram_ea_start_node_tl +\tl_new:N \l_ENdiagram_ea_end_node_tl + +\fp_new:N \l_ENdiagram_ea_connect_start_fp +\fp_new:N \l_ENdiagram_ea_connect_end_fp + +\keys_define:nn { ENdiagram / ShowEa } + { + max .choice: , + max / all .code:n = \bool_set_true:N \l_ENdiagram_ea_all_bool , + max / first .code:n = \bool_set_false:N \l_ENdiagram_ea_all_bool , + tikz .tl_set:N = \l_ENdiagram_ea_tikz_tl , + connect .tl_set:N = \l_ENdiagram_ea_connect_tikz_tl , + from .code:n = + { + \bool_set_true:N \l_ENdiagram_ea_coordinates_bool + \ENdiagram_detect_ea:n { #1 } + } , + label .code:n = + { + \tl_if_eq:nnTF { true } { #1 } + { \bool_set_true:N \l_ENdiagram_ea_label_bool } + { + \tl_if_eq:nnF { false } { #1 } + { + \bool_set_true:N \l_ENdiagram_ea_own_label_bool + \bool_set_true:N \l_ENdiagram_ea_label_bool + \tl_set:Nn \l_ENdiagram_ea_label_text_tl { #1 } + } + } + } , + label .default:n = true , + label-side .choice: , + label-side / right .code:n = + { \tl_set:Nn \l_ENdiagram_ea_label_side_tl { right } } , + label-side / left .code:n = + { \tl_set:Nn \l_ENdiagram_ea_label_side_tl { left } } , + label-pos .tl_set:N = \l_ENdiagram_ea_label_pos_tl , + label-tikz .tl_set:N = \l_ENdiagram_ea_label_tikz_tl + } + +\cs_new_nopar:Npn \ENdiagram_detect_ea:n #1 + { + % remember blanks + \tl_set:Nn \l_tmpa_tl { #1 } + \tl_replace_all:Nnn \l_tmpa_tl { ~ } { @@@ } + \exp_after:wN \ENdiagram_detect_ea_auxi:nn \l_tmpa_tl \q_nil + } + +\cs_new_nopar:Npn \ENdiagram_detect_ea_auxi:nn (#1) #2 \q_nil + { + % recover blanks in node #1 + \tl_set:Nn \l_tmpa_tl { #1 } + \tl_replace_all:Nnn \l_tmpa_tl { @@@ } { ~ } + \tl_set_eq:NN \l_ENdiagram_ea_start_node_tl \l_tmpa_tl + \ENdiagram_detect_ea_auxii:nn #2 + } + +\cs_new_nopar:Npn \ENdiagram_detect_ea_auxii:nn #1 (#2) + { + % recover blanks in node #2 + \tl_set:Nn \l_tmpa_tl { #2 } + \tl_set:Nn \l_tmpb_tl { #1 } + \tl_replace_all:Nnn \l_tmpa_tl { @@@ } { ~ } + \tl_set_eq:NN \l_ENdiagram_ea_end_node_tl \l_tmpa_tl + % ignore blanks in between and test for right syntax + \tl_remove_all:Nn \l_tmpb_tl { @@@ } + \exp_args:No \tl_if_eq:nnF { \l_tmpb_tl } { to } + { \msg_error:nn { ENdiagram } { ShowEa } } + + } + +\NewDocumentCommand \ENdiagram_show_ea:w { o } + { + \int_gincr:N \g_ENdiagram_ea_int + \group_begin: + \IfNoValueF { #1 } { \keys_set:nn { ENdiagram / ShowEa } { #1 } } + \bool_if:NTF \l_ENdiagram_ea_coordinates_bool + { + \ENdiagram_draw:xn { \l_ENdiagram_ea_tikz_tl } + { + ( \l_ENdiagram_ea_end_node_tl |- \l_ENdiagram_ea_start_node_tl ) + -- + ( \l_ENdiagram_ea_end_node_tl ) + } + \bool_if:NT \l_ENdiagram_ea_label_bool + { + \bool_if:nT + { + \l_ENdiagram_energy_unit_bool && + \l_ENdiagram_calculate_bool && + !\l_ENdiagram_ea_own_label_bool + } + { + % determine length of Ea-line + \ENdiagram_draw:nn { } + { + let \p1 = (\l_ENdiagram_ea_start_node_tl), + \p2 = (\l_ENdiagram_ea_end_node_tl) + in + node at (\p2) { \dim_gset:Nn \g_tmpa_dim { \y2 - \y1 } } + } + % convert length of Ea-line into energy value + \fp_set:Nn \l_tmpb_fp { \dim_to_fp:Nn { 1cm } } + \fp_set:Nn \l_tmpa_fp + { \dim_to_fp:n { \g_tmpa_dim } / \l_tmpb_fp * \l_ENdiagram_energy_step_tl } + \bool_if:NTF \l_ENdiagram_energy_round_places_bool + { + \fp_round_places:Nn \l_tmpa_fp + { \l_ENdiagram_energy_round_tl } + } + { + \fp_round_figures:Nn \l_tmpa_fp + { \l_ENdiagram_energy_round_tl } + } + \tl_set:Nn \l_ENdiagram_ea_value_tl + { + ~ = ~ \exp_args:Noo \SI + { \fp_to_tl:N \l_tmpa_fp } + { \l_ENdiagram_energy_unit_tl } + } + } + \ENdiagram_draw:xn + { \l_ENdiagram_ea_label_tikz_tl } + { + node[\l_ENdiagram_ea_label_side_tl] at + ($ + (\l_ENdiagram_ea_end_node_tl) + !\l_ENdiagram_ea_label_pos_tl! + (\l_ENdiagram_ea_end_node_tl |- \l_ENdiagram_ea_start_node_tl) + $) + { \l_ENdiagram_ea_label_text_tl \l_ENdiagram_ea_value_tl } + } + } + \ENdiagram_draw:xn { \l_ENdiagram_ea_connect_tikz_tl } + { + ( \l_ENdiagram_ea_start_node_tl ) + -- + ( \l_ENdiagram_ea_end_node_tl |- \l_ENdiagram_ea_start_node_tl ) + node + ( + ea-end + \int_to_arabic:n { \g_ENdiagram_curve_int }- + \int_to_arabic:n { \g_ENdiagram_ea_int }- + 0 + ) {} + } + \bool_if:NT \l_ENdiagram_debug_bool + { + \ENdiagram_draw:nn { inner~sep=0,font=\tiny } + { + ( + ea-end + \int_to_arabic:n { \g_ENdiagram_curve_int }- + \int_to_arabic:n { \g_ENdiagram_ea_int }- + 0 + ) + node[below~right,fill=yellow!10] + { + ea-end + \int_to_arabic:n { \g_ENdiagram_curve_int }- + \int_to_arabic:n { \g_ENdiagram_ea_int }- + 0 + } + } + } + } + { + \int_do_until:nn + { \l_ENdiagram_ea_count_int >= \g_ENdiagram_points_max_int - 1 } + { + \fp_set:Nn \l_tmpa_tl + { + \clist_item:Nn \l_ENdiagram_points_clist + { \int_eval:n { \l_ENdiagram_ea_count_int + 1 } } + } + \fp_set:Nn \l_tmpb_tl + { + \clist_item:Nn \l_ENdiagram_points_clist + { \int_eval:n { \l_ENdiagram_ea_count_int + 2 } } + } + \fp_compare:nNnT { \l_tmpa_tl } < { \l_tmpb_tl } + { + \exp_args:NNf \prop_get:NnN \l_ENdiagram_points_prop + { \int_eval:n { \l_ENdiagram_ea_count_int + 1 } } \l_tmpc_tl + \fp_set:Nn \l_ENdiagram_ea_connect_end_fp { \l_tmpc_tl } + \exp_args:NNf \prop_get:NnN \l_ENdiagram_points_prop + { \int_eval:n { \l_ENdiagram_ea_count_int } } \l_tmpc_tl + \fp_set:Nn \l_ENdiagram_ea_connect_start_fp { \l_tmpc_tl } + \ENdiagram_draw:xn { \l_ENdiagram_ea_tikz_tl } + { + ( \fp_to_tl:N \l_ENdiagram_ea_connect_end_fp , \fp_to_tl:N \l_tmpa_tl ) + node + ( + ea-end + \int_to_arabic:n { \g_ENdiagram_curve_int }- + \int_to_arabic:n { \g_ENdiagram_ea_int }- + \int_to_arabic:n { \l_ENdiagram_ea_count_int } + ) { } + -- + ( \fp_to_tl:N \l_ENdiagram_ea_connect_end_fp , \fp_to_tl:N \l_tmpb_tl ) + } + \bool_if:NT \l_ENdiagram_ea_label_bool + { + \bool_if:nT + { + \l_ENdiagram_energy_unit_bool && + \l_ENdiagram_calculate_bool && + !\l_ENdiagram_ea_own_label_bool + } + { + \fp_set:Nn \l_tmpb_fp { \l_tmpb_tl } + \fp_sub:Nn \l_tmpb_fp { \l_tmpa_tl } + \fp_mul:Nn \l_tmpb_fp { \l_ENdiagram_energy_step_tl } + \tl_set:Nn \l_ENdiagram_ea_value_tl + { + ~ = ~ \exp_args:Noo \SI + { \fp_to_tl:N \l_tmpb_fp } + { \l_ENdiagram_energy_unit_tl } + } + } + \ENdiagram_draw:xn { \l_ENdiagram_ea_label_tikz_tl } + { + node[\l_ENdiagram_ea_label_side_tl] at + ($ + ( \fp_to_tl:N \l_ENdiagram_ea_connect_end_fp , \fp_to_tl:N \l_tmpa_tl ) + !\l_ENdiagram_ea_label_pos_tl! + ( \fp_to_tl:N \l_ENdiagram_ea_connect_end_fp , \fp_to_tl:N \l_tmpb_tl ) + $) + { \l_ENdiagram_ea_label_text_tl \l_ENdiagram_ea_value_tl } + } + } + \ENdiagram_draw:xn { \l_ENdiagram_ea_connect_tikz_tl } + { + ( \fp_to_tl:N \l_ENdiagram_ea_connect_end_fp , \fp_to_tl:N \l_tmpa_tl ) + -- + ++ + ( + \fp_to_tl:N \l_ENdiagram_ea_connect_start_fp + - + \fp_to_tl:N \l_ENdiagram_ea_connect_end_fp , 0 + ) + } + \bool_if:NT \l_ENdiagram_debug_bool + { + \ENdiagram_draw:nn { inner~sep=0,font=\tiny } + { + ( + ea-end + \int_to_arabic:n { \g_ENdiagram_curve_int }- + \int_to_arabic:n { \g_ENdiagram_ea_int }- + \int_to_arabic:n { \l_ENdiagram_ea_count_int } + ) + node[below~right,fill=yellow!10] + { + ea-end + \int_to_arabic:n { \g_ENdiagram_curve_int }- + \int_to_arabic:n { \g_ENdiagram_ea_int }- + \int_to_arabic:n { \l_ENdiagram_ea_count_int } + } + node[above~right,red] + { ( \fp_to_tl:N \l_ENdiagram_ea_connect_end_fp , \fp_to_tl:N \l_tmpa_tl ) } + } + } + \bool_if:NF \l_ENdiagram_ea_all_bool + { + % set count unreasonably high to ensure we're over + % \g_ENdiagram_points_max_int + \int_add:Nn \l_ENdiagram_ea_count_int { 1000 } + } + } + \int_incr:N \l_ENdiagram_ea_count_int + } + } + \group_end: + } + +% --------------------------------------------------------------------------- % +% add axis labels +\bool_new:N \l_ENdiagram_add_axis_yl_bool +\bool_set_true:N \l_ENdiagram_add_axis_yl_bool +\bool_new:N \l_ENdiagram_add_axis_yr_bool +\bool_new:N \l_ENdiagram_add_axis_x_bool + +\tl_new:N \l_ENdiagram_add_axis_connect_tl +\tl_set:Nn \l_ENdiagram_add_axis_connect_tl { dashed,help~lines } +\tl_new:N \l_ENdiagram_add_axis_font_tl + +\keys_define:nn { ENdiagram / AddAxisLabel } + { + axis .choice: , + axis / y-l .code:n = + { + \bool_set_true:N \l_ENdiagram_add_axis_yl_bool + \bool_set_false:N \l_ENdiagram_add_axis_yr_bool + \bool_set_false:N \l_ENdiagram_add_axis_x_bool + } , + axis / y-r .code:n = + { + \bool_set_false:N \l_ENdiagram_add_axis_yl_bool + \bool_set_true:N \l_ENdiagram_add_axis_yr_bool + \bool_set_false:N \l_ENdiagram_add_axis_x_bool + } , + axis / x .code:n = + { + \bool_set_false:N \l_ENdiagram_add_axis_yl_bool + \bool_set_false:N \l_ENdiagram_add_axis_yr_bool + \bool_set_true:N \l_ENdiagram_add_axis_x_bool + } , + connect .tl_set:N = \l_ENdiagram_add_axis_connect_tl , + font .tl_set:N = \l_ENdiagram_add_axis_font_tl + } + +\NewDocumentCommand \ENdiagram_add_axis_label:w { so > { \SplitList { ; } } m } + { + \ENdiagram_make_origin: + \group_begin: + \tl_clear:N \l_tmpa_tl + \tl_clear:N \l_tmpb_tl + \tl_clear:N \l_tmpc_tl + \IfNoValueF { #2 } { \keys_set:nn { ENdiagram / AddAxisLabel } { #2 } } + \IfBooleanTF { #1 } + { % list of "ticks" + \bool_if:NT \l_ENdiagram_add_axis_yl_bool + { \ENdiagram_add_axis_label_yl_ticks:n { #3 } } + \bool_if:NT \l_ENdiagram_add_axis_yr_bool + { \ENdiagram_add_axis_label_yr_ticks:n { #3 } } + \bool_if:NT \l_ENdiagram_add_axis_x_bool + { \ENdiagram_add_axis_label_x_ticks:n { #3 } } + } + { % list of points + \bool_if:NT \l_ENdiagram_add_axis_yl_bool + { \ENdiagram_add_axis_label_yl_points:n { #3 } } + \bool_if:NT \l_ENdiagram_add_axis_yr_bool + { \ENdiagram_add_axis_label_yr_points:n { #3 } } + \bool_if:NT \l_ENdiagram_add_axis_x_bool + { \ENdiagram_add_axis_label_x_points:n { #3 } } + } + \group_end: + } + +\cs_new_nopar:Npn \ENdiagram_add_axis_label_yl_ticks:n #1 + { + \tl_map_inline:nn { #1 } + { + \tl_if_in:nnTF { ##1 } { [ } + { + \group_begin: + \ENdiagram_get_tick_arg_and_label:w ##1 \q_stop + \fp_set:Nn \l_tmpb_fp { \l_tmpb_tl } + \bool_if:NT \l_ENdiagram_energy_bool + { + \fp_mul:Nn \l_tmpb_fp { \l_ENdiagram_energy_step_tl } + \fp_sub:Nn \l_tmpb_fp { \l_ENdiagram_energy_zero_tl } + \bool_if:NTF \l_ENdiagram_energy_round_places_bool + { + \fp_round_places:Nn \l_tmpb_fp + { \l_ENdiagram_energy_round_tl } + } + { + \fp_round_figures:Nn \l_tmpb_fp + { \l_ENdiagram_energy_round_tl } + } + \tl_set:Nn \l_tmpb_tl { \fp_to_tl:N \l_tmpb_fp } + } + \ENdiagram_draw:nx { } + { + let \exp_not:N \p1 = (origin-l) + in + ( \exp_not:N \x1 , \fp_to_tl:N \l_tmpa_fp ) -- ++ (-3pt,0) + node[left,font=\exp_not:o \l_ENdiagram_add_axis_font_tl,\l_tmpc_tl] + { \l_tmpb_tl } + } + \group_end: + } + { + \fp_set:Nn \l_tmpa_fp { ##1 } + \bool_if:NT \l_ENdiagram_energy_bool + { + \fp_mul:Nn \l_tmpa_fp { \l_ENdiagram_energy_step_tl } + \fp_sub:Nn \l_tmpa_fp { \l_ENdiagram_energy_zero_tl } + } + \ENdiagram_draw:nn { } + { + let \p1 = (origin-l) + in + ( \x1 , ##1 ) -- ++ (-3pt,0) + node[left,font=\l_ENdiagram_add_axis_font_tl] + { \fp_to_tl:N \l_tmpa_fp } + } + } + } + } + +% TODO: sollte Energie-Skala und Rundung beachten! +\cs_new_nopar:Npn \ENdiagram_add_axis_label_yr_ticks:n #1 + { + \tl_map_inline:nn { #1 } + { + \tl_if_in:nnTF { ##1 } { [ } + { + \group_begin: + \ENdiagram_get_tick_arg_and_label:w ##1 \q_stop + \ENdiagram_draw:nx { } + { + ( \fp_to_tl:N \g_ENdiagram_x_max_fp , \l_tmpa_tl ) -- ++ (3pt,0) + node[right,font=\exp_not:o \l_ENdiagram_add_axis_font_tl,\l_tmpc_tl] + { \l_tmpb_tl } + } + \group_end: + } + { + \ENdiagram_draw:nn { } + { + let \p1 = (origin-r) + in + ( \x1 , ##1 ) -- ++ (3pt,0) + node[right,font=\l_ENdiagram_add_axis_font_tl] { ##1 } + } + } + } + } + +\cs_new_nopar:Npn \ENdiagram_add_axis_label_x_ticks:n #1 + { + \tl_map_inline:nn { #1 } + { + \tl_if_in:nnTF { ##1 } { [ } + { + \group_begin: + \ENdiagram_get_tick_arg_and_label:w ##1 \q_stop + \ENdiagram_draw:nx { } + { + let \exp_not:N \p1 = (origin-l) + in + ( \l_tmpa_tl , \exp_not:N \y1 ) -- ++ (-3pt,0) + node[below,font=\exp_not:o \l_ENdiagram_add_axis_font_tl,\l_tmpc_tl] + { \l_tmpb_tl } + } + \group_end: + } + { + \ENdiagram_draw:nn { } + { + let \p1 = (origin-l) + in + ( ##1 , \y1 ) -- ++ (-3pt,0) + node[below,font=\l_ENdiagram_add_axis_font_tl] { ##1 } + } + } + } + } + +\cs_new_nopar:Npn \ENdiagram_add_axis_label_yl_points:n #1 + { + \tl_map_inline:nn { #1 } + { + \tl_if_in:nnTF { ##1 } { [ } + { + \group_begin: + \ENdiagram_get_tick_point_and_label:w ##1 \q_stop + \ENdiagram_draw:xn { \l_ENdiagram_add_axis_connect_tl } + { + (\l_tmpa_tl) -- (\l_tmpa_tl -| origin-l) + } + \ENdiagram_draw:nx { } + { + (\l_tmpa_tl -| origin-l) -- ++ (-3pt,0) + node[left,font=\exp_not:o \l_ENdiagram_add_axis_font_tl,\l_tmpc_tl] + { \l_tmpb_tl } + } + \group_end: + } + { + \group_begin: + \ENdiagram_get_tick_node:w ##1 \q_stop + \ENdiagram_draw:xn { \l_ENdiagram_add_axis_connect_tl } + { + (\l_tmpa_tl) -- (\l_tmpa_tl -| origin-l) + } + \ENdiagram_draw:nn { } + { + (\l_tmpa_tl -| origin-l) -- ++ (-3pt,0) + } + \group_end: + } + } + } + +\cs_new_nopar:Npn \ENdiagram_add_axis_label_yr_points:n #1 + { + \tl_map_inline:nn { #1 } + { + \tl_if_in:nnTF { ##1 } { [ } + { + \group_begin: + \ENdiagram_get_tick_point_and_label:w ##1 \q_stop + \ENdiagram_draw:xn { \l_ENdiagram_add_axis_connect_tl } + { + (\l_tmpa_tl) -- (\l_tmpa_tl -| origin-r) + } + \ENdiagram_draw:nx { } + { + (\l_tmpa_tl -| origin-r) -- ++ (3pt,0) + node[right,font=\exp_not:o \l_ENdiagram_add_axis_font_tl,\l_tmpc_tl] + { \l_tmpb_tl } + } + \group_end: + } + { + \group_begin: + \ENdiagram_get_tick_node:w ##1 \q_stop + \ENdiagram_draw:xn { \l_ENdiagram_add_axis_connect_tl } + { + (\l_tmpa_tl) -- (\l_tmpa_tl -| origin-r) + } + \ENdiagram_draw:nn { } + { + (\l_tmpa_tl -| origin-r) -- ++ (3pt,0) + } + \group_end: + } + } + } + +\cs_new_nopar:Npn \ENdiagram_add_axis_label_x_points:n #1 + { + \tl_map_inline:nn { #1 } + { + \tl_if_in:nnTF { ##1 } { [ } + { + \group_begin: + \ENdiagram_get_tick_point_and_label:w ##1 \q_stop + \ENdiagram_draw:xn { \l_ENdiagram_add_axis_connect_tl } + { + (\l_tmpa_tl) -- (\l_tmpa_tl |- origin-l) + } + \ENdiagram_draw:nx { } + { + (\l_tmpa_tl |- origin-l) -- ++ (-3pt,0) + node[below,font=\exp_not:o \l_ENdiagram_add_axis_font_tl,\l_tmpc_tl] + { \l_tmpb_tl } + } + \group_end: + } + { + \group_begin: + \ENdiagram_get_tick_node:w ##1 \q_stop + \ENdiagram_draw:xn { \l_ENdiagram_add_axis_connect_tl } + { + (\l_tmpa_tl) -- (\l_tmpa_tl |- origin-l) + } + \ENdiagram_draw:nn { } + { + (\l_tmpa_tl |- origin-l) -- ++ (-3pt,0) + } + \group_end: + } + } + } + +\cs_new_nopar:Npn \ENdiagram_get_tick_arg_and_label:w #1[#2] \q_stop + { + \fp_set:Nn \l_tmpa_fp { #1 } + \ENdiagram_get_label_and_tikz:n { #2 } + } + +\cs_new_nopar:Npn \ENdiagram_get_tick_point_and_label:w (#1)[#2] \q_stop + { + \tl_set:Nn \l_tmpa_tl { #1 } + \ENdiagram_get_label_and_tikz:n { #2 } + } + +\cs_new_nopar:Npn \ENdiagram_get_tick_node:w (#1) \q_stop + { \tl_set:Nn \l_tmpa_tl { #1 } } + +\NewDocumentCommand \ENdiagram_get_label_and_tikz:n { > { \SplitArgument { 1 } { , } } m } + { \ENdiagram_get_label_and_tikz_aux:nn #1 } + +\cs_new_nopar:Npn \ENdiagram_get_label_and_tikz_aux:nn #1#2 + { + \IfNoValueF { #1 } + { \tl_set:Nn \l_tmpb_tl { #1 } } + \IfNoValueF { #2 } { \tl_set:Nn \l_tmpc_tl { #2 } } + } + +% --------------------------------------------------------------------------- % +% make origin +\bool_new:N \l_ENdiagram_origin_made_bool + +\cs_new_nopar:Npn \ENdiagram_make_origin: + { + \bool_if:NF \l_ENdiagram_origin_made_bool + { + \bool_set_true:N \l_ENdiagram_origin_made_bool + \fp_gsub:Nn \g_ENdiagram_y_min_fp { 1 } + \fp_gadd:Nn \g_ENdiagram_y_max_fp { 1 } + \fp_gsub:Nn \g_ENdiagram_x_min_fp { 1.5 } + \fp_gsub:Nn \g_ENdiagram_x_min_fp { \l_ENdiagram_diagram_l_offset_tl } + \fp_gadd:Nn \g_ENdiagram_x_max_fp { 1.5 } + \ENdiagram_draw:nn {} + { + coordinate (origin-l) at + (-1.5-\l_ENdiagram_diagram_l_offset_tl,\fp_to_tl:N \g_ENdiagram_y_min_fp ) + } + \bool_if:NT \l_ENdiagram_debug_bool + { + \fp_set:Nn \l_tmpa_tl { -1.5 } + \fp_sub:Nn \l_tmpa_tl { \l_ENdiagram_diagram_l_offset_tl } + \ENdiagram_draw:nn { red } { (origin-l) circle (2pt) } + \ENdiagram_draw:nn { font=\tiny,inner~sep=0 } + { + node[above~right,red] at (origin-l) + { ( \fp_to_tl:N \l_tmpa_tl , \fp_to_tl:N \g_ENdiagram_y_min_fp ) } + node[fill=yellow!10,below~right] at (origin-l) + { origin-l } + } + } + \ENdiagram_draw:nn {} + { + coordinate (origin-r) at + (\fp_to_tl:N \g_ENdiagram_x_max_fp ,\fp_to_tl:N \g_ENdiagram_y_min_fp ) + } + \bool_if:NT \l_ENdiagram_debug_bool + { + \ENdiagram_draw:nn { red } { (origin-r) circle (2pt) } + \ENdiagram_draw:nn { font=\tiny,inner~sep=0 } + { + node[above~right,red] at (origin-r) + { ( \fp_to_tl:N \g_ENdiagram_x_max_fp ,\fp_to_tl:N \g_ENdiagram_y_min_fp ) } + node[fill=yellow!10,below~right] at (origin-r) + { origin-r } + } + } + } + } + +% --------------------------------------------------------------------------- % +% main environment +\bool_new:N \l_ENdiagram_y_axis_left_bool +\bool_set_true:N \l_ENdiagram_y_axis_left_bool +\bool_new:N \l_ENdiagram_y_axis_right_bool +\bool_new:N \l_ENdiagram_y_label_pos_bool +\bool_set_true:N \l_ENdiagram_y_label_pos_bool +\bool_new:N \l_ENdiagram_x_axis_bool +\bool_set_true:N \l_ENdiagram_x_axis_bool +\bool_new:N \l_ENdiagram_x_label_pos_bool +\bool_set_true:N \l_ENdiagram_x_label_pos_bool +\bool_new:N \l_ENdiagram_axes_all_bool +\bool_new:N \l_ENdiagram_axes_ticks_bool +\bool_new:N \l_ENdiagram_axes_ticks_yl_bool +\bool_new:N \l_ENdiagram_axes_ticks_yr_bool +\bool_new:N \l_ENdiagram_axes_add_ticks_bool +\bool_new:N \l_ENdiagram_energy_bool +\bool_new:N \l_ENdiagram_energy_unit_bool +\bool_new:N \l_ENdiagram_energy_round_places_bool +\bool_new:N \l_ENdiagram_calculate_bool +\bool_set_true:N \l_ENdiagram_calculate_bool + +\tl_new:N \l_ENdiagram_tikz_tl +\tl_new:N \l_ENdiagram_y_axis_tikz_tl +\tl_new:N \l_ENdiagram_x_axis_tikz_tl +\tl_new:N \l_ENdiagram_axes_ticks_step_tl +\tl_set:Nn \l_ENdiagram_axes_ticks_step_tl { 1 } +\tl_new:N \l_ENdiagram_y_label_pos_tl +\tl_set:Nn \l_ENdiagram_y_label_pos_tl { pos = .5 , } +\tl_new:N \l_ENdiagram_y_label_anchor_tl +\tl_set:Nn \l_ENdiagram_y_label_anchor_tl { sloped } +\tl_new:N \l_ENdiagram_y_label_text_tl +\tl_set:Nn \l_ENdiagram_y_label_text_tl { $E$ } +\tl_new:N \l_ENdiagram_y_label_angle_tl +\tl_set:Nn \l_ENdiagram_y_label_angle_tl { 0 } +\tl_new:N \l_ENdiagram_y_label_offset_tl +\tl_new:N \l_ENdiagram_x_label_pos_tl +\tl_set:Nn \l_ENdiagram_x_label_pos_tl { pos = .5 , } +\tl_new:N \l_ENdiagram_x_label_anchor_tl +\tl_set:Nn \l_ENdiagram_x_label_anchor_tl { below } +\tl_new:N \l_ENdiagram_x_label_text_tl +\tl_set:Nn \l_ENdiagram_x_label_text_tl { $\xi$ } +\tl_new:N \l_ENdiagram_x_label_angle_tl +\tl_set:Nn \l_ENdiagram_x_label_angle_tl { 0 } +\tl_new:N \l_ENdiagram_x_label_offset_tl +\tl_new:N \l_ENdiagram_diagram_l_offset_tl +\tl_set:Nn \l_ENdiagram_diagram_l_offset_tl { 0 } +\tl_new:N \l_ENdiagram_diagram_r_offset_tl +\tl_set:Nn \l_ENdiagram_diagram_r_offset_tl { 0 } +\tl_new:N \l_ENdiagram_diagram_scale_tl +\tl_set:Nn \l_ENdiagram_diagram_scale_tl { 1 } +\tl_new:N \l_ENdiagram_diagram_unit_factor_tl +\tl_set:Nn \l_ENdiagram_diagram_unit_factor_tl { .5 } +\tl_new:N \l_ENdiagram_energy_step_tl +\tl_set:Nn \l_ENdiagram_energy_step_tl { 1 } +\tl_new:N \l_ENdiagram_energy_unit_tl +\tl_new:N \l_ENdiagram_energy_unit_separator_tl +\tl_set:Nn \l_ENdiagram_energy_unit_separator_tl { / } +\tl_new:N \l_ENdiagram_energy_zero_tl +\tl_set:Nn \l_ENdiagram_energy_zero_tl { 0 } +\tl_new:N \l_ENdiagram_energy_round_tl +\tl_set:Nn \l_ENdiagram_energy_round_tl { 3 } + +\cs_new_nopar:Npn \ENdiagram_determine_unit:n #1 + { + \dim_set:Nn \l_tmpa_dim { 1pt * \dim_ratio:nn { #1 } { 1cm } } + \tl_set:Nn \l_ENdiagram_diagram_unit_factor_tl { \dim_use:N \l_tmpa_dim } + \tl_remove_once:Nn \l_ENdiagram_diagram_unit_factor_tl { pt } + } + +\keys_define:nn { ENdiagram } + { + debug .bool_set:N = \l_ENdiagram_debug_bool , + debug .default:n = true , + draft .bool_set:N = \l_ENdiagram_debug_bool , + draft .default:n = true , + final .choice: , + final / true .code:n = + { \bool_set_false:N \l_ENdiagram_debug_bool } , + final / false .code:n = + { \bool_set_true:N \l_ENdiagram_debug_bool } , + final .default:n = true , + axes .choice: , + axes / y .code:n = + { + \bool_set_true:N \l_ENdiagram_y_axis_left_bool + \bool_set_false:N \l_ENdiagram_y_axis_right_bool + \bool_set_false:N \l_ENdiagram_x_axis_bool + } , + axes / y-l .code:n = + { + \bool_set_true:N \l_ENdiagram_y_axis_left_bool + \bool_set_false:N \l_ENdiagram_y_axis_right_bool + \bool_set_false:N \l_ENdiagram_x_axis_bool + } , + axes / y-r .code:n = + { + \bool_set_false:N \l_ENdiagram_y_axis_left_bool + \bool_set_true:N \l_ENdiagram_y_axis_right_bool + \bool_set_false:N \l_ENdiagram_x_axis_bool + } , + axes / x .code:n = + { + \bool_set_false:N \l_ENdiagram_y_axis_left_bool + \bool_set_false:N \l_ENdiagram_y_axis_right_bool + \bool_set_true:N \l_ENdiagram_x_axis_bool + } , + axes / xy .code:n = + { + \bool_set_true:N \l_ENdiagram_y_axis_left_bool + \bool_set_false:N \l_ENdiagram_y_axis_right_bool + \bool_set_true:N \l_ENdiagram_x_axis_bool + } , + axes / all .code:n = + { \bool_set_true:N \l_ENdiagram_axes_all_bool } , + axes / false .code:n = + { + \bool_set_false:N \l_ENdiagram_y_axis_left_bool + \bool_set_false:N \l_ENdiagram_y_axis_right_bool + \bool_set_false:N \l_ENdiagram_x_axis_bool + } , + y-axis .tl_set:N = \l_ENdiagram_y_axis_tikz_tl , + x-axis .tl_set:N = \l_ENdiagram_x_axis_tikz_tl , + y-label .choice: , + y-label / above .code:n = + { + \bool_set_false:N \l_ENdiagram_y_label_pos_bool + \tl_clear:N \l_ENdiagram_y_label_anchor_tl + } , + y-label / left .code:n = + { + \bool_set_true:N \l_ENdiagram_y_label_pos_bool + \tl_set:Nn \l_ENdiagram_y_label_anchor_tl { sloped } + } , +% y-label-axis .code:n = , % TODO: left/right/both + % darauf achten, dass das mit "axes" korreliert. + y-label-pos .code:n = + { \tl_set:Nn \l_ENdiagram_y_label_pos_tl { pos = #1 , } } , + y-label-offset .code:n = + { \tl_set:Nn \l_ENdiagram_y_label_offset_tl { = #1 } } , + y-label-text .tl_set:N = \l_ENdiagram_y_label_text_tl , + y-label-angle .tl_set:N = \l_ENdiagram_y_label_angle_tl , + x-label .choice: , + x-label / right .code:n = + { + \bool_set_false:N \l_ENdiagram_x_label_pos_bool + \tl_set:Nn \l_ENdiagram_x_label_anchor_tl { right } + } , + x-label / below .code:n = + { + \bool_set_true:N \l_ENdiagram_x_label_pos_bool + \tl_set:Nn \l_ENdiagram_x_label_anchor_tl { below } + } , + x-label-pos .code:n = + { \tl_set:Nn \l_ENdiagram_x_label_pos_tl { pos = #1 , } } , + x-label-offset .code:n = + { \tl_set:Nn \l_ENdiagram_x_label_offset_tl { = #1 } } , + x-label-text .tl_set:N = \l_ENdiagram_x_label_text_tl , + x-label-angle .tl_set:N = \l_ENdiagram_x_label_angle_tl , + offset .code:n = + { + \tl_set:Nn \l_ENdiagram_diagram_l_offset_tl { #1 } + \tl_set:Nn \l_ENdiagram_diagram_r_offset_tl { #1 } + } , + l-offset .tl_set:N = \l_ENdiagram_diagram_l_offset_tl , + r-offset .tl_set:N = \l_ENdiagram_diagram_r_offset_tl , + scale .tl_set:N = \l_ENdiagram_diagram_scale_tl , + unit .code:n = \ENdiagram_determine_unit:n { #1 } , + tikz .tl_set:N = \l_ENdiagram_tikz_tl , + energy-step .code:n = + \tl_set:Nn \l_ENdiagram_energy_step_tl { #1 } + \bool_set_true:N \l_ENdiagram_energy_bool , + energy-zero .tl_set:N = \l_ENdiagram_energy_zero_tl , + energy-unit .code:n = + \tl_set:Nn \l_ENdiagram_energy_unit_tl { #1 } + \bool_set_true:N \l_ENdiagram_energy_unit_bool , + energy-unit-separator .tl_set:N = \l_ENdiagram_energy_unit_separator_tl , + energy-round-places .bool_set:N = \l_ENdiagram_energy_round_places_bool , + energy-round-places .default:n = true , + energy-round .tl_set:N = \l_ENdiagram_energy_round_tl , + calculate .bool_set:N = \l_ENdiagram_calculate_bool , + calculate .default:n = true , +% TODO darauf achten, dass das mit "axes" korreliert + ticks .choice: , + ticks / y .code:n = + \bool_set_true:N \l_ENdiagram_axes_ticks_bool , + ticks / y-l .code:n = + \bool_set_true:N \l_ENdiagram_axes_ticks_yl_bool , + ticks / y-r .code:n = + \bool_set_true:N \l_ENdiagram_axes_ticks_yr_bool , + ticks / none .code:n = + \bool_set_false:N \l_ENdiagram_axes_ticks_bool + \bool_set_false:N \l_ENdiagram_axes_ticks_yl_bool + \bool_set_false:N \l_ENdiagram_axes_ticks_yr_bool , + ticks .default:n = y , + ticks-step .tl_set:N = \l_ENdiagram_axes_ticks_step_tl + } + +\NewDocumentEnvironment { endiagram } { o } + { + \IfNoValueF { #1 } { \keys_set:nn { ENdiagram } { #1 } } + \int_gzero:N \g_ENdiagram_curve_int + \cs_set_eq:NN \ENcurve \ENdiagram_curve:w + \cs_set_eq:NN \ShowNiveaus \ENdiagram_show_niveaus:w + \cs_set_eq:NN \ShowGain \ENdiagram_show_gain:w + \cs_set_eq:NN \ShowEa \ENdiagram_show_ea:w + \cs_set_eq:NN \AddAxisLabel \ENdiagram_add_axis_label:w + \cs_set_eq:NN \MakeOrigin \ENdiagram_make_origin: + \ENdiagram_start_tikzpicture:x + { + scale=\l_ENdiagram_diagram_scale_tl*\l_ENdiagram_diagram_unit_factor_tl , + \l_ENdiagram_tikz_tl + } + } + { + \ENdiagram_make_origin: + % linke y-Achse + \bool_if:NT \l_ENdiagram_energy_unit_bool + { + \tl_put_right:Nn \l_ENdiagram_y_label_text_tl + { + \tl_use:N \l_ENdiagram_energy_unit_separator_tl + \exp_args:No \si { \l_ENdiagram_energy_unit_tl } + } + } + \bool_if:nT { \l_ENdiagram_y_axis_left_bool || \l_ENdiagram_axes_all_bool } + { + \bool_if:NF \l_ENdiagram_y_label_pos_bool { \tl_clear:N \l_ENdiagram_y_label_pos_tl } + \ENdiagram_draw:xx { -> , \l_ENdiagram_y_axis_tikz_tl } + { + (-1.5-\l_ENdiagram_diagram_l_offset_tl,\fp_to_tl:N \g_ENdiagram_y_min_fp ) + -- + (-1.5-\l_ENdiagram_diagram_l_offset_tl,\fp_to_tl:N \g_ENdiagram_y_max_fp ) + node + [ + \l_ENdiagram_y_label_pos_tl + above \l_ENdiagram_y_label_offset_tl , + rotate = \l_ENdiagram_y_label_angle_tl , + \l_ENdiagram_y_label_anchor_tl + ] + { \l_ENdiagram_y_label_text_tl } + } + % TODO: "energy-zero" beachten: ticks auch am Nullpunkt starten, egal ob dort auch ein niveau sitzt + \bool_if:nT { \l_ENdiagram_axes_ticks_bool || \l_ENdiagram_axes_ticks_yl_bool } + { + \bool_set_true:N \l_ENdiagram_axes_add_ticks_bool + \fp_set:Nn \l_tmpa_fp { \g_ENdiagram_y_min_fp + \l_ENdiagram_axes_ticks_step_tl } + \bool_while_do:Nn \l_ENdiagram_axes_add_ticks_bool + { + \fp_set_eq:NN \l_tmpb_fp \l_tmpa_fp + \tl_clear:N \l_tmpc_tl + \ENdiagram_add_axis_label_yl_ticks:n { { \l_tmpa_fp [ \fp_to_tl:N \l_tmpb_fp ] } } + \fp_add:Nn \l_tmpa_fp { \l_ENdiagram_axes_ticks_step_tl } + \fp_compare:nNnF { \l_tmpa_fp } < { \g_ENdiagram_y_max_fp } + { \bool_set_false:N \l_ENdiagram_axes_add_ticks_bool } + } + } + } + % x-Achse + \bool_if:NT \l_ENdiagram_show_gain_right_bool + { + \fp_gadd:Nn \g_ENdiagram_x_max_fp { \g_ENdiagram_gain_offset_tl } + \fp_gadd:Nn \g_ENdiagram_x_max_fp { 1 } + } + \fp_gadd:Nn \g_ENdiagram_x_max_fp { \l_ENdiagram_diagram_r_offset_tl } + \bool_if:nT { \l_ENdiagram_x_axis_bool || \l_ENdiagram_axes_all_bool } + { + \bool_if:NF \l_ENdiagram_x_label_pos_bool { \tl_clear:N \l_ENdiagram_x_label_pos_tl } + \ENdiagram_draw:xx + { + \bool_if:nT + { \l_ENdiagram_x_axis_bool && !\l_ENdiagram_y_axis_right_bool && !\l_ENdiagram_axes_all_bool } + { -> , } + \l_ENdiagram_x_axis_tikz_tl + } + { + (-1.5-\l_ENdiagram_diagram_l_offset_tl,\fp_to_tl:N \g_ENdiagram_y_min_fp ) + -- + (\fp_to_tl:N \g_ENdiagram_x_max_fp ,\fp_to_tl:N \g_ENdiagram_y_min_fp ) + node + [ + \l_ENdiagram_x_label_pos_tl + rotate = \l_ENdiagram_x_label_angle_tl , + sloped , + \l_ENdiagram_x_label_anchor_tl \l_ENdiagram_x_label_offset_tl , + ] + { \exp_not:N \l_ENdiagram_x_label_text_tl } + } + } + % rechte y-Achse + \bool_if:nT { \l_ENdiagram_y_axis_right_bool || \l_ENdiagram_axes_all_bool } + { + \ENdiagram_draw:xf { -> , \l_ENdiagram_y_axis_tikz_tl } + { + (\fp_to_tl:N \g_ENdiagram_x_max_fp,\fp_to_tl:N \g_ENdiagram_y_min_fp) + -- + (\fp_to_tl:N \g_ENdiagram_x_max_fp,\fp_to_tl:N \g_ENdiagram_y_max_fp ) + } + % TODO "energy-zero" beachten! Ticks werden nicht gezeichnet, wenn nicht extra spezifiziert + \bool_if:nT { \l_ENdiagram_axes_ticks_bool || \l_ENdiagram_axes_ticks_yr_bool } + { + \bool_set_true:N \l_ENdiagram_axes_add_ticks_bool + \fp_set_eq:NN \l_tmpa_fp \g_ENdiagram_y_min_fp + \fp_add:Nn \l_tmpa_fp { \l_ENdiagram_axes_ticks_step_tl } + \bool_while_do:Nn \l_ENdiagram_axes_add_ticks_bool + { + \fp_set_eq:NN \l_tmpb_fp \l_tmpa_fp + \fp_mul:Nn \l_tmpb_fp { \l_ENdiagram_energy_step_tl } + \tl_clear:N \l_tmpc_tl + \ENdiagram_add_axis_label_yr_ticks:n { { \l_tmpa_fp [ \fp_to_tl:N \l_tmpb_fp ] } } + \fp_add:Nn \l_tmpa_fp { \l_ENdiagram_axes_ticks_step_tl } + \fp_compare:nNnF { \l_tmpa_fp } < { \g_ENdiagram_y_max_fp } + { \bool_set_false:N \l_ENdiagram_axes_add_ticks_bool } + } + } + } + \bool_if:NT \l_ENdiagram_debug_bool + { + \fp_add:Nn \g_ENdiagram_x_max_fp { 1 } + \fp_add:Nn \g_ENdiagram_y_max_fp { 1 } + \fp_sub:Nn \g_ENdiagram_x_min_fp { 1 } + \fp_sub:Nn \g_ENdiagram_y_min_fp { 1 } + \draw[help~lines,densely~dotted,opacity=.7] + (\fp_to_tl:N \g_ENdiagram_x_min_fp,\fp_to_tl:N \g_ENdiagram_y_min_fp) + grid + (\fp_to_tl:N \g_ENdiagram_x_max_fp,\fp_to_tl:N \g_ENdiagram_y_max_fp) ; + \draw[red] (0,0) circle (3pt) node[right,font=\tiny] at (0,0) {(0,0)} ; + } + \ENdiagram_end_tikzpicture: + \fp_gzero:N \g_ENdiagram_y_min_fp + \fp_gzero:N \g_ENdiagram_y_max_fp + \fp_gzero:N \g_ENdiagram_x_max_fp + \fp_gzero:N \g_ENdiagram_x_min_fp + \tl_gset:Nn \g_ENdiagram_gain_offset_tl { 0 } + \int_gzero:N \g_ENdiagram_ea_int + } + +% --------------------------------------------------------------------------- % +% setup +\NewDocumentCommand \ENsetup { om } + { + \IfNoValueTF { #1 } + { \keys_set:nn { ENdiagram } { #2 } } + { \keys_set:nn { ENdiagram / #1 } { #2 } } + } + +% --------------------------------------------------------------------------- % +% package options: +\ProcessKeysOptions { ENdiagram } + +\tex_endinput:D +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Version history +2012/02/31 v0.0 +2012/06/26 v0.1 +2012/08/20 v0.1a - most basic necessary changes due to new l3fp module => more + revisions on various places still needed! + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% TODO +- \ENcurve und \AddAxisLabel so anpassen, dass Eingaben der Energieskala folgen?! +- revise the whole code especially with respect to fp calculations \ No newline at end of file -- cgit v1.2.3