diff options
author | Karl Berry <karl@freefriends.org> | 2014-07-20 22:10:34 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-07-20 22:10:34 +0000 |
commit | a2cfb7237c96e698f1f2933b008104555610ee89 (patch) | |
tree | 2f64ba48065ad97b0156dba404fa274782167269 /Master/texmf-dist/tex/latex/chemschemex | |
parent | 3939eb6308172d96585a35eddc3214f037d356cf (diff) |
chemschemex (20jul14)
git-svn-id: svn://tug.org/texlive/trunk@34667 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemschemex')
-rw-r--r-- | Master/texmf-dist/tex/latex/chemschemex/chemschemex.sty | 1127 |
1 files changed, 1127 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/chemschemex/chemschemex.sty b/Master/texmf-dist/tex/latex/chemschemex/chemschemex.sty new file mode 100644 index 00000000000..a4f80eb66ed --- /dev/null +++ b/Master/texmf-dist/tex/latex/chemschemex/chemschemex.sty @@ -0,0 +1,1127 @@ +%% +%% This is file `chemschemex.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% chemschemex.dtx (with options: `package') +%% +%% This is a generated file. +%% +%% Copyright (C) 2014 by Dominik Siegel +%% +%% This file may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.2 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.2 or later is part of all distributions of +%% LaTeX version 1999/12/01 or later. +%% +%% +%% To produce the documentation, do the following +%% +%% latex chemschemex.dtx +\NeedsTeXFormat{LaTeX2e}[2005/12/01] +\ProvidesPackage{chemschemex}[2014/07/15 v1.0 Typeset chemical schemes] +\RequirePackage{xkeyval} +\RequirePackage{etextools} +\RequirePackage{xargs} +\RequirePackage{ifthen} +\RequirePackage{suffix} +\RequirePackage{fancylabel} +\fancyref@DefineFamily{}{CSX} +\def\fancylabelformatCSX{\arabic{fancylabel}}% +\def\fancysublabelformatCSX{\arabic{fancylabel}\alph{fancysublabel}}% +\def\fancyonlysublabelformatCSX{\alph{fancysublabel}}% +\RequirePackage{graphicx} +\RequirePackage{tikz} +\usetikzlibrary{% + shapes.multipart,% + decorations,% + decorations.markings,% + positioning,% + arrows.meta% +} +\define@key{chemschemex}{image}{% + % #1=additional options + % #2=filename of the image + \newcommand{\CSXimage}[2][]{% + \includegraphics[#1,##1]{##2}% + } +} +\define@key{chemschemex}{labelseparator}{% + \def\CSXlabelsep{#1}% +} +\define@key{chemschemex}{arrowadvance}{% + \def\CSXarrowadvance{#1}% +} +\presetkeys{chemschemex}{% + image={scale=0.7},% + labelseparator={:\,},% + arrowadvance={10pt},% +}{} +\ProcessOptionsX<chemschemex> +\tikzset{% + CSXsettextwidth/.style={% + text width=(% + % if + (\CSXtextwidth - \CSXimagewidth - \CSXmaxlabelwidth)>0% + % then + ?(\CSXimagewidth - \CSXmaxlabelwidth)% + % else + :(\CSXtextwidth+0.00001)% + ),% + },% + CSXsetlabelwidth/.style={% + text width=(% + % if + (\CSXlabelwidth)>0% + % then + ?(\CSXlabelwidth+0.00001)% + % else + :(0.00001)% + ),% + },% + CSXshiftA/.style={},% + CSXshiftB/.style={},% + CSXshiftcompensation/.style={},% +} +\tikzset{% + % TikZ + CSX/.style={% + remember picture% + },% + % Matrix + CSXmatrix/.style={% + column sep=10pt,% + row sep=4pt,% + nodes={% + inner xsep=0pt,% + inner ysep=1pt,% + outer sep=0pt% + },% + every odd row/.style={anchor=center},% + every even row/.style={anchor=north},% + },% + % Structure caption + CSXcaption/.style={% + node distance=0pt,% + },% + CSXcaptionLabelandText/.style={% + align=right,% + every two node part/.style={% + align=justify% + },% + },% + CSXcaptionTextOnly/.style={% + align=justify% + },% + % Fonts + CSXlabelfont/.style={% + font={\footnotesize\sffamily\bfseries}% + },% + CSXtextfont/.style={% + font={\footnotesize\sffamily}% + },% + CSXarrowfont/.style={% + font={\footnotesize\sffamily}% + },% + CSXsimple/.style={% + x=3pt,% + y=3pt,% + line width=0.7pt% + },% + % Arrows + CSXarrowupper/.style={% + align=flush center,% + },% + CSXarrowlower/.style={% + align=flush center% + },% + CSXStructInArrow/.style={% + node distance=1pt,% + text width=,% + inner sep=0pt,% + outer sep=0pt% + },% + CSXallarrows/.style={% + x=1pt,y=1pt,% + line width=0.7,% + inner ysep=3,% + >=Classical TikZ Rightarrow,% + },% + CSXdoublearrows/.style={% + double distance=1.5,% + >=Implies% + },% + CSXharpoonup/.style={% + >={Classical TikZ Rightarrow[harpoon]}% + },% + CSXharpoondown/.style={% + >={Classical TikZ Rightarrow[harpoon,swap]}% + },% + CSXRightArrow/.style={% + ->% + },% + CSXRightupHarpoon/.style={% + ->[harpoon]% + },% + CSXRightdownHarpoon/.style={% + ->[{harpoon,swap}]% + },% + CSXLeftArrow/.style={% + <-% + },% + CSXLeftupHarpoon/.style={% + <[{harpoon,swap}]-% + },% + CSXLeftdownHarpoon/.style={% + <[harpoon]-% + },% + CSXLeftRightArrow/.style={% + <->% + },% + CSXLeftupRightupHarpoon/.style={% + <[{harpoon,swap}]->[harpoon]% + },% + CSXLeftupRightdownHarpoon/.style={% + <[{harpoon,swap}]->[{harpoon,swap}]% + },% + CSXLeftdownRightupHarpoon/.style={% + <[{harpoon}]->[{harpoon}]% + },% + CSXLeftdownRightdownHarpoon/.style={% + <[{harpoon}]->[{harpoon,swap}]% + },% + CSXequilibrium/.style={% + inner ysep/.expanded=(1+\pgfkeysvalueof{/pgf/inner ysep}),% + CSXshiftA/.style={yshift=1},% + CSXshiftB/.style={yshift=1},% + CSXshiftcompensation/.style={yshift=-1},% + postaction=decorate,% + decoration={% + markings,% + mark=at position 0.5 with{% + \draw([yshift=-1]\CSXnodename .east) to% + ([yshift=-1]\CSXnodename .west);% + }% + }% + },% + CSXRightequilibrium/.style={% + inner ysep/.expanded=(1+\pgfkeysvalueof{/pgf/inner ysep}),% + CSXshiftA/.style={yshift=1},% + CSXshiftB/.style={yshift=1},% + CSXshiftcompensation/.style={yshift=-1},% + postaction=decorate,% + decoration={% + markings,% + mark=at position 0.5 with{% + \draw([yshift=-1,xshift=-0.25\CSXarrowlength]\CSXnodename .east) to% + ([yshift=-1,xshift=0.25\CSXarrowlength]\CSXnodename .west);% + }% + }% + },% + CSXLeftequilibrium/.style={% + inner ysep/.expanded=(1+\pgfkeysvalueof{/pgf/inner ysep}),% + CSXshiftA/.style={yshift=1,xshift=0.25\CSXarrowlength},% + CSXshiftB/.style={yshift=1,xshift=-0.25\CSXarrowlength},% + CSXshiftcompensation/.style={yshift=-1},% + postaction=decorate,% + decoration={% + markings,% + mark=at position 0.5 with{% + \draw([yshift=-1]\CSXnodename .east) to% + ([yshift=-1]\CSXnodename .west);% + }% + }% + },% + CSXslashtwoarrow/.style={% + inner ysep/.expanded=(1.5+\pgfkeysvalueof{/pgf/inner ysep}),% + CSXshiftA/.style={yshift=1.5,xshift=5},% + CSXshiftB/.style={yshift=1.5},% + CSXshiftcompensation/.style={yshift=-1.5,xshift=-2.5},% + postaction=decorate,% + decoration={% + markings,% + mark=at position 0.5 with{% + \draw([yshift=-1.5]\CSXnodename .west) to% + ([yshift=-1.5,xshift=-5]\CSXnodename .east);% + }% + }% + },% + CSXbackslashtwoarrow/.style={% + inner ysep/.expanded=(1.5+\pgfkeysvalueof{/pgf/inner ysep}),% + CSXshiftA/.style={yshift=1.5},% + CSXshiftB/.style={yshift=1.5,xshift=-5},% + CSXshiftcompensation/.style={yshift=-1.5,xshift=2.5},% + postaction=decorate,% + decoration={% + markings,% + mark=at position 0.5 with{% + \draw([yshift=-1.5,xshift=5]\CSXnodename .west) to% + ([yshift=-1.5]\CSXnodename .east);% + }% + }% + },% + CSXslashthreearrow/.style={% + inner ysep/.expanded=(3+\pgfkeysvalueof{/pgf/inner ysep}),% + CSXshiftA/.style={xshift=5},% + CSXshiftB/.style={xshift=-5},% + CSXshiftcompensation/.style={x=1.4,y=1.4},% + postaction=decorate,% + decoration={% + markings,% + mark=at position 0.5 with{% + \draw([yshift=3,xshift=10]\CSXnodename .west) to% + ([yshift=3]\CSXnodename .east);% + \draw([yshift=-3]\CSXnodename .west) to% + ([yshift=-3,xshift=-10]\CSXnodename .east);% + }% + }% + },% + CSXbackslashthreearrow/.style={% + inner ysep/.expanded=(3+\pgfkeysvalueof{/pgf/inner ysep}),% + CSXshiftA/.style={xshift=5},% + CSXshiftB/.style={xshift=-5},% + CSXshiftcompensation/.style={x=1.4,y=1.4},% + postaction=decorate,% + decoration={% + markings,% + mark=at position 0.5 with{% + \draw([yshift=3]\CSXnodename .west) to% + ([yshift=3,xshift=-10]\CSXnodename .east);% + \draw([yshift=-3,xshift=10]\CSXnodename .west) to% + ([yshift=-3]\CSXnodename .east);% + }% + }% + },% + CSXCrossArrow/.style={% + inner ysep/.expanded=1.5+\pgfkeysvalueof{/pgf/inner ysep},% + postaction=decorate,% + decoration={% + markings,% + mark=at position 0.5 with{% + \draw[-,solid,CSXshiftcompensation](-3,-3)--(3,3);% + \draw[-,solid,CSXshiftcompensation](3,-3)--(-3,3);% + }% + }% + },% + CSXStrikeArrow/.style={% + inner ysep/.expanded=2+\pgfkeysvalueof{/pgf/inner ysep},% + postaction=decorate,% + decoration={% + markings,% + mark=at position 0.5 with{% + \draw[-,solid,CSXshiftcompensation](-2,-3.5)--(2, 3.5);% + }% + }% + },% + CSXDStrikeArrow/.style={% + inner ysep/.expanded=2+\pgfkeysvalueof{/pgf/inner ysep},% + postaction=decorate,% + decoration={% + markings,% + mark=at position 0.5 with{% + \draw[-,solid,xshift=-2,CSXshiftcompensation](-2,-3.5)--(2, 3.5);% + \draw[-,solid,xshift=2,CSXshiftcompensation](-2,-3.5)--(2, 3.5);% + }% + }% + }% +} +\newif\ifCSX@scheme\CSX@schemefalse % Is true, if the struct appears in a Chemscheme environment +\newif\ifCSX@generate@@@caption@% Is needed to get label and text out of the caption passed to customstruct +\newif\ifCSX@generate@@@caption@LastEntryWasTextOnly% Is needed to detect text-only caption entries +\newlength{\CSXimagewidth}\setlength{\CSXimagewidth}{0pt} +\newlength{\CSXlabelwidth}\setlength{\CSXlabelwidth}{0pt} +\newlength{\CSXmaxlabelwidth}\setlength{\CSXmaxlabelwidth}{0pt} +\newlength{\CSXtextwidth}\setlength{\CSXtextwidth}{0pt} +\newlength{\CSXmaxtextwidth}\setlength{\CSXmaxtextwidth}{0pt} +\newlength{\CSXarrowlength}\setlength{\CSXarrowlength}{0pt} +\newcounter{CSXscheme}\setcounter{CSXscheme}{1} +\newcounter{CSXstruct}\setcounter{CSXstruct}{0} +\newcounter{CSXstructinarrow}\setcounter{CSXstructinarrow}{0} +\newcounter{CSXcaption}\setcounter{CSXcaption}{0} +\def\CSX@structlist@filenamesorted{} +\newcommand{\newstruct}[5][]{% + % #1=comma-separated list of subcaptions + % #2=filename + % #3=structname + % #4=Structname + % #5=abbreviation + \@ifundefined{CSX@newstruct@#2@structname}{% + \global\@namedef{CSX@newstruct@#2@structname}{#3}% + \global\@namedef{CSX@newstruct@#2@Structname}{#4}% + \global\@namedef{CSX@newstruct@#2@abbreviation}{#5}% + \ifthenelse{\equal{#1}{}}{}{% + \setcounter{CSXcaption}{0}% No need to define a new counter, just use the CSXcaption + \fancyref@foreach{\CSX@newsubstruct}{#2}{#1}% + }% + \AtBeginDocument{% + \immediate\write\@auxout{% + \string\fancyref@addtolist + {\string{#2\string}}% + {\string\CSX@structlist@filenamesorted}% + }% + }% + }{% + \PackageError{chemschemex}{Multiple definitions of '#2' by % + \string\newstruct}{}% + }% +} +\@onlypreamble\newstruct +\DeclareRobustCommand{\structname}[1]{% + \@ifundefined{CSX@newstruct@#1@structname}{% + ???% + \PackageWarning{chemschemex}{No structure '#1' defined by \string\newstruct}% + }{% + \ifthenelse{\equal{\@nameuse{CSX@newstruct@#1@structname}}{}}{% + ???% + \PackageWarning{chemschemex}{structname of structure '#1' is empty.}% + }{% + \@nameuse{CSX@newstruct@#1@structname}% + }% + }% +} +\DeclareRobustCommand{\Structname}[1]{% + \@ifundefined{CSX@newstruct@#1@Structname}{% + ???% + \PackageWarning{chemschemex}{No structure '#1' defined by \string\newstruct}% + }{% + \ifthenelse{\equal{\@nameuse{CSX@newstruct@#1@Structname}}{}}{% + ???% + \PackageWarning{chemschemex}{Structname of structure '#1' is empty.}% + }{% + \@nameuse{CSX@newstruct@#1@Structname}% + }% + }% +} +\DeclareRobustCommand{\structabbr}[1]{% + \@ifundefined{CSX@newstruct@#1@abbreviation}{% + ???% + \PackageWarning{chemschemex}{No structure '#1' defined by \string\newstruct}% + }{% + \ifthenelse{\equal{\@nameuse{CSX@newstruct@#1@abbreviation}}{}}{% + ???% + \PackageWarning{chemschemex}{structabbr of structure '#1' is empty.}% + }{% + \@nameuse{CSX@newstruct@#1@abbreviation}% + }% + }% +} +\newcommandx\customstruct[4][1={},2={}]{% + % #1=TikZ option for caption + % #2=TikZ option for image + % #3=caption + % #4=image + \customstruct@outarrow[#1][#2]{#3}{#4}% +} +\newcommandx\struct[6][1={},2=CSX,3={},4={},5={},usedefault]{% + % #1=caption + % #2=family + % #3=image options + % #4=TikZ option for caption + % #5=TikZ option for image + % #6=filename + \@struct{#1}{#2}{#6}% + \expandnext{\customstruct[#4][#5]}{\@@struct}{\CSXimage[#3]{#6}}% +} +\newcommandx\structalt[7][1={},2=CSX,3={},4={},5={},usedefault]{% + % #1=caption + % #2=family + % #3=image options + % #4=TikZ option for caption + % #5=TikZ option for image + % #6=filename of the referenced image + % #7=filename of the image shown instead of #6 + \@struct{#1}{#2}{#6}% + \expandnext{\customstruct[#4][#5]}{\@@struct}{\CSXimage[#3]{#7}}% +} +\WithSuffix\newcommandx\struct*[6][1={},2=CSX,3={},4={},5={},usedefault]{% + % #1=caption + % #2=family + % #3=image options + % #4=TikZ option for caption + % #5=TikZ option for image + % #6=filename + \@struct*{#1}{#2}{#6}% + \expandnext{\customstruct[#4][#5]}{\@@struct}{\CSXimage[#3]{#6}}% +} +\WithSuffix\newcommandx\structalt*[7][1={},2=CSX,3={},4={},5={},usedefault]{% + % #1=caption + % #2=family + % #3=image options + % #4=TikZ option for caption + % #5=TikZ option for image + % #6=filename of the referenced image + % #7=filename of the image shown instead of #6 + \@struct*{#1}{#2}{#6}% + \expandnext{\customstruct[#4][#5]}{\@@struct}{\CSXimage[#3]{#7}}% +} +\WithSuffix\newcommandx\struct-[5][1={},2={},3={},4={},usedefault]{% + % #1=caption + % #2=image options + % #3=TikZ option for caption + % #4=TikZ option for image + % #5=filename + \expandnext{\customstruct[#3][#4]}{{{},{#1}}}{\CSXimage[#2]{#5}}% +} +\newcommandx\Struct[6][1=CSX,2={},3={},4={},usedefault]{% + % #1=family + % #2=image options + % #3=TikZ option for caption + % #4=TikZ option for image + % #5=list of sublabels previously defined with \newstruct + % #6=filename + \@Struct{#1}{#5}{#6}% + \expandnext{\customstruct[#3][#4]}{\@@struct}{\CSXimage[#2]{#6}}% +} +\newcommandx\Structalt[7][1=CSX,2={},3={},4={},usedefault]{% + % #1=family + % #2=image options + % #3=TikZ option for caption + % #4=TikZ option for image + % #5=list of sublabels previously defined with \newstruct + % #6=filename of the referenced image + % #7=filename of the image shown instead of #6 + \@Struct{#1}{#5}{#6}% + \expandnext{\customstruct[#3][#4]}{\@@struct}{\CSXimage[#2]{#7}}% +} +\WithSuffix\newcommandx\Struct*[6][1=CSX,2={},3={},4={},usedefault]{% + % #1=family + % #2=image options + % #3=TikZ option for caption + % #4=TikZ option for image + % #5=list of sublabels previously defined with \newstruct + % #6=filename + \@Struct*{#1}{#5}{#6}% + \expandnext{\customstruct[#3][#4]}{\@@struct}{\CSXimage[#2]{#6}}% +} +\WithSuffix\newcommandx\Structalt*[7][1=CSX,2={},3={},4={},usedefault]{% + % #1=family + % #2=image options + % #3=TikZ option for caption + % #4=TikZ option for image + % #5=list of sublabels previously defined with \newstruct + % #6=filename of the referenced image + % #7=filename of the image shown instead of #6 + \@Struct*{#1}{#5}{#6}% + \expandnext{\customstruct[#3][#4]}{\@@struct}{\CSXimage[#2]{#7}}% +} +\newcommand{\structplus}{% + \customstruct{}{\tikz[CSXsimple]{\draw[-](1,0)to(-1,0);\draw[-](0,1)to(0,-1);}}% +} +\newcommand{\structminus}{% + \customstruct{}{\tikz[CSXsimple]{\draw[-](1,0)to(-1,0);}}% +} +\def\ChemschemeNextRow@list{}% +\newcommand{\ChemschemeNextRow}[1][]{% + \ExpandNext{\fancyref@addtolist}{\theCSXstruct}{\ChemschemeNextRow@list}% + \expandafter\def\csname ChemschemeNextRow@\theCSXstruct\endcsname{#1}% + \ignorespaces% +} +\newenvironment{Chemscheme}{% + \CSX@schemetrue% + \ignorespaces% +}{% + \CSX@print% + \CSX@schemefalse% +} +\DeclareRobustCommand\structref[2][CSX]{% + % #1=family + % #2=label + \CSXstructref{\fancyref[#1]{#2}}% +} +\WithSuffix\DeclareRobustCommand\structref*[2][CSX]{% + % #1=family + % #2=label + \CSXstructref{\fancyref*[#1]{#2}}% +} +\DeclareRobustCommand\structsubref[3][CSX]{% + % #1=family + % #2=label + % #3=sublabel + \CSXstructref{\fancysubref[#1]{#2}{#3}}% +} +\WithSuffix\DeclareRobustCommand\structsubref-[3][CSX]{% + % #1=family + % #2=label + % #3=sublabel + \CSXstructref{\fancysubref-[#1]{#2}{#3}}% +} +\WithSuffix\DeclareRobustCommand\structsubref*[3][CSX]{% + % #1=family + % #2=label + % #3=sublabel + \CSXstructref{\fancysubref*[#1]{#2}{#3}}% +} +\newcommand{\CSXstructref}[1]{% + % #1=fancyref command + \textbf{#1}% +} +\newcommand{\CSXcommands}[1]{% + \gappto\CSX@commands{#1}% + \ignorespaces% +} +\def\CSX@commands{}% +\newcommand{\CSX@newsubstruct}[2]{% + % #1=label + % #2=caption + \stepcounter{CSXcaption}% + \xdef\chemschemes@getcountervalue{% + \theCSXcaption% + }% + \expandafter\xdef\csname CSX@newstruct@#1@subcaption@% + \chemschemes@getcountervalue\endcsname{#2}% +} +\newcommand{\CSX@customarrow@widestcaption}[2]{% + % #1=label + % #2=style + \pgfmathwidth{"% + \noexpand\tikz[minimum width=0pt,inner sep=0pt,outer sep=0pt]{% + \noexpand\node[\expandonce{#2}]{\noexpand#1};% + }% + "}% + \pgfmathsetlength{\CSXlabelwidth}{\pgfmathresult}% + \ifnum\CSXlabelwidth>\CSXarrowlength% + \pgfmathsetlength{\CSXarrowlength}{\pgfmathresult}% + \edef\CSX@arrowlength{\pgfmathresult}% + \fi% +} +\def\CSX@savebox@set#1#2{% + % #1=boxname + % #2=box content + \@ifundefined{#1}{% + \expandnext{\newsavebox}{\csname #1\endcsname}% + }{} + \expandnext{\global\sbox}{\csname #1\endcsname}{#2}% + \expandnext{\usebox}{\csname #1\endcsname}% +}% +\def\CSX@savebox@show#1#2{% + % #1=boxname + % #2=box content + \expandnext{\usebox}{\csname #1\endcsname}% +}% +\newcommand{\customarrow}[4][\the\CSXarrowlength]{% + % #1=length + % #2=arrow style + % #3=upper text + % #4=lower text + \stepcounter{CSXstruct}% + % Measure upper und lower text + \setlength{\CSXarrowlength}{0pt}% + \def\CSX@nodename{Scheme\theCSXscheme Image\theCSXstruct}% + \def\CSXcustomarrow@uppertext{% + \let\customstruct\customstruct@inarrow% + \def\customstruct@inarrow@nodename{\CSX@nodename Upper}% + #3% + \let\customstruct\customstruct@outarrow% + }% + \def\CSXcustomarrow@lowertext{% + \let\customstruct\customstruct@inarrow% + \def\customstruct@inarrow@nodename{\CSX@nodename Lower}% + #4% + \let\customstruct\customstruct@outarrow% + }% + \let\CSX@savebox\CSX@savebox@set% + \edef\CSX@arrowlength{0}% + \CSX@customarrow@widestcaption{\CSXcustomarrow@uppertext}{CSXarrowfont,CSXarrowupper}% + \CSX@customarrow@widestcaption{\CSXcustomarrow@lowertext}{CSXarrowfont,CSXarrowlower}% + \let\CSX@savebox\CSX@savebox@show% + % Set matrix entries + \pgfmathsetlength{\CSXarrowlength}{\CSX@arrowlength + \CSXarrowadvance}% + \edef\customarrow@temp{% + % Reserve space in matrix + \noexpand\node(\CSX@nodename)% + {\noexpand\hbox to #1{}};% + % Add arrow command + \noexpand\CSXcommands{% + \noexpand\pgfmathsetlength{\noexpand\CSXarrowlength}{#1}% + \noexpand\def\noexpand\CSXnodename{\CSX@nodename}% + \noexpand\draw [text width=(#1-\CSXarrowadvance),#2]% + ([CSXshiftA]\noexpand\CSXnodename .west) to% + node (\noexpand\CSXnodename Upper)% + [CSXshiftcompensation,CSXarrowfont,CSXarrowupper,auto]% + {\expandonce\CSXcustomarrow@uppertext}% + node (\noexpand\CSXnodename Lower)% + [CSXshiftcompensation,CSXarrowfont,CSXarrowlower,auto,swap]% + {\expandonce\CSXcustomarrow@lowertext}% + ([CSXshiftB]\noexpand\CSXnodename .east);% + }% + }% + \expandnext{\expandafter\gdef\csname CSX@list@image@\theCSXstruct\endcsname}{% + \customarrow@temp% + }% + \expandafter\gdef\csname CSX@list@caption@\theCSXstruct\endcsname{% + \node(Scheme\theCSXscheme Caption\theCSXstruct){};% + }% + \ifCSX@scheme% + % Inside Chemscheme environment + \else% + % Outside Chemscheme environment + \CSX@print% + \fi% + \ignorespaces% +} +\newcommand{\CSXdeclarearrow}[2]{% + % #1=macro name + % #2=TikZ style + \newcommand{#1}[3][\the\CSXarrowlength]{% + % ##1=length + % ##2=upper caption + % ##3=lower caption + \customarrow[##1]{#2}{##2}{##3}% + } +} +\newcommand{\CSXdeclarearrowbundle}[2]{% + % #1=macro name + % #2=TikZ style + % normal + \CSX@declarearrowbundle{#1}{#2}% + % dashed + \CSX@declarearrowbundle{#1Dashed}{#2,dashed}% +} +\newcommand{\CSX@declarearrowbundle}[2]{% + % #1=macro name + % #2=TikZ style + % normal arrow + \expandnext{\CSXdeclarearrow}{\csname #1\endcsname}{#2}% + % crossed out arrow + \expandnext{\CSXdeclarearrow}{\csname C#1\endcsname}{#2,CSXCrossArrow}% + % striked out arrow + \expandnext{\CSXdeclarearrow}{\csname S#1\endcsname}{#2,CSXStrikeArrow}% + % Double striked out arrow + \expandnext{\CSXdeclarearrow}{\csname DS#1\endcsname}{#2,CSXDStrikeArrow}% +} +\CSXdeclarearrowbundle{RightArrow}{CSXallarrows,CSXRightArrow} +\CSXdeclarearrowbundle{LeftArrow}{CSXallarrows,CSXLeftArrow} +\CSXdeclarearrowbundle{LeftRightArrow}{CSXallarrows,CSXLeftRightArrow} +\CSXdeclarearrowbundle{DoubleRightArrow}{CSXallarrows,CSXdoublearrows,CSXRightArrow} +\CSXdeclarearrowbundle{DoubleLeftArrow}{CSXallarrows,CSXdoublearrows,CSXLeftArrow} +\CSXdeclarearrowbundle{DoubleLeftRightArrow}{CSXallarrows,CSXdoublearrows,CSXLeftRightArrow} +\CSXdeclarearrowbundle{RightupHarpoon}{CSXallarrows,CSXRightupHarpoon} +\CSXdeclarearrowbundle{RightdownHarpoon}{CSXallarrows,CSXRightdownHarpoon} +\CSXdeclarearrowbundle{LeftupHarpoon}{CSXallarrows,CSXLeftupHarpoon} +\CSXdeclarearrowbundle{LeftdownHarpoon}{CSXallarrows,CSXLeftdownHarpoon} +\CSXdeclarearrowbundle{LeftupRightupHarpoon}{CSXallarrows,CSXLeftupRightupHarpoon} +\CSXdeclarearrowbundle{LeftupRightdownHarpoon}{CSXallarrows,CSXLeftupRightdownHarpoon} +\CSXdeclarearrowbundle{LeftdownRightupHarpoon}{CSXallarrows,CSXLeftdownRightupHarpoon} +\CSXdeclarearrowbundle{LeftdownRightdownHarpoon}{CSXallarrows,CSXLeftdownRightdownHarpoon} +\CSXdeclarearrowbundle{Equilibrium}{CSXallarrows,CSXequilibrium,CSXRightupHarpoon} +\CSXdeclarearrowbundle{RightEquilibrium}{CSXallarrows,CSXRightequilibrium,CSXRightupHarpoon} +\CSXdeclarearrowbundle{LeftEquilibrium}{CSXallarrows,CSXLeftequilibrium,CSXRightupHarpoon} +\CSXdeclarearrowbundle{RRightEquilibrium}{CSXallarrows,CSXLeftequilibrium,CSXLeftupHarpoon} +\CSXdeclarearrowbundle{LLeftEquilibrium}{CSXallarrows,CSXRightequilibrium,CSXLeftupHarpoon} +\CSXdeclarearrowbundle{TwoRightArrow}{CSXallarrows,CSXslashtwoarrow,CSXRightArrow} +\CSXdeclarearrowbundle{TTwoRightArrow}{CSXallarrows,CSXbackslashtwoarrow,CSXRightArrow} +\CSXdeclarearrowbundle{TwoLeftArrow}{CSXallarrows,CSXslashtwoarrow,CSXLeftArrow} +\CSXdeclarearrowbundle{TTwoLeftArrow}{CSXallarrows,CSXbackslashtwoarrow,CSXLeftArrow} +\CSXdeclarearrowbundle{ThreeRightArrow}{CSXallarrows,CSXslashthreearrow,CSXRightArrow} +\CSXdeclarearrowbundle{TThreeRightArrow}{CSXallarrows,CSXbackslashthreearrow,CSXRightArrow} +\CSXdeclarearrowbundle{ThreeLeftArrow}{CSXallarrows,CSXslashthreearrow,CSXLeftArrow} +\CSXdeclarearrowbundle{TThreeLeftArrow}{CSXallarrows,CSXbackslashthreearrow,CSXLeftArrow} +\newcommand{\@struct}[3]{% + % #1=caption + % #2=family + % #3=filename + \ifthenelse{\equal{#1}{}}{% + \def\@@struct{{{\fancylabel[#2]{#3}},{}}}% + }{% + \def\@@struct{{{\def\fancylabelShowLabelEvent{\CSXlabelsep}\fancylabel[#2]{#3}},{#1}}}% + }% +} +\WithSuffix\newcommand\@struct*[3]{% + % #1=caption + % #2=family + % #3=filename + \def\@@struct{{{\fancylabel*[#2]{#3}},{#1}}}% +} +\newcommand\@Struct[3]{% + % #1=family + % #2=list of sublabels previously defined with \newstruct + % #3=filename + % Use the sort-function of the fancylabel package to sort the label-list + \def\@@struct{}% + \def\fancyref@@@@@sort{fancyref@PrevRun@#1@#3@\fancyref@@sort@value}% + \def\fancyref@sort@list{}% + \def\fancyref@sort@labellist@unsorted{}% + \fancyref@sort{#2}% + \expandnext{\fancyref@addtolist}% + {\fancyref@sort@labellist@unsorted}% + {\fancyref@sort@list}% + \edef\CSX@sorted@list{\fancyref@sort@list}% + % Generate the caption + \def\@Struct@family{#1}% + \def\@Struct@filename{#3}% + \expandnext{\fancyref@foreach{\@@Struct}{}}{\CSX@sorted@list}% +} +\newcommand{\@@Struct}[2]{% + % #1= + % #2=sublabel + \@ifundefined{CSX@newstruct@\@Struct@filename @subcaption@#2}{% + \PackageError{chemschemex}{Substructure '#2' not defined as % + substructure of '\@Struct@filename '. % + Use the \noexpand\newstruct command for % + the definition of substructures.}{}% + }{% + \fancyref@addtolist{% + {{\def\fancylabelShowLabelEvent{\CSXlabelsep}\fancysublabel[\@Struct@family]{\@Struct@filename}{#2}},% + {\@nameuse{CSX@newstruct@\@Struct@filename @subcaption@#2}}}}% + {\@@struct}% + }% +} +\WithSuffix\newcommand\@Struct*[3]{% + % #1=family + % #2=list of sublabels previously defined with \newstruct + % #3=filename + \def\@@struct{{{\fancysublabel[#1]{#3}{#2}},{}}}% +} +\newcommandx\customstruct@outarrow[4][1={},2={}]{% + % #1=TikZ option for caption + % #2=TikZ option for image + % #3=caption + % #4=image + \stepcounter{CSXstruct}% + % Set Image + \edef\customstruct@outarrow@temp{% + \noexpand\node[\expandonce{#2}](Scheme\theCSXscheme Image\theCSXstruct){\expandonce{#4}};% + }% + \expandnext{\expandafter\gdef\csname CSX@list@image@\theCSXstruct\endcsname}{% + \customstruct@outarrow@temp% + }% + % Generate caption + \CSXgeneratecaption{#3}{#4}{Scheme\theCSXscheme Caption\theCSXstruct}{#1}% + % Set caption + \edef\customstruct@outarrow@temp{% + \noexpand\node(Scheme\theCSXscheme Caption\theCSXstruct){% + \noexpand\tikz[CSXcaption,\expandonce{#1}]{% + \expandonce\CSXcaption% + }% + };% + }% + \expandnext{\expandafter\gdef\csname CSX@list@caption@\theCSXstruct\endcsname}{% + \customstruct@outarrow@temp% + }% + \ifCSX@scheme% + % Inside Chemscheme environment + \else% + % Outside Chemscheme environment + \CSX@print% + \fi% + \ignorespaces% +} +\newcommandx\customstruct@inarrow[4][1={},2={}]{% + % #1=TikZ option for caption + % #2=TikZ option for image + % #3=caption + % #4=image + \stepcounter{CSXstructinarrow}% + \CSXgeneratecaption{#3}{#4}{\customstruct@inarrow@nodename Caption\theCSXstructinarrow}{#1}% + \ifthenelse{\CSXmaxlabelwidth=0 \AND \CSXmaxtextwidth=0}{% + \edef\customstruct@inarrow@temp{% + \noexpand\tikz[remember picture,CSXStructInArrow]{% + \noexpand\node [\expandonce{#2}]% + (\customstruct@inarrow@nodename Image\theCSXstructinarrow)% + {\expandonce{#4}};% + }% + }% + }{% + \edef\customstruct@inarrow@temp{% + \noexpand\tikz[remember picture,CSXStructInArrow,% + baseline=(\CSX@generate@caption@captionname Entry\theCSXcaption .base)]{% + \noexpand\node [\expandonce{#2}]% + (\customstruct@inarrow@nodename Image\theCSXstructinarrow)% + {\expandonce{#4}};% + \noexpand\node [below=of \customstruct@inarrow@nodename Image\theCSXstructinarrow]% + (\customstruct@inarrow@nodename Caption\theCSXstructinarrow)% + {\noexpand\tikz[CSXcaption,\expandonce{#1}]{\expandonce\CSXcaption}};% + }% + }% + }% + \expandnext{\CSX@savebox{CSX@savebox@\theCSXstructinarrow}}{% + \customstruct@inarrow@temp% + }% + \ignorespaces% +} +\newcommand{\CSXgeneratecaption}[4]{% + % #1=list of labels and text: {{label1},{text1}},{{label2},{text2}},... + % #2=Image + % #3=caption name + % #4=caption style + \setcounter{CSXcaption}{0}% + \setlength{\CSXmaxlabelwidth}{0pt}% + \setlength{\CSXmaxtextwidth}{0pt}% + \def\CSXcaption{}% + \def\CSX@generate@caption@image{#2}% + \def\CSX@generate@caption@captionname{#3}% + \def\CSX@generate@caption@captionstyle{CSXcaption,#4}% + \CSX@generate@@@caption@true% + \ifthenelse{\equal{#1}{}}{}{% + \expandnext\expandnext\expandnext{% + \fancyref@foreach{\CSX@generate@@caption}{}% + }{#1}% + }% +} +\newcommand{\CSX@generate@@caption}[2]{% + % #1= + % #2=label and text: {label1},{text1} + \edef\CSX@generate@@@caption@lastCSXcaption{\theCSXcaption}% + \stepcounter{CSXcaption}% + \fancyref@foreach{\CSX@generate@@@caption}{}{#2}% + % Execute text-only event + \ifCSX@generate@@@caption@\else% + \CSX@generate@@@caption@TextOnly% + {\CSX@generate@caption@image}% + {\CSX@generate@caption@captionname Entry\theCSXcaption}% + {\CSX@generate@caption@captionname Entry\CSX@generate@@@caption@lastCSXcaption}% + {\CSX@generate@@@caption@label}% + \CSX@generate@@@caption@true% + \fi% +} +\newcommand{\CSX@generate@@@caption}[2]{% + % #1= + % #2=label or text: label1 or text1 + \ifCSX@generate@@@caption@% + % Label + \def\CSX@generate@@@caption@label{#2}% + \CSX@generate@@@caption@false% + \else% + % Text and execute label-and-text event + \def\CSX@generate@@@caption@text{#2}% + \CSX@generate@@@caption@LabelAndText% + {\CSX@generate@caption@image}% + {\CSX@generate@caption@captionname Entry\theCSXcaption}% + {\CSX@generate@caption@captionname Entry\CSX@generate@@@caption@lastCSXcaption}% + {\CSX@generate@@@caption@label}% + {\CSX@generate@@@caption@text}% + \CSX@generate@@@caption@true% + \def\CSX@generate@@@caption@label{}% + \def\CSX@generate@@@caption@text{}% + \fi% +} +\newcommand{\CSX@setimagewidth}[1]{% + % #1=image + \pgfmathwidth{"% + \noexpand\tikz[minimum width=0pt,inner sep=0pt,outer sep=0pt]{% + \noexpand\node{\noexpand#1};% + }% + "}% + \edef\CSX@imagewidth{\pgfmathresult}% +} +\newcommand{\CSX@setmaxlabelwidth}[1]{% + % #1=label + \pgfmathwidth{"% + \noexpand\tikz[\expandonce\CSX@generate@caption@captionstyle ,minimum width=0pt,inner sep=0pt,outer sep=0pt]{% + \noexpand\node[CSXlabelfont]{\noexpand#1};% + }% + "}% + \pgfmathsetlength{\CSXlabelwidth}{\pgfmathresult}% + \edef\CSX@labelwidth{\pgfmathresult}% + \ifnum\CSXlabelwidth<\CSXmaxlabelwidth% + \else% + \pgfmathsetlength{\CSXmaxlabelwidth}{\pgfmathresult}% + \edef\CSX@maxlabelwidth{\pgfmathresult}% + \fi% +} +\newcommand{\CSX@settextwidth}[1]{% + % #1=text + \pgfmathwidth{"% + \noexpand\tikz[\expandonce\CSX@generate@caption@captionstyle ,minimum width=0pt,inner sep=0pt,outer sep=0pt]{% + \noexpand\node[CSXtextfont]{\noexpand#1};% + }% + "}% + \pgfmathsetlength{\CSXtextwidth}{\pgfmathresult}% + \edef\CSX@textwidth{\pgfmathresult}% + \ifnum\CSXtextwidth<\CSXmaxtextwidth% + \else% + \pgfmathsetlength{\CSXmaxtextwidth}{\pgfmathresult}% + \edef\CSX@maxtextwidth{\pgfmathresult}% + \fi% +} +\newcommand{\CSX@setvphantom}{% + \ifdim\CSXlabelwidth=0pt% + \ifdim\CSXtextwidth=0pt% + \def\CSX@vphantom{}% + \else% + \def\CSX@vphantom{font/.expand once={\tikz@textfont\vphantom{Ag}}}% + \fi% + \else% + \def\CSX@vphantom{font/.expand once={\tikz@textfont\vphantom{Ag}}}% + \fi% +} +\newcommand{\CSX@generate@@@caption@LabelAndText}[5]{% + % #1=image command + % #2=node name + % #3=last node name + % #4=label + % #5=text + % Get the image width + \CSX@setimagewidth{#1}% + % Get the widest label + \CSX@setmaxlabelwidth{#4}% + % Measure the text width + \def\CSX@textwidth{0}% + \CSX@settextwidth{#5}% + \CSX@setvphantom% + % Typeset caption + \edef\CSX@generate@@@caption@tempentry{% + \noexpand\gappto\noexpand\CSXcaption{% + % Set \CSXimagewidth + \noexpand\pgfmathsetlength{\noexpand\CSXimagewidth}% + {\CSX@imagewidth}% + % Set \CSXlabelwidth + \noexpand\pgfmathsetlength{\noexpand\CSXlabelwidth}% + {\CSX@labelwidth}% + % Set \CSXmaxlabelwidth + \noexpand\pgfmathsetlength{\noexpand\CSXmaxlabelwidth}% + {\CSX@maxlabelwidth}% + % Set \CSXtextwidth + \noexpand\pgfmathsetlength{\noexpand\CSXtextwidth}% + {\CSX@textwidth}% + % Set \CSXmaxtextwidth + \noexpand\pgfmathsetlength{\noexpand\CSXmaxtextwidth}% + {\CSX@maxtextwidth}% + % Print node + \noexpand\node(#2)[% + CSXlabelfont,% + \expandonce\CSX@vphantom,% + CSXsetlabelwidth,% + CSXcaptionLabelandText,% + rectangle split,% + rectangle split horizontal,% + rectangle split parts=2,% + rectangle split part align=base,% + every two node part/.append style={% + CSXtextfont,% + CSXsettextwidth,% + },% + \ifCSX@generate@@@caption@LastEntryWasTextOnly% + \ifnum\theCSXcaption>1% + below=of #3.south,% + \fi% + \else% + \ifnum\theCSXcaption>1% + below left=of #3.one split south,% + \fi% + anchor=one split north% + \fi% + ]{% + \expandonce#4% + \noexpand\nodepart{two}% + \expandonce#5% + };% + }% + }\CSX@generate@@@caption@tempentry% + \CSX@generate@@@caption@LastEntryWasTextOnlyfalse% +} +\newcommand{\CSX@generate@@@caption@TextOnly}[4]{% + % #1=image command + % #2=node name + % #3=last node name + % #4=label + % Get the image width + \CSX@setimagewidth{#1}% + % Get the widest label + \CSX@setmaxlabelwidth{}% + % Measure the text width + \def\CSX@textwidth{0}% + \CSX@settextwidth{#4}% + \CSX@setvphantom% + % Typeset caption + \edef\CSX@generate@@@caption@tempentry{% + \noexpand\gappto\noexpand\CSXcaption{% + % Set \CSXimagewidth + \noexpand\pgfmathsetlength{\noexpand\CSXimagewidth}% + {\CSX@imagewidth}% + % Set \CSXmaxlabelwidth + \noexpand\pgfmathsetlength{\noexpand\CSXmaxlabelwidth}% + {\CSX@maxlabelwidth}% + % Set \CSXtextwidth + \noexpand\pgfmathsetlength{\noexpand\CSXtextwidth}% + {\CSX@textwidth}% + % Set \CSXmaxtextwidth + \noexpand\pgfmathsetlength{\noexpand\CSXmaxtextwidth}% + {\CSX@maxtextwidth}% + % Print node + \noexpand\node(#2)[% + CSXtextfont,% + \expandonce\CSX@vphantom,% + CSXsettextwidth,% + CSXcaptionTextOnly,% + \ifnum\theCSXcaption>1% + below=of #3.south,% + \fi% + ]{% + \expandonce#4% + };% + }% + }\CSX@generate@@@caption@tempentry% + \CSX@generate@@@caption@LastEntryWasTextOnlytrue% +} +\newcommand{\CSX@print}{% + \ifnum\theCSXstruct=0% + \PackageWarning{chemschemex}{Empty Chemscheme environment detected.} + \else% + \let\CSX@printlist\empty% + \CSX@@print% + \fi% + \setcounter{CSXstructinarrow}{0}% + % Print scheme + \begin{tikzpicture}[CSX]% + \matrix [CSXmatrix]{% + \CSX@printlist% + };% + \CSX@commands% + \end{tikzpicture}% + \stepcounter{CSXscheme}% + \setcounter{CSXstruct}{0}% + \setcounter{CSXstructinarrow}{0}% + \gdef\CSX@printlist{}% + \gdef\CSX@commands{}% + \gdef\ChemschemeNextRow@list{}% +} +\newcommand{\CSX@@print}{% + % #1= + % #2=row (integer) + \def\lastx{1}% + \ChemschemeNextRow% + \foreach \x [remember=\xplus as \lastx,% + evaluate=\x as \xplus using int(\x+1)]% + in \ChemschemeNextRow@list {% + \ifthenelse{\x < \lastx}{}{% + % Create Image row + \foreach \y in {\lastx,...,\x}{% + \CSX@@@print{\csname CSX@list@image@\y\endcsname}% + }% + \gappto\CSX@printlist{\pgfmatrixendrow}% + % Create Caption row + \foreach \y in {\lastx,...,\x}{% + \CSX@@@print{\csname CSX@list@caption@\y\endcsname}% + }% + \edef\CSX@print@tempentry{% + \noexpand\gappto\noexpand\CSX@printlist{% + \noexpand\pgfmatrixendrow[\csname ChemschemeNextRow@\x\endcsname]% + }% + }\CSX@print@tempentry% + }% + }% +} +\newcommand{\CSX@@@print}[2]{% + % #1=image + \ifnum\y<\x% + \def\CSX@@@print@nextcell{\pgfmatrixnextcell}% + \else% + \def\CSX@@@print@nextcell{}% + \fi% + \edef\CSX@print@tempentry{% + \noexpand\gappto\noexpand\CSX@printlist{% + \noexpand#1% + \expandonce\CSX@@@print@nextcell% + }% + }\CSX@print@tempentry% +} +\endinput +%% +%% End of file `chemschemex.sty'. |