Debian Codegraph @

texmf-dist/source/latex/chemschemex/chemschemex.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2014-2018 by Dominik Siegel
4 %
5 % This file may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either
7 % version 1.2 of this license or (at your option) any later
8 % version. The latest version of this license is in:
9 %
10 % http://www.latex-project.org/lppl.txt
11 %
12 % and version 1.2 or later is part of all distributions of
13 % LaTeX version 1999/12/01 or later.
14 %%
15 %% To produce the documentation, do the following
16 %%
17 %% latex chemschemex.dtx
18 %
19 % <package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
20 % <package>\ProvidesPackage{chemschemex}
21 % <package>[2018/01/20 v1.2]
22 %
23 %<*driver>
24 \documentclass{ltxdoc}
25 \usepackage{chemschemex}
26 \usepackage{caption}
27 \usepackage{float}
28 \newfloat{example}{htbp}{los}%
29 \floatname{example}{Example}%
30 \captionsetup{font={footnotesize},textfont={sf},labelfont={sf,bf}}
31 \usepackage{sectsty}
32 \usepackage[hidelinks]{hyperref}
33 \usepackage{fancyvrb}
34 \allsectionsfont{\sffamily}
35 \GetFileInfo{chemschemex.dtx}
36 \EnableCrossrefs
37 \CodelineIndex
38 \OnlyDescription
39 \RecordChanges
40 \newstruct[{R=H},{R=Me},{R=Ph}]{maleimid}{maleimid}{Maleimid}{}
41 \newstruct{cp}{cyclopentadiene}{Cyclopentadiene}{cp}
42 \newstruct[{R=H},{R=Me},{R=Ph}]{product}{}{}{}
43 \date{2018/01/20}
44 \begin{document}
45 \DocInput{chemschemex.dtx}
46 \end{document}
47 %</driver>
48 % \fi
49 %
50 % \CheckSum{0}
51 %
52 % \CharacterTable
53 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
54 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
55 % Digits \0\1\2\3\4\5\6\7\8\9
56 % Exclamation \! Double quote \" Hash (number) \#
57 % Dollar \$ Percent \% Ampersand \&
58 % Acute accent \' Left paren \( Right paren \)
59 % Asterisk \* Plus \+ Comma \,
60 % Minus \- Point \. Solidus \/
61 % Colon \: Semicolon \; Less than \<
62 % Equals \= Greater than \> Question mark \?
63 % Commercial at \@ Left bracket \[ Backslash \\
64 % Right bracket \] Circumflex \^ Underscore \_
65 % Grave accent \` Left brace \{ Vertical bar \|
66 % Right brace \} Tilde \~}
67 %
68 % \changes{v1.0}{2014/07/15}{Initial version}
69 % \changes{v1.1}{2017/04/02}{Bug within the \textbackslash Struct command fixed}
70 % \changes{v1.1.1}{2017/04/03}{No code changes, documentation attached}
71 % \changes{v1.2}{2018/01/20}{Dependency on etextools (causes some compatibility issues) removed}
72 %
73 % \GetFileInfo{chemschemex.sty}
74 %
75 %
76 % \title{The \CSX{} package\thanks{This document corresponds to \CSX{}~\fileversion{}, dated \filedate.}}
77 %
78 % \author{Dominik Siegel \\ \texttt{[email protected]}}
79 % \newcommand{\CSX}{\textsf{chemschemex}}
80 % \newcommand{\FL}{\textsf{fancylabel}}
81 % \newcommand{\TikZ}{\textsf{Ti\emph{k}Z}}
82 %
83 % \maketitle
84 %
85 % \begin{abstract}
86 % The \CSX{} package provides a comfortable method for the typesetting of (chemical) schemes based on \TikZ{} code, including an automatical structure referencing.
87 % \end{abstract}
88 %
89 % \begin{example}
90 % \begin{minipage}[c]{0.49\linewidth}
91 % \begin{Chemscheme}
92 % \struct{maleimid}
93 % \RightArrow{\struct{cp}}{DEE}
94 % \struct[80\,\%]{product}
95 % \end{Chemscheme}
96 % \end{minipage}
97 % \begin{minipage}[c]{0.5\linewidth}
98 %\begin{verbatim}
99 %\begin{Chemscheme}
100 % \struct{maleimid}
101 % \RightArrow{\struct{cp}}{DEE}
102 % \struct[80\,\%]{product}
103 %\end{Chemscheme}
104 %\end{verbatim}
105 % \end{minipage}
106 % \caption{Chemical scheme (left) produced by a simple code (right).}\label{fig.intro.1}
107 % \end{example}
108 %
109 % \tableofcontents
110 %
111 % \section{Introduction and motivation}
112 % While \LaTeX{} is a powerful tool for mathematical or physical issues the typesetting of chemistry derived problems is still a little bit annoying. When I wrote my thesis in organic chemistry I missed a package which produces chemical schemes as easy as you include a graphic into your document. I simply wanted to draw my structures in \textsc{ChemDraw}, inlcude them into my document and label them.
113 %
114 % The packages \textsf{chemscheme} and \textsf{chemnum} offer a possibility to rerender image files for this purpose. Nevertheless, they only modify a scheme that already exists. This means, that arrows, margins, alignments and other parameters cannot be defined or changed globally in your document.
115 %
116 % By using the \TikZ{} and the \FL{} package (which has actually been written as slave of this package) the \CSX{} package meets all these requirements (see example \ref{fig.intro.1}).
117 %
118 %
119 %
120 % \section{Usage}
121 % \noindent\DescribeMacro{\usepackage}
122 % |\usepackage[<options>]{chemschemex}|\vspace{0.5em}
123 %
124 % \noindent The command above will load the \CSX{} package. It requires the packages \textsf{xkeyval}, \textsf{etextools}, \textsf{xargs}, \textsf{ifthen}, \textsf{suffix}, \TikZ{}, \textsf{graphicx}, and \FL{}. I strongly recommend to read the documentation of the \FL{} package because all referencing functions are provided by this package. It contains a lot of useful options that are not described in this documentation.
125 %
126 %
127 % \newpage
128 % \section{User commands}
129 %
130 % \subsection{Basic commands}
131 % \noindent\DescribeMacro{\customstruct}
132 % |\customstruct[<TikZ-capt>][<TikZ-obj>]{<capt>}{<obj>}|\vspace{0.5em}
133 %
134 % \noindent The |\customstruct| command typesets the object \textcolor{red}{|<obj>|} in the first row of a \TikZ{} matrix and the caption \textcolor{blue}{|<capt>|} in the second row. The caption is supposed to be given as comma-separated list of label(s) and text. The two optional arguments |<TikZ-capt>| and |<TikZ-obj>| can be used to pass options to \TikZ{} elements (for further information see section \ref{custom}). All the following structure commands are based on |\customstruct|.
135 %
136 % \begin{minipage}{0.27\linewidth}
137 % \begin{Chemscheme}
138 % \customstruct[nodes={draw=blue}]
139 % [draw=red]
140 % {{{label1:},{text}},{{ll2:},{a longer text}}}
141 % {object e.g. image}
142 % \end{Chemscheme}
143 % \end{minipage}
144 % \begin{minipage}{0.6\linewidth}
145 % \begin{verbatim}
146 % \customstruct[nodes={draw=blue}][draw=red]
147 % {{{label1:},{text}},
148 % {{ll2:},{a longer text}}}
149 % {object e.g. image}
150 % \end{verbatim}
151 % \end{minipage}
152 %
153 %
154 % \vspace{3ex}\noindent\DescribeMacro{\CSXimage}
155 % |\CSXimage[<img-opt>]{<img>}|\vspace{0.5em}
156 %
157 % \noindent The |\CSXimage| command includes the image |<img>| using the global options |<global-img-opt>| defined by the |image| option (see section \ref{image}) and the options given by |<img-opt>|. This command is used in all the following structure commands and expands to |\includegraphics[<global-img-opt>,<img-opt>]{<img>}|.
158 %
159 %
160 %
161 % \subsection{Structure commands}
162 % \vspace{3ex}\noindent\DescribeMacro{\struct}
163 % |\struct[<capt>][<fam>][<img-opt>][<TikZ-capt>][<TikZ-obj>]{<img>}|\vspace{0.5em}
164 %
165 % \noindent The |\struct| command inlcudes the image |<img>|, sets a fancylabel (therefore it uses |<img>| as marker and |<fam>| as family, default: |<fam>|=|CSX|; the use of families is described in the \FL{} package) and prints it. If a |<caption>| is given, it will also print the caption behind the label. The macro |\CSXlabelsep| can be changed with the |labelseparator| option.
166 %
167 % \begin{minipage}{0.2\linewidth}
168 % \struct[text]{maleimid}
169 % \end{minipage}
170 % \begin{minipage}{0.79\linewidth}
171 % \begin{verbatim}
172 % \struct[text]{maleimid}
173 % expands to:
174 % \customstruct{{{\fancylabel[CSX]{maleimid}\CSXlabelsep},{}}}
175 % {\CSXimage{maleimid}}
176 % \end{verbatim}
177 % \end{minipage}
178 %
179 %
180 % \newpage
181 % \vspace{3ex}\noindent\DescribeMacro{\structalt}
182 % |\structalt[<capt>][<fam>][<img-opt>][<TikZ-capt>][<TikZ-obj>]{<img>}{<alt-img>}|\vspace{0.5em}
183 %
184 % \noindent The |\structalt| command includes an image |<alt-img>| but the labeling corresponds to |<img>|.
185 %
186 % \begin{minipage}{0.2\linewidth}
187 % \structalt{product}{product_num}
188 % \end{minipage}
189 % \begin{minipage}{0.7\linewidth}
190 % \begin{verbatim}
191 % \structalt{product}{product_num}
192 % expands to:
193 % \customstruct{{{\fancylabel[CSX]{product}},{}}}
194 % {\CSXimage{product_num}}
195 % \end{verbatim}
196 % \end{minipage}
197 %
198 %
199 % \vspace{3ex}\noindent\DescribeMacro{\struct*}
200 % \noindent\DescribeMacro{\structalt*}
201 % |\struct*[<capt>][<fam>][<img-opt>][<TikZ-capt>][<TikZ-obj>]{<img>}|\\
202 % |\structalt*[<capt>][<fam>][<img-opt>][<TikZ-capt>][<TikZ-obj>]{<img>}{<alt-img>}|\vspace{0.5em}
203 %
204 % \noindent The |\struct*| and |\structalt*| commands do the same as the corresponding nonstarred versions but use |\fancylabel*| instead of |\fancylabel|. This means, that a label for this structure will be defined but not printed.
205 %
206 % \begin{minipage}{0.2\linewidth}
207 % \struct*{maleimid}
208 % \end{minipage}
209 % \begin{minipage}{0.7\linewidth}
210 % \begin{verbatim}
211 % \struct*{maleimid}
212 % expands to:
213 % \customstruct{{{\fancylabel*[CSX]{maleimid}},{}}}
214 % {\CSXimage{maleimid}}
215 % \end{verbatim}
216 % \end{minipage}
217 %
218 %
219 % \vspace{3ex}\noindent\DescribeMacro{\struct-}
220 % |\struct-[<capt>][<img-opt>][<TikZ-capt>][<TikZ-obj>]{<img>}|\vspace{0.5em}
221 %
222 % \noindent The |\struct-| command includes an image |<img>| without any labeling.
223 %
224 % \begin{minipage}{0.2\linewidth}
225 % \struct-[text]{maleimid}
226 % \end{minipage}
227 % \begin{minipage}{0.7\linewidth}
228 % \begin{verbatim}
229 % \struct-[text]{maleimid}
230 % expands to:
231 % \customstruct{{{},{text}}}
232 % {\CSXimage{maleimid}}
233 % \end{verbatim}
234 % \end{minipage}
235 %
236 %
237 %
238 %
239 % \vspace{3ex}\noindent\DescribeMacro{\newstruct}
240 % |\newstruct[<sublabels>]{<img>}{<structname>}{<Structname>}{<abbr>}|\vspace{0.5em}
241 %
242 % \noindent If you want to use substructures you have to define them in the preamble. The optional argument |<sublabels>| is a comma-separated list of subcaptions. Whenever you want to refer to them you just have to use their numbers. In this example the first entry (|R=H|) gets the number 1, the second entry (|R=Me|) gets the number 2 and so on. If you use a structure without substructures it is not necessary to use |\newstruct|. However, the |\newstruct| command defines the name (and Name) und abbreviation of the structure what allows you to use the commands |\structname|, |\Structname| and |\structabbr| for this structure.\vspace{2ex}
243 %
244 % \begin{minipage}{0.9\linewidth}
245 % \begin{verbatim}
246 %\newstruct[{R=H},{R=Me},{R=Ph}]{product}{}{}{}
247 % \end{verbatim}
248 % \end{minipage}
249 %
250 % \vspace{3ex}\noindent\textbf{Note:} All of the following structure commands assume that |\newstruct| has been used for the filename |<img>| before.
251 %
252 % \vspace{3ex}\noindent\DescribeMacro{\Struct}
253 % |\Struct[<fam>][<img-opt>][<TikZ-capt>][<TikZ-obj>]{<sublabels>}{<img>}|\vspace{0.5em}
254 %
255 % \noindent To use the |\Struct| command, the structure and its substructure have to be defined by the |\newstruct| command. It inlcudes the image |<img>|, sets the sublabels given in the comma-separated list of |<sublabels>| and prints each sublabel with the subcaption previously given to the |\newstruct| command (one line per sublabel).
256 %
257 % \begin{minipage}{0.2\linewidth}
258 % \Struct{1,2,3}{product}
259 % \end{minipage}
260 % \begin{minipage}{0.7\linewidth}
261 % \begin{verbatim}
262 % \Struct{1,2,3}{product}
263 % expands to:
264 % \customstruct{{{\fancysublabel[CSX]{product}{1}\CSXlabelsep},{R=H}},
265 % {{\fancysublabel[CSX]{product}{2}\CSXlabelsep},{R=Me}},
266 % {{\fancysublabel[CSX]{product}{3}\CSXlabelsep},{R=Ph}}}
267 % {\CSXimage{product}}
268 % \end{verbatim}
269 % \end{minipage}
270 %
271 % \vspace{3ex}\noindent\DescribeMacro{\Struct*}
272 % |\Struct*[<fam>][<img-opt>][<TikZ-capt>][<TikZ-obj>]{<sublabels>}{<img>}|\vspace{0.5em}
273 %
274 % \noindent To use the |\Struct*| command, the structure and its substructure have to be defined by the |\newstruct| command. It inlcudes the image |<filename>|, sets the sublabels given in the comma-separated list of |<sublabels>| and prints each sublabel without its subcaption previously given to the |\newstruct| command.
275 %
276 % \begin{minipage}{0.2\linewidth}
277 % \Struct*{1,3}{product}
278 % \end{minipage}
279 % \begin{minipage}{0.7\linewidth}
280 % \begin{verbatim}
281 % \Struct*{1,3}{product}
282 % expands to:
283 % \customstruct{{{\fancysublabel[CSX]{product}{1,3}},{}}}
284 % {\CSXimage{product}}
285 % \end{verbatim}
286 % \end{minipage}
287 %
288 %
289 % \vspace{3ex}\noindent\DescribeMacro{\Structalt}
290 % |\Structalt[<fam>][<img-opt>][<TikZ-capt>][<TikZ-obj>]{<sublabels>}{<img>}{<alt-img>}|\vspace{0.5em}
291 %
292 % \noindent Works like the |\Struct| command but includes the image |<alt-img>|. Labeling corresponds to |<img>|.
293 %
294 %
295 % \vspace{3ex}\noindent\DescribeMacro{\Structalt*}
296 % |\Structalt*[<fam>][<img-opt>][<TikZ-capt>][<TikZ-obj>]{<sublabels>}{<img>}{<alt-img>}|\vspace{0.5em}
297 %
298 % \noindent Works like the |\Struct*| command but includes the image |<alt-img>|. Labeling corresponds to |<img>|.
299 %
300 %
301 % \vspace{3ex}\noindent\DescribeMacro{\structname}
302 % |\structname{<img>}|\vspace{0.5em}
303 %
304 % \noindent Prints the name of the structure |<img>| that has been previously defined by the |\newstruct| command. This command is recommended for the chemical name without a leading capital letter (inside a sentence).
305 %
306 %
307 % \vspace{3ex}\noindent\DescribeMacro{\Structname}
308 % |\Structname{<img>}|\vspace{0.5em}
309 %
310 % \noindent Prints the name of the structure |<img>| that has been previously defined by the |\newstruct| command. This command is recommended for the chemical name with a leading capital letter (at the beginning of a sentence).
311 %
312 %
313 % \vspace{3ex}\noindent\DescribeMacro{\structabbr}
314 % |\structabbr{<img>}|\vspace{0.5em}
315 %
316 % \noindent Prints the abbreviation of the structure |<img>| that has been previously defined by the |\newstruct| command.
317 %
318 %
319 %
320 %
321 % \subsection{The Chemscheme environment}
322 %
323 % \noindent\DescribeEnv{Chemscheme}
324 % |\begin{Chemscheme}...structure code...\end{Chemscheme}|\vspace{0.5em}
325 %
326 % \noindent If a structure command appears outside a |Chemscheme| environment each command will typeset the image and caption in its own matrix. This causes no kind of adjustment.
327 %
328 % \begin{minipage}{0.3\linewidth}
329 % \struct{cp}
330 % \struct[long caption]{maleimid}
331 % \end{minipage}
332 % \begin{minipage}{0.59\linewidth}
333 % \begin{verbatim}
334 % \struct{cp}
335 % \struct[long caption]{maleimid}
336 % \end{verbatim}
337 % \end{minipage}
338 %
339 % \noindent But if structure commands appear inside a |Chemscheme| environment all images and captions are printed in one matrix. This causes adjustment of the image (by default center) and the caption row (by default top) according to the \TikZ{} style |CSXmatrix|.
340 %
341 %
342 % \begin{minipage}{0.3\linewidth}
343 % \begin{Chemscheme}
344 % \struct{cp}
345 % \struct[long caption]{maleimid}
346 % \end{Chemscheme}
347 % \end{minipage}
348 % \begin{minipage}{0.59\linewidth}
349 % \begin{verbatim}
350 % \begin{Chemscheme}
351 % \struct{cp}
352 % \struct[long caption]{maleimid}
353 % \end{Chemscheme}
354 % \end{verbatim}
355 % \end{minipage}
356 %
357 %
358 % \vspace{3ex}\noindent\DescribeMacro{\ChemschemeNextRow}
359 % |\ChemschemeNextRow[<row-sep>]|\vspace{0.5em}
360 %
361 % \noindent If you want to use the matrix adjustment over multiple lines you can produce a 'linebreak' using the |\ChemschemeNextRow| command. The optional argument |<row-sep>| allows you to define the space between the rows.
362 %
363 % \begin{minipage}[c]{0.49\linewidth}
364 % \begin{Chemscheme}
365 % \struct{maleimid}
366 % \RightArrow{\struct{cp}}{DEE}
367 % \struct[80\,\%]{product}
368 % \ChemschemeNextRow[10pt]
369 % \struct[80\,\%]{product}
370 % \LeftArrow{\struct{cp}}{DEE}
371 % \struct{maleimid}
372 % \end{Chemscheme}
373 % \end{minipage}
374 % \begin{minipage}[c]{0.5\linewidth}
375 %\begin{verbatim}
376 %\begin{Chemscheme}
377 % \struct{maleimid}
378 % \RightArrow{\struct{cp}}{DEE}
379 % \struct[80\,\%]{product}
380 % \ChemschemeNextRow[10pt]
381 % \struct[80\,\%]{product}
382 % \LeftArrow{\struct{cp}}{DEE}
383 % \struct{maleimid}
384 %\end{Chemscheme}
385 %\end{verbatim}
386 % \end{minipage}
387 %
388 % \begin{minipage}[c]{0.49\linewidth}
389 % \begin{Chemscheme}
390 % \struct{maleimid}
391 % \RightArrow{\struct{cp}}{DEE}
392 % \struct[80\,\%]{product}
393 % \end{Chemscheme}
394 % \begin{Chemscheme}
395 % \struct[80\,\%]{product}
396 % \LeftArrow{\struct{cp}}{DEE}
397 % \struct{maleimid}
398 % \end{Chemscheme}
399 % \end{minipage}
400 % \begin{minipage}[c]{0.5\linewidth}
401 %\begin{verbatim}
402 %\begin{Chemscheme}
403 % \struct{maleimid}
404 % \RightArrow{\struct{cp}}{DEE}
405 % \struct[80\,\%]{product}
406 %\end{Chemscheme}
407 %\begin{Chemscheme}
408 % \struct[80\,\%]{product}
409 % \LeftArrow{\struct{cp}}{DEE}
410 % \struct{maleimid}
411 %\end{Chemscheme}
412 %\end{verbatim}
413 % \end{minipage}
414 %
415 %
416 %
417 % \vspace{3ex}\noindent\DescribeMacro{\CSXcommands}
418 % |\CSXcommands{<TikZ-code>}|\vspace{0.5em}
419 %
420 % \noindent The |CSXcommands| macro allows you to draw any \TikZ{} element(s) after the typesetting of the structure matrix.
421 %
422 % \hspace{-30pt}\begin{minipage}[c]{0.39\linewidth}
423 % \begin{Chemscheme}
424 % \struct{maleimid}
425 % \RightArrow{\struct{cp}}{DEE}
426 % \Struct{1,2}{product}
427 % \CSXcommands{\draw[->,CSXallarrows,draw=red]
428 % (Scheme\theCSXscheme Caption3Entry1.west) to
429 % ([xshift=-8pt]Scheme\theCSXscheme Caption3Entry1.west) to
430 % node[auto,swap,CSXlabelfont,red]{a}
431 % ([xshift=-8pt]Scheme\theCSXscheme Caption3Entry2.west) to
432 % (Scheme\theCSXscheme Caption3Entry2.west);}
433 % \end{Chemscheme}
434 % \end{minipage}
435 % \begin{minipage}[c]{0.6\linewidth}
436 %\begin{verbatim}
437 %\begin{Chemscheme}
438 % \struct{maleimid}
439 % \RightArrow{\struct{cp}}{DEE}
440 % \Struct{1,2}{product}
441 % \CSXcommands{
442 % \draw[->,CSXallarrows,draw=red]
443 % (Scheme\theCSXscheme Caption3Entry1.west) to
444 % ([xshift=-8pt]Scheme\theCSXscheme Caption3Entry1.west) to
445 % node[auto,swap,CSXlabelfont,red]{a}
446 % ([xshift=-8pt]Scheme\theCSXscheme Caption3Entry2.west) to
447 % (Scheme\theCSXscheme Caption3Entry2.west);
448 % }
449 %\end{Chemscheme}
450 %\end{verbatim}
451 % \end{minipage}
452 %
453 %
454 %
455 % \newpage
456 % \subsection{Ref commands}
457 % \noindent\DescribeMacro{\structref}
458 % \noindent\DescribeMacro{\structref*}
459 % \noindent\DescribeMacro{\structsubref}
460 % \noindent\DescribeMacro{\structsubref-}
461 % \noindent\DescribeMacro{\structsubref*}
462 % |\structref[<fam>]{<img>}|\\
463 % |\structref*[<fam>]{<img>}|\\
464 % |\structsubref[<fam>]{<img>}{<sublabels>}|\\
465 % |\structsubref-[<fam>]{<img>}{<sublabels>}|\\
466 % |\structsubref*[<fam>]{<img>}{<sublabels>}|\vspace{0.5em}
467 %
468 % \noindent The \CSX{} package defines ref commands that actually do exactly what their analogs from the \FL{} package do, but with |CSX| as default family.\footnote{For further information please have a look into the \textsf{fancylabel} package documentation.}
469 %
470 %
471 %
472 % \vspace{3ex}\noindent\DescribeMacro{\CSXstructref}
473 % \noindent The |\CSXstructref| macro allows you to change the style of all referencing commands that are shown above. The definition is shown below and may be changed as required.
474 %\begin{verbatim}
475 % \newcommand{\CSXstructref}[1]{%
476 % % #1=fancyref command
477 % \textbf{#1}%
478 % }
479 %\end{verbatim}
480 %
481 %
482 % \subsection{Arrows and simples}
483 %
484 % \noindent\DescribeMacro{\customarrow}
485 % |\customarrow[<length>]{<style>}{<upper-capt>}{<lower-capt>}|\vspace{0.5em}
486 %
487 % \noindent The basic command for arrows is the |\customarrow| command. If the optional argument |<length>| is used, the arrow will have this length. Otherwise the arrow is stretched to the length of the widest caption advanced by the length globally defined via the |arrowadvance| option. The style argument |<style>| allows you to pass options to the \TikZ{} |\draw| command.\vspace{1em}
488 %
489 % \begin{minipage}{0.25\linewidth}
490 % \customarrow{->,line width=1pt}{this is a long caption}{short}
491 % \end{minipage}
492 % \begin{minipage}{0.74\linewidth}
493 % \begin{verbatim}
494 % \customarrow{->,line width=1pt}
495 % {this is a long caption}
496 % {short}
497 % \end{verbatim}
498 % \end{minipage}
499 %
500 % \begin{minipage}{0.25\linewidth}
501 % \customarrow[60pt]{->,CSXarrowupper/.append style={red}}{this is a long caption}{short}
502 % \end{minipage}
503 % \begin{minipage}{0.74\linewidth}
504 % \begin{verbatim}
505 % \customarrow[60pt]
506 % {->,CSXarrowupper/.append style={red}}
507 % {this is a long caption}
508 % {short}
509 % \end{verbatim}
510 % \end{minipage}
511 %
512 %
513 % \noindent\DescribeMacro{\RightArrow}
514 % \noindent\DescribeMacro{\<arrow-cmd>}
515 % |\RightArrow[<length>]{<upper-capt>}{<lower-capt>}|\\
516 % |\<arrow-cmd>[<length>]{<upper-capt>}{<lower-capt>}|\vspace{0.5em}
517 %
518 % \noindent The table below shows a couple of arrows that are based on the |\customarrow| command. You might define some other arrows using the |\CSXdeclarearrow| command.
519 %
520 % {
521 % \newcommand{\CSXarrowtablex}[2][60pt]{
522 % \CSXarrowtable[#1]{#2}
523 % \CSXarrowtable[#1]{C#2}
524 % \CSXarrowtable[#1]{S#2}
525 % \CSXarrowtable[#1]{DS#2}
526 % }
527 % \newcommand{\CSXarrowtable}[2][60pt]{
528 % \csname #2\endcsname[#1]{}{\textbackslash #2}
529 % }
530 % \def\CSXarrowadvance{0pt}
531 % \tikzset{%
532 % CSXarrowfont/.style={%
533 % font={\tiny\sffamily},%
534 % },%
535 % CSXmatrix/.style={%
536 % column sep=20pt,%
537 % row sep=5pt,%
538 % }%
539 % }
540 % \begin{Chemscheme}
541 % \CSXarrowtablex{RightArrow}\ChemschemeNextRow
542 % \CSXarrowtablex{RightArrowDashed}
543 % \end{Chemscheme}
544 %
545 % \noindent All shown arrows have a normal, a crossed out (leading |C|), a striked out (leading |S|) and a double striked out (leading |DS|) version of the solid and the dashed (appending |Dashed|) arrow.
546 %
547 % \begin{Chemscheme}
548 % \CSXarrowtable{RightArrow}
549 % \CSXarrowtable{LeftArrow}
550 % \CSXarrowtable{LeftRightArrow}\ChemschemeNextRow
551 % \CSXarrowtable{DoubleRightArrow}
552 % \CSXarrowtable{DoubleLeftArrow}
553 % \CSXarrowtable{DoubleLeftRightArrow}\ChemschemeNextRow
554 % \CSXarrowtable{RightupHarpoon}
555 % \CSXarrowtable{RightdownHarpoon}
556 % \CSXarrowtable{LeftupHarpoon}
557 % \CSXarrowtable{LeftdownHarpoon}\ChemschemeNextRow
558 % \CSXarrowtable{LeftupRightupHarpoon}
559 % \CSXarrowtable{LeftupRightdownHarpoon}
560 % \CSXarrowtable{LeftdownRightupHarpoon}
561 % \CSXarrowtable{LeftdownRightdownHarpoon}\ChemschemeNextRow
562 % \CSXarrowtable{Equilibrium}
563 % \CSXarrowtable{RightEquilibrium}
564 % \CSXarrowtable{RRightEquilibrium}
565 % \CSXarrowtable{LeftEquilibrium}
566 % \CSXarrowtable{LLeftEquilibrium}\ChemschemeNextRow
567 % \CSXarrowtable{TwoRightArrow}
568 % \CSXarrowtable{TTwoRightArrow}
569 % \CSXarrowtable{TwoLeftArrow}
570 % \CSXarrowtable{TTwoLeftArrow}\ChemschemeNextRow
571 % \CSXarrowtable{ThreeRightArrow}
572 % \CSXarrowtable{TThreeRightArrow}
573 % \CSXarrowtable{ThreeLeftArrow}
574 % \CSXarrowtable{TThreeLeftArrow}
575 % \end{Chemscheme}
576 % }
577 %
578 %
579 % \vspace{3ex}\noindent\DescribeMacro{\CSXdeclarearrow}
580 % |\CSXdeclarearrow{<arrow-cmd>}{<style>}|\vspace{0.5em}
581 %
582 % \noindent You can use the |\CSXdeclarearrow| command to declare arrows based on the customstruct command. The definition of |\RightArrow| is:
583 %
584 % \begin{verbatim}
585 % \CSXdeclarearrow{\RightArrow}{CSXnormalarrows,CSXRightArrow}
586 % \end{verbatim}
587 %
588 % \noindent Considering the default setting of |CSXnormalarrows| and |CSXRightArrow| this means:
589 %
590 % \begin{verbatim}
591 % \CSXdeclarearrow{\RightArrow}{line width=0.7pt,->}
592 % \end{verbatim}
593 %
594 %
595 % \noindent\DescribeMacro{\structplus}
596 % \noindent\DescribeMacro{\structminus}
597 % |\structplus|\\
598 % |\structminus|\vspace{0.5em}
599 %
600 % \noindent The simples (this is how I call arrow-like elements without a upper or lower caption) |\structplus| and |\structminus| can be used like any structure or arrow command:
601 %
602 % \begin{minipage}{0.59\linewidth}
603 % \begin{Chemscheme}
604 % \struct{maleimid}
605 % \structplus
606 % \struct{cp}
607 % \RightArrow{}{DEE}
608 % \struct{product}
609 % \end{Chemscheme}
610 % \end{minipage}
611 % \begin{minipage}{0.35\linewidth}
612 % \begin{verbatim}
613 % \begin{Chemscheme}
614 % \struct{maleimid}
615 % \structplus
616 % \struct{cp}
617 % \RightArrow{}{DEE}
618 % \struct{product}
619 % \end{Chemscheme}
620 % \end{verbatim}
621 % \end{minipage}
622 %
623 %
624 %
625 %
626 % \section{Options}
627 % \subsection{The image option}\label{image}
628 % \noindent\DescribeMacro{image=}
629 % |\usepackage[image={<global-img-opt>}]{chemschemex}|\vspace{0.5em}
630 %
631 % \noindent All structure commands except |\customstruct| internally use the |\CSXimage| command to include pictures with |\includegraphics|. The |image| option allows you to define options that will be passed to any image that is inserted via |\CSXimage|. The default value is |image={scale=0.7}|.
632 %
633 %
634 % \subsection{The labelseparator option}
635 % \noindent\DescribeMacro{labelseparator=}
636 % |\usepackage[labelseparator=<value>]{chemschemex}|\vspace{0.5em}
637 %
638 % \noindent The |<value>| given by the |labelseparator| option is set behind every |\fancylabel| inside a structure command if some text follows. The value is saved in |\CSXlabelsep|. The default value is |labelseparator={:\,}|.
639 %
640 %\begin{Chemscheme}
641 % \struct[text]{maleimid}
642 % \CSXcommands{%
643 % \draw[<-,draw=red]([xshift=-2pt]Scheme\theCSXscheme Caption1Entry1.one split south)%
644 % to ([xshift=-2pt,yshift=-10pt]Scheme\theCSXscheme Caption1Entry1.one split south) node[yshift=-3pt,font={\tiny\sffamily}]{\textcolor{red}{labelseparator}};
645 % }
646 %\end{Chemscheme}
647 %
648 %
649 %
650 %
651 % \subsection{The arrowadvance option}
652 % \noindent\DescribeMacro{arrowadvance=}
653 % |\usepackage[arrowadvance=<length>]{chemschemex}|\vspace{0.5em}
654 %
655 % \noindent Every arrow with undefined length argument will be as long as its widest caption plus the length given by the |arrowadvance| option. This is also the minimal length of an arrow (when no captions are given). The default value is |arrowadvance=10pt|.
656 %
657 %
658 %
659 %
660 % \section{Customization and advanced examples}
661 % \subsection{Predefined \TikZ{} styles}\label{custom}
662 %
663 % \noindent There are a lot of \TikZ{} styles that are already defined by the \CSX{} package. The following two examples show the code that is generated by \CSX{} and hopefully help you to understand the function of each style. Some of them can be changed (\textcolor{green!75!black}{green}), some of them must not be changed (\textcolor{red}{red}) to prevent strange results or even errors. If you want to change fonts please use the \textcolor{blue}{blue} coloured styles instead of appending |font=| to any style since this will cause wrong calculations. The \textcolor{orange}{orange} entries are styles that are optional arguments of |\customstruct|.
664 %
665 % \begin{minipage}{0.16\linewidth}
666 % \customstruct{{{text}}}{\CSXimage{maleimid}}
667 % \end{minipage}
668 % \begin{minipage}{0.7\linewidth}
669 % \begin{verbatim}
670 % \customstruct{{{text}}}{\CSXimage{maleimid}}
671 % \end{verbatim}
672 % \end{minipage}
673 %
674 % \newcommand{\textred}[1]{\textcolor{red}{#1}}
675 % \newcommand{\textblue}[1]{\textcolor{blue}{#1}}
676 % \newcommand{\textorange}[1]{\textcolor{orange}{#1}}
677 % \newcommand{\textgreen}[1]{\textcolor{green!75!black}{#1}}
678 % \begin{Verbatim}[gobble=1,fontsize=\small,commandchars=!*~]
679 %\begin{tikzpicture}[!textgreen*CSX~]
680 % \matrix [!textgreen*CSXmatrix~]{
681 % % Image row
682 % \node[!textorange*<TikZ-obj>~]
683 % (Scheme1Image1)
684 % {\CSXimage{maleimid}};\\
685 % % Caption row
686 % \node(Scheme1Caption1)
687 % {\tikz[!textgreen*CSXcaption~,!textorange*<TikZ-capt>~]
688 % {\node[!textblue*CSXtextfont~,!textred*CSXsettextwidth~,!textgreen*CSXcaptionTextOnly~]
689 % (Scheme1Caption1Entry1)
690 % {text};
691 % }
692 % };\\
693 % };
694 %\end{tikzpicture}
695 % \end{Verbatim}
696 %
697 %
698 %
699 % \vspace{3ex}\begin{minipage}{0.42\linewidth}
700 % \begin{Chemscheme}
701 % \customstruct{{{text}}}{\CSXimage{maleimid}}
702 % \RightArrow{\customstruct{{{1},{}}}{\CSXimage{cp}}}{DEE}
703 % \customstruct{{{label 1},{text 1}},
704 % {{label 2},{text 2}},
705 % {text 3}}
706 % {\CSXimage{product}}
707 % \end{Chemscheme}
708 % \end{minipage}
709 % \begin{minipage}{0.56\linewidth}
710 % \begin{verbatim}
711 % \begin{Chemscheme}
712 % \customstruct{{{text}}}{\CSXimage{maleimid}}
713 % \RightArrow{\customstruct{{{1},{}}}
714 % {\CSXimage{cp}}}{DEE}
715 % \customstruct{{{label 1},{text 1}},
716 % {{label 2},{text 2}},
717 % {text 3}}
718 % {\CSXimage{product}}
719 % \end{Chemscheme}
720 % \end{verbatim}
721 % \end{minipage}
722 %
723 % \begin{Verbatim}[gobble=1,fontsize=\small,commandchars=!*~]
724 %\begin{tikzpicture}[!textgreen*CSX~]
725 % \matrix [!textgreen*CSXmatrix~]{
726 % % Image row
727 % \node[!textorange*<TikZ-obj>~]
728 % (Scheme1Image1)
729 % {\CSXimage{maleimid}};&
730 % \node(Scheme1Image2)
731 % {\hbox to <arrowlength>{}};&
732 % \node[!textorange*<TikZ-obj>~]
733 % (Scheme1Image3)
734 % {\CSXimage{product}};\\
735 % % Caption row
736 % \node(Scheme1Caption1)
737 % {\tikz[!textgreen*CSXcaption~,!textorange*<TikZ-capt>~]
738 % {\node[!textblue*CSXtextfont~,!textred*CSXsettextwidth~,!textgreen*CSXcaptionTextOnly~]
739 % (Scheme1Caption1Entry1)
740 % {text};
741 % }
742 % };&
743 % \node(Scheme1Caption2)
744 % {};&
745 % \node(Scheme1Caption3)
746 % {\tikz[!textgreen*CSXcaption~,!textorange*<TikZ-capt>~]
747 % {\node[!textblue*CSXlabelfont~,!textred*CSXsetlabelwidth~,!textgreen*CSXcaptionLabelandText~,
748 % rectangle split,rectangle split horizontal,
749 % rectangle split parts=2,rectangle split part align=base,
750 % every two node part/.style={!textblue*CSXtextfont~,!textred*CSXsettextwidth~}]
751 % (Scheme1Caption3Entry1)
752 % {label 1\nodepart{two}text 1};
753 % \node[!textblue*CSXlabelfont~,!textred*CSXsetlabelwidth~,!textgreen*CSXcaptionLabelandText~,
754 % rectangle split,rectangle split horizontal,
755 % rectangle split parts=2,rectangle split part align=base,
756 % every two node part/.style={!textblue*CSXtextfont~,!textred*CSXsettextwidth~}
757 % below left=of Scheme1Caption3Entry1.one split south,
758 % anchor=one split north]
759 % (Scheme1Caption3Entry2)
760 % {label 2\nodepart{two}text 2};
761 % \node[!textblue*CSXtextfont~,!textred*CSXsettextwidth~,!textgreen*CSXcaptionTextOnly~%
762 % below=of Scheme1Caption3Entry2.south]
763 % (Scheme1Caption3Entry3)
764 % {text 3};
765 % }
766 % };\\
767 % };
768 % \draw[!textgreen*CSXallarrows~,CSXRightArrow,text width=(<arrowlength>-\CSXarrowadvance)]
769 % ([CSXshiftA]Scheme1Image2.west) to
770 % node(Scheme1Image2Upper)
771 % [!textblue*CSXarrowfont~,!textgreen*CSXarrowupper~,auto]
772 % {\tikz[remember picture,!textgreen*CSXStructInArrow~]
773 % {\node[!textorange*<TikZ-obj>~]
774 % (Scheme1Image2UpperImage1)
775 % {\CSXimage{cp}};
776 % \node[below=of Scheme1Image2UpperImage1]
777 % (Scheme1Image2UpperCaption1)
778 % {\tikz[CSXcaption,!textorange*<TikZ-capt>~]
779 % {\node[!textblue*CSXlabelfont~,!textred*CSXsetlabelwidth~,
780 % !textgreen*CSXcaptionLabelandText~,rectangle split,
781 % rectangle split horizontal,
782 % rectangle split parts=2,
783 % rectangle split part align=base,
784 % every two node part/.style={
785 % !textblue*CSXtextfont~,
786 % !textred*CSXsettextwidth~
787 % }]
788 % (Scheme1Image2UpperCaption1Entry1)
789 % {1\nodepart{two}};
790 % }
791 % };
792 % }
793 % }
794 % node(Scheme1Image2Lower)
795 % [!textblue*CSXarrowfont~,!textgreen*CSXarrowlower~,auto,swap]
796 % {DEE}
797 % ([CSXshiftB]Scheme1Image2.east);
798 %\end{tikzpicture}
799 % \end{Verbatim}
800 %
801 % \subsection{Style adjustment -- some examples}
802 %
803 % \noindent As already mentioned above, please use the styles \textblue{|CSXlabelfont|} and \textblue{|CSXtextfont|} for any changes of the node font. This is necessary to ensure correct measurements. For local font adjustment of captions in structure commands use the optional argument \textorange{|<TikZ-capt>|}.
804 %
805 % \begin{minipage}{0.15\linewidth}
806 % \struct[text]{maleimid}
807 % \end{minipage}
808 % \begin{minipage}{0.75\linewidth}
809 % \begin{Verbatim}[gobble=1,fontsize=\small]
810 %\struct[text]{maleimid}
811 % \end{Verbatim}
812 % \end{minipage}
813 %
814 % \begin{minipage}{0.15\linewidth}
815 % \struct[text][][][CSXlabelfont/.style={red,font={\large}}]{maleimid}
816 % \end{minipage}
817 % \begin{minipage}{0.75\linewidth}
818 % \begin{Verbatim}[gobble=1,fontsize=\small]
819 %\struct[text]
820 % []
821 % []
822 % [CSXlabelfont/.style={red,font={\large}}]
823 % {maleimid}
824 % \end{Verbatim}
825 % \end{minipage}
826 %
827 % \begin{minipage}{0.15\linewidth}
828 % \struct[text][][][nodes={draw=green},CSXtextfont/.style={blue,font={\large}}]{maleimid}
829 % \end{minipage}
830 % \begin{minipage}{0.75\linewidth}
831 % \begin{Verbatim}[gobble=1,fontsize=\small]
832 %\struct[text]
833 % []
834 % []
835 % [nodes={draw=green},
836 % CSXtextfont/.style={blue,font={\large}}]
837 % {maleimid}
838 % \end{Verbatim}
839 % \end{minipage}
840 %
841 % \begin{minipage}{0.15\linewidth}
842 % \struct[][][scale=1.5][][draw=red]{maleimid}
843 % \end{minipage}
844 % \begin{minipage}{0.75\linewidth}
845 % \begin{Verbatim}[gobble=1,fontsize=\small]
846 %\struct[][][scale=1.5][][draw=red]{maleimid}
847 % \end{Verbatim}
848 % \end{minipage}
849 %
850 %
851 % \subsection{Chemical mechanisms}
852 % \noindent For more complex chemical mechanisms you can either use the matrix provided by the |Chemscheme| environment or the internal commands |\CSXimage| and |\fancylabel|:
853 %
854 % {
855 %\tikzset{
856 % CSXmatrix/.append style={
857 % column sep=30pt,
858 % }
859 %}
860 % \begin{Chemscheme}
861 % \struct{R2-CH=CH-R1}
862 % \struct{Ru=CH2}
863 % \struct{R1-CH=CH2}\ChemschemeNextRow[20pt]
864 % \struct{CH2=CH-R2}
865 % \struct{Ru=CH-R1}
866 % \struct{C2H4}
867 % \CSXcommands{
868 % \draw[->,draw=blue] (Scheme\theCSXscheme Image4)
869 % to [bend right=90,distance=22pt] (Scheme\theCSXscheme Image1);
870 % \draw[->,draw=red] (Scheme\theCSXscheme Image5)
871 % to [bend right=-90,distance=22pt] (Scheme\theCSXscheme Image2);
872 % \draw[->,draw=orange] (Scheme\theCSXscheme Image2)
873 % to [bend right=-90,distance=22pt] (Scheme\theCSXscheme Image5);
874 % \draw[->,draw=green!75!black] (Scheme\theCSXscheme Image3)
875 % to [bend right=90,distance=22pt] (Scheme\theCSXscheme Image6);
876 % }
877 % \end{Chemscheme}
878 % }
879 %
880 % \begin{Verbatim}[gobble=1,fontsize=\small,commandchars=?*~]
881 %\tikzset{CSXmatrix/.append style={column sep=30pt}}
882 %\begin{Chemscheme}
883 % \struct{R2-CH=CH-R1}
884 % \struct{Ru=CH2}
885 % \struct{R1-CH=CH2}\ChemschemeNextRow[20pt]
886 % \struct{CH2=CH-R2}
887 % \struct{Ru=CH-R1}
888 % \struct{C2H4}
889 % \CSXcommands{
890 % \draw[->,?textblue*draw=blue~] (Scheme\theCSXscheme Image4)
891 % to [bend right=90,distance=22pt] (Scheme\theCSXscheme Image1);
892 % \draw[->,?textred*draw=red~] (Scheme\theCSXscheme Image5)
893 % to [bend right=-90,distance=22pt] (Scheme\theCSXscheme Image2);
894 % \draw[->,?textorange*draw=orange~] (Scheme\theCSXscheme Image2)
895 % to [bend right=-90,distance=22pt] (Scheme\theCSXscheme Image5);
896 % \draw[->,?textgreen*draw=green!75!black~] (Scheme\theCSXscheme Image3)
897 % to [bend right=90,distance=22pt] (Scheme\theCSXscheme Image6);
898 % }
899 %\end{Chemscheme}
900 % \end{Verbatim}
901 %
902 % \tikz[node distance=1pt,mycaption/.style={CSXlabelfont}]{
903 % \node (n) at (0,2){\CSXimage{Ru=CH2}};
904 % \node (ncapt) [mycaption,below=of n] {\fancylabel[CSX]{Ru=CH2}};
905 % \node (s) at (0,-2){\CSXimage{Ru=CH-R1}};
906 % \node (scapt) [mycaption,below=of s] {\fancylabel[CSX]{Ru=CH-R1}};
907 % \node (nw) at (-4,1){\CSXimage{R2-CH=CH-R1}};
908 % \node (nwcapt) [mycaption,below=of nw] {\fancylabel[CSX]{R2-CH=CH-R1}};
909 % \node (sw) at (-4,-1){\CSXimage{CH2=CH-R2}};
910 % \node (swcapt) [mycaption,below=of sw] {\fancylabel[CSX]{CH2=CH-R2}};
911 % \node (ne) at (4,1){\CSXimage{R1-CH=CH2}};
912 % \node (necapt) [mycaption,below=of ne] {\fancylabel[CSX]{R1-CH=CH2}};
913 % \node (se) at (4,-1){\CSXimage{C2H4}};
914 % \node (ecapt) [mycaption,below=of se] {\fancylabel[CSX]{C2H4}};
915 % \node (w) at (-2.5,0) {};
916 % \node (e) at (2.5,0) {};
917 % \draw [->] (s) to [out=180,in=270] (w) to [out=90,in=180] (n);
918 % \draw [->] (n) to [out=0,in=90] (e) to [out=270,in=0] (s);
919 % \draw [->] (sw) to [out=0,in=270] (w) to [out=90,in=0] (nw);
920 % \draw [->] (ne) to [out=180,in=90] (e) to [out=270,in=180] (se);
921 % }
922 %
923 % \begin{Verbatim}[gobble=1,fontsize=\small,commandchars=?*~]
924 % \tikz[node distance=1pt,mycaption/.style={CSXlabelfont}]{
925 % \node (n) at (0,2){\CSXimage{Ru=CH2}};
926 % \node (ncapt) [mycaption,below=of n] {\fancylabel[CSX]{Ru=CH2}};
927 % \node (s) at (0,-2){\CSXimage{Ru=CH-R1}};
928 % \node (scapt) [mycaption,below=of s] {\fancylabel[CSX]{Ru=CH-R1}};
929 % \node (nw) at (-4,1){\CSXimage{R2-CH=CH-R1}};
930 % \node (nwcapt) [mycaption,below=of nw] {\fancylabel[CSX]{R2-CH=CH-R1}};
931 % \node (sw) at (-4,-1){\CSXimage{CH2=CH-R2}};
932 % \node (swcapt) [mycaption,below=of sw] {\fancylabel[CSX]{CH2=CH-R2}};
933 % \node (ne) at (4,1){\CSXimage{R1-CH=CH2}};
934 % \node (necapt) [mycaption,below=of ne] {\fancylabel[CSX]{R1-CH=CH2}};
935 % \node (se) at (4,-1){\CSXimage{C2H4}};
936 % \node (ecapt) [mycaption,below=of se] {\fancylabel[CSX]{C2H4}};
937 % \node (w) at (-2.5,0) {};
938 % \node (e) at (2.5,0) {};
939 % \draw [->] (s) to [out=180,in=270] (w) to [out=90,in=180] (n);
940 % \draw [->] (n) to [out=0,in=90] (e) to [out=270,in=0] (s);
941 % \draw [->] (sw) to [out=0,in=270] (w) to [out=90,in=0] (nw);
942 % \draw [->] (ne) to [out=180,in=90] (e) to [out=270,in=180] (se);
943 % }
944 % \end{Verbatim}
945 %
946 % \section{Change history}
947 % \begin{itemize}
948 % \item[2014/07/15] Initial version
949 % \item[2017/04/03] Bug within the \textbackslash Struct command fixed
950 % \item[2018/01/20] Dependencies changed (\textsf{xifthen} instead of \textsf{ifthen}, \textsf{etoolbox} instead of \textsf{etextools}). Loading \textsf{etextools} caused compatibility issues with some other packages.
951 % \end{itemize}
952 %
953 % \StopEventually{}
954 %
955 % \section{The implementation}
956 % \subsection{Identification}
957 % \begin{macrocode}
958 \NeedsTeXFormat{LaTeX2e}[2005/12/01]
959 \ProvidesPackage{chemschemex}[2018/01/20 v1.2 Typeset chemical schemes]
960 % \end{macrocode}
961 %
962 % \subsection{Loading packages and define counter formats}
963 % \begin{macrocode}
964 \NeedsTeXFormat{LaTeX2e}[2005/12/01]
965 \ProvidesPackage{chemschemex}[2017/04/03 v1.1.1 Typeset chemical schemes]
966 \RequirePackage{xkeyval}
967 \RequirePackage{etoolbox}
968 \RequirePackage{xargs}
969 \RequirePackage{xifthen}
970 \RequirePackage{suffix}
971 \RequirePackage{fancylabel}
972 \fancyref@DefineFamily{}{CSX}
973 \def\fancylabelformatCSX{\arabic{fancylabel}}
974 \def\fancysublabelformatCSX{\arabic{fancylabel}\alph{fancysublabel}}
975 \def\fancyonlysublabelformatCSX{\alph{fancysublabel}}
976 \RequirePackage{graphicx}
977 \RequirePackage{tikz}
978 \usetikzlibrary{%
979 shapes.multipart,%
980 decorations,%
981 decorations.markings,%
982 positioning,%
983 arrows.meta%
984 }
985 % \end{macrocode}
986 %
987 % \subsection{The options}
988 % \begin{macro}{image=}
989 % \begin{macrocode}
990 \define@key{chemschemex}{image}{%
991 % #1=additional options
992 % #2=filename of the image
993 \newcommand{\CSXimage}[2][]{%
994 \includegraphics[#1,##1]{##2}%
995 }%
996 }
997 % \end{macrocode}
998 % \end{macro}
999 % \begin{macro}{labelseparator=}
1000 % \begin{macrocode}
1001 \define@key{chemschemex}{labelseparator}{%
1002 \def\CSXlabelsep{#1}%
1003 }
1004 % \end{macrocode}
1005 % \end{macro}
1006 % \begin{macro}{arrowadvance=}
1007 % \begin{macrocode}
1008 \define@key{chemschemex}{arrowadvance}{%
1009 \def\CSXarrowadvance{#1}%
1010 }
1011 % \end{macrocode}
1012 % \end{macro}
1013 % \begin{macrocode}
1014 \presetkeys{chemschemex}{%
1015 image={scale=0.7},%
1016 labelseparator={:\,},%
1017 arrowadvance={10pt},%
1018 }{}
1019 \ProcessOptionsX<chemschemex>
1020 % \end{macrocode}
1021 % \subsection{TikZ styles}
1022 % \begin{macrocode}
1023 % TikZ styles that must not be changed
1024 \tikzset{%
1025 CSXsettextwidth/.style={%
1026 text width=(%
1027 % if
1028 (\CSXtextwidth - \CSXimagewidth - \CSXmaxlabelwidth)>0%
1029 % then
1030 ?(\CSXimagewidth - \CSXmaxlabelwidth)%
1031 % else
1032 :(\CSXtextwidth+0.00001)%
1033 ),%
1034 },%
1035 CSXsetlabelwidth/.style={%
1036 text width=(%
1037 % if
1038 (\CSXlabelwidth)>0%
1039 % then
1040 ?(\CSXlabelwidth+0.00001)%
1041 % else
1042 :(0.00001)%
1043 ),%
1044 },%
1045 CSXshiftA/.style={},%
1046 CSXshiftB/.style={},%
1047 CSXshiftcompensation/.style={},%
1048 }
1049 % TikZ styles that can be changed
1050 \tikzset{%
1051 % TikZ
1052 CSX/.style={%
1053 remember picture%
1054 },%
1055 % Matrix
1056 CSXmatrix/.style={%
1057 column sep=10pt,%
1058 row sep=4pt,%
1059 nodes={%
1060 inner xsep=0pt,%
1061 inner ysep=1pt,%
1062 outer sep=0pt%
1063 },%
1064 every odd row/.style={anchor=center},%
1065 every even row/.style={anchor=north},%
1066 },%
1067 % Structure caption
1068 CSXcaption/.style={%
1069 node distance=0pt,%
1070 },%
1071 CSXcaptionLabelandText/.style={%
1072 align=right,%
1073 every two node part/.style={%
1074 align=justify%
1075 },%
1076 },%
1077 CSXcaptionTextOnly/.style={%
1078 align=justify%
1079 },%
1080 % Fonts
1081 CSXlabelfont/.style={%
1082 font={\footnotesize\sffamily\bfseries}%
1083 },%
1084 CSXtextfont/.style={%
1085 font={\footnotesize\sffamily}%
1086 },%
1087 CSXarrowfont/.style={%
1088 font={\footnotesize\sffamily}%
1089 },%
1090 CSXsimple/.style={%
1091 x=3pt,%
1092 y=3pt,%
1093 line width=0.7pt%
1094 },%
1095 % Arrows
1096 CSXarrowupper/.style={%
1097 align=flush center,%
1098 },%
1099 CSXarrowlower/.style={%
1100 align=flush center%
1101 },%
1102 CSXStructInArrow/.style={%
1103 node distance=1pt,%
1104 text width=,%
1105 inner sep=0pt,%
1106 outer sep=0pt%
1107 },%
1108 CSXallarrows/.style={%
1109 x=1pt,y=1pt,%
1110 line width=0.7,%
1111 inner ysep=3,%
1112 >=Classical TikZ Rightarrow,%
1113 },%
1114 CSXdoublearrows/.style={%
1115 double distance=1.5,%
1116 >=Implies%
1117 },%
1118 CSXharpoonup/.style={%
1119 >={Classical TikZ Rightarrow[harpoon]}%
1120 },%
1121 CSXharpoondown/.style={%
1122 >={Classical TikZ Rightarrow[harpoon,swap]}%
1123 },%
1124 CSXRightArrow/.style={%
1125 ->%
1126 },%
1127 CSXRightupHarpoon/.style={%
1128 ->[harpoon]%
1129 },%
1130 CSXRightdownHarpoon/.style={%
1131 ->[{harpoon,swap}]%
1132 },%
1133 CSXLeftArrow/.style={%
1134 <-%
1135 },%
1136 CSXLeftupHarpoon/.style={%
1137 <[{harpoon,swap}]-%
1138 },%
1139 CSXLeftdownHarpoon/.style={%
1140 <[harpoon]-%
1141 },%
1142 CSXLeftRightArrow/.style={%
1143 <->%
1144 },%
1145 CSXLeftupRightupHarpoon/.style={%
1146 <[{harpoon,swap}]->[harpoon]%
1147 },%
1148 CSXLeftupRightdownHarpoon/.style={%
1149 <[{harpoon,swap}]->[{harpoon,swap}]%
1150 },%
1151 CSXLeftdownRightupHarpoon/.style={%
1152 <[{harpoon}]->[{harpoon}]%
1153 },%
1154 CSXLeftdownRightdownHarpoon/.style={%
1155 <[{harpoon}]->[{harpoon,swap}]%
1156 },%
1157 CSXequilibrium/.style={%
1158 inner ysep/.expanded=(1+\pgfkeysvalueof{/pgf/inner ysep}),%
1159 CSXshiftA/.style={yshift=1},%
1160 CSXshiftB/.style={yshift=1},%
1161 CSXshiftcompensation/.style={yshift=-1},%
1162 postaction=decorate,%
1163 decoration={%
1164 markings,%
1165 mark=at position 0.5 with{%
1166 \draw([yshift=-1]\CSXnodename .east) to%
1167 ([yshift=-1]\CSXnodename .west);%
1168 }%
1169 }%
1170 },%
1171 CSXRightequilibrium/.style={%
1172 inner ysep/.expanded=(1+\pgfkeysvalueof{/pgf/inner ysep}),%
1173 CSXshiftA/.style={yshift=1},%
1174 CSXshiftB/.style={yshift=1},%
1175 CSXshiftcompensation/.style={yshift=-1},%
1176 postaction=decorate,%
1177 decoration={%
1178 markings,%
1179 mark=at position 0.5 with{%
1180 \draw([yshift=-1,xshift=-0.25\CSXarrowlength]\CSXnodename .east) to%
1181 ([yshift=-1,xshift=0.25\CSXarrowlength]\CSXnodename .west);%
1182 }%
1183 }%
1184 },%
1185 CSXLeftequilibrium/.style={%
1186 inner ysep/.expanded=(1+\pgfkeysvalueof{/pgf/inner ysep}),%
1187 CSXshiftA/.style={yshift=1,xshift=0.25\CSXarrowlength},%
1188 CSXshiftB/.style={yshift=1,xshift=-0.25\CSXarrowlength},%
1189 CSXshiftcompensation/.style={yshift=-1},%
1190 postaction=decorate,%
1191 decoration={%
1192 markings,%
1193 mark=at position 0.5 with{%
1194 \draw([yshift=-1]\CSXnodename .east) to%
1195 ([yshift=-1]\CSXnodename .west);%
1196 }%
1197 }%
1198 },%
1199 CSXslashtwoarrow/.style={%
1200 inner ysep/.expanded=(1.5+\pgfkeysvalueof{/pgf/inner ysep}),%
1201 CSXshiftA/.style={yshift=1.5,xshift=5},%
1202 CSXshiftB/.style={yshift=1.5},%
1203 CSXshiftcompensation/.style={yshift=-1.5,xshift=-2.5},%
1204 postaction=decorate,%
1205 decoration={%
1206 markings,%
1207 mark=at position 0.5 with{%
1208 \draw([yshift=-1.5]\CSXnodename .west) to%
1209 ([yshift=-1.5,xshift=-5]\CSXnodename .east);%
1210 }%
1211 }%
1212 },%
1213 CSXbackslashtwoarrow/.style={%
1214 inner ysep/.expanded=(1.5+\pgfkeysvalueof{/pgf/inner ysep}),%
1215 CSXshiftA/.style={yshift=1.5},%
1216 CSXshiftB/.style={yshift=1.5,xshift=-5},%
1217 CSXshiftcompensation/.style={yshift=-1.5,xshift=2.5},%
1218 postaction=decorate,%
1219 decoration={%
1220 markings,%
1221 mark=at position 0.5 with{%
1222 \draw([yshift=-1.5,xshift=5]\CSXnodename .west) to%
1223 ([yshift=-1.5]\CSXnodename .east);%
1224 }%
1225 }%
1226 },%
1227 CSXslashthreearrow/.style={%
1228 inner ysep/.expanded=(3+\pgfkeysvalueof{/pgf/inner ysep}),%
1229 CSXshiftA/.style={xshift=5},%
1230 CSXshiftB/.style={xshift=-5},%
1231 CSXshiftcompensation/.style={x=1.4,y=1.4},%
1232 postaction=decorate,%
1233 decoration={%
1234 markings,%
1235 mark=at position 0.5 with{%
1236 \draw([yshift=3,xshift=10]\CSXnodename .west) to%
1237 ([yshift=3]\CSXnodename .east);%
1238 \draw([yshift=-3]\CSXnodename .west) to%
1239 ([yshift=-3,xshift=-10]\CSXnodename .east);%
1240 }%
1241 }%
1242 },%
1243 CSXbackslashthreearrow/.style={%
1244 inner ysep/.expanded=(3+\pgfkeysvalueof{/pgf/inner ysep}),%
1245 CSXshiftA/.style={xshift=5},%
1246 CSXshiftB/.style={xshift=-5},%
1247 CSXshiftcompensation/.style={x=1.4,y=1.4},%
1248 postaction=decorate,%
1249 decoration={%
1250 markings,%
1251 mark=at position 0.5 with{%
1252 \draw([yshift=3]\CSXnodename .west) to%
1253 ([yshift=3,xshift=-10]\CSXnodename .east);%
1254 \draw([yshift=-3,xshift=10]\CSXnodename .west) to%
1255 ([yshift=-3]\CSXnodename .east);%
1256 }%
1257 }%
1258 },%
1259 CSXCrossArrow/.style={%
1260 inner ysep/.expanded=1.5+\pgfkeysvalueof{/pgf/inner ysep},%
1261 postaction=decorate,%
1262 decoration={%
1263 markings,%
1264 mark=at position 0.5 with{%
1265 \draw[-,solid,CSXshiftcompensation](-3,-3)--(3,3);%
1266 \draw[-,solid,CSXshiftcompensation](3,-3)--(-3,3);%
1267 }%
1268 }%
1269 },%
1270 CSXStrikeArrow/.style={%
1271 inner ysep/.expanded=2+\pgfkeysvalueof{/pgf/inner ysep},%
1272 postaction=decorate,%
1273 decoration={%
1274 markings,%
1275 mark=at position 0.5 with{%
1276 \draw[-,solid,CSXshiftcompensation](-2,-3.5)--(2, 3.5);%
1277 }%
1278 }%
1279 },%
1280 CSXDStrikeArrow/.style={%
1281 inner ysep/.expanded=2+\pgfkeysvalueof{/pgf/inner ysep},%
1282 postaction=decorate,%
1283 decoration={%
1284 markings,%
1285 mark=at position 0.5 with{%
1286 \draw[-,solid,xshift=-2,CSXshiftcompensation](-2,-3.5)--(2, 3.5);%
1287 \draw[-,solid,xshift=2,CSXshiftcompensation](-2,-3.5)--(2, 3.5);%
1288 }%
1289 }%
1290 }%
1291 }
1292 % \end{macrocode}
1293 % \subsection{Booleans, Lengths and Counters}
1294 % \begin{macrocode}
1295 % Booleans
1296 \newif\ifCSX@scheme\CSX@schemefalse % Is true, if the struct appears in a Chemscheme environment
1297 \newif\ifCSX@generate@@@caption@ % Is needed to get label and text out of the caption passed to customstruct
1298 \newif\ifCSX@generate@@@caption@LastEntryWasTextOnly % Is needed to detect text-only caption entries
1299 % Lengths
1300 \newlength{\CSXimagewidth}\setlength{\CSXimagewidth}{0pt}
1301 \newlength{\CSXlabelwidth}\setlength{\CSXlabelwidth}{0pt}
1302 \newlength{\CSXmaxlabelwidth}\setlength{\CSXmaxlabelwidth}{0pt}
1303 \newlength{\CSXtextwidth}\setlength{\CSXtextwidth}{0pt}
1304 \newlength{\CSXmaxtextwidth}\setlength{\CSXmaxtextwidth}{0pt}
1305 \newlength{\CSXarrowlength}\setlength{\CSXarrowlength}{0pt}
1306 % Counters
1307 \newcounter{CSXscheme}\setcounter{CSXscheme}{1}
1308 \newcounter{CSXstruct}\setcounter{CSXstruct}{0}
1309 \newcounter{CSXstructinarrow}\setcounter{CSXstructinarrow}{0}
1310 \newcounter{CSXcaption}\setcounter{CSXcaption}{0}
1311 % \end{macrocode}
1312 % \subsection{User macros}
1313 % \begin{macro}{\newstruct}
1314 % \begin{macrocode}
1315 \def\CSX@structlist@filenamesorted{}
1316 \newcommand{\newstruct}[5][]{%
1317 % #1=comma-separated list of subcaptions
1318 % #2=filename
1319 % #3=structname
1320 % #4=Structname
1321 % #5=abbreviation
1322 \@ifundefined{CSX@newstruct@#2@structname}{%
1323 \global\@namedef{CSX@newstruct@#2@structname}{#3}%
1324 \global\@namedef{CSX@newstruct@#2@Structname}{#4}%
1325 \global\@namedef{CSX@newstruct@#2@abbreviation}{#5}%
1326 \ifthenelse{\equal{#1}{}}{}{%
1327 \setcounter{CSXcaption}{0}% No need to define a new counter, just use the CSXcaption
1328 \fancyref@foreach{\CSX@newsubstruct}{#2}{#1}%
1329 }%
1330 \AtBeginDocument{%
1331 \immediate\write\@auxout{%
1332 \string\fancyref@addtolist%
1333 {\string{#2\string}}%
1334 {\string\CSX@structlist@filenamesorted}%
1335 }%
1336 }%
1337 }{%
1338 \PackageError{chemschemex}{Multiple definitions of '#2' by %
1339 \string\newstruct}{}%
1340 }%
1341 }
1342 \@onlypreamble\newstruct
1343 % \end{macrocode}
1344 % \end{macro}
1345 % \begin{macro}{\structname}
1346 % \begin{macrocode}
1347 \DeclareRobustCommand{\structname}[1]{%
1348 \@ifundefined{CSX@newstruct@#1@structname}{%
1349 ???%
1350 \PackageWarning{chemschemex}{No structure '#1' defined by \string\newstruct}%
1351 }{%
1352 \ifthenelse{\equal{\@nameuse{CSX@newstruct@#1@structname}}{}}{%
1353 ???%
1354 \PackageWarning{chemschemex}{structname of structure '#1' is empty.}%
1355 }{%
1356 \@nameuse{CSX@newstruct@#1@structname}%
1357 }%
1358 }%
1359 }
1360 % \end{macrocode}
1361 % \end{macro}
1362 % \begin{macro}{\Structname}
1363 % \begin{macrocode}
1364 \DeclareRobustCommand{\Structname}[1]{%
1365 \@ifundefined{CSX@newstruct@#1@Structname}{%
1366 ???%
1367 \PackageWarning{chemschemex}{No structure '#1' defined by \string\newstruct}%
1368 }{%
1369 \ifthenelse{\equal{\@nameuse{CSX@newstruct@#1@Structname}}{}}{%
1370 ???%
1371 \PackageWarning{chemschemex}{Structname of structure '#1' is empty.}%
1372 }{%
1373 \@nameuse{CSX@newstruct@#1@Structname}%
1374 }%
1375 }%
1376 }
1377 % \end{macrocode}
1378 % \end{macro}
1379 % \begin{macro}{\structabbr}
1380 % \begin{macrocode}
1381 \DeclareRobustCommand{\structabbr}[1]{%
1382 \@ifundefined{CSX@newstruct@#1@abbreviation}{%
1383 ???%
1384 \PackageWarning{chemschemex}{No structure '#1' defined by \string\newstruct}%
1385 }{%
1386 \ifthenelse{\equal{\@nameuse{CSX@newstruct@#1@abbreviation}}{}}{%
1387 ???%
1388 \PackageWarning{chemschemex}{structabbr of structure '#1' is empty.}%
1389 }{%
1390 \@nameuse{CSX@newstruct@#1@abbreviation}%
1391 }%
1392 }%
1393 }
1394 % \end{macrocode}
1395 % \end{macro}
1396 % \begin{macro}{\customstruct}
1397 % \begin{macrocode}
1398 \newcommandx\customstruct[4][1={},2={}]{%
1399 % #1=TikZ option for caption
1400 % #2=TikZ option for image
1401 % #3=caption
1402 % #4=image
1403 \customstruct@outarrow[#1][#2]{#3}{#4}%
1404 }
1405 % \end{macrocode}
1406 % \end{macro}
1407 % \begin{macro}{\struct}
1408 % \begin{macrocode}
1409 \newcommandx\struct[6][1={},2=CSX,3={},4={},5={},usedefault]{%
1410 % #1=caption
1411 % #2=family
1412 % #3=image options
1413 % #4=TikZ option for caption
1414 % #5=TikZ option for image
1415 % #6=filename
1416 \@struct{#1}{#2}{#6}%
1417 \customstruct[#4][#5]{\@@struct}{\CSXimage[#3]{#6}}%
1418 }
1419 % \end{macrocode}
1420 % \end{macro}
1421 % \begin{macro}{\structalt}
1422 % \begin{macrocode}
1423 \newcommandx\structalt[7][1={},2=CSX,3={},4={},5={},usedefault]{%
1424 % #1=caption
1425 % #2=family
1426 % #3=image options
1427 % #4=TikZ option for caption
1428 % #5=TikZ option for image
1429 % #6=filename of the referenced image
1430 % #7=filename of the image shown instead of #6
1431 \@struct{#1}{#2}{#6}%
1432 \customstruct[#4][#5]{\@@struct}{\CSXimage[#3]{#7}}%
1433 }
1434 % \end{macrocode}
1435 % \end{macro}
1436 % \begin{macro}{\struct*}
1437 % \begin{macrocode}
1438 \WithSuffix\newcommandx\struct*[6][1={},2=CSX,3={},4={},5={},usedefault]{%
1439 % #1=caption
1440 % #2=family
1441 % #3=image options
1442 % #4=TikZ option for caption
1443 % #5=TikZ option for image
1444 % #6=filename
1445 \@struct*{#1}{#2}{#6}%
1446 \customstruct[#4][#5]{\@@struct}{\CSXimage[#3]{#6}}%
1447 }
1448 % \end{macrocode}
1449 % \end{macro}
1450 % \begin{macro}{\structalt*}
1451 % \begin{macrocode}
1452 \WithSuffix\newcommandx\structalt*[7][1={},2=CSX,3={},4={},5={},usedefault]{%
1453 % #1=caption
1454 % #2=family
1455 % #3=image options
1456 % #4=TikZ option for caption
1457 % #5=TikZ option for image
1458 % #6=filename of the referenced image
1459 % #7=filename of the image shown instead of #6
1460 \@struct*{#1}{#2}{#6}%
1461 \customstruct[#4][#5]{\@@struct}{\CSXimage[#3]{#7}}%
1462 }
1463 % \end{macrocode}
1464 % \end{macro}
1465 % \begin{macro}{\struct-}
1466 % \begin{macrocode}
1467 \WithSuffix\newcommandx\struct-[5][1={},2={},3={},4={},usedefault]{%
1468 % #1=caption
1469 % #2=image options
1470 % #3=TikZ option for caption
1471 % #4=TikZ option for image
1472 % #5=filename
1473 \customstruct[#3][#4]{{{},{#1}}}{\CSXimage[#2]{#5}}%
1474 }
1475 % \end{macrocode}
1476 % \end{macro}
1477 % \begin{macro}{\Struct}
1478 % \begin{macrocode}
1479 \newcommandx\Struct[6][1=CSX,2={},3={},4={},usedefault]{%
1480 % #1=family
1481 % #2=image options
1482 % #3=TikZ option for caption
1483 % #4=TikZ option for image
1484 % #5=list of sublabels previously defined with \newstruct
1485 % #6=filename
1486 \@Struct{#1}{#5}{#6}%
1487 \customstruct[#3][#4]{\@@struct}{\CSXimage[#2]{#6}}%
1488 }
1489 % \end{macrocode}
1490 % \end{macro}
1491 % \begin{macro}{\Structalt}
1492 % \begin{macrocode}
1493 \newcommandx\Structalt[7][1=CSX,2={},3={},4={},usedefault]{%
1494 % #1=family
1495 % #2=image options
1496 % #3=TikZ option for caption
1497 % #4=TikZ option for image
1498 % #5=list of sublabels previously defined with \newstruct
1499 % #6=filename of the referenced image
1500 % #7=filename of the image shown instead of #6
1501 \@Struct{#1}{#5}{#6}%
1502 \customstruct[#3][#4]{\@@struct}{\CSXimage[#2]{#7}}%
1503 }
1504 % \end{macrocode}
1505 % \end{macro}
1506 % \begin{macro}{\Struct*}
1507 % \begin{macrocode}
1508 \WithSuffix\newcommandx\Struct*[6][1=CSX,2={},3={},4={},usedefault]{%
1509 % #1=family
1510 % #2=image options
1511 % #3=TikZ option for caption
1512 % #4=TikZ option for image
1513 % #5=list of sublabels previously defined with \newstruct
1514 % #6=filename
1515 \@Struct*{#1}{#5}{#6}%
1516 \customstruct[#3][#4]{\@@struct}{\CSXimage[#2]{#6}}%
1517 }
1518 % \end{macrocode}
1519 % \end{macro}
1520 % \begin{macro}{\Structalt*}
1521 % \begin{macrocode}
1522 \WithSuffix\newcommandx\Structalt*[7][1=CSX,2={},3={},4={},usedefault]{%
1523 % #1=family
1524 % #2=image options
1525 % #3=TikZ option for caption
1526 % #4=TikZ option for image
1527 % #5=list of sublabels previously defined with \newstruct
1528 % #6=filename of the referenced image
1529 % #7=filename of the image shown instead of #6
1530 \@Struct*{#1}{#5}{#6}%
1531 \customstruct[#3][#4]{\@@struct}{\CSXimage[#2]{#7}}%
1532 }
1533 % \end{macrocode}
1534 % \end{macro}
1535 % \begin{macro}{\structplus}
1536 % \begin{macrocode}
1537 \newcommand{\structplus}{%
1538 \customstruct{}{\tikz[CSXsimple]{\draw[-](1,0)to(-1,0);\draw[-](0,1)to(0,-1);}}%
1539 }
1540 % \end{macrocode}
1541 % \end{macro}
1542 % \begin{macro}{\structminus}
1543 % \begin{macrocode}
1544 \newcommand{\structminus}{%
1545 \customstruct{}{\tikz[CSXsimple]{\draw[-](1,0)to(-1,0);}}%
1546 }
1547 % \end{macrocode}
1548 % \end{macro}
1549 % \begin{macro}{\ChemschemeNextRow}
1550 % \begin{macrocode}
1551 \def\ChemschemeNextRow@list{}%
1552 \newcommand{\ChemschemeNextRow}[1][]{%
1553 % #1=vertical margin
1554 \edef\ChemschemeNextRow@helper{\noexpand\fancyref@addtolist{\theCSXstruct}{\noexpand\ChemschemeNextRow@list}}%
1555 \ChemschemeNextRow@helper%
1556 \expandafter\def\csname ChemschemeNextRow@\theCSXstruct\endcsname{#1}%
1557 \ignorespaces%
1558 }
1559 % \end{macrocode}
1560 % \end{macro}
1561 % \begin{environment}{Chemscheme}
1562 % \begin{macrocode}
1563 \newenvironment{Chemscheme}{%
1564 \CSX@schemetrue%
1565 \ignorespaces%
1566 }{%
1567 \CSX@print%
1568 \CSX@schemefalse%
1569 }
1570 % \end{macrocode}
1571 % \end{environment}
1572 % \begin{macro}{\structref}
1573 % \begin{macrocode}
1574 \DeclareRobustCommand\structref[2][CSX]{%
1575 % #1=family
1576 % #2=label
1577 \CSXstructref{\fancyref[#1]{#2}}%
1578 }
1579 % \end{macrocode}
1580 % \end{macro}
1581 % \begin{macro}{\structref*}
1582 % \begin{macrocode}
1583 \WithSuffix\DeclareRobustCommand\structref*[2][CSX]{%
1584 % #1=family
1585 % #2=label
1586 \CSXstructref{\fancyref*[#1]{#2}}%
1587 }
1588 % \end{macrocode}
1589 % \end{macro}
1590 % \begin{macro}{\structsubref}
1591 % \begin{macrocode}
1592 \DeclareRobustCommand\structsubref[3][CSX]{%
1593 % #1=family
1594 % #2=label
1595 % #3=sublabel
1596 \CSXstructref{\fancysubref[#1]{#2}{#3}}%
1597 }
1598 % \end{macrocode}
1599 % \end{macro}
1600 % \begin{macro}{\structsubref-}
1601 % \begin{macrocode}
1602 \WithSuffix\DeclareRobustCommand\structsubref-[3][CSX]{%
1603 % #1=family
1604 % #2=label
1605 % #3=sublabel
1606 \CSXstructref{\fancysubref-[#1]{#2}{#3}}%
1607 }
1608 % \end{macrocode}
1609 % \end{macro}
1610 % \begin{macro}{\structsubref*}
1611 % \begin{macrocode}
1612 \WithSuffix\DeclareRobustCommand\structsubref*[3][CSX]{%
1613 % #1=family
1614 % #2=label
1615 % #3=sublabel
1616 \CSXstructref{\fancysubref*[#1]{#2}{#3}}%
1617 }
1618 % \end{macrocode}
1619 % \end{macro}
1620 % \begin{macro}{\CSXstructref}
1621 % \begin{macrocode}
1622 \newcommand{\CSXstructref}[1]{%
1623 % #1=fancyref command
1624 \textbf{#1}%
1625 }
1626 % \end{macrocode}
1627 % \end{macro}
1628 % \begin{macro}{\CSXcommands}
1629 % \begin{macrocode}
1630 \newcommand{\CSXcommands}[1]{%
1631 \gappto\CSX@commands{#1}%
1632 \ignorespaces%
1633 }
1634 \def\CSX@commands{}%
1635 % \end{macrocode}
1636 % \end{macro}
1637 % \subsection{Helper macros}
1638 % \begin{macro}{\CSX@newsubstruct}
1639 % \begin{macrocode}
1640 \newcommand{\CSX@newsubstruct}[2]{%
1641 % #1=label
1642 % #2=caption
1643 \stepcounter{CSXcaption}%
1644 \xdef\chemschemes@getcountervalue{%
1645 \theCSXcaption%
1646 }%
1647 \expandafter\xdef\csname CSX@newstruct@#1@subcaption@%
1648 \chemschemes@getcountervalue\endcsname{#2}%
1649 }
1650 % \end{macrocode}
1651 % \end{macro}
1652 % \begin{macro}{\CSX@customarrow@widestcaption}
1653 % \begin{macrocode}
1654 \newcommand{\CSX@customarrow@widestcaption}[2]{%
1655 % #1=label
1656 % #2=style
1657 \pgfmathwidth{"%
1658 \noexpand\tikz[minimum width=0pt,inner sep=0pt,outer sep=0pt]{%
1659 \noexpand\node[\expandonce{#2}]{\noexpand#1};%
1660 }%
1661 "}%
1662 \pgfmathsetlength{\CSXlabelwidth}{\pgfmathresult}%
1663 \ifnum\CSXlabelwidth>\CSXarrowlength%
1664 \pgfmathsetlength{\CSXarrowlength}{\pgfmathresult}%
1665 \edef\CSX@arrowlength{\pgfmathresult}%
1666 \fi%
1667 }
1668 % \end{macrocode}
1669 % \end{macro}
1670 % \begin{macro}{\CSX@savebox@set}
1671 % \begin{macrocode}
1672 \def\CSX@savebox@set#1#2{%
1673 % #1=boxname
1674 % #2=box content
1675 \@ifundefined{#1}{%
1676 \edef\CSX@savebox@set@helper{\noexpand\newsavebox{\csname #1\endcsname}}\CSX@savebox@set@helper%
1677 }{}
1678 \global\sbox{\csname #1\endcsname}{#2}%
1679 \usebox{\csname #1\endcsname}%
1680 }%
1681 % \end{macrocode}
1682 % \end{macro}
1683 % \begin{macro}{CSX@savebox@show}
1684 % \begin{macrocode}
1685 \def\CSX@savebox@show#1#2{%
1686 % #1=boxname
1687 % #2=box content
1688 \usebox{\@nameuse{#1}}%
1689 }%
1690 % \end{macrocode}
1691 % \end{macro}
1692 % \begin{macro}{\customarrow}
1693 % \begin{macrocode}
1694 \newcommand{\customarrow}[4][\the\CSXarrowlength]{%
1695 % #1=length
1696 % #2=arrow style
1697 % #3=upper text
1698 % #4=lower text
1699 \stepcounter{CSXstruct}%
1700 % Measure upper und lower text
1701 \setlength{\CSXarrowlength}{0pt}%
1702 \def\CSX@nodename{Scheme\theCSXscheme Image\theCSXstruct}%
1703 \def\CSXcustomarrow@uppertext{%
1704 \let\customstruct\customstruct@inarrow%
1705 \def\customstruct@inarrow@nodename{\CSX@nodename Upper}%
1706 #3%
1707 \let\customstruct\customstruct@outarrow%
1708 }%
1709 \def\CSXcustomarrow@lowertext{%
1710 \let\customstruct\customstruct@inarrow%
1711 \def\customstruct@inarrow@nodename{\CSX@nodename Lower}%
1712 #4%
1713 \let\customstruct\customstruct@outarrow%
1714 }%
1715 \let\CSX@savebox\CSX@savebox@set%
1716 \edef\CSX@arrowlength{0}%
1717 \CSX@customarrow@widestcaption{\CSXcustomarrow@uppertext}{CSXarrowfont,CSXarrowupper}%
1718 \CSX@customarrow@widestcaption{\CSXcustomarrow@lowertext}{CSXarrowfont,CSXarrowlower}%
1719 \let\CSX@savebox\CSX@savebox@show%
1720 % Set matrix entries
1721 \pgfmathsetlength{\CSXarrowlength}{\CSX@arrowlength + \CSXarrowadvance}%
1722 \edef\customarrow@temp{%
1723 % Reserve space in matrix
1724 \noexpand\node(\CSX@nodename)%
1725 {\noexpand\hbox to #1{}};%
1726 % Add arrow command
1727 \noexpand\CSXcommands{%
1728 \noexpand\pgfmathsetlength{\noexpand\CSXarrowlength}{#1}%
1729 \noexpand\def\noexpand\CSXnodename{\CSX@nodename}%
1730 \noexpand\draw [text width=(#1-\CSXarrowadvance),#2]%
1731 ([CSXshiftA]\noexpand\CSXnodename .west) to%
1732 node (\noexpand\CSXnodename Upper)%
1733 [CSXshiftcompensation,CSXarrowfont,CSXarrowupper,auto]%
1734 {\expandonce\CSXcustomarrow@uppertext}%
1735 node (\noexpand\CSXnodename Lower)%
1736 [CSXshiftcompensation,CSXarrowfont,CSXarrowlower,auto,swap]%
1737 {\expandonce\CSXcustomarrow@lowertext}%
1738 ([CSXshiftB]\noexpand\CSXnodename .east);%
1739 }%
1740 }%
1741 \edef\customarrow@helper{%
1742 \noexpand\expandafter\noexpand\gdef\noexpand\csname CSX@list@image@\theCSXstruct\endcsname{%
1743 \expandonce\customarrow@temp%
1744 }%
1745 }\customarrow@helper%
1746 \expandafter\gdef\csname CSX@list@caption@\theCSXstruct\endcsname{%
1747 \node(Scheme\theCSXscheme Caption\theCSXstruct){};%
1748 }%
1749 \ifCSX@scheme%
1750 % Inside Chemscheme environment
1751 \else%
1752 % Outside Chemscheme environment
1753 \CSX@print%
1754 \fi%
1755 \ignorespaces%
1756 }
1757 % \end{macrocode}
1758 % \end{macro}
1759 % \begin{macro}{\CSXdeclarearrow}
1760 % \begin{macrocode}
1761 \newcommand{\CSXdeclarearrow}[2]{%
1762 % #1=macro name
1763 % #2=TikZ style
1764 \newcommand{#1}[3][\the\CSXarrowlength]{%
1765 % ##1=length
1766 % ##2=upper caption
1767 % ##3=lower caption
1768 \customarrow[##1]{#2}{##2}{##3}%
1769 }
1770 }
1771 % \end{macrocode}
1772 % \end{macro}
1773 % \begin{macro}{\CSXdeclarearrowbundle}
1774 % \begin{macrocode}
1775 \newcommand{\CSXdeclarearrowbundle}[2]{%
1776 % #1=macro name
1777 % #2=TikZ style
1778 % normal
1779 \CSX@declarearrowbundle{#1}{#2}%
1780 % dashed
1781 \CSX@declarearrowbundle{#1Dashed}{#2,dashed}%
1782 }
1783 % \end{macrocode}
1784 % \end{macro}
1785 % \begin{macro}{\CSX@declarearrowbundle}
1786 % \begin{macrocode}
1787 \newcommand{\CSX@declarearrowbundle}[2]{%
1788 % #1=macro name
1789 % #2=TikZ style
1790 \edef\CSX@declarearrowbundle@helper{%
1791 % normal arrow
1792 \noexpand\CSXdeclarearrow{\csname #1\endcsname}{#2}%
1793 % crossed out arrow
1794 \noexpand\CSXdeclarearrow{\csname C#1\endcsname}{#2,CSXCrossArrow}%
1795 % striked out arrow
1796 \noexpand\CSXdeclarearrow{\csname S#1\endcsname}{#2,CSXStrikeArrow}%
1797 % Double striked out arrow
1798 \noexpand\CSXdeclarearrow{\csname DS#1\endcsname}{#2,CSXDStrikeArrow}%
1799 }\CSX@declarearrowbundle@helper%
1800 }
1801 % Normal arrows
1802 \CSXdeclarearrowbundle{RightArrow}{CSXallarrows,CSXRightArrow}
1803 \CSXdeclarearrowbundle{LeftArrow}{CSXallarrows,CSXLeftArrow}
1804 \CSXdeclarearrowbundle{LeftRightArrow}{CSXallarrows,CSXLeftRightArrow}
1805 % Double arrow
1806 \CSXdeclarearrowbundle{DoubleRightArrow}{CSXallarrows,CSXdoublearrows,CSXRightArrow}
1807 \CSXdeclarearrowbundle{DoubleLeftArrow}{CSXallarrows,CSXdoublearrows,CSXLeftArrow}
1808 \CSXdeclarearrowbundle{DoubleLeftRightArrow}{CSXallarrows,CSXdoublearrows,CSXLeftRightArrow}
1809 % Single harpoons
1810 \CSXdeclarearrowbundle{RightupHarpoon}{CSXallarrows,CSXRightupHarpoon}
1811 \CSXdeclarearrowbundle{RightdownHarpoon}{CSXallarrows,CSXRightdownHarpoon}
1812 \CSXdeclarearrowbundle{LeftupHarpoon}{CSXallarrows,CSXLeftupHarpoon}
1813 \CSXdeclarearrowbundle{LeftdownHarpoon}{CSXallarrows,CSXLeftdownHarpoon}
1814 \CSXdeclarearrowbundle{LeftupRightupHarpoon}{CSXallarrows,CSXLeftupRightupHarpoon}
1815 \CSXdeclarearrowbundle{LeftupRightdownHarpoon}{CSXallarrows,CSXLeftupRightdownHarpoon}
1816 \CSXdeclarearrowbundle{LeftdownRightupHarpoon}{CSXallarrows,CSXLeftdownRightupHarpoon}
1817 \CSXdeclarearrowbundle{LeftdownRightdownHarpoon}{CSXallarrows,CSXLeftdownRightdownHarpoon}
1818 % Equilibrium
1819 \CSXdeclarearrowbundle{Equilibrium}{CSXallarrows,CSXequilibrium,CSXRightupHarpoon}
1820 \CSXdeclarearrowbundle{RightEquilibrium}{CSXallarrows,CSXRightequilibrium,CSXRightupHarpoon}
1821 \CSXdeclarearrowbundle{LeftEquilibrium}{CSXallarrows,CSXLeftequilibrium,CSXRightupHarpoon}
1822 \CSXdeclarearrowbundle{RRightEquilibrium}{CSXallarrows,CSXLeftequilibrium,CSXLeftupHarpoon}
1823 \CSXdeclarearrowbundle{LLeftEquilibrium}{CSXallarrows,CSXRightequilibrium,CSXLeftupHarpoon}
1824 % Two Arrows
1825 \CSXdeclarearrowbundle{TwoRightArrow}{CSXallarrows,CSXslashtwoarrow,CSXRightArrow}
1826 \CSXdeclarearrowbundle{TTwoRightArrow}{CSXallarrows,CSXbackslashtwoarrow,CSXRightArrow}
1827 \CSXdeclarearrowbundle{TwoLeftArrow}{CSXallarrows,CSXslashtwoarrow,CSXLeftArrow}
1828 \CSXdeclarearrowbundle{TTwoLeftArrow}{CSXallarrows,CSXbackslashtwoarrow,CSXLeftArrow}
1829 % Three Arrows
1830 \CSXdeclarearrowbundle{ThreeRightArrow}{CSXallarrows,CSXslashthreearrow,CSXRightArrow}
1831 \CSXdeclarearrowbundle{TThreeRightArrow}{CSXallarrows,CSXbackslashthreearrow,CSXRightArrow}
1832 \CSXdeclarearrowbundle{ThreeLeftArrow}{CSXallarrows,CSXslashthreearrow,CSXLeftArrow}
1833 \CSXdeclarearrowbundle{TThreeLeftArrow}{CSXallarrows,CSXbackslashthreearrow,CSXLeftArrow}
1834 % \end{macrocode}
1835 % \end{macro}
1836 % \begin{macro}{\@struct}
1837 % \begin{macrocode}
1838 \newcommand{\@struct}[3]{%
1839 % #1=caption
1840 % #2=family
1841 % #3=filename
1842 \ifthenelse{\equal{#1}{}}{%
1843 \def\@@struct{{{\fancylabel[#2]{#3}},{}}}%
1844 }{%
1845 \def\@@struct{{{\protecting{\def\fancylabelShowLabelEvent{\CSXlabelsep}}\fancylabel[#2]{#3}},{#1}}}%
1846 }%
1847 }
1848 % \end{macrocode}
1849 % \end{macro}
1850 % \begin{macro}{\@struct*}
1851 % \begin{macrocode}
1852 \WithSuffix\newcommand\@struct*[3]{%
1853 % #1=caption
1854 % #2=family
1855 % #3=filename
1856 \def\@@struct{{{\fancylabel*[#2]{#3}},{#1}}}%
1857 }
1858 % \end{macrocode}
1859 % \end{macro}
1860 % \begin{macro}{\@Struct}
1861 % \begin{macrocode}
1862 \newcommand\@Struct[3]{%
1863 % #1=family
1864 % #2=list of sublabels previously defined with \newstruct
1865 % #3=filename
1866 % Use the sort-function of the fancylabel package to sort the label-list
1867 \def\@@struct{}%
1868 \def\fancyref@@@@@sort{fancyref@PrevRun@#1@#3@\fancyref@@sort@value}%
1869 \def\fancyref@sort@list{}%
1870 \def\fancyref@sort@labellist@unsorted{}%
1871 \fancyref@sort{#2}%
1872 \edef\@Struct@helper{%
1873 \noexpand\fancyref@addtolist{\fancyref@sort@labellist@unsorted}{\noexpand\fancyref@sort@list}%
1874 }\@Struct@helper%
1875 \edef\CSX@sorted@list{\fancyref@sort@list}%
1876 % Generate the caption
1877 \edef\@@Struct##1##2{%
1878 % ##1=
1879 % ##2=sublabel
1880 \noexpand\@ifundefined{CSX@newstruct@#3@subcaption@##2}{%
1881 \noexpand\PackageError{chemschemex}{Substructure '##2' not defined as %
1882 substructure of '#3'. %
1883 For the definition of substructures %
1884 use the command \string\newstruct.}{}%
1885 }{%
1886 \noexpand\fancyref@addtolist{%
1887 {{\noexpand\protecting{\noexpand\def\noexpand\fancylabelShowLabelEvent{\noexpand\CSXlabelsep}}%
1888 \noexpand\fancysublabel[#1]{#3}{##2}},%
1889 {\noexpand\@nameuse{CSX@newstruct@#3@subcaption@##2}}}}%
1890 {\noexpand\@@struct}%
1891 }%
1892 }%
1893 \edef\@Struct@helper{%
1894 \noexpand\fancyref@foreach{\noexpand\@@Struct}{}{\CSX@sorted@list}%
1895 }\@Struct@helper%
1896 }
1897 % \end{macrocode}
1898 % \end{macro}
1899 % \begin{macro}{\@Struct*}
1900 % \begin{macrocode}
1901 \WithSuffix\newcommand\@Struct*[3]{%
1902 % #1=family
1903 % #2=list of sublabels previously defined with \newstruct
1904 % #3=filename
1905 \def\@@struct{{{\fancysublabel[#1]{#3}{#2}},{}}}%
1906 }
1907 % \end{macrocode}
1908 % \end{macro}
1909 % \begin{macro}{\customstruct@outarrow}
1910 % \begin{macrocode}
1911 \newcommandx\customstruct@outarrow[4][1={},2={}]{%
1912 % #1=TikZ option for caption
1913 % #2=TikZ option for image
1914 % #3=caption
1915 % #4=image
1916 \stepcounter{CSXstruct}%
1917 % Set Image
1918 \edef\customstruct@outarrow@temp{%
1919 \noexpand\node[\expandonce{#2}](Scheme\theCSXscheme Image\theCSXstruct){\expandonce{#4}};%
1920 }%
1921 \edef\customstruct@outarrow@helper{%
1922 \noexpand\expandafter\noexpand\gdef\noexpand\csname CSX@list@image@\theCSXstruct\endcsname{%
1923 \expandonce\customstruct@outarrow@temp%
1924 }%
1925 }\customstruct@outarrow@helper%
1926 % Generate caption
1927 \CSXgeneratecaption{#3}{#4}{Scheme\theCSXscheme Caption\theCSXstruct}{#1}%
1928 % Set caption
1929 \edef\customstruct@outarrow@temp{%
1930 \noexpand\node(Scheme\theCSXscheme Caption\theCSXstruct){%
1931 \noexpand\tikz[CSXcaption,\expandonce{#1}]{%
1932 \expandonce\CSXcaption%
1933 }%
1934 };%
1935 }%
1936 \edef\customstruct@outarrow@helper{%
1937 \noexpand\expandafter\noexpand\gdef\noexpand\csname CSX@list@caption@\theCSXstruct\endcsname{%
1938 \expandonce\customstruct@outarrow@temp%
1939 }%
1940 }\customstruct@outarrow@helper%
1941 \ifCSX@scheme%
1942 % Inside Chemscheme environment
1943 \else%
1944 % Outside Chemscheme environment
1945 \CSX@print%
1946 \fi%
1947 \ignorespaces%
1948 }
1949 % \end{macrocode}
1950 % \end{macro}
1951 % \begin{macro}{\customstruct@inarrow}
1952 % \begin{macrocode}
1953 \newcommandx\customstruct@inarrow[4][1={},2={}]{%
1954 % #1=TikZ option for caption
1955 % #2=TikZ option for image
1956 % #3=caption
1957 % #4=image
1958 \stepcounter{CSXstructinarrow}%
1959 \CSXgeneratecaption{#3}{#4}{\customstruct@inarrow@nodename Caption\theCSXstructinarrow}{#1}%
1960 \ifthenelse{\CSXmaxlabelwidth=0 \AND \CSXmaxtextwidth=0}{%
1961 \edef\customstruct@inarrow@temp{%
1962 \noexpand\tikz[remember picture,CSXStructInArrow]{%
1963 \noexpand\node [\expandonce{#2}]%
1964 (\customstruct@inarrow@nodename Image\theCSXstructinarrow)%
1965 {\expandonce{#4}};%
1966 }%
1967 }%
1968 }{%
1969 \edef\customstruct@inarrow@temp{%
1970 \noexpand\tikz[remember picture,CSXStructInArrow,%
1971 baseline=(\CSX@generate@caption@captionname Entry\theCSXcaption .base)]{%
1972 \noexpand\node [\expandonce{#2}]%
1973 (\customstruct@inarrow@nodename Image\theCSXstructinarrow)%
1974 {\expandonce{#4}};%
1975 \noexpand\node [below=of \customstruct@inarrow@nodename Image\theCSXstructinarrow]%
1976 (\customstruct@inarrow@nodename Caption\theCSXstructinarrow)%
1977 {\noexpand\tikz[CSXcaption,\expandonce{#1}]{\expandonce\CSXcaption}};%
1978 }%
1979 }%
1980 }%
1981 \CSX@savebox{CSX@savebox@\theCSXstructinarrow}{%
1982 \customstruct@inarrow@temp%
1983 }%
1984 \ignorespaces%
1985 }
1986 % \end{macrocode}
1987 % \end{macro}
1988 % \begin{macro}{\CSXgeneratecaption}
1989 % \begin{macrocode}
1990 \newcommand{\CSXgeneratecaption}[4]{%
1991 % #1=list of labels and text: {{label1},{text1}},{{label2},{text2}},...
1992 % #2=Image
1993 % #3=caption name
1994 % #4=caption style
1995 \setcounter{CSXcaption}{0}%
1996 \setlength{\CSXmaxlabelwidth}{0pt}%
1997 \setlength{\CSXmaxtextwidth}{0pt}%
1998 \def\CSXcaption{}%
1999 \def\CSX@generate@caption@image{#2}%
2000 \def\CSX@generate@caption@captionname{#3}%
2001 \def\CSX@generate@caption@captionstyle{CSXcaption,#4}%
2002 \CSX@generate@@@caption@true%
2003 \ifthenelse{\equal{#1}{}}{}{%
2004 \protected@edef\CSXgeneratecaption@helper{\noexpand\fancyref@foreach{\noexpand\CSX@generate@@caption}{}{#1}}%
2005 \CSXgeneratecaption@helper%
2006 }%
2007 }
2008 % \end{macrocode}
2009 % \end{macro}
2010 % \begin{macro}{\CSX@generate@@caption}
2011 % \begin{macrocode}
2012 \newcommand{\CSX@generate@@caption}[2]{%
2013 % #1=
2014 % #2=label and text: {label1},{text1}
2015 \edef\CSX@generate@@@caption@lastCSXcaption{\theCSXcaption}%
2016 \stepcounter{CSXcaption}%
2017 \fancyref@foreach{\CSX@generate@@@caption}{}{#2}%
2018 % Execute text-only event
2019 \ifCSX@generate@@@caption@\else%
2020 \CSX@generate@@@caption@TextOnly%
2021 {\CSX@generate@caption@image}%
2022 {\CSX@generate@caption@captionname Entry\theCSXcaption}%
2023 {\CSX@generate@caption@captionname Entry\CSX@generate@@@caption@lastCSXcaption}%
2024 {\CSX@generate@@@caption@label}%
2025 \CSX@generate@@@caption@true%
2026 \fi%
2027 }
2028 % \end{macrocode}
2029 % \end{macro}
2030 % \begin{macro}{\CSX@generate@@@caption}
2031 % \begin{macrocode}
2032 \newcommand{\CSX@generate@@@caption}[2]{%
2033 % #1=
2034 % #2=label or text: label1 or text1
2035 \ifCSX@generate@@@caption@%
2036 % Label
2037 \def\CSX@generate@@@caption@label{#2}%
2038 \CSX@generate@@@caption@false%
2039 \else%
2040 % Text and execute label-and-text event
2041 \def\CSX@generate@@@caption@text{#2}%
2042 \CSX@generate@@@caption@LabelAndText%
2043 {\CSX@generate@caption@image}%
2044 {\CSX@generate@caption@captionname Entry\theCSXcaption}%
2045 {\CSX@generate@caption@captionname Entry\CSX@generate@@@caption@lastCSXcaption}%
2046 {\CSX@generate@@@caption@label}%
2047 {\CSX@generate@@@caption@text}%
2048 \CSX@generate@@@caption@true%
2049 \def\CSX@generate@@@caption@label{}%
2050 \def\CSX@generate@@@caption@text{}%
2051 \fi%
2052 }
2053 % \end{macrocode}
2054 % \end{macro}
2055 % \begin{macro}{\CSX@setimagewidth}
2056 % \begin{macrocode}
2057 \newcommand{\CSX@setimagewidth}[1]{%
2058 % #1=image
2059 \pgfmathwidth{"%
2060 \noexpand\tikz[minimum width=0pt,inner sep=0pt,outer sep=0pt]{%
2061 \noexpand\node{\noexpand#1};%
2062 }%
2063 "}%
2064 \edef\CSX@imagewidth{\pgfmathresult}%
2065 }
2066 % \end{macrocode}
2067 % \end{macro}
2068 % \begin{macro}{\CSX@setmaxlabelwidth}
2069 % \begin{macrocode}
2070 \newcommand{\CSX@setmaxlabelwidth}[1]{%
2071 % #1=label
2072 \pgfmathwidth{"%
2073 \noexpand\tikz[\expandonce\CSX@generate@caption@captionstyle ,minimum width=0pt,inner sep=0pt,outer sep=0pt]{%
2074 \noexpand\node[CSXlabelfont]{\noexpand#1};%
2075 }%
2076 "}%
2077 \pgfmathsetlength{\CSXlabelwidth}{\pgfmathresult}%
2078 \edef\CSX@labelwidth{\pgfmathresult}%
2079 \ifnum\CSXlabelwidth<\CSXmaxlabelwidth%
2080 \else%
2081 \pgfmathsetlength{\CSXmaxlabelwidth}{\pgfmathresult}%
2082 \edef\CSX@maxlabelwidth{\pgfmathresult}%
2083 \fi%
2084 }
2085 % \end{macrocode}
2086 % \end{macro}
2087 % \begin{macro}{\CSX@settextwidth}
2088 % \begin{macrocode}
2089 \newcommand{\CSX@settextwidth}[1]{%
2090 % #1=text
2091 \pgfmathwidth{"%
2092 \noexpand\tikz[\expandonce\CSX@generate@caption@captionstyle ,minimum width=0pt,inner sep=0pt,outer sep=0pt]{%
2093 \noexpand\node[CSXtextfont]{\noexpand#1};%
2094 }%
2095 "}%
2096 \pgfmathsetlength{\CSXtextwidth}{\pgfmathresult}%
2097 \edef\CSX@textwidth{\pgfmathresult}%
2098 \ifnum\CSXtextwidth<\CSXmaxtextwidth%
2099 \else%
2100 \pgfmathsetlength{\CSXmaxtextwidth}{\pgfmathresult}%
2101 \edef\CSX@maxtextwidth{\pgfmathresult}%
2102 \fi%
2103 }
2104 % \end{macrocode}
2105 % \end{macro}
2106 % \begin{macro}{\CSX@setvphantom}
2107 % \begin{macrocode}
2108 \newcommand{\CSX@setvphantom}{%
2109 \ifdim\CSXlabelwidth=0pt%
2110 \ifdim\CSXtextwidth=0pt%
2111 \def\CSX@vphantom{}%
2112 \else%
2113 \def\CSX@vphantom{font/.expand once={\tikz@textfont\vphantom{Ag}}}%
2114 \fi%
2115 \else%
2116 \def\CSX@vphantom{font/.expand once={\tikz@textfont\vphantom{Ag}}}%
2117 \fi%
2118 }
2119 % \end{macrocode}
2120 % \end{macro}
2121 % \begin{macro}{\CSX@generate@@@caption@LabelAndText}
2122 % \begin{macrocode}
2123 \newcommand{\CSX@generate@@@caption@LabelAndText}[5]{%
2124 % #1=image command
2125 % #2=node name
2126 % #3=last node name
2127 % #4=label
2128 % #5=text
2129 % Get the image width
2130 \CSX@setimagewidth{#1}%
2131 % Get the widest label
2132 \CSX@setmaxlabelwidth{#4}%
2133 % Measure the text width
2134 \def\CSX@textwidth{0}%
2135 \CSX@settextwidth{#5}%
2136 \CSX@setvphantom%
2137 % Typeset caption
2138 \edef\CSX@generate@@@caption@tempentry{%
2139 \noexpand\gappto\noexpand\CSXcaption{%
2140 % Set \CSXimagewidth
2141 \noexpand\pgfmathsetlength{\noexpand\CSXimagewidth}%
2142 {\CSX@imagewidth}%
2143 % Set \CSXlabelwidth
2144 \noexpand\pgfmathsetlength{\noexpand\CSXlabelwidth}%
2145 {\CSX@labelwidth}%
2146 % Set \CSXmaxlabelwidth
2147 \noexpand\pgfmathsetlength{\noexpand\CSXmaxlabelwidth}%
2148 {\CSX@maxlabelwidth}%
2149 % Set \CSXtextwidth
2150 \noexpand\pgfmathsetlength{\noexpand\CSXtextwidth}%
2151 {\CSX@textwidth}%
2152 % Set \CSXmaxtextwidth
2153 \noexpand\pgfmathsetlength{\noexpand\CSXmaxtextwidth}%
2154 {\CSX@maxtextwidth}%
2155 % Print node
2156 \noexpand\node(#2)[%
2157 CSXlabelfont,%
2158 \expandonce\CSX@vphantom,%
2159 CSXsetlabelwidth,%
2160 CSXcaptionLabelandText,%
2161 rectangle split,%
2162 rectangle split horizontal,%
2163 rectangle split parts=2,%
2164 rectangle split part align=base,%
2165 every two node part/.append style={%
2166 CSXtextfont,%
2167 CSXsettextwidth,%
2168 },%
2169 \ifCSX@generate@@@caption@LastEntryWasTextOnly%
2170 \ifnum\theCSXcaption>1%
2171 below=of #3.south,%
2172 \fi%
2173 \else%
2174 \ifnum\theCSXcaption>1%
2175 below left=of #3.one split south,%
2176 \fi%
2177 anchor=one split north%
2178 \fi%
2179 ]{%
2180 \expandonce#4%
2181 \noexpand\nodepart{two}%
2182 \expandonce#5%
2183 };%
2184 }%
2185 }\CSX@generate@@@caption@tempentry%
2186 \CSX@generate@@@caption@LastEntryWasTextOnlyfalse%
2187 }
2188 % \end{macrocode}
2189 % \end{macro}
2190 % \begin{macro}{\CSX@generate@@@caption@TextOnly}
2191 % \begin{macrocode}
2192 \newcommand{\CSX@generate@@@caption@TextOnly}[4]{%
2193 % #1=image command
2194 % #2=node name
2195 % #3=last node name
2196 % #4=label
2197 % Get the image width
2198 \CSX@setimagewidth{#1}%
2199 % Get the widest label
2200 \CSX@setmaxlabelwidth{}%
2201 % Measure the text width
2202 \def\CSX@textwidth{0}%
2203 \CSX@settextwidth{#4}%
2204 \CSX@setvphantom%
2205 % Typeset caption
2206 \edef\CSX@generate@@@caption@tempentry{%
2207 \noexpand\gappto\noexpand\CSXcaption{%
2208 % Set \CSXimagewidth
2209 \noexpand\pgfmathsetlength{\noexpand\CSXimagewidth}%
2210 {\CSX@imagewidth}%
2211 % Set \CSXmaxlabelwidth
2212 \noexpand\pgfmathsetlength{\noexpand\CSXmaxlabelwidth}%
2213 {\CSX@maxlabelwidth}%
2214 % Set \CSXtextwidth
2215 \noexpand\pgfmathsetlength{\noexpand\CSXtextwidth}%
2216 {\CSX@textwidth}%
2217 % Set \CSXmaxtextwidth
2218 \noexpand\pgfmathsetlength{\noexpand\CSXmaxtextwidth}%
2219 {\CSX@maxtextwidth}%
2220 % Print node
2221 \noexpand\node(#2)[%
2222 CSXtextfont,%
2223 \expandonce\CSX@vphantom,%
2224 CSXsettextwidth,%
2225 CSXcaptionTextOnly,%
2226 \ifnum\theCSXcaption>1%
2227 below=of #3.south,%
2228 \fi%
2229 ]{%
2230 \expandonce#4%
2231 };%
2232 }%
2233 }\CSX@generate@@@caption@tempentry%
2234 \CSX@generate@@@caption@LastEntryWasTextOnlytrue%
2235 }
2236 % \end{macrocode}
2237 % \end{macro}
2238 % \begin{macro}{\CSX@print}
2239 % \begin{macrocode}
2240 \newcommand{\CSX@print}{%
2241 \ifnum\theCSXstruct=0%
2242 \PackageWarning{chemschemex}{Empty Chemscheme environment detected.}
2243 \else%
2244 \let\CSX@printlist\empty%
2245 \CSX@@print%
2246 \fi%
2247 \setcounter{CSXstructinarrow}{0}%
2248 % Print scheme
2249 \begin{tikzpicture}[CSX]%
2250 \matrix [CSXmatrix]{%
2251 \CSX@printlist%
2252 };%
2253 \CSX@commands%
2254 \end{tikzpicture}%
2255 \stepcounter{CSXscheme}%
2256 \setcounter{CSXstruct}{0}%
2257 \setcounter{CSXstructinarrow}{0}%
2258 \gdef\CSX@printlist{}%
2259 \gdef\CSX@commands{}%
2260 \gdef\ChemschemeNextRow@list{}%
2261 }
2262 % \end{macrocode}
2263 % \end{macro}
2264 % \begin{macro}{\CSX@@print}
2265 % \begin{macrocode}
2266 \newcommand{\CSX@@print}{%
2267 % #1=
2268 % #2=row (integer)
2269 \def\lastx{1}%
2270 \ChemschemeNextRow%
2271 \foreach \x [remember=\xplus as \lastx,%
2272 evaluate=\x as \xplus using int(\x+1)]%
2273 in \ChemschemeNextRow@list {%
2274 \ifthenelse{\x < \lastx}{}{%
2275 % Create Image row
2276 \foreach \y in {\lastx,...,\x}{%
2277 \CSX@@@print{\csname CSX@list@image@\y\endcsname}%
2278 }%
2279 \gappto\CSX@printlist{\pgfmatrixendrow}%
2280 % Create Caption row
2281 \foreach \y in {\lastx,...,\x}{%
2282 \CSX@@@print{\csname CSX@list@caption@\y\endcsname}%
2283 }%
2284 \edef\CSX@print@tempentry{%
2285 \noexpand\gappto\noexpand\CSX@printlist{%
2286 \noexpand\pgfmatrixendrow[\csname ChemschemeNextRow@\x\endcsname]%
2287 }%
2288 }\CSX@print@tempentry%
2289 }%
2290 }%
2291 }
2292 % \end{macrocode}
2293 % \end{macro}
2294 % \begin{macro}{\CSX@@@print}
2295 % \begin{macrocode}
2296 \newcommand{\CSX@@@print}[2]{%
2297 % #1=image
2298 \ifnum\y<\x%
2299 \def\CSX@@@print@nextcell{\pgfmatrixnextcell}%
2300 \else%
2301 \def\CSX@@@print@nextcell{}%
2302 \fi%
2303 \edef\CSX@print@tempentry{%
2304 \noexpand\gappto\noexpand\CSX@printlist{%
2305 \noexpand#1%
2306 \expandonce\CSX@@@print@nextcell%
2307 }%
2308 }\CSX@print@tempentry%
2309 }
2310 % \end{macrocode}
2311 % \end{macro}
2312 %
2313 %
2314 \endinput
2315 % \Finale