summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-05-04 21:12:17 +0000
committerKarl Berry <karl@freefriends.org>2019-05-04 21:12:17 +0000
commitdf0394b906ec3163f4eb24ef363bd57eed5b2911 (patch)
treec58649e2ccf831906e1098cb90709e8efcb6894d /Master/texmf-dist/tex/generic
parent1960f0c86ec365f8f61c24c32037e2c20b52ff89 (diff)
chemfig (18apr19)
git-svn-id: svn://tug.org/texlive/trunk@50983 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic')
-rw-r--r--Master/texmf-dist/tex/generic/chemfig/chemfig.sty4
-rw-r--r--Master/texmf-dist/tex/generic/chemfig/chemfig.tex3255
-rw-r--r--Master/texmf-dist/tex/generic/chemfig/t-chemfig.tex4
3 files changed, 1766 insertions, 1497 deletions
diff --git a/Master/texmf-dist/tex/generic/chemfig/chemfig.sty b/Master/texmf-dist/tex/generic/chemfig/chemfig.sty
index d1920b6c641..48e93146eb7 100644
--- a/Master/texmf-dist/tex/generic/chemfig/chemfig.sty
+++ b/Master/texmf-dist/tex/generic/chemfig/chemfig.sty
@@ -2,6 +2,6 @@
\input chemfig.tex
\ProvidesPackage\CFname[\CFdate\space v\CFver\space Draw molecule with an easy syntax (CT)]
\def\printatom#1{\ensuremath{\mathrm{#1}}}% \printatom pour LaTeX.
-\def\CF@begin@tikzpicture{\begin{tikzpicture}}%
-\def\CF@end@tikzpicture{\end{tikzpicture}}%
+\expandafter\def\csname CF\string_begintikzpicture\endcsname{\begin{tikzpicture}}%
+\expandafter\def\csname CF\string_endtikzpicture\endcsname{\end{tikzpicture}}%
\endinput \ No newline at end of file
diff --git a/Master/texmf-dist/tex/generic/chemfig/chemfig.tex b/Master/texmf-dist/tex/generic/chemfig/chemfig.tex
index 87243a1c9a5..a7826763ca4 100644
--- a/Master/texmf-dist/tex/generic/chemfig/chemfig.tex
+++ b/Master/texmf-dist/tex/generic/chemfig/chemfig.tex
@@ -4,9 +4,9 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
\def\CFname {chemfig} %
-\def\CFver {1.34} %
+\def\CFver {1.4} %
% %
-\def\CFdate {2019/02/23} %
+\def\CFdate {2019/04/18} %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
@@ -39,6 +39,7 @@
Package: \CFname\space\CFdate\space\space v\CFver\space\space
Draw molecule with an easy syntax (CT)}%
\fi
+
%------------------------- Vérification etex -------------------------
\begingroup
\edef\CFtempa{\meaning\eTeXversion}
@@ -66,124 +67,282 @@
%-------------------------- Régime catcodes --------------------------
\begingroup
\def\X#1{\catcode\number`#1=\number\catcode`#1\relax}
- \xdef\CFrestorecatcode{\X\[\X\]\X\:\X\(\X\)\X\,\X\-\X\=\X\~\X\!\X\?\X\<\X\>\X\;\X\*\X\|\X\@\X\ }%
+ \xdef\CFrestorecatcode{\X\[\X\]\X\:\X\(\X\)\X\,\X\-\X\=\X\~\X\!\X\?\X\<\X\>\X\;\X\*\X\|\X\@\X\ \X\_}%
\endgroup
\catcode`\[12 \catcode`\]12 \catcode`\:12 \catcode`\(12
\catcode`\)12 \catcode`\,12 \catcode`\-12 \catcode`\=12
\catcode`\~12 \catcode`\!12 \catcode`\?12 \catcode`\<12
\catcode`\>12 \catcode`\;12 \catcode`\*12 \catcode`\|12
-\catcode`\@11 \catcode`\#6 \catcode`\ 10
+\catcode`\@12 \catcode`\#6 \catcode`\ 10 \catcode`\_11
%--------------------------- Allocations -----------------------------
-\newcount\CF@cnt@atomingroup
-\newcount\CF@cnt@groupnumber
-\newcount\CF@cnt@atomnumber
-\newcount\CF@cnt@cycle
-\newcount\CF@compound@cnt
-
-\newif\ifCF@incycle
-\newif\ifCF@cyclearc
-\newif\ifCF@definesubmol
-\newif\ifCF@name@dp@adjust
-\newif\ifCF@macrofixedbondlength
-\newif\ifCF@name@start
-\newif\ifCF@name@end
-
-\newdimen\CF@dim
-\newdimen\CF@arrow@size
-
-\newbox\CF@lewis@box
-\newbox\CF@box@boxa
-\newbox\CF@stuff@box
+\newcount\CF_cntatomgroup
+\newcount\CF_cntgroup
+\newcount\CF_cntatom
+\newcount\CF_cntcycle
+\newcount\CF_cntcompound
+
+\newif\ifCF_incycle
+\newif\ifCF_cyclearc
+\newif\ifCF_definesubmol
+\newif\ifCF_adjustnamedp
+\newif\ifCF_macrofixedbondlength
+\newif\ifCF_lewisoverlay
+
+\newdimen\CF_dim
+\newdimen\CF_arrowsize
+\newdimen\CF_zero \CF_zero=0pt
+
+\newbox\CF_boxlewis
+\newbox\CF_box
+\newbox\CF_boxstuff
+
+\newtoks\CF_substtoks
%-------------------------- Petites macros ---------------------------
-\def\CF@quark{\CF@quark}
-\long\def\CF@execfirst#1#2{#1}
-\long\def\CF@execsecond#1#2{#2}
-\long\def\CF@id#1{#1}
-\long\def\CF@gobarg#1{}
-\long\def\CF@gobtwoargs#1#2{}
-\def\CF@firsttonil#1#2\@nil{#1}
-\def\CF@sanitize@lastitem#1,\empty#2\@nil{#1}
-\def\CF@gobtikzinstruction#1;{}
-\def\CF@makeother#1{\catcode`#1=12\relax}
-\def\CF@lettoken#1#2{\let#1= #2}\CF@lettoken\CF@sptoken{ }
-\def\CF@ifx#1#2{\ifx#1#2\expandafter\CF@execfirst\else\expandafter\CF@execsecond\fi}
-\def\CF@ifempty#1{\ifx\empty#1\empty\expandafter\CF@execfirst\else\expandafter\CF@execsecond\fi}
-\def\CF@doifempty#1{\ifx\empty#1\empty\expandafter\CF@id\else\expandafter\CF@gobarg\fi}
-\def\CF@doifnotempty#1{\ifx\empty#1\empty\expandafter\CF@gobarg\else\expandafter\CF@id\fi}
-\def\CF@gobtonil#1\@nil{}
-\edef\CF@hash{\string#}
-\edef\CF@arobas{\string @}
-\def\CF@three@ea{\expandafter\expandafter\expandafter}
-\def\CF@exp@macroarg#1#2{\expandafter#1\expandafter{#2}}
-\def\CF@eexp@macroarg#1#2{\expandafter\expandafter\expandafter#1\expandafter\expandafter\expandafter{#2}}
-\def\CF@exp@twomacroargs#1#2#3{\CF@exp@second{\CF@exp@macroarg#1{#2}}{#3}}
-\def\CF@exp@threemacroargs#1#2#3#4{\CF@exp@second{\CF@exp@twomacroargs#1{#2}{#3}}{#4}}
-\def\CF@swap@arg#1#2{#2{#1}}
-\def\CF@exp@second#1#2{\CF@exp@macroarg\CF@swap@arg{#2}{#1}}% \CF@exp@second<{arg1>}{<arg2>} donne "<arg1>{*<arg2>}"
-\def\CF@eexp@second#1#2{\CF@eexp@macroarg\CF@swap@arg{#2}{#1}}% \CF@eexp@second{<arg1>}{<arg2>} donne "<arg1>{**<arg2>}"
-\def\CF@swap@unarg#1#2{#2#1}
-\def\CF@exp@after#1#2{\CF@exp@macroarg\CF@swap@unarg{#2}{#1}}% \CF@exp@after{<arg1>}{<arg2>} donne "<arg1>*<arg2>"
-\def\CF@eexp@after#1#2{\CF@eexp@macroarg\CF@swap@unarg{#2}{#1}}% \CF@eexp@after{<arg1>}{<arg2>} donne "<arg1>**<arg2>"
-\def\CF@add@tocs#1#2{\CF@exp@second{\def#1}{#1#2}}
-\def\CF@eadd@tocs#1#2{\CF@exp@second{\CF@add@tocs#1}{#2}}\let\CF@expadd@tocs\CF@eadd@tocs
-\def\CF@preadd@tocs#1#2{\CF@exp@second{\CF@preadd@tocs@a#1{#2}}#1}
-\def\CF@preadd@tocs@a#1#2#3{\def#1{#2#3}}
-\def\CF@edefadd@tocs#1#2{%
- \edef\CF@tmp@str{#2}%
- \CF@exp@second{\CF@add@tocs#1}{\CF@tmp@str}%
-}
-\long\def\CF@ifnextchar#1#2#3{%
- \let\CF@ifnextchar@tok=#1% <- espace indésirable, bugfix v1.31
- \def\CF@ifnextchar@codetrue{#2}%
- \def\CF@ifnextchar@codefalse{#3}%
- \futurelet\CF@temptok\CF@ifnextchar@i}
-\def\CF@ifnextchar@i{%
- \CF@ifx\CF@temptok\CF@sptoken
- \CF@ifnextchar@ii
- {\CF@ifx\CF@temptok\CF@ifnextchar@tok\CF@ifnextchar@codetrue\CF@ifnextchar@codefalse}%
-}
-\expandafter\def\expandafter\CF@ifnextchar@ii\space{\futurelet\CF@temptok\CF@ifnextchar@i}
-\def\CF@ifstar#1{\CF@ifnextchar*{\CF@execfirst{#1}}}
-\long\def\CF@testopt#1#2{\CF@ifnextchar[{#1}{#1[{#2}]}}
-\def\CF@error#1{\errmessage{Package \CFname\space Error: #1.}}
-\def\CF@warning#1{\immediate\write-1{Package \CFname\space Warning: #1^^J}}
-\def\CF@if@integer#1{%
+\let\CF_begintikzpicture\tikzpicture
+\let\CF_endtikzpicture \endtikzpicture
+\def\CF_quark{\CF_quark}
+\def\CF_execfirst#1#2{#1}
+\def\CF_execsecond#1#2{#2}
+\def\CF_id#1{#1}
+\def\CF_gobarg#1{}
+\def\CF_gobtwoargs#1#2{}
+\def\CF_firsttonil#1#2\_nil{#1}
+\def\CF_sanitizelastitem#1,\empty#2\_nil{#1}
+\def\CF_gobtikzinstruction#1;{}
+\def\CF_makeother#1{\catcode`#1=12\relax}
+\def\CF_lettoken#1#2{\let#1= #2}\CF_lettoken\CF_sptoken{ }
+\def\CF_ifx#1#2{\ifx#1#2\expandafter\CF_execfirst\else\expandafter\CF_execsecond\fi}
+\def\CF_ifempty#1{\ifx\empty#1\empty\expandafter\CF_execfirst\else\expandafter\CF_execsecond\fi}
+\def\CF_ifnum#1{\ifnum#1\expandafter\CF_execfirst\else\expandafter\CF_execsecond\fi}
+\def\CF_doifempty#1{\ifx\empty#1\empty\expandafter\CF_id\else\expandafter\CF_gobarg\fi}
+\def\CF_doifnotempty#1{\ifx\empty#1\empty\expandafter\CF_gobarg\else\expandafter\CF_id\fi}
+\def\CF_gobtonil#1\_nil{}
+\edef\CFhash{\string#}
+\begingroup
+ \catcode`\_8
+ \expandafter\gdef\csname CF\string_underscore\endcsname{_}
+\endgroup
+\def\CF_threeea{\expandafter\expandafter\expandafter}
+\def\CF_exptwomacroargs#1#2#3{\CF_expsecond{\CF_expsecond#1{#2}}{#3}}
+\def\CF_expthreemacroargs#1#2#3#4{\CF_expsecond{\CF_exptwomacroargs#1{#2}{#3}}{#4}}
+\def\CF_swaparg#1#2{#2{#1}}
+\def\CF_expsecond#1#2{\expandafter\CF_swaparg\expandafter{#2}{#1}}% \CF_expsecond<{arg1>}{<arg2>} donne "<arg1>{*<arg2>}"
+\def\CF_eexpsecond#1#2{\expandafter\expandafter\expandafter\CF_swaparg\expandafter\expandafter\expandafter{#2}{#1}}% \CF_eexpsecond{<arg1>}{<arg2>} donne "<arg1>{**<arg2>}"
+\def\CF_swapunbrace#1#2{#2#1}
+\def\CF_expafter#1#2{\expandafter\CF_swapunbrace\expandafter{#2}{#1}}% \CF_expafter{<arg1>}{<arg2>} donne "<arg1>*<arg2>"
+\def\CF_eexpafter#1#2{\expandafter\expandafter\expandafter\CF_swapunbrace\expandafter\expandafter\expandafter{#2}{#1}}% \CF_eexpafter{<arg1>}{<arg2>} donne "<arg1>**<arg2>"
+\def\CF_addtomacro#1#2{\CF_expsecond{\def#1}{#1#2}}
+\def\CF_eaddtomacro#1#2{\CF_expsecond{\CF_addtomacro#1}{#2}}
+\def\CF_preaddtomacro#1#2{\CF_expsecond{\CF_preaddtomacroa#1{#2}}#1}
+\def\CF_preaddtomacroa#1#2#3{\def#1{#2#3}}
+\def\CF_addtotoks#1#2{#1\expandafter{\the#1#2}}
+\def\CF_eaddtotoks#1#2{\expandafter\CF_addtotoks\expandafter#1\expandafter{#2}}
+\def\CF_assigntonil#1#2\_nil{\def#1{#2}}
+\def\CF_edefaddtomacro#1#2{%
+ \edef\CF_temp{#2}%
+ \CF_expsecond{\CF_addtomacro#1}{\CF_temp}%
+}
+\def\CF_ifnextchar#1#2#3{%
+ \let\CF_ifnextchartok=#1% <- espace indésirable, bugfix v1.31
+ \def\CF_ifnextcharcodetrue{#2}%
+ \def\CF_ifnextcharcodefalse{#3}%
+ \futurelet\CF_temptok\CF_ifnextchara
+}
+\def\CF_ifnextchara{%
+ \CF_ifx\CF_temptok\CF_sptoken
+ {\CF_ifnextcharb
+ }
+ {\CF_ifx\CF_temptok\CF_ifnextchartok
+ \CF_ifnextcharcodetrue
+ \CF_ifnextcharcodefalse
+ }%
+}
+\expandafter\def\expandafter\CF_ifnextcharb\space{\futurelet\CF_temptok\CF_ifnextchara}
+\def\CF_ifstar#1{\CF_ifnextchar*{\CF_execfirst{#1}}}
+\def\CF_testopt#1#2{\CF_ifnextchar[{#1}{#1[{#2}]}}
+\def\CF_error#1{\errmessage{Package \CFname\space Error: #1.}}
+\def\CF_warning#1{\immediate\write-1{Package \CFname\space Warning: #1^^J}}
+\def\CF_ifinteger#1{%
\begingroup
- \afterassignment\CF@after@integer
- \CF@cnt@cycle0#1\relax
+ \afterassignment\CF_afterinteger
+ \CF_cntcycle0#1\relax
}
-\def\CF@after@integer#1\relax{%
+\def\CF_afterinteger#1\relax{%
\endgroup
- \CF@ifempty{#1}%
-}
-\def\CF@if@firsttokmatch#1#2{% est ce que #1 et #2 commencent par les mêmes tokens ?
- \futurelet\CF@toks@a\CF@gobtonil#1\relax\@nil
- \futurelet\CF@toks@b\CF@gobtonil#2\relax\@nil
- \CF@ifx\CF@toks@a\CF@toks@b
-}
-\def\CF@if@firsttokin#1{% teste si le token qui commence #1 appartient aux tokens mis dans #2
- \futurelet\CF@toks@a\CF@gobtonil#1\relax\@nil
- \CF@if@firsttokin@a
-}
-\def\CF@if@firsttokin@a#1{%
- \CF@ifempty{#1}
- \CF@execsecond
- {\futurelet\CF@toks@b\CF@gobtonil#1\relax\@nil
- \CF@ifx\CF@toks@a\CF@toks@b
- \CF@execfirst
- {\CF@exp@macroarg\CF@if@firsttokin@a{\CF@gobarg#1}}%
+ \CF_ifempty{#1}%
+}
+\def\CF_iffirsttokmatch#1#2{% est ce que #1 et #2 commencent par les mêmes tokens ?
+ \futurelet\CF_toksa\CF_gobtonil#1\relax\_nil
+ \futurelet\CF_toksb\CF_gobtonil#2\relax\_nil
+ \CF_ifx\CF_toksa\CF_toksb
+}
+\def\CF_iffirsttokin#1{% teste si le token qui commence #1 appartient aux tokens mis dans #2
+ \futurelet\CF_toksa\CF_gobtonil#1\relax\_nil
+ \CF_iffirsttokina
+}
+\def\CF_iffirsttokina#1{%
+ \CF_ifempty{#1}
+ {\CF_execsecond
+ }
+ {\futurelet\CF_toksb\CF_gobtonil#1\relax\_nil
+ \CF_ifx\CF_toksa\CF_toksb
+ {\CF_execfirst}
+ {\CF_expsecond\CF_iffirsttokina{\CF_gobarg#1}}%
+ }%
+}
+\def\CF_ifinstr#1#2{%
+ \def\CF_ifinstra##1#2##2\_nil{%
+ \ifx\empty##2\empty
+ \expandafter\CF_execsecond
+ \else
+ \expandafter\CF_execfirst
+ \fi}%
+ \CF_ifinstra#1\__nil#2\_nil
+}
+\def\CF_afterspace#1 #2\_nil{#2}
+\def\CF_valuetomacro#1[#2]#3{% #1= macro #2=valeur défaut #3=clé
+ \CF_eexpsecond{\def#1}{\useKV[chemfig]{#3}}%
+ \CF_ifx#1\empty
+ {\def#1{#2}}
+ {}%
+}
+
+%--------------------------- Substitution ----------------------------
+\def\CF_ifstartwith#1#2{% #1=<texte> #2=<motif>
+ \CF_ifempty{#1}%
+ {\CF_execsecond
+ }
+ {\def\CF_startwithcode{#1}%
+ \def\CF_startwithpattern{#2}%
+ \CF_ifstartwitha
+ }%
+}
+\def\CF_ifstartwitha{%
+ \CF_grabfirstarg\CF_startwithcode\CF_firstargcode
+ \CF_grabfirstarg\CF_startwithpattern\CF_firstargpattern
+ \CF_ifx\CF_firstargcode\CF_firstargpattern
+ {\CF_expsecond\CF_ifempty\CF_startwithpattern
+ {\CF_execfirst
+ }
+ {\CF_expsecond\CF_ifempty\CF_startwithcode
+ \CF_execsecond
+ \CF_ifstartwitha
+ }%
+ }
+ {\CF_execsecond
+ }%
+}
+\def\CF_grabfirstarg#1#2{%
+ \CF_ifx#1\empty
+ {\let#2\empty
+ }
+ {\def\CF_grabmacro{#2}%
+ \CF_expsecond\CF_ifbracefirst#1%
+ {\expandafter\CF_grabbracearg#1\_nil#1}
+ {\CF_expafter{\futurelet\CF_nexttok\CF_grabfirstarga}#1\_nil#1}%
}%
}
-\def\CF@if@instr#1#2{%
- \def\CF@if@instr@a##1#2##2\@nil{\ifx\empty##2\empty\expandafter\CF@execsecond\else\expandafter\CF@execfirst\fi}%
- \CF@if@instr@a#1\@@nil#2\@nil
+\def\CF_grabfirstarga{%
+ \CF_ifx\CF_nexttok\CF_sptoken
+ \CF_grabspacearg
+ \CF_grabnormalarg
+}
+\def\CF_grabbracearg#1{%
+ \expandafter\def\CF_grabmacro{{#1}}%
+ \CF_grabargassigntonil\relax
+}
+\expandafter\def\expandafter\CF_grabspacearg\space{%
+ \expandafter\def\CF_grabmacro{ }%
+ \CF_grabargassigntonil\relax
+}
+\def\CF_grabnormalarg#1{%
+ \expandafter\def\CF_grabmacro{#1}%
+ \CF_grabargassigntonil\relax
+}
+\def\CF_grabargassigntonil#1\_nil#2{\CF_expsecond{\def#2}{\CF_gobarg#1}}
+\def\CF_ifbracefirst#1{\CF_ifnum{\catcode\CF_threeea`\expandafter\CF_firsttonil\detokenize{#1.}\_nil=1 }}
+\def\CF_substonly#1#2{% #1=entier maxi>0 #2=macro : dans la sc#1, remplace tous les <motif> par <pattern> sauf lorsque le motif est suivi d'un caractère >#1
+ \def\CF_atendsubstitute{\edef#2{\the\CF_substtoks}}% macro exécutée à la fin
+ \let\CF_substnogroups\CF_substnogrouponly
+ \CF_ifnum{#1>0 }
+ {\let\CF_testifx\empty
+ \foreach\CF_x in {1,...,#1}{\xdef\CF_testifx{\unexpanded\expandafter{\CF_testifx}\unexpanded\expandafter{\expandafter\ifx\CF_x\CF_nexttok1\fi}}}%
+ \let\CF_testif\empty
+ \foreach\CF_x in {1,...,#1}{\xdef\CF_testif{\unexpanded\expandafter{\CF_testif}\unexpanded\expandafter{\expandafter\if\CF_x\CF_nexttok1\fi}}}%
+ \CF_expsecond\CF_substi#2%
+ }
+ {\CF_substall#2%
+ }%
}
-\def\CF@after@space#1 #2\@nil{#2}
-\def\CF@valuetomacro#1[#2]#3{% #1= macro #2=valeur défaut #3=clé
- \CF@eexp@second{\def#1}{\useKV[chemfig]{#3}}%
- \ifx#1\empty\def#1{#2}\fi
+\def\CF_substnogrouponly{%
+ \CF_exptwomacroargs\CF_ifstartwith\CF_substcode\CF_substsubst
+ {\CF_grabfirstarg\CF_substcode\CF_temp
+ \CF_expafter{\futurelet\CF_nexttok\CF_gobtonil}\CF_substcode\relax\_nil
+ \CF_ifnum{0\CF_testifx=1 }% si le prochain token est \let-égal à 1...#1
+ {\edef\CF_nexttok{\CF_threeea\CF_firsttonil\expandafter\string\CF_substcode\_nil}% le détokéniser
+ \CF_ifnum{0\CF_testif=1 }
+ {\CF_eaddtotoks\CF_substtoks\CF_temp
+ \CF_grabfirstarg\CF_substcode\CF_temp
+ \CF_eaddtotoks\CF_substtoks\CF_temp
+ }
+ {\CF_eaddtotoks\CF_substtoks\CF_substpattern
+ }%
+ }
+ {\CF_eaddtotoks\CF_substtoks\CF_substpattern
+ }%
+ \CF_substgroups
+ }
+ {\CF_expsecond\CF_ifempty\CF_substcode
+ {\CF_atendsubstitute
+ }
+ {\CF_grabfirstarg\CF_substcode\CF_substauxarg
+ \CF_eaddtotoks\CF_substtoks\CF_substauxarg
+ \CF_substgroups
+ }%
+ }%
+}
+\def\CF_substall#1{% #1=macro
+ \def\CF_atendsubstitute{\edef#1{\the\CF_substtoks}}% macro exécutée à la fin
+ \let\CF_substnogroups\CF_substnogroupall
+ \CF_expsecond\CF_substi#1%
+}
+\def\CF_substnogroupall{%
+ \CF_exptwomacroargs\CF_ifstartwith\CF_substcode\CF_substsubst
+ {\CF_eaddtotoks\CF_substtoks\CF_substpattern
+ \CF_grabfirstarg\CF_substcode\CF_temp
+ \CF_substgroups
+ }
+ {\CF_expsecond\CF_ifempty\CF_substcode
+ {\CF_atendsubstitute
+ }
+ {\CF_grabfirstarg\CF_substcode\CF_substauxarg
+ \CF_eaddtotoks\CF_substtoks\CF_substauxarg
+ \CF_substgroups
+ }%
+ }%
+}
+\def\CF_substi#1#2#3{% #1=<texte> #2=<motif> #3=<motif de substi>
+ \def\CF_substcode{#1}\def\CF_substsubst{#2}\def\CF_substpattern{#3}%
+ \CF_substtoks={}%
+ \CF_substgroups
+}
+
+\def\CF_substgroups{%
+ \CF_expsecond\CF_ifbracefirst\CF_substcode
+ {\CF_grabfirstarg\CF_substcode\CF_substauxarg
+ \begingroup
+ \def\CF_atendsubstitute{%
+ \expandafter\endgroup\expandafter\CF_addtotoks\expandafter\CF_substtoks\expandafter{\expandafter{\the\CF_substtoks}}%
+ \CF_substgroups
+ }%
+ \CF_substtoks{}% initialiser à vide
+ \expandafter\def\expandafter\CF_substcode\CF_substauxarg
+ \CF_substgroups
+ }%
+ {\CF_substnogroups
+ }%
}
%---------------------------- Paramètres -----------------------------
@@ -209,8 +368,9 @@
lewis length =1.5ex,
lewis style ={},
lewis dist =0.3em,
- lewis radius =0.15ex,% [nouveau] rayon des disques
- cycle radius coeff =0.75,% [nouveau] coeff du rayon du cercle dans les cycles
+ lewis radius =0.15ex,
+ lewis diag coeff =1,
+ cycle radius coeff =0.75,
stack sep =1.5pt,
scheme debug =false,
compound style ={},
@@ -219,11 +379,11 @@
arrow angle =0,
arrow coeff =1,
arrow style ={},
- arrow double sep =2pt,% [nouveau] espacement entre les doubles fleches
- arrow double coeff =0.6,% [nouveau] coefficient de la petite fleche par rapport à la grande
- arrow double harpoon=true,% [nouveau] fleche double forme harpon ou pas
+ arrow double sep =2pt,
+ arrow double coeff =0.6,
+ arrow double harpoon=true,
arrow label sep =3pt,
- arrow head =-CF,% [nouveau] style de bout de fleche
+ arrow head =-CF,
+ sep left =0.5em,
+ sep right =0.5em,
+ vshift =0pt,
@@ -231,228 +391,150 @@
}
\resetchemfig
-\def\CF@warningdeprecated#1{\CF@warning{The macro \string#1 is deprecated. Please, use \string\setchemfig}}
-\def\setcrambond{%
- \CF@warningdeprecated\setcrambond
- \CF@ifstar
- {\setchemfig{cram rectangle=true }\CF@setcrambond}
- {\setchemfig{cram rectangle=false}\CF@setcrambond}%
-}
-\def\CF@setcrambond#1#2#3{\setchemfig{cram width=#1,cram dash width=#2,cram dash sep=#3}}
-\def\setatomsep#1{%
- \CF@warningdeprecated\setatomsep
- \setchemfig{atom sep=#1}%
-}
-\def\setbondoffset#1{%
- \CF@warningdeprecated\setbondoffset
- \setchemfig{bond offset=#1}%
-}
-\def\setdoublesep#1{%
- \CF@warningdeprecated\setdoublesep
- \setchemfig{double bond sep=#1}%
-}
-\def\setangleincrement#1{%
- \CF@warningdeprecated\setangleincrement
- \setchemfig{angle increment=#1}%
-}
-\def\enablefixedbondlength{%
- \CF@warningdeprecated\enablefixedbondlength
- \setchemfig{fixed length=true}%
-}
-\def\disablefixedbondlength{%
- \CF@warningdeprecated\disablefixedbondlength
- \setchemfig{fixed length=false}%
-}
-\def\setnodestyle#1{%
- \CF@warningdeprecated\setnodestyle
- \setchemfig{node style={#1}}%
-}
-\def\setbondstyle#1{%
- \CF@warningdeprecated\setbondstyle
- \setchemfig{bond style={#1}}%
-}
-\def\setlewis{%
- \CF@warningdeprecated\setlewis
- \CF@testopt\CF@setlewis{0.3ex}%
-}
-\def\CF@setlewis[#1]#2#3#4{\setchemfig{lewis | width=#1,lewis sep=#2,lewis length=#3,lewis style={#4}}}
-\def\setlewisdist#1{%
- \CF@warningdeprecated\setlewisdist
- \setchemfig{lewis dist=#1}%
-}
-\def\setstacksep#1{%
- \CF@warningdeprecated\setstacksep
- \setchemfig{stack sep=#1}%
-}
-\def\setcompoundstyle#1{%
- \CF@warningdeprecated\setcompoundstyle
- \setnodestyle\setchemfig{compound style={#1}}%
-}
-\def\CF@setdefault@a#1,#2,#3\@nil#4#5#6{%
- \setchemfig{#4=#1}%
- \CF@if@firsttokmatch\CF@quark{#2\relax}
- {\setchemfig{#5={},#6={}}}%
- {\setchemfig{#5={#2}}%
- \CF@if@firsttokmatch\CF@quark{#3\relax}
- {\setchemfig{#6={}}}%
- {\CF@setdefault@b#3\@nil{#6}}%
- }%
-}
-\def\CF@setdefault@b#1,\CF@quark#2\@nil#3{\setchemfig{#3={#1}}}
-\def\setarrowdefault#1{%
- \CF@warningdeprecated\setarrowdefault
- \CF@setdefault@a#1,\CF@quark,\CF@quark\@nil{arrow angle}{arrow coeff}{arrow style}%
-}
-\def\setandsign#1{%
- \CF@warningdeprecated\setandsign
- \CF@setdefault@a#1,\CF@quark,\CF@quark\@nil{+ sep left}{+ sep right}{+ vshift}%
-}
-\def\setarrowoffset#1{%
- \CF@warningdeprecated\setarrowoffset
- \setchemfig{arrow offset=#1}%
-}
-\def\setcompoundsep#1{%
- \CF@warningdeprecated\setcompoundsep
- \setchemfig{compound sep=#1}%
-}
-\def\setarrowlabelsep#1{%
- \CF@warningdeprecated\setarrowlabelsep
- \setchemfig{arrow label sep=#1}%
-}
-\def\enablebondjoin{%
- \CF@warningdeprecated\enablebondjoin
- \setchemfig{bond join=true}%
-}
-\def\disablebondjoin{%
- \CF@warningdeprecated\disablebondjoin
- \setchemfig{bond join=false}%
-}
-\def\schemedebug#1{%
- \CF@warningdeprecated\schemedebug
- \setchemfig{scheme debug=#1}%
-}
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% D E S S I N M O L É C U L E S %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\def\CF@sanitize@catcode{%
- \CF@makeother\[\CF@makeother\]\CF@makeother\:\CF@makeother\(\CF@makeother\)%
- \CF@makeother\,\CF@makeother\-\CF@makeother\=\CF@makeother\~\CF@makeother\!%
- \CF@makeother\?\CF@makeother\<\CF@makeother\>\CF@makeother\;\CF@makeother\*%
- \CF@makeother\|\CF@makeother\#\CF@makeother\@%
+\def\CF_sanitizecatcode{%
+ \CF_makeother\[\CF_makeother\]\CF_makeother\:\CF_makeother\(\CF_makeother\)%
+ \CF_makeother\,\CF_makeother\-\CF_makeother\=\CF_makeother\~\CF_makeother\!%
+ \CF_makeother\?\CF_makeother\<\CF_makeother\>\CF_makeother\;\CF_makeother\*%
+ \CF_makeother\|\CF_makeother\#\CF_makeother\@%
}
-\def\CF@node@content{\expandafter\printatom\expandafter{\csname atom@\number\CF@cnt@atomnumber\endcsname\CF@node@strut}}
+\def\CF_nodecontent{\CF_expsecond\printatom{\csname atom_\number\CF_cntatom\endcsname\CF_nodestrut}}
\def\chemskipalign{%
- \CF@doifempty\CF@bond@outcontentsaved% sauf si un \chemskipalign a été fait à l'atome précédent
- {\global\let\CF@bond@outcontentsaved\CF@bond@outcontent}% sauvegarder l'atome d'où vient la liaison
- \let\CF@node@strut\empty
+ \CF_doifempty\CF_bondoutcontentsaved% sauf si un \chemskipalign a été fait à l'atome précédent
+ {\global\let\CF_bondoutcontentsaved\CF_bondoutcontent}% sauvegarder l'atome d'où vient la liaison
+ \let\CF_nodestrut\empty
}
-\def\CF@empty@node{{}}
+\def\CF_emptynode{{}}
-\def\definesubmol{\CF@definesubmoltrue\def@submol}
-\def\redefinesubmol{\CF@definesubmolfalse\def@submol}
+\def\definesubmol{\CF_definesubmoltrue\def_submol}
+\def\redefinesubmol{\CF_definesubmolfalse\def_submol}
-\def\def@submol#1{%
- \CF@cnt@atomingroup=0 % nombre d'arguments supposé
- \def\CF@tmp@str{#1}% nom
- \futurelet\CF@toks@a\CF@test@nxttok
+\def\def_submol#1{%
+ \CF_cntatomgroup=0 % nombre d'arguments supposé
+ \def\CF_temp{#1}% nom
+ \futurelet\CF_toksa\CF_submoltestnxttok
}
-\def\CF@test@nxttok{%
- \if[\noexpand\CF@toks@a\expandafter\CF@execfirst\else\expandafter\CF@execsecond\fi
- {\CF@exp@macroarg\CF@grab@optalias{\CF@tmp@str}}%
- {\afterassignment\CF@test@nxttok@a% pas d'argument entre crochet
- \CF@cnt@atomingroup=0% cherche le nombre d'arguments éventuel
+\def\CF_submoltestnxttok{%
+ \if[\noexpand\CF_toksa\expandafter\CF_execfirst\else\expandafter\CF_execsecond\fi
+ {\begingroup\CF_sanitizecatcode\CF_expsecond\CF_submolgrabopt{\CF_temp}%
+ }
+ {\afterassignment\CF_submoltestnxttoka% pas d'argument entre crochet
+ \CF_cntatomgroup=0% cherche le nombre d'arguments éventuels
}%
}
-\def\CF@test@nxttok@a{\futurelet\CF@toks@a\CF@test@nxttok@b}
+\def\CF_submoltestnxttoka{\futurelet\CF_toksa\CF_submoltestnxttokb}
-\def\CF@test@nxttok@b{%
- \if[\noexpand\CF@toks@a\expandafter\CF@execfirst\else\expandafter\CF@execsecond\fi
- {\CF@exp@macroarg\CF@grab@optalias{\CF@tmp@str}}
- {\CF@exp@second{\def@submol@a}\CF@tmp@str{}}%
+\def\CF_submoltestnxttokb{%
+ \if[\noexpand\CF_toksa\expandafter\CF_execfirst\else\expandafter\CF_execsecond\fi
+ {\begingroup\CF_sanitizecatcode\CF_expsecond\CF_submolgrabopt{\CF_temp}}
+ {\CF_expsecond{\def_submola}\CF_temp{}}%
}
-\def\CF@grab@optalias#1[#2]#{\def@submol@a{#1}{#2}}
-
-\def\CF@make@listofargs#1{%
- \toks\z@{}%
- \CF@cnt@groupnumber#1\relax
- \CF@make@listofargs@a1%
-}
+\def\CF_submolgrabopt#1[#2]#{\endgroup\def_submola{#1}{#2}}
-\def\CF@make@listofargs@a#1{%
- \unless\ifnum#1>\CF@cnt@groupnumber
- \toks\z@\expandafter{\the\toks\z@###1}%
- \expandafter\CF@make@listofargs@a\expandafter{\number\numexpr#1+1\expandafter}%
- \fi
-}
-
-\def\def@submol@a#1{% #1 nom
- \ifcat\relax\expandafter\noexpand\CF@firsttonil#1\@nil\expandafter\CF@execfirst\else\expandafter\CF@execsecond\fi% si #1 est une séquence de contrôle
- {\expandafter\ifdefined\CF@firsttonil#1\@nil
- \ifCF@definesubmol
- \immediate\write-1{Package \CFname\space Warning: the submol \expandafter\string\CF@firsttonil#1\@nil\space is already defined, the previous definition is lost}%
+\def\def_submola#1{% #1 nom
+ \CF_ifnum{0\CF_ifnum{\CF_cntatomgroup<0 }1{\CF_ifnum{\CF_cntatomgroup>9 }10}>0 }
+ {\CF_error{Invalid number of arguments in submol \detokenize\expandafter{\string#1}. Defining it with 0 argument}%
+ \CF_cntatomgroup=0
+ }
+ {}%
+ \ifcat\relax\expandafter\noexpand\CF_firsttonil#1\_nil\expandafter\CF_execfirst\else\expandafter\CF_execsecond\fi% si #1 est une séquence de contrôle
+ {\expandafter\ifdefined\CF_firsttonil#1\_nil
+ \ifCF_definesubmol
+ \CF_warning{the submol \expandafter\string\CF_firsttonil#1\_nil\space is already defined, the previous definition is lost}%
\fi
\fi
- \def@submol@b{#1}%
+ \begingroup
+ \CF_sanitizecatcode
+ \def_submolb{#1}%
}
- {\ifcsname CF@@#1\endcsname
- \ifCF@definesubmol
- \immediate\write-1{Package \CFname\space Warning:the submol "#1" is already defined, the previous definition is lost}%
+ {\ifcsname CF__#1\endcsname
+ \ifCF_definesubmol
+ \CF_warning{the submol "#1" is already defined, the previous definition is lost}%
\fi
\fi
- \expandafter\def@submol@b\csname CF@@#1\endcsname
+ \begingroup
+ \CF_sanitizecatcode
+ \expandafter\def_submolb\csname CF__#1\endcsname
}%
}
-\def\def@submol@b#1#2#3{% #1 nom sous forme de macro, #2 = code si liaison arrive de droite , #3 = code si liaison arrive de gauche, \CF@cnt@atomingroup = nombre d'arguments
- \CF@make@listofargs\CF@cnt@atomingroup
- \CF@ifempty{#2}%
- {\CF@exp@after{\expandafter\def\CF@firsttonil#1\@nil}{\the\toks\z@}{\empty#3}}
- {\CF@exp@after{\expandafter\def\CF@firsttonil#1\@nil}{\the\toks\z@}{%
- \romannumeral
- \ifdim\CF@current@angle pt>90pt
- \ifdim\CF@current@angle pt<270pt
- \expandafter\expandafter\expandafter\CF@execfirst
- \else
- \expandafter\expandafter\expandafter\CF@execsecond
- \fi
- \else
- \expandafter\CF@execsecond
- \fi
- {\z@#2}{\z@#3}}%
- }%
+\def\def_submolb#1#2#3{% #1 nom sous forme de macro, #2 = code si liaison arrive de droite , #3 = code si liaison arrive de gauche, \CF_cntatomgroup = nombre d'arguments
+ \def\CF_tempa{#2}\CF_doifnotempty{#2}{\CF_expsecond{\CF_expsecond\CF_substonly{\number\CF_cntatomgroup}\CF_tempa}{\CFhash}{\CFhash}}%
+ \def\CF_tempb{#3}\CF_expsecond{\CF_expsecond\CF_substonly{\number\CF_cntatomgroup}\CF_tempb}{\CFhash}{\CFhash}%
+ \CF_expsecond{\CF_expsecond{\def_submolc{#1}}\CF_tempa}\CF_tempb
}
-\def\CF@seek@node#1#2#3{% cherche un noeud au début de #1 l'assigne dans la sc #2 et met le reste dans #3
+\def\def_submolc#1#2#3{% #1 nom sous forme de macro, #2 = code si liaison arrive de droite , #3 = code si liaison arrive de gauche, \CF_cntatomgroup = nombre d'arguments
+ \endgroup
+ \begingroup
+ \global\toks0{\gdef\CFthesubmol}%
+ \CF_ifnum{\CF_cntatomgroup>0 }
+ {\foreach\CF_x in {1,...,\CF_cntatomgroup}{%
+ \edef\CF_temp{\CFhash\CF_x}%
+ \global\toks0\expandafter\expandafter\expandafter{\expandafter\the\expandafter\toks\expandafter0\CF_temp}%
+ }%
+ }
+ {}%
+ \CF_sanitizecatcode \catcode`\#6 \endlinechar-1 \everyeof{\noexpand}%
+ \CF_ifempty{#2}%
+ {\scantokens\expandafter{\the\toks0{\empty#3}}%
+ }%
+ {\scantokens\expandafter{%
+ \the\toks0{%
+ \romannumeral
+ \csname CF_exec%
+ \ifdim\csname CF_currentangle\endcsname pt>90pt
+ \ifdim\csname CF_currentangle\endcsname pt<270pt
+ first%
+ \else
+ second%
+ \fi
+ \else
+ second%
+ \fi
+ \endcsname
+ {0 #2}{0 #3}%
+ }%
+ }%
+ }%
+ \endgroup
+ \let#1\CFthesubmol
+}
+
+\def\CF_seeknode#1#2#3{% cherche un noeud au début de #1 l'assigne dans la sc #2 et met le reste dans #3
\let#2\empty
\def#3{#1}%
- \CF@if@firsttokmatch{#1}{ }%
- {\CF@exp@macroarg\CF@seek@node@a{\romannumeral-`\.\noexpand#1}#2#3}% ignore les espaces au début du groupe d'atome
- {\CF@seek@node@a{#1}#2#3}%
-}
-
-\def\CF@seek@node@a#1#2#3{%
- \CF@ifempty{#1}%
- {\let#3\empty}
- {\futurelet\CF@toks@a\CF@gobtonil#1\relax\@nil
- \CF@ifx\CF@toks@a\@sptoken
- {\CF@add@tocs#2{ }%
- \CF@exp@macroarg\CF@seek@node@a{\CF@after@space#1\@nil}#2#3%
+ \CF_iffirsttokmatch{#1}{ }%
+ {\CF_expsecond\CF_seeknodea{\romannumeral-`\.\noexpand#1}#2#3}% ignore les espaces au début du groupe d'atome
+ {\CF_seeknodea{#1}#2#3}%
+}
+
+\def\CF_seeknodea#1#2#3{%
+ \CF_ifempty{#1}%
+ {\let#3\empty
+ }
+ {\futurelet\CF_toksa\CF_gobtonil#1\relax\_nil
+ \CF_ifx\CF_toksa\CF_sptoken
+ {\CF_addtomacro#2{ }%
+ \CF_expsecond\CF_seeknodea{\CF_afterspace#1\_nil}#2#3%
}%
- {\CF@ifx\CF@toks@a\bgroup
- {\CF@eadd@tocs#2{\expandafter{\CF@firsttonil#1\@nil}}%
- \CF@exp@macroarg\CF@seek@node@a{\CF@gobarg#1}#2#3%
+ {\CF_ifx\CF_toksa\bgroup
+ {\CF_eaddtomacro#2{\expandafter{\CF_firsttonil#1\_nil}}%
+ \CF_expsecond\CF_seeknodea{\CF_gobarg#1}#2#3%
}%
- {\CF@if@firsttokin@a{-=(*<>!~}%
- {\def#3{#1}}%
- {\CF@eadd@tocs#2{\CF@firsttonil#1\@nil}%
- \CF@exp@macroarg\CF@seek@node@a{\CF@gobarg#1}#2#3%
+ {\CF_iffirsttokina{-=(*<>!~}%
+ {\def#3{#1}%
+ }%
+ {\CF_eaddtomacro#2{\CF_firsttonil#1\_nil}%
+ \CF_expsecond\CF_seeknodea{\CF_gobarg#1}#2#3%
}%
}%
}%
@@ -461,895 +543,983 @@
% on sait que #1 commence par -,=,~,<,>. On analyse cette liaison
% #2 reçoit le type de liaisons (1 pour -, 2 pour =, 3 pour ~)
-\def\CF@bond@findcode#1#2{%
- \futurelet\CF@toks@a\CF@gobtonil#1\@nil
+\def\CF_assignbondcode#1#2{%
+ \futurelet\CF_toksa\CF_gobtonil#1\_nil
\edef#2{%
- \ifx-\CF@toks@a1\else
- \ifx=\CF@toks@a2\else
- \ifx~\CF@toks@a3\else
- \ifx>\CF@toks@a4\else
- \ifx<\CF@toks@a5\else0% si 0 --> il y a une erreur non due à l'utilisateur
+ \ifx-\CF_toksa1\else
+ \ifx=\CF_toksa2\else
+ \ifx~\CF_toksa3\else
+ \ifx>\CF_toksa4\else
+ \ifx<\CF_toksa5\else0% si 0 --> il y a une erreur non due à l'utilisateur
\fi\fi\fi\fi\fi}%
- \ifnum#2>\thr@@% si c'est une liaison de Cram
- \CF@exp@after{\futurelet\CF@toks@a\CF@gobtonil}{\CF@gobarg#1\@nil}% chope le caractère suivant
- \CF@ifx:\CF@toks@a
- {\edef#2{\number\numexpr#2+2}}% si c 'est un ":", signe du pointillé, ajoute 2
- {\CF@ifx|\CF@toks@a{\edef#2{\number\numexpr#2+4}}{}}% si c 'est un "|", signe du triangle évidé, ajouter 4
+ \ifnum#2>3 % si c'est une liaison de Cram
+ \CF_expafter{\futurelet\CF_toksa\CF_gobtonil}{\CF_gobarg#1\_nil}% chope le caractère suivant
+ \CF_ifx:\CF_toksa
+ {\edef#2{\number\numexpr#2+2}% si c 'est un ":", signe du pointillé, ajoute 2
+ }%
+ {\CF_ifx|\CF_toksa% si c 'est un "|", signe du triangle évidé, ajouter 4
+ {\edef#2{\number\numexpr#2+4}}
+ {}%
+ }%
\fi
}
-\def\CF@analyse@bondoffset#1,#2\@nil{%
- \def\CF@start@offset{#1}\def\CF@end@offset{#2}%
+\def\CF_grabbondoffseta#1,#2\_nil{%
+ \def\CF_startoffset{#1}\def\CF_endoffset{#2}%
}
-\def\CF@grab@bondoffset#1(#2)#3\@nil{%
- \CF@doifnotempty{#2}%
- {\CF@if@instr{#2},%
- {\CF@analyse@bondoffset#2\@nil}%
- {\def\CF@start@offset{#2}}%
+\def\CF_grabbondoffset#1(#2)#3\_nil{%
+ \CF_doifnotempty{#2}%
+ {\CF_ifinstr{#2},%
+ {\CF_grabbondoffseta#2\_nil}%
+ {\def\CF_startoffset{#2}}%
}%
- \def\CF@remain@afterbond{#3}%
-}
-
-\def\CF@analyse@bond#1#2{%
- \CF@bond@findcode{#1}#2%
- \CF@exp@second{\def\CF@remain@afterbond}{\CF@gobarg#1}%mange le premier signe de la liaison
- \let\CF@doublebond@type\z@
- \ifnum#2=\tw@% si c'est une double liaison, regarde s'il y a un + ou - derrière
- \CF@exp@after{\futurelet\CF@toks@a\CF@gobtonil}{\CF@gobarg#1\@nil}%
- \CF@ifx^\CF@toks@a
- {\let\CF@doublebond@type\@ne
- \CF@exp@second{\def\CF@remain@afterbond}{\CF@gobtwoargs#1}% mange le "^"
+ \def\CF_remainafterbond{#3}%
+}
+
+\def\CF_analysebond#1#2{%
+ \CF_assignbondcode{#1}#2%
+ \CF_expsecond{\def\CF_remainafterbond}{\CF_gobarg#1}%mange le premier signe de la liaison
+ \let\CF_doublebondtype\CF_zero
+ \ifnum#2=2 % si c'est une double liaison, regarde s'il y a un + ou - derrière
+ \CF_expafter{\futurelet\CF_toksa\CF_gobtonil}{\CF_gobarg#1\_nil}%
+ \CF_ifx^\CF_toksa
+ {\def\CF_doublebondtype{1}%
+ \CF_expsecond{\def\CF_remainafterbond}{\CF_gobtwoargs#1}% mange le "^"
}
- {\ifx_\CF@toks@a
- \let\CF@doublebond@type\tw@
- \CF@exp@second{\def\CF@remain@afterbond}{\CF@gobtwoargs#1}% mange le "_"
+ {\expandafter\ifx\CF_underscore\CF_toksa
+ \def\CF_doublebondtype{2}%
+ \CF_expsecond{\def\CF_remainafterbond}{\CF_gobtwoargs#1}% mange le "_"
\fi
}%
\else
\ifnum#2>5 % si c'est une laision de Cram pointillée ou triangle évidé
- \CF@exp@second{\def\CF@remain@afterbond}{\CF@gobtwoargs#1}% mange un caractère de plus
+ \CF_expsecond{\def\CF_remainafterbond}{\CF_gobtwoargs#1}% mange un caractère de plus
\fi
\fi
- \CF@exp@twomacroargs\CF@if@firsttokmatch\CF@remain@afterbond\CF@hash%
- {\expandafter\CF@grab@bondoffset\CF@remain@afterbond\@nil}%
+ \CF_expsecond\CF_iffirsttokmatch\CF_remainafterbond\CFhash
+ {\CF_eexpsecond\CF_iffirsttokmatch{\expandafter\CF_gobarg\CF_remainafterbond.}(%si parenthèse juste après
+ {\expandafter\CF_grabbondoffset\CF_remainafterbond\_nil}
+ {}%
+ }%
{}%
- \CF@exp@twomacroargs\CF@if@firsttokmatch\CF@remain@afterbond\CF@arobas
- {\expandafter\CF@grab@movearg\CF@remain@afterbond\@nil}%
+ \CF_expsecond\CF_iffirsttokmatch\CF_remainafterbond @%
+ {\expandafter\CF_grabmovearg\CF_remainafterbond\_nil}%
{}%
- \CF@exp@macroarg\CF@if@firsttokmatch{\CF@remain@afterbond}[%
- {\expandafter\CF@analyse@optarg\CF@remain@afterbond\@nil\CF@remain@afterbond}%
- {\let\CF@current@stringangle\default@stringangle
- \let\CF@current@length\default@length
- \let\CF@current@fromatom\default@fromatom
- \let\CF@current@toatom\default@toatom
- \let\CF@current@tikz\default@tikz
- \let\CF@movebond@name\empty
+ \CF_expsecond\CF_iffirsttokmatch{\CF_remainafterbond}[%
+ {\expandafter\CF_analyseoptarg\CF_remainafterbond\_nil\CF_remainafterbond
+ }%
+ {\let\CF_currentstringangle\CF_defaultstringangle
+ \let\CF_currentlength\CF_defaultlength
+ \let\CF_currentfromatom\CF_defaultfromatom
+ \let\CF_currenttoatom\CF_defaulttoatom
+ \let\CF_currenttikz\CF_defaulttikz
+ \let\CF_movebondname\empty
}%
- \ifCF@incycle
- \pgfmathsetmacro\CF@cycle@increment@angle{360/\CF@cycle@num+\CF@initcycle@angle}%
- \edef\CF@current@stringangle{::+\CF@cycle@increment@angle}%
- \def\CF@initcycle@angle{0}%
- \let\CF@current@length\default@length% et on ignore la longueur de liaison spécifiée
+ \ifCF_incycle
+ \pgfmathsetmacro\CF_cycleincrementangle{360/\CF_cyclenum+\CF_initcycleangle}%
+ \edef\CF_currentstringangle{::+\CF_cycleincrementangle}%
+ \def\CF_initcycleangle{0}%
+ \let\CF_currentlength\CF_defaultlength% et on ignore la longueur de liaison spécifiée
\fi
- \CF@exp@macroarg\CF@set@bondangle{\CF@current@stringangle}\CF@current@angle
+ \CF_expsecond\CF_setbondangle{\CF_currentstringangle}\CF_currentangle
}
-\def\CF@set@bondangle#1#2{% le code de la direction est contenu dans #1, en sortie, #2 contient l'angle
- \CF@ifempty{#1}%
- {\let#2\default@angle}
- {\if:\expandafter\noexpand\CF@firsttonil#1\@nil
- \if:\CF@three@ea\noexpand\expandafter\CF@firsttonil\CF@gobarg#1\@nil
- \pgfmathsetmacro#2{\CF@previous@angle+\expandafter\CF@gobarg\CF@gobarg#1}%
+\def\CF_setbondangle#1#2{% le code de la direction est contenu dans #1, en sortie, #2 contient l'angle
+ \CF_ifempty{#1}%
+ {\let#2\CF_defaultangle
+ }
+ {\if:\expandafter\noexpand\CF_firsttonil#1\_nil
+ \if:\CF_threeea\noexpand\expandafter\CF_firsttonil\CF_gobarg#1\_nil
+ \pgfmathsetmacro#2{\CF_previousangle+\expandafter\CF_gobarg\CF_gobarg#1}%
\else
- \pgfmathsetmacro#2{\CF@gobarg#1}%
+ \pgfmathsetmacro#2{\CF_gobarg#1}%
\fi
\else
- \pgfmathsetmacro#2{#1*\CF@angle@increment}%
+ \pgfmathsetmacro#2{#1*\CF_angleincrement}%
\fi% puis normalise l'angle entre 0 et 360
- \ifdim\ifdim#2pt<\z@-\fi#2pt>360pt \pgfmathsetmacro#2{#2-360*floor(#2/360)}\fi% si |#2|>360
- \ifdim#2pt<\z@\pgfmathsetmacro#2{#2+360}\fi
+ \ifdim\ifdim#2pt<0pt -\fi#2pt>360pt
+ \pgfmathsetmacro#2{#2-360*floor(#2/360)}%
+ \fi% si |#2|>360
+ \ifdim#2pt<0pt
+ \pgfmathsetmacro#2{#2+360}%
+ \fi
}%
}
-\def\CF@int@part#1.#2\@nil{#1 }
-
-\def\CF@analyse@movearg#1,#2\@nil#3{%
- \def#3{#1}\def\CF@movebond@coeff{#2}%
+\def\CF_analysemovearg#1,#2\_nil#3{%
+ \def#3{#1}\def\CF_movebondcoeff{#2}%
}
-% Argument limités légitimes ici car #2 (qui est ce qui suit "@{<nom>}" dans l'argument optionnel) ne DOIT
-% pas commencer par une accolade.
-\expandafter\def\expandafter\CF@grab@movearg\CF@arobas#1#2\@nil{%
- \CF@if@instr{#1},%
- {\CF@analyse@movearg#1\@nil\CF@movebond@name}%
- {\def\CF@movebond@name{#1}\def\CF@movebond@coeff{0.5}}%
- \def\CF@remain@optarg{#2}%
+% Argument limités légitimes ici car #2 (qui est ce qui suit "@{<nom>}" dans l'argument optionnel) ne DOIT PAS
+% commencer par une accolade.
+\def\CF_grabmovearg @#1#2\_nil{%
+ \CF_ifinstr{#1},%
+ {\CF_analysemovearg#1\_nil\CF_movebondname}%
+ {\def\CF_movebondname{#1}\def\CF_movebondcoeff{0.5}}%
+ \def\CF_remainoptarg{#2}%
}
-\def\CF@testempty@andassign#1#2#3{\CF@ifempty{#2}{\let#1#3}{\def#1{#2}}}
+\def\CF_testemptyandassign#1#2#3{%
+ \CF_ifempty{#2}
+ {\let#1#3}
+ {\def#1{#2}}%
+}
-\def\CF@parse@optlist#1,#2,#3,#4,#5\@nil{%
- \CF@testempty@andassign\CF@current@stringangle{#1}\default@stringangle
- \CF@testempty@andassign\CF@current@length{#2}\default@length
- \CF@testempty@andassign\CF@current@fromatom{#3}\default@fromatom
- \CF@testempty@andassign\CF@current@toatom{#4}\default@toatom
- \expandafter\CF@testempty@andassign\expandafter\CF@current@tikz\expandafter{\CF@sanitize@lastitem#5,\empty\@nil}\default@tikz
+\def\CF_parseoptlist#1,#2,#3,#4,#5\_nil{%
+ \CF_testemptyandassign\CF_currentstringangle{#1}\CF_defaultstringangle
+ \CF_testemptyandassign\CF_currentlength {#2}\CF_defaultlength
+ \CF_testemptyandassign\CF_currentfromatom {#3}\CF_defaultfromatom
+ \CF_testemptyandassign\CF_currenttoatom {#4}\CF_defaulttoatom
+ \CF_expsecond{\CF_testemptyandassign\CF_currenttikz}{\CF_sanitizelastitem#5,\empty\_nil}\CF_defaulttikz
}%
-\def\CF@analyse@optarg[#1]#2\@nil#3{%
- \CF@doifnotempty{#1}%
- {\CF@exp@after{\CF@if@firsttokmatch{#1}}{\CF@arobas}%
- {\CF@grab@movearg#1\@nil}%
- {\let\CF@movebond@name\empty
- \def\CF@remain@optarg{#1}%
+\def\CF_analyseoptarg[#1]{%
+ \CF_doifnotempty{#1}%
+ {\CF_iffirsttokmatch{#1}{@}%
+ {\CF_grabmovearg#1\_nil
+ }
+ {\let\CF_movebondname\empty
+ \def\CF_remainoptarg{#1}%
}%
- \expandafter\CF@parse@optlist\CF@remain@optarg,\empty,\empty,\empty,\empty\@nil
- \def#3{#2}%
+ \expandafter\CF_parseoptlist\CF_remainoptarg,\empty,\empty,\empty,\empty\_nil
}%
+ \CF_analyseoptarga\relax
}
-\def\CF@seek@submol{%
- \CF@exp@second{\def\CF@remain@molecule}{\romannumeral-`\.\expandafter\noexpand\CF@remain@molecule}%
- \CF@exp@macroarg\CF@if@firsttokmatch{\CF@remain@molecule}!%
- {\CF@eexp@second{\def\CF@remain@molecule}{\expandafter\CF@gobarg\CF@remain@molecule}% enlève le "!"
- \CF@ifx\empty\CF@remain@molecule{\errmessage{Package \CFname\space Error: no submol name found after "!"}}{}%
- \ifcat\relax\CF@three@ea\noexpand\expandafter\CF@firsttonil\CF@remain@molecule*\@nil
- \CF@eexp@second{\CF@exp@second{\def\CF@remain@molecule}}{\CF@remain@molecule}%
+\def\CF_analyseoptarga#1\_nil#2{%
+ \CF_expsecond{\def#2}{\CF_gobarg#1}%
+}
+
+\def\CF_seeksubmol{%
+ \CF_expsecond{\def\CF_molecule}{\romannumeral-`\.\expandafter\noexpand\CF_molecule}%
+ \CF_expsecond\CF_iffirsttokmatch{\CF_molecule}!%
+ {\CF_eexpsecond{\def\CF_molecule}{\expandafter\CF_gobarg\CF_molecule}% enlève le "!"
+ \CF_ifx\empty\CF_molecule
+ {\CF_error{no submol name found after "!"}}
+ {}%
+ \ifcat\relax\CF_threeea\noexpand\expandafter\CF_firsttonil\CF_molecule*\_nil
+ \expandafter\CF_seeksubmola\CF_molecule\_nil
\else
- \expandafter\CF@seek@submol@a\CF@remain@molecule\@nil
+ \expandafter\CF_seeksubmolb\CF_molecule\_nil
\fi
- \CF@seek@submol
+ \CF_seeksubmol
}%
{}%
}
-\def\CF@seek@submol@a#1#2\@nil{% #1=nom
- \CF@eexp@second{\CF@exp@second{\def\CF@remain@molecule}}{\csname CF@@#1\endcsname#2}%
-}
+\def\CF_seeksubmola#1{\CF_seeksubmolc#1\relax}
-\def\CF@insert@emptygroup#1{% insère {} au début de la sc #1
- \CF@exp@second{\def#1}{\expandafter{\expandafter}#1}%
-}
+\def\CF_seeksubmolb#1{\expandafter\CF_seeksubmolc\csname CF__#1\endcsname\relax}% nom de la sous molécule
-\def\chemfig{%
- \CF@ifstar
- {\CF@warning{Do not use star \string\chemfig\space but set the key "fixed lengths"}%
- \CF@macrofixedbondlengthtrue\CF@chemfig@a
- }
- {\ifboolKV[chemfig]{fixed length}
- \CF@macrofixedbondlengthtrue
- \CF@macrofixedbondlengthfalse
- \CF@chemfig@a}%
+\def\CF_seeksubmolc#1#2\_nil{%#1=macro de la sous molécule #2=reste du code commençant par \relax
+ \CF_expsecond{\CF_eexpsecond{\def\CF_molecule}}{\expandafter#1\CF_gobarg#2}% supprime le \relax puis ajoute la macro au début et la 2-développe
}
-\def\CF@chemfig@a{\CF@testopt\CF@chemfig@b{}}
+\def\CF_insertemptygroup#1{% insère {} au début de la sc #1
+ \CF_expsecond{\def#1}{\expandafter{\expandafter}#1}%
+}
-\def\CF@chemfig@b[#1]{\CF@testopt{\CF@chemfig@c[#1]}{}}
+\def\chemfig{\CF_testopt\CF_chemfiga{}}
-\def\CF@chemfig@c[#1][#2]{%
- \if\relax\detokenize{#1#2}\relax\else
- \CF@warning{Do not use optional arguments but set the keys "tikz node style" and "tikz code"}%
- \fi
- \edef\CF@tmp@str{[remember picture,every node/.style={anchor=base,inner sep=\z@,outer sep=\z@,minimum size=\z@,\ifx\empty#2\empty\useKV[chemfig]{atom style}\else#2\fi},baseline,\ifx\empty#1\empty\useKV[chemfig]{chemfig style}\else#1\fi]}%
- \CF@exp@threemacroargs\CF@chemfig@d\CF@begin@tikzpicture\CF@tmp@str\CF@end@tikzpicture
+\def\CF_chemfiga[#1]{%
+ \begingroup
+ \edef\CF_temp{%
+ \unexpanded\expandafter{\CF_begintikzpicture}%
+ [remember picture,%
+ every node/.style={%
+ anchor=base,%
+ inner sep=0pt,%
+ outer sep=0pt,%
+ minimum size=0pt,%
+ \unexpanded\CF_threeea{\useKV[chemfig]{atom style}}%
+ },%
+ baseline,%
+ \unexpanded\CF_threeea{\useKV[chemfig]{chemfig style}}%
+ ]%
+ }%
+ \CF_sanitizecatcode
+ \CF_exptwomacroargs\CF_chemfigb\CF_begintikzpicture\CF_endtikzpicture[#1]%
}
-\def\CF@chemfig@d#1#2#3#4{%
- #1#2%
+\def\CF_chemfigb#1#2[#3]#4{%
+ \endgroup
\begingroup
- \let\CF@hook@list\empty
- \ifboolKV[chemfig]{bond join}
- {\let\CF@draw@axisbond\CF@draw@axisbond@join}
- {\let\CF@draw@axisbond\CF@draw@axisbond@nojoin}%
- \ifboolKV[chemfig]{cram rectangle}
- {\let\CF@clipcramornot\CF@gobtikzinstruction}
- {\let\CF@clipcramornot\clip}%
- \CF@valuetomacro\CF@cram@basewidth[1.5ex]{cram width}%
- \CF@valuetomacro\CF@cram@dashlength[1pt]{cram dash width}%
- \CF@valuetomacro\CF@cram@dashsep[2pt]{cram dash sep}%
- \CF@valuetomacro\CF@atom@sep[3em]{atom sep}% espacement des atomes liés
- \CF@valuetomacro\CF@bond@offset[2pt]{bond offset}%
- \CF@valuetomacro\CF@double@sep[2pt]{double bond sep}%
- \CF@valuetomacro\CF@angle@increment[45]{angle increment}%
- \CF@valuetomacro\CF@node@style[]{node style}%
- \CF@valuetomacro\CF@bond@style[]{bond style}%
- \CF@valuetomacro\CF@stacksep[1.5pt]{stack sep}%
- \CF@valuetomacro\CF@cycle@inraduiscoeff[0.75]{cycle radius coeff}% coeff multiplicateur du rayon des arcs dans les cycles
- \CF@incyclefalse
- \CF@cnt@groupnumber\z@
- \let\CF@last@action\z@% 0=début du dessin 1=tracé d'un noeud 2=tracé d'une liaison
- \let\CF@start@offset\empty
- \let\CF@end@offset\empty
- \let\CF@bond@outcontentsaved\empty
- \def\CF@cycle@anglecorrection{180/\CF@cycle@num}%
- \def\default@angle{0}%
- \def\default@stringangle{:0}% angle pris par défaut si le champ est vide
- \def\default@length{1}%
- \let\default@fromatom\empty% numero de l'atome d'où partent les liaisons par défaut
- \let\default@toatom\empty% numéro de l'atome où arrivent les laisons par défaut
- \let\default@tikz\empty
- \let\CF@previous@bondangle\empty
- \let\CF@joinbond\z@
- \let\CF@previous@tikz\empty
- \everyeof{\@nil}\endlinechar-1
- \CF@sanitize@catcode
- \expandafter\assign@tonil\expandafter\CF@remain@molecule\scantokens{#4}%
- \CF@exp@macroarg\CF@chemfig@e{\CF@remain@molecule}%
- #3%
- \let\CF@split@state\z@
-}
-
-\def\CF@chemfig@e#1{% #1 est le code de la molécule
- \ifnum\CF@last@action=\thr@@
- \ifCF@incycle
- \def\default@angle{0}%
+ \setchemfig{#3}%
+ \edef\CF_temp{%
+ \unexpanded{#1}[%
+ remember picture,%
+ every node/.style={%
+ anchor=base,%
+ inner sep=0pt,%
+ outer sep=0pt,%
+ minimum size=0pt,%
+ \unexpanded\CF_threeea{\useKV[chemfig]{atom style}}%
+ },%
+ baseline,%
+ \unexpanded\CF_threeea{\useKV[chemfig]{chemfig style}}%
+ ]%
+ }%
+ \CF_temp% début du tikzpicture
+ \begingroup% \endgroup rajouté en sortie de tracé par \CF_chemfigd
+ \let\CF_hooklist\empty
+ \CF_expsecond\setchemfig{#3}%
+ \ifboolKV[chemfig]{fixed length}
+ {\CF_macrofixedbondlengthtrue}
+ {\CF_macrofixedbondlengthfalse}%
+ \ifboolKV[chemfig]{bond join}
+ {\let\CF_drawaxisbond\CF_drawaxisbondjoin}
+ {\let\CF_drawaxisbond\CF_drawaxisbondnojoin}%
+ \ifboolKV[chemfig]{cram rectangle}
+ {\let\CF_clipcramornot\CF_gobtikzinstruction}
+ {\let\CF_clipcramornot\clip}%
+ \CF_valuetomacro\CF_crambasewidth [1.5ex]{cram width}%
+ \CF_valuetomacro\CF_cramdashlength [1pt]{cram dash width}%
+ \CF_valuetomacro\CF_cramdashsep [2pt]{cram dash sep}%
+ \CF_valuetomacro\CF_atomsep [3em]{atom sep}% espacement des atomes liés
+ \CF_valuetomacro\CF_bondoffset [2pt]{bond offset}%
+ \CF_valuetomacro\CF_doublesep [2pt]{double bond sep}%
+ \CF_valuetomacro\CF_angleincrement [45]{angle increment}%
+ \CF_valuetomacro\CF_nodestyle []{node style}%
+ \CF_valuetomacro\CF_bondstyle []{bond style}%
+ \CF_valuetomacro\CF_stacksep [1.5pt]{stack sep}%
+ \CF_valuetomacro\CF_cycleradiuscoeff[0.75]{cycle radius coeff}% coeff multiplicateur du rayon des arcs dans les cycles
+ \CF_incyclefalse
+ \CF_cntgroup0
+ \let\CF_lastaction\CF_zero% 0=début du dessin 1=tracé d'un noeud 2=tracé d'une liaison
+ \let\CF_startoffset\empty
+ \let\CF_endoffset\empty
+ \let\CF_bondoutcontentsaved\empty
+ \def\CF_cycleanglecorrection{180/\CF_cyclenum}%
+ \def\CF_defaultangle{0}%
+ \def\CF_defaultstringangle{:0}% angle pris par défaut si le champ est vide
+ \def\CF_defaultlength{1}%
+ \let\CF_defaultfromatom\empty% numero de l'atome d'où partent les liaisons par défaut
+ \let\CF_defaulttoatom\empty% numéro de l'atome où arrivent les laisons par défaut
+ \let\CF_defaulttikz\empty
+ \let\CF_previousbondangle\empty
+ \let\CF_joinbond\CF_zero
+ \let\CF_previoustikz\empty
+ \everyeof{\_nil}\endlinechar-1
+ \CF_sanitizecatcode
+ \expandafter\CF_assigntonil\expandafter\CF_molecule\scantokens{#4}%
+ \CF_expsecond{\CF_substall\CF_molecule}\CFhash\CFhash
+ \CF_expsecond\CF_chemfigc{\CF_molecule}%
+ %\endgroup <-- rajouté par \CF_chemfigd
+ #2% fin du tikzpicture
+ \endgroup
+ \let\CF_flipstate\CF_zero
+}
+
+\def\CF_chemfigc#1{% #1 est le code de la molécule
+ \ifnum\CF_lastaction=3
+ \ifCF_incycle
+ \def\CF_defaultangle{0}%
\else
- \ifnum\CF@cnt@cycle=\z@% si c'est le début d'un cycle
- \pgfmathsetmacro\default@angle{\CF@previous@angle+180+\CF@cycle@anglecorrection}% on met la liaison à +180° + correction
+ \ifnum\CF_cntcycle=0 % si c'est le début d'un cycle
+ \pgfmathsetmacro\CF_defaultangle{\CF_previousangle+180+\CF_cycleanglecorrection}% on met la liaison à +180° + correction
\else
- \pgfmathsetmacro\default@angle{\CF@previous@angle-90+180/\CF@cycle@num}% sinon à la bissectrice du sommet du cycle
+ \pgfmathsetmacro\CF_defaultangle{\CF_previousangle-90+180/\CF_cyclenum}% sinon à la bissectrice du sommet du cycle
\fi
\fi
- \let\default@stringangle\empty
+ \let\CF_defaultstringangle\empty
\fi
- \let\CF@current@angle\default@angle
- \def\CF@remain@molecule{#1}%
- \CF@seek@submol% alias en premier ?
- \if[\CF@three@ea\noexpand\expandafter\CF@firsttonil\CF@remain@molecule\@nil
- \expandafter\CF@analyse@optarg\CF@remain@molecule\@nil\CF@remain@molecule
- \CF@exp@macroarg\CF@set@bondangle{\CF@current@stringangle}\CF@current@angle
- \let\default@angle\CF@current@angle
- \let\CF@previous@angle\CF@current@angle
- \CF@doifnotempty\CF@current@stringangle{\let\default@angle\CF@current@angle}%
- \CF@doifnotempty\CF@current@length{\let\default@length\CF@current@length}%
- \CF@doifnotempty\CF@current@fromatom{\let\default@fromatom\CF@current@fromatom}%
- \CF@doifnotempty\CF@current@toatom{\let\default@toatom\CF@current@toatom}%
- \CF@doifnotempty\CF@current@tikz{\let\default@tikz\CF@current@tikz}%
- \CF@seek@submol
+ \let\CF_currentangle\CF_defaultangle
+ \def\CF_molecule{#1}%
+ \CF_seeksubmol% alias en premier ?
+ \if[\CF_threeea\noexpand\expandafter\CF_firsttonil\CF_molecule\_nil
+ \expandafter\CF_analyseoptarg\CF_molecule\_nil\CF_molecule
+ \CF_expsecond\CF_setbondangle{\CF_currentstringangle}\CF_currentangle
+ \let\CF_defaultangle\CF_currentangle
+ \let\CF_previousangle\CF_currentangle
+ \CF_doifnotempty\CF_currentstringangle{\let\CF_defaultangle\CF_currentangle}%
+ \CF_doifnotempty\CF_currentlength {\let\CF_defaultlength\CF_currentlength}%
+ \CF_doifnotempty\CF_currentfromatom {\let\CF_defaultfromatom\CF_currentfromatom}%
+ \CF_doifnotempty\CF_currenttoatom {\let\CF_defaulttoatom\CF_currenttoatom}%
+ \CF_doifnotempty\CF_currenttikz {\let\CF_defaulttikz\CF_currenttikz}%
+ \CF_seeksubmol
\fi
- \edef\default@stringangle{:\default@angle}%
- \let\CF@current@length\default@length
- \let\CF@current@fromatom\default@fromatom
- \let\CF@current@toatom\default@toatom
- \let\CF@current@tikz\default@tikz
- \ifCF@incycle% si on commence un cycle
- \let\CF@current@angle\CF@previous@angle
- \ifCF@cyclearc% on doit tracer l'arc de cercle dans le cycle ?
- \pgfmathsetmacro\CF@cyclearc@radius{\CF@cycle@inraduiscoeff*\CF@current@length*\CF@atom@sep/(2*tan(180/\CF@cycle@num))}%
- \pgfmathsetmacro\CF@cyclearc@initangle{\CF@current@angle+\CF@initcycle@angle+180/\CF@cycle@num+90}
- \pgfmathparse{\CF@current@length*\CF@atom@sep/(2*sin(180/\CF@cycle@num))}%
- \node[at=(\CF@bond@outnode),shift=(\CF@cyclearc@initangle:\pgfmathresult pt)](arccenter){};% le centre de l'arc
- \node[at=(arccenter),shift=(\CF@cyclearc@startangle:\CF@cyclearc@radius pt)](initarc){};% le début de l'arc
- \expandafter\draw\expandafter[\CF@cyclearc@directtikz](initarc) arc (\CF@cyclearc@startangle:\CF@cyclearc@endangle:\CF@cyclearc@radius pt);
+ \edef\CF_defaultstringangle{:\CF_defaultangle}%
+ \let\CF_currentlength\CF_defaultlength
+ \let\CF_currentfromatom\CF_defaultfromatom
+ \let\CF_currenttoatom\CF_defaulttoatom
+ \let\CF_currenttikz\CF_defaulttikz
+ \ifCF_incycle% si on commence un cycle
+ \let\CF_currentangle\CF_previousangle
+ \ifCF_cyclearc% on doit tracer l'arc de cercle dans le cycle ?
+ \pgfmathsetmacro\CF_cyclearcradius{\CF_cycleradiuscoeff*\CF_currentlength*\CF_atomsep/(2*tan(180/\CF_cyclenum))}%
+ \pgfmathsetmacro\CF_cyclearcinitangle{\CF_currentangle+\CF_initcycleangle+180/\CF_cyclenum+90}
+ \pgfmathparse{\CF_currentlength*\CF_atomsep/(2*sin(180/\CF_cyclenum))}%
+ \node[at=(\CF_bondoutnode),shift=(\CF_cyclearcinitangle:\pgfmathresult pt)](arccenter){};% le centre de l'arc
+ \node[at=(arccenter),shift=(\CF_cyclearcstartangle:\CF_cyclearcradius pt)](initarc){};% le début de l'arc
+ \CF_expafter{\draw[}\CF_cyclearcdirecttikz](initarc) arc (\CF_cyclearcstartangle:\CF_cyclearcendangle:\CF_cyclearcradius pt);
\fi
\else
- \let\CF@current@angle\default@angle
+ \let\CF_currentangle\CF_defaultangle
\fi
- \ifnum\CF@last@action=\z@
- \let\CF@previous@angle\default@angle
- \node(CF@node){};
- \CF@exp@macroarg\CF@if@firsttokin{\CF@remain@molecule}{-=(*~?<>}%
- {\CF@insert@emptygroup\CF@remain@molecule}%
+ \ifnum\CF_lastaction=0
+ \let\CF_previousangle\CF_defaultangle
+ \node(CF_node){};
+ \CF_expsecond\CF_iffirsttokin{\CF_molecule}{-=(*~?<>}%
+ {\CF_insertemptygroup\CF_molecule}%
{}%
\fi
- \CF@chemfig@f
-}
-
-\def\CF@chemfig@f{%
- \let\CF@next@action\CF@chemfig@f% à priori, on reboucle
- \CF@ifx\CF@remain@molecule\empty
- {\let\CF@next@action\endgroup}
- {\CF@seek@submol
- \CF@exp@macroarg\CF@seek@node{\CF@remain@molecule}\CF@current@atomgroup\CF@remain@molecule
- \CF@ifx\empty\CF@current@atomgroup% pas de noeud pour commencer ?
- {\def\CF@bond@outnode{%
- n\CF@last@groupnumber-%
- \ifx\CF@current@fromatom\empty
- \ifdim\CF@current@angle pt<90pt \number\CF@cnt@atomingroup
- \else\ifdim\CF@current@angle pt>270pt \number\CF@cnt@atomingroup\else1\fi
+ \CF_chemfigd
+}
+
+\def\CF_chemfigd{%
+ \let\CF_nextaction\CF_chemfigd% à priori, on reboucle
+ \CF_ifx\CF_molecule\empty
+ {\let\CF_nextaction\endgroup
+ }
+ {\CF_seeksubmol
+ \CF_expsecond\CF_seeknode{\CF_molecule}\CF_currentatomgroup\CF_molecule
+ \CF_ifx\empty\CF_currentatomgroup% pas de noeud pour commencer ?
+ {\def\CF_bondoutnode{%
+ n\CF_lastgroupnumber-%
+ \ifx\CF_currentfromatom\empty
+ \ifdim\CF_currentangle pt<90pt
+ \number\CF_cntatomgroup
+ \else
+ \ifdim\CF_currentangle pt>270pt
+ \number\CF_cntatomgroup
+ \else
+ 1%
+ \fi
\fi
\else
- \CF@current@fromatom
+ \CF_currentfromatom
\fi}%
- \CF@exp@after{\futurelet\CF@toks@a\CF@gobtonil}{\CF@remain@molecule\relax\@nil}%
- \CF@if@firsttokin@a{-=<>~}% la suite est une liaison
- {\ifnum\CF@last@action=\tw@% c'est la deuxième liaison consécutive ?
- \CF@insert@emptygroup\CF@remain@molecule% insère un groupe vide
- \edef\CF@bond@outnode{\CF@bond@outnode}%
+ \CF_expafter{\futurelet\CF_toksa\CF_gobtonil}{\CF_molecule\relax\_nil}%
+ \CF_iffirsttokina{-=<>~}% la suite est une liaison
+ {\ifnum\CF_lastaction=2 % c'est la deuxième liaison consécutive ?
+ \CF_insertemptygroup\CF_molecule% insère un groupe vide
+ \edef\CF_bondoutnode{\CF_bondoutnode}%
\else
- \ifCF@incycle\advance\CF@cnt@cycle\@ne\fi
- \CF@exp@macroarg\CF@analyse@bond{\CF@remain@molecule}\CF@bond@type
- \edef\CF@bond@outnode{\CF@bond@outnode}%
- \let\CF@remain@molecule\CF@remain@afterbond
- \ifCF@incycle
- \ifnum\CF@cnt@cycle=\CF@cycle@num\relax
- \CF@three@ea\CF@execfirst
+ \ifCF_incycle
+ \advance\CF_cntcycle1
+ \fi
+ \CF_expsecond\CF_analysebond{\CF_molecule}\CF_bondtype
+ \edef\CF_bondoutnode{\CF_bondoutnode}%
+ \let\CF_molecule\CF_remainafterbond
+ \ifCF_incycle
+ \ifnum\CF_cntcycle=\CF_cyclenum\relax
+ \CF_threeea\CF_execfirst
\else
- \ifnum\CF@cnt@cycle=\@ne
- \let\CF@cycle@firsttikz\CF@current@tikz
- \CF@doifnotempty\CF@start@offset{\let\CF@cycle@joinlast\z@}%
+ \ifnum\CF_cntcycle=1
+ \let\CF_cyclefirsttikz\CF_currenttikz
+ \CF_doifnotempty\CF_startoffset{\let\CF_cyclejoinlast\CF_zero}%
\fi
- \CF@three@ea\CF@execsecond
+ \CF_threeea\CF_execsecond
\fi
\else
- \expandafter\CF@execsecond
+ \expandafter\CF_execsecond
\fi
- {\let\CF@next@action\endgroup
- \CF@draw@bond\CF@bond@type{\CF@bond@outnode}{\CF@hook@cycle}\CF@previous@atomgroup\CF@hook@atomgroup
+ {\let\CF_nextaction\endgroup
+ \CF_drawbond\CF_bondtype{\CF_bondoutnode}{\CF_hookcycle}\CF_previousatomgroup\CF_hookatomgroup
}%
- {\node[at=(\CF@bond@outnode\ifCF@incycle\else\ifCF@macrofixedbondlength.\CF@current@angle\fi\fi),shift=(\ifcase\CF@split@state\or180-\or-\fi\CF@current@angle:\CF@current@length*\CF@atom@sep)](CF@node){};
- \let\CF@previous@angle\CF@current@angle
- \let\CF@last@action\tw@
+ {\node[at=(\CF_bondoutnode\ifCF_incycle\else\ifCF_macrofixedbondlength.\CF_currentangle\fi\fi),shift=(\ifcase\CF_flipstate\or180-\or-\fi\CF_currentangle:\CF_currentlength*\CF_atomsep)](CF_node){};
+ \let\CF_previousangle\CF_currentangle
+ \def\CF_lastaction{2}%
}%
\fi
- \ifcat\relax\detokenize\expandafter{\romannumeral-`\.\expandafter\noexpand\CF@remain@molecule}\relax
+ \ifcat\relax\detokenize\expandafter{\romannumeral-`\.\expandafter\noexpand\CF_molecule}\relax
% s'il ne reste plus rien après la liaison (sans tenir compte de l'espace devant)-> insère un groupe vide
- \CF@insert@emptygroup\CF@remain@molecule
+ \CF_insertemptygroup\CF_molecule
\fi
}%
- {\edef\CF@bond@outnode{\CF@bond@outnode}% évalue le l'atome de départ de liaison
- \CF@ifx(\CF@toks@a% une parenthèse pour commencer ?
- {\ifnum\CF@last@action=\tw@% il y avait une liaison juste avant ?
- \CF@insert@emptygroup\CF@remain@molecule
+ {\edef\CF_bondoutnode{\CF_bondoutnode}% évalue le l'atome de départ de liaison
+ \CF_ifx(\CF_toksa% une parenthèse pour commencer ?
+ {\ifnum\CF_lastaction=2 % il y avait une liaison juste avant ?
+ \CF_insertemptygroup\CF_molecule
\else
- \CF@exp@macroarg\CF@grab@submol{\CF@remain@molecule}%
+ \CF_expsecond\CF_grabsubmol{\CF_molecule}%
\begingroup
- \ifCF@incycle\let\CF@last@action\thr@@\fi% on était dans un cycle
- \CF@incyclefalse
- \aftergroup\CF@chemfig@f
- \def\CF@next@action{\CF@exp@macroarg\CF@chemfig@e{\CF@sub@mol}}%
+ \ifCF_incycle\def\CF_lastaction{3}\fi% on était dans un cycle
+ \CF_incyclefalse
+ \aftergroup\CF_chemfigd
+ \def\CF_nextaction{\CF_expsecond\CF_chemfigc{\CF_molinparen}}%
\fi
}%
- {\CF@ifx\CF@remain@molecule\empty
- {\let\CF@next@action\endgroup}
+ {\CF_ifx\CF_molecule\empty
+ {\let\CF_nextaction\endgroup
+ }
{% ce qui reste après le noeud courant n'est pas vide, ne commence pas par "-=~", ni par une parenthèse
- \CF@ifx*\CF@toks@a% un cycle ?
- {\ifnum\CF@last@action=\tw@
- \CF@insert@emptygroup\CF@remain@molecule% insère un groupe vide
+ \CF_ifx*\CF_toksa% un cycle ?
+ {\ifnum\CF_lastaction=2
+ \CF_insertemptygroup\CF_molecule% insère un groupe vide
\else
- \ifCF@incycle\let\CF@last@action\thr@@\fi% on était dans un cycle
- \ifnum\CF@last@action=\thr@@\let\CF@lastcycle@num\CF@cycle@num\fi
- \CF@eexp@macroarg\CF@if@firsttokmatch{\expandafter\CF@gobarg\CF@remain@molecule}*%
- {\CF@eexp@second{\def\CF@remain@molecule}{\expandafter\CF@gobarg\CF@remain@molecule}% enlève la 1er étoile
- \CF@eexp@macroarg\CF@if@firsttokmatch{\expandafter\CF@gobarg\CF@remain@molecule}[% un crochet ensuite ?
- {\expandafter\CF@cycle@parsepreamblewithoptarg\CF@remain@molecule\@nil% \begingroup inclus
+ \ifCF_incycle
+ \def\CF_lastaction{3}%
+ \fi% on était dans un cycle
+ \ifnum\CF_lastaction=3
+ \let\CF_lastcyclenum\CF_cyclenum
+ \fi
+ \CF_eexpsecond\CF_iffirsttokmatch{\expandafter\CF_gobarg\CF_molecule}*%
+ {\CF_eexpsecond{\def\CF_molecule}{\expandafter\CF_gobarg\CF_molecule}% enlève la 1er étoile
+ \CF_eexpsecond\CF_iffirsttokmatch{\expandafter\CF_gobarg\CF_molecule}[% un crochet ensuite ?
+ {\expandafter\CF_cycleparsepreamblewithoptarg\CF_molecule\_nil% \begingroup inclus
}%
- {\def\CF@cyclearc@startangle{0}\def\CF@cyclearc@endangle{360}%
- \let\CF@cyclearc@directtikz\empty
- \expandafter\CF@cycle@parsepreamble\CF@remain@molecule\@nil% \begingroup inclus
+ {\def\CF_cyclearcstartangle{0}\def\CF_cyclearcendangle{360}%
+ \let\CF_cyclearcdirecttikz\empty
+ \expandafter\CF_cycleparsepreamble\CF_molecule\_nil% \begingroup inclus
}%
- \CF@cyclearctrue
+ \CF_cyclearctrue
}%
- {\expandafter\CF@cycle@parsepreamble\CF@remain@molecule\@nil% \begingroup inclus
- \CF@cyclearcfalse
+ {\expandafter\CF_cycleparsepreamble\CF_molecule\_nil% \begingroup inclus
+ \CF_cyclearcfalse
}%
- \CF@cnt@cycle\z@
- \edef\CF@hook@cycle{\CF@bond@outnode}%
- \let\CF@hook@atomgroup\CF@previous@atomgroup
- \CF@ifx\CF@hook@atomgroup\CF@empty@node
- {\let\CF@cycle@joinlast\@ne}% joindre le dernier
- {\let\CF@cycle@joinlast\z@}
- \CF@incycletrue
- \ifnum\CF@last@action=\thr@@
- \pgfmathsetmacro\CF@initcycle@angle{360/\CF@lastcycle@num-180}% c'est un cycle dans un cycle
+ \CF_cntcycle0
+ \edef\CF_hookcycle{\CF_bondoutnode}%
+ \let\CF_hookatomgroup\CF_previousatomgroup
+ \CF_ifx\CF_hookatomgroup\CF_emptynode
+ {\def\CF_cyclejoinlast{1}}% joindre le dernier
+ {\def\CF_cyclejoinlast{0}}
+ \CF_incycletrue
+ \ifnum\CF_lastaction=3
+ \pgfmathsetmacro\CF_initcycleangle{360/\CF_lastcyclenum-180}% c'est un cycle dans un cycle
\else
- \pgfmathsetmacro\CF@initcycle@angle{-180/\CF@cycle@num-90+\CF@cycle@anglecorrection}%
+ \pgfmathsetmacro\CF_initcycleangle{-180/\CF_cyclenum-90+\CF_cycleanglecorrection}%
\fi
- \aftergroup\CF@chemfig@f
- \def\CF@next@action{\CF@exp@macroarg\CF@chemfig@e{\CF@sub@mol}}%
+ \aftergroup\CF_chemfigd
+ \def\CF_nextaction{\CF_expsecond\CF_chemfigc{\CF_molinparen}}%
\fi
}%
- {\errmessage{Package \CFname\space Error: something went wrong here: \detokenize\expandafter{\CF@remain@molecule}^^JIf you think it's a bug, please, send a Minimal Example to the author.}%
+ {\CF_error{something went wrong here: \detokenize\expandafter{\CF_molecule}^^JIf you think it's a bug, please, send a Minimal Example to the author}%
}%
}%
}%
}%
}%
- {\CF@exp@threemacroargs\CF@draw@atomgroup\CF@current@angle\CF@current@toatom\CF@current@atomgroup
+ {\CF_expthreemacroargs\CF_drawatomgroup\CF_currentangle\CF_currenttoatom\CF_currentatomgroup
}%
}%
- \CF@next@action
+ \CF_nextaction
}
-\def\CF@cycle@parsepreamble*#1#2\@nil{%
- \ifnum#1<\thr@@
- \errmessage{Package \CFname\space Error: A cycle must be at least a triangle.^^JThe number following "*" must be 3 or more}%
+\def\CF_cycleparsepreamble*#1#2\_nil{%
+ \ifnum#1<3
+ \CF_error{a cycle must be at least a triangle.^^JThe number following "*" must be 3 or more}%
\fi
- \def\CF@remain@molecule{#2}%
- \CF@exp@macroarg\CF@grab@submol{\CF@remain@molecule}%
+ \def\CF_molecule{#2}%
+ \CF_expsecond\CF_grabsubmol{\CF_molecule}%
\begingroup
- \def\CF@cycle@num{#1}%
+ \def\CF_cyclenum{#1}%
}
-\def\CF@cycle@parsepreamblewithoptarg*[#1]#2#3\@nil{%
- \CF@cycle@parseoptarg#1,\empty,\empty,\empty\@nil
- \CF@cycle@parsepreamble*#2#3\@nil
+\def\CF_cycleparsepreamblewithoptarg*[#1]#2#3\_nil{%
+ \CF_cycleparseoptarg#1,\empty,\empty,\empty\_nil
+ \CF_cycleparsepreamble*#2#3\_nil
}
-\def\CF@cycle@parseoptarg#1,#2,#3\@nil{%
- \CF@ifempty{#1}{\def\CF@cyclearc@startangle{0}}{\def\CF@cyclearc@startangle{#1}}%
- \CF@ifempty{#2}{\def\CF@cyclearc@endangle{360}}{\def\CF@cyclearc@endangle{#2}}%
- \CF@exp@second{\def\CF@cyclearc@directtikz}{\CF@sanitize@lastitem#3,\empty\@nil}%
+\def\CF_cycleparseoptarg#1,#2,#3\_nil{%
+ \CF_ifempty{#1}
+ {\def\CF_cyclearcstartangle{0}}
+ {\def\CF_cyclearcstartangle{#1}}%
+ \CF_ifempty{#2}
+ {\def\CF_cyclearcendangle{360}}
+ {\def\CF_cyclearcendangle{#2}}%
+ \CF_expsecond{\def\CF_cyclearcdirecttikz}{\CF_sanitizelastitem#3,\empty\_nil}%
}
-\def\CF@grab@submol#1{%
+\def\CF_grabsubmol#1{%
\begingroup
- \catcode`(\@ne\catcode`)\tw@
- \CF@three@ea
+ \catcode`(1 \catcode`)2
+ \CF_threeea
\endgroup
- \expandafter\CF@grab@submol@a\scantokens{\relax#1}%
+ \expandafter\CF_grabsubmola\scantokens{\relax#1}%
}
-\def\CF@grab@submol@a#1\@nil{%
- \expandafter\assign@tonil\expandafter\CF@remain@molecule\scantokens\CF@three@ea{\expandafter\CF@gobarg\CF@gobarg#1}%
- \expandafter\assign@tonil\expandafter\CF@sub@mol\scantokens\CF@three@ea{\expandafter\CF@firsttonil\CF@gobarg#1\@nil}%
+\def\CF_grabsubmola#1\_nil{%
+ \expandafter\CF_assigntonil\expandafter\CF_molecule\scantokens\CF_threeea{\expandafter\CF_gobarg \CF_gobarg#1}%
+ \expandafter\CF_assigntonil\expandafter\CF_molinparen\scantokens\CF_threeea{\expandafter\CF_firsttonil\CF_gobarg#1\_nil}%
}
-\def\assign@tonil#1#2\@nil{\def#1{#2}}
-
-\def\CF@ifcar@isupperletter#1{%
+\def\CF_ifcarisupperletter#1{%
\ifcat\relax\noexpand#1%
- \let\CF@next\CF@execsecond% faux si c'est une sc
+ \let\CF_next\CF_execsecond% faux si c'est une sc
\else
\ifnum`#1<`A
- \let\CF@next\CF@execsecond
+ \let\CF_next\CF_execsecond
\else
\ifnum`#1>`Z
- \let\CF@next\CF@execsecond
+ \let\CF_next\CF_execsecond
\else
- \let\CF@next\CF@execfirst
+ \let\CF_next\CF_execfirst
\fi
\fi
\fi
- \CF@next
+ \CF_next
}
% Créé 4 noeuds au dessus et au dessous des noeuds #1 et #2
% à une distance de #3 du noeud #1 et #4 du noeud #2
-\def\CF@create@normnodes#1#2#3#4{%
- \CF@doifnotempty{#3}
- {\node[shape=coordinate,at=(#1),xshift=#3*\CF@norm@x,yshift=#3*\CF@norm@y](#11){};
- \node[shape=coordinate,at=(#1),xshift=-#3*\CF@norm@x,yshift=-#3*\CF@norm@y](#12){};
+\def\CF_createnormnodes#1#2#3#4{%
+ \CF_doifnotempty{#3}
+ {\node[shape=coordinate,at=(#1),xshift=#3*\CF_normx,yshift=#3*\CF_normy](#11){};
+ \node[shape=coordinate,at=(#1),xshift=-#3*\CF_normx,yshift=-#3*\CF_normy](#12){};
}%
- \CF@doifnotempty{#4}
- {\node[shape=coordinate,at=(#2),xshift=#4*\CF@norm@x,yshift=#4*\CF@norm@y](#21){};
- \node[shape=coordinate,at=(#2),xshift=-#4*\CF@norm@x,yshift=-#4*\CF@norm@y](#22){};
+ \CF_doifnotempty{#4}
+ {\node[shape=coordinate,at=(#2),xshift=#4*\CF_normx,yshift=#4*\CF_normy](#21){};
+ \node[shape=coordinate,at=(#2),xshift=-#4*\CF_normx,yshift=-#4*\CF_normy](#22){};
}%
}
-\def\CF@compute@nodevect#1#2{%
- \pgfextractx\CF@dim{\pgfpointanchor{#1}{center}}\edef\CF@dimax{\the\CF@dim}%
- \pgfextracty\CF@dim{\pgfpointanchor{#1}{center}}\edef\CF@dimay{\the\CF@dim}%
- \pgfextractx\CF@dim{\pgfpointanchor{#2}{center}}\edef\CF@dimbx{\the\CF@dim}%
- \pgfextracty\CF@dim{\pgfpointanchor{#2}{center}}\edef\CF@dimby{\the\CF@dim}%
- \pgfmathsetmacro\CF@len@vector{veclen(\CF@dimbx-\CF@dimax,\CF@dimby-\CF@dimay)}%
- \pgfmathsetmacro\CF@norm@x{(\CF@dimay-\CF@dimby)/\CF@len@vector}%
- \pgfmathsetmacro\CF@norm@y{(\CF@dimbx-\CF@dimax)/\CF@len@vector}%
+\def\CF_computenodevect#1#2{%
+ \pgfextractx\CF_dim{\pgfpointanchor{#1}{center}}\edef\CF_dimax{\the\CF_dim}%
+ \pgfextracty\CF_dim{\pgfpointanchor{#1}{center}}\edef\CF_dimay{\the\CF_dim}%
+ \pgfextractx\CF_dim{\pgfpointanchor{#2}{center}}\edef\CF_dimbx{\the\CF_dim}%
+ \pgfextracty\CF_dim{\pgfpointanchor{#2}{center}}\edef\CF_dimby{\the\CF_dim}%
+ \pgfmathsetmacro\CF_vectorlen{veclen(\CF_dimbx-\CF_dimax,\CF_dimby-\CF_dimay)}%
+ \pgfmathsetmacro\CF_normx{(\CF_dimay-\CF_dimby)/\CF_vectorlen}%
+ \pgfmathsetmacro\CF_normy{(\CF_dimbx-\CF_dimax)/\CF_vectorlen}%
}
-\def\CF@set@offset#1#2{%
- \CF@doifempty#1%
- {\edef#1{\ifx#2\CF@empty@node0pt\else\ifx#2\empty0pt\else\CF@bond@offset\fi\fi}}%
+\def\CF_setoffset#1#2{%
+ \CF_doifempty#1%
+ {\edef#1{%
+ \ifx#2\CF_emptynode
+ 0pt%
+ \else
+ \ifx#2\empty
+ 0pt%
+ \else
+ \CF_bondoffset
+ \fi
+ \fi}%
+ }%
}
-\def\CF@draw@bond#1#2#3#4#5{% #1=type de liaison #2 et #3:nom de noeuds de début et fin #4 et #5: contenu des atomes de début et fin
- \CF@set@offset\CF@start@offset#4%
- \CF@set@offset\CF@end@offset#5%
- \let\CF@current@bondstyle\CF@bond@style
- \CF@doifnotempty\CF@current@tikz{\CF@eadd@tocs\CF@current@bondstyle{\expandafter,\CF@current@tikz}}%
+\def\CF_drawbond#1#2#3#4#5{% #1=type de liaison #2 et #3:nom de noeuds de début et fin #4 et #5: contenu des atomes de début et fin
+ \CF_setoffset\CF_startoffset#4%
+ \CF_setoffset\CF_endoffset#5%
+ \let\CF_currentbondstyle\CF_bondstyle
+ \CF_doifnotempty\CF_currenttikz{\CF_eaddtomacro\CF_currentbondstyle{\expandafter,\CF_currenttikz}}%
\path(#2)--(#3)coordinate[pos=0](#2@)coordinate[pos=1](#3@);%
- \CF@compute@nodevect{#2@}{#3@}%
- \pgfmathsetmacro\CF@start@coeff{\CF@start@offset/\CF@len@vector}%
- \pgfmathsetmacro\CF@end@coeff{1-\CF@end@offset/\CF@len@vector}%
- \path(#2@)--(#3@)coordinate[pos=\CF@start@coeff](#2@@)coordinate[pos=\CF@end@coeff](#3@@);%
- \CF@doifnotempty\CF@movebond@name% on doit poser un noeud sur la liaison
- {\path(#2@@)--(#3@@)coordinate[overlay,pos=\CF@movebond@coeff](\CF@movebond@name);
- \let\CF@movebond@name\empty
+ \CF_computenodevect{#2@}{#3@}%
+ \pgfmathsetmacro\CF_startcoeff{\CF_startoffset/\CF_vectorlen}%
+ \pgfmathsetmacro\CF_endcoeff{1-\CF_endoffset/\CF_vectorlen}%
+ \path(#2@)--(#3@)coordinate[pos=\CF_startcoeff](#2@@)coordinate[pos=\CF_endcoeff](#3@@);%
+ \CF_doifnotempty\CF_movebondname% on doit poser un noeud sur la liaison
+ {\path(#2@@)--(#3@@)coordinate[overlay,pos=\CF_movebondcoeff](\CF_movebondname);
+ \let\CF_movebondname\empty
}%
\ifcase#1\relax
- \errmessage{Package \CFname\space Error: unknown bond type, this error should not occur^^JIf you think it's a bug, send a Minimal Example to the author}%
+ \CF_error{unknown bond type, this error should not occur^^JIf you think it's a bug, send a Minimal Example to the author}%
\or% 1 = liaison simple
- \CF@draw@axisbond{#2}{#3}% trace la liaison simple dans l'axe
+ \CF_drawaxisbond{#2}{#3}% trace la liaison simple dans l'axe
\or% 2 = liaison double
- \ifCF@incycle
- \ifnum\CF@doublebond@type=\z@
- \let\CF@doublebond@type\@ne
+ \ifCF_incycle
+ \ifnum\CF_doublebondtype=0
+ \def\CF_doublebondtype{1}%
\fi
- \ifnum\CF@split@state>\z@
- \let\CF@doublebond@type\tw@
+ \ifnum\CF_flipstate>0
+ \def\CF_doublebondtype{2}%
\fi
- \pgfmathsetmacro\CF@doublebond@lengthcorrection{\CF@double@sep*tan(180/\CF@cycle@num)}%
+ \pgfmathsetmacro\CF_doublebondlengthcorrection{\CF_doublesep*tan(180/\CF_cyclenum)}%
\fi
- \ifcase\CF@doublebond@type
- \CF@create@normnodes{#2@@}{#3@@}{\CF@double@sep/2}{\CF@double@sep/2}%
- \CF@draw@bond@a(#2@@1)--(#3@@1);
- \CF@draw@bond@a(#2@@2)--(#3@@2);
- \let\CF@joinbond\z@
+ \ifcase\CF_doublebondtype
+ \CF_createnormnodes{#2@@}{#3@@}{\CF_doublesep/2}{\CF_doublesep/2}%
+ \CF_drawbonda(#2@@1)--(#3@@1);
+ \CF_drawbonda(#2@@2)--(#3@@2);
+ \let\CF_joinbond\CF_zero
\or
- \CF@create@normnodes{#2@@}{#3@@}\CF@double@sep\CF@double@sep
- \CF@draw@axisbond{#2}{#3}% trace la liaison simple dans l'axe\CF@draw@bond@a(#2@@)--(#3@@);
+ \CF_createnormnodes{#2@@}{#3@@}\CF_doublesep\CF_doublesep
+ \CF_drawaxisbond{#2}{#3}% trace la liaison simple dans l'axe\CF_drawbonda(#2@@)--(#3@@);
\begingroup% ajuste éventuellement les longueurs des liaisons doubles
- \ifCF@incycle
- \ifdim\CF@start@offset=\z@
- \CF@edefadd@tocs\CF@current@bondstyle{,shorten <=\CF@doublebond@lengthcorrection pt}%
+ \ifCF_incycle
+ \ifdim\CF_startoffset=0pt
+ \CF_edefaddtomacro\CF_currentbondstyle{,shorten <=\CF_doublebondlengthcorrection pt}%
\fi
- \ifdim\CF@end@offset=\z@
- \CF@edefadd@tocs\CF@current@bondstyle{,shorten >=\CF@doublebond@lengthcorrection pt}%
+ \ifdim\CF_endoffset=0pt
+ \CF_edefaddtomacro\CF_currentbondstyle{,shorten >=\CF_doublebondlengthcorrection pt}%
\fi
\fi
- \CF@draw@bond@a(#2@@1)--(#3@@1);
+ \CF_drawbonda(#2@@1)--(#3@@1);
\endgroup
\or
- \CF@create@normnodes{#2@@}{#3@@}\CF@double@sep\CF@double@sep
- \CF@draw@axisbond{#2}{#3}% trace la liaison simple dans l'axe\CF@draw@bond@a(#2@@)--(#3@@);
+ \CF_createnormnodes{#2@@}{#3@@}\CF_doublesep\CF_doublesep
+ \CF_drawaxisbond{#2}{#3}% trace la liaison simple dans l'axe\CF_drawbonda(#2@@)--(#3@@);
\begingroup% ajuste éventuellement les longueurs des liaisons doubles
- \ifCF@incycle
- \ifdim\CF@start@offset=\z@
- \CF@edefadd@tocs\CF@current@bondstyle{,shorten \ifnum\CF@split@state=\z@<=-\else>=\fi\CF@doublebond@lengthcorrection pt}%
+ \ifCF_incycle
+ \ifdim\CF_startoffset=0pt
+ \CF_edefaddtomacro\CF_currentbondstyle{,shorten \ifnum\CF_flipstate=0 <=-\else>=\fi\CF_doublebondlengthcorrection pt}%
\fi
- \ifdim\CF@end@offset=\z@
- \CF@edefadd@tocs\CF@current@bondstyle{,shorten \ifnum\CF@split@state=\z@>=-\else<=\fi\CF@doublebond@lengthcorrection pt}%
+ \ifdim\CF_endoffset=0pt
+ \CF_edefaddtomacro\CF_currentbondstyle{,shorten \ifnum\CF_flipstate=0 >=-\else<=\fi\CF_doublebondlengthcorrection pt}%
\fi
\fi
- \CF@draw@bond@a(#2@@2)--(#3@@2);
+ \CF_drawbonda(#2@@2)--(#3@@2);
\endgroup
\fi
\or% 3 = liaison triple
- \CF@create@normnodes{#2@@}{#3@@}\CF@double@sep\CF@double@sep
- \CF@draw@axisbond{#2}{#3}% trace la liaison simple dans l'axe\CF@draw@bond@a(#2@@)--(#3@@);
- \CF@draw@bond@a(#2@@1)--(#3@@1);
- \CF@draw@bond@a(#2@@2)--(#3@@2);
+ \CF_createnormnodes{#2@@}{#3@@}\CF_doublesep\CF_doublesep
+ \CF_drawaxisbond{#2}{#3}% trace la liaison simple dans l'axe\CF_drawbonda(#2@@)--(#3@@);
+ \CF_drawbonda(#2@@1)--(#3@@1);
+ \CF_drawbonda(#2@@2)--(#3@@2);
\or% 4 = liaison Cram pleine de #2 vers #3
- \CF@create@normnodes{#2@@}{#3@@}{\CF@cram@basewidth/2}{}%
- \expandafter\filldraw\expandafter[\CF@current@bondstyle,line join=bevel](#2@@1)--(#2@@2)--(#3@@)--cycle;
- \let\CF@joinbond\z@
+ \CF_createnormnodes{#2@@}{#3@@}{\CF_crambasewidth/2}{}%
+ \CF_expafter{\filldraw[}\CF_currentbondstyle,line join=bevel](#2@@1)--(#2@@2)--(#3@@)--cycle;
+ \let\CF_joinbond\CF_zero
\or% 5 = liaison Cram creuse de #3 vers #2
- \CF@create@normnodes{#3@@}{#2@@}{\CF@cram@basewidth/2}{}%
- \expandafter\filldraw\expandafter[\CF@current@bondstyle,line join=bevel](#3@@1)--(#3@@2)--(#2@@)--cycle;
- \let\CF@joinbond\z@
+ \CF_createnormnodes{#3@@}{#2@@}{\CF_crambasewidth/2}{}%
+ \CF_expafter{\filldraw[}\CF_currentbondstyle,line join=bevel](#3@@1)--(#3@@2)--(#2@@)--cycle;
+ \let\CF_joinbond\CF_zero
\or% 6 = liaison Cram pointillée de #2 vers #3
\scope
- \CF@create@normnodes{#2@@}{#3@@}{\CF@cram@basewidth/2}{}%
- \CF@clipcramornot(#2@@1)--(#2@@2)--(#3@@)--(#2@@1);
- \expandafter\draw\expandafter[\CF@current@bondstyle,dash pattern=on \CF@cram@dashlength off \CF@cram@dashsep,line width=\CF@cram@basewidth](#2@@)--(#3@@);
+ \CF_createnormnodes{#2@@}{#3@@}{\CF_crambasewidth/2}{}%
+ \CF_clipcramornot(#2@@1)--(#2@@2)--(#3@@)--(#2@@1);
+ \CF_expafter{\draw[}\CF_currentbondstyle,dash pattern=on \CF_cramdashlength off \CF_cramdashsep,line width=\CF_crambasewidth](#2@@)--(#3@@);
\endscope
- \let\CF@joinbond\z@
+ \let\CF_joinbond\CF_zero
\or% 7 = liaison Cram pointillée de #3 vers #2
\scope
- \CF@create@normnodes{#3@@}{#2@@}{\CF@cram@basewidth/2}{}%
- \CF@clipcramornot(#3@@1)--(#3@@2)--(#2@@)--(#3@@1);
- \expandafter\draw\expandafter[\CF@current@bondstyle,dash pattern=on \CF@cram@dashlength off \CF@cram@dashsep,line width=\CF@cram@basewidth](#3@@)--(#2@@);
+ \CF_createnormnodes{#3@@}{#2@@}{\CF_crambasewidth/2}{}%
+ \CF_clipcramornot(#3@@1)--(#3@@2)--(#2@@)--(#3@@1);
+ \CF_expafter{\draw[}\CF_currentbondstyle,dash pattern=on \CF_cramdashlength off \CF_cramdashsep,line width=\CF_crambasewidth](#3@@)--(#2@@);
\endscope
- \let\CF@joinbond\z@
+ \let\CF_joinbond\CF_zero
\or% 8 = liaison cram rectangle évidé de #2 vers #3
- \CF@create@normnodes{#2@@}{#3@@}{\CF@cram@basewidth/2}{}%
- \expandafter\draw\expandafter[\CF@current@bondstyle,line join=bevel](#2@@1)--(#2@@2)--(#3@@)--cycle;
- \let\CF@joinbond\z@
+ \CF_createnormnodes{#2@@}{#3@@}{\CF_crambasewidth/2}{}%
+ \CF_expafter{\draw[}\CF_currentbondstyle,line join=bevel](#2@@1)--(#2@@2)--(#3@@)--cycle;
+ \let\CF_joinbond\CF_zero
\or% 9 = liaison cram rectangle évidé de #3 vers #1
- \CF@create@normnodes{#3@@}{#2@@}{\CF@cram@basewidth/2}{}%
- \expandafter\draw\expandafter[\CF@current@bondstyle,line join=bevel](#3@@1)--(#3@@2)--(#2@@)--cycle;
- \let\CF@joinbond\z@
+ \CF_createnormnodes{#3@@}{#2@@}{\CF_crambasewidth/2}{}%
+ \CF_expafter{\draw[}\CF_currentbondstyle,line join=bevel](#3@@1)--(#3@@2)--(#2@@)--cycle;
+ \let\CF_joinbond\CF_zero
\else
- \errmessage{Package \CFname\space Error: unknown bond type, this error should not occur^^JIf you think it's a bug, send a Minimal Example to the author}%
+ \CF_error{unknown bond type, this error should not occur^^JIf you think it's a bug, send a Minimal Example to the author}%
\fi
- \let\CF@start@offset\empty
- \let\CF@end@offset\empty
- \let\CF@previous@tikz\CF@current@tikz
- \let\CF@previous@bondangle\CF@previous@angle
- \def\CF@previous@bond{#1}%
-}
-
-\def\CF@draw@axisbond@nojoin#1#2{\CF@draw@bond@a(#1@@)--(#2@@);}
-
-\def\CF@draw@axisbond@join#1#2{% dessine une liaison simple dans l'axe avec raccord rétrograde
- \ifCF@incycle\ifnum\CF@cnt@cycle=\CF@cycle@num\relax\let\CF@next@tikz\CF@cycle@firsttikz\fi\fi
- \ifnum\CF@joinbond=\z@
- \ifCF@incycle
- \ifnum\CF@cnt@cycle=\CF@cycle@num\relax
- \ifnum\CF@cycle@joinlast=\@ne
- \CF@draw@bond@a(#1@@)--(#2@@)--%
- ([shift=(\CF@previous@bondangle+2*\CF@cycle@increment@angle:.5\pgflinewidth)]#2@@);
+ \let\CF_startoffset\empty
+ \let\CF_endoffset\empty
+ \let\CF_previoustikz\CF_currenttikz
+ \let\CF_previousbondangle\CF_previousangle
+ \def\CF_previousbond{#1}%
+}
+
+\def\CF_drawaxisbondnojoin#1#2{\CF_drawbonda(#1@@)--(#2@@);}
+
+\def\CF_drawaxisbondjoin#1#2{% dessine une liaison simple dans l'axe avec raccord rétrograde
+ \ifCF_incycle\ifnum\CF_cntcycle=\CF_cyclenum\relax
+ \let\CF_nexttikz\CF_cyclefirsttikz
+ \fi\fi
+ \ifnum\CF_joinbond=0
+ \ifCF_incycle
+ \ifnum\CF_cntcycle=\CF_cyclenum\relax
+ \ifnum\CF_cyclejoinlast=1
+ \CF_drawbonda(#1@@)--(#2@@)--%
+ ([shift=(\CF_previousbondangle+2*\CF_cycleincrementangle:.5\pgflinewidth)]#2@@);
\else
- \CF@draw@bond@a(#1@@)--(#2@@);
+ \CF_drawbonda(#1@@)--(#2@@);
\fi
\else
- \CF@draw@bond@a(#1@@)--(#2@@);
+ \CF_drawbonda(#1@@)--(#2@@);
\fi
\else
- \CF@draw@bond@a(#1@@)--(#2@@);
+ \CF_drawbonda(#1@@)--(#2@@);
\fi
- \let\CF@joinbond\@ne
+ \def\CF_joinbond{1}%
\else
- \CF@ifx\CF@previous@tikz\CF@current@tikz
- {\let\CF@joinbond\@ne
- \CF@ifx\CF@previous@atomgroup\CF@empty@node
- {\CF@ifx\CF@previous@bondangle\empty% si début molécule
- {\CF@draw@bond@a(#1@@)--(#2@@);
+ \CF_ifx\CF_previoustikz\CF_currenttikz
+ {\def\CF_joinbond{1}%
+ \CF_ifx\CF_previousatomgroup\CF_emptynode
+ {\CF_ifx\CF_previousbondangle\empty% si début molécule
+ {\CF_drawbonda(#1@@)--(#2@@);
}
- {\ifdim\CF@start@offset=\z@
- \ifCF@incycle
- \ifnum\CF@cnt@cycle=\CF@cycle@num\relax
- \ifnum\CF@cycle@joinlast=\@ne
- \CF@ifx\CF@cycle@firsttikz\CF@current@tikz
- {\CF@draw@bond@a([shift=(\CF@previous@bondangle:-.5\pgflinewidth)]#1@@)--(#1@@)--(#2@@)--%
- ([shift=(\CF@previous@bondangle+2*\CF@cycle@increment@angle:.5\pgflinewidth)]#2@@);
+ {\ifdim\CF_startoffset=0pt
+ \ifCF_incycle
+ \ifnum\CF_cntcycle=\CF_cyclenum\relax
+ \ifnum\CF_cyclejoinlast=1
+ \CF_ifx\CF_cyclefirsttikz\CF_currenttikz
+ {\CF_drawbonda([shift=(\CF_previousbondangle:-.5\pgflinewidth)]#1@@)--(#1@@)--(#2@@)--%
+ ([shift=(\CF_previousbondangle+2*\CF_cycleincrementangle:.5\pgflinewidth)]#2@@);
}
- {\CF@draw@bond@a([shift=(\CF@previous@bondangle:-.5\pgflinewidth)]#1@@)--(#1@@)--(#2@@);
+ {\CF_drawbonda([shift=(\CF_previousbondangle:-.5\pgflinewidth)]#1@@)--(#1@@)--(#2@@);
}%
\else
- \CF@draw@bond@a([shift=(\CF@previous@bondangle:-.5\pgflinewidth)]#1@@)--(#1@@)--(#2@@);
+ \CF_drawbonda([shift=(\CF_previousbondangle:-.5\pgflinewidth)]#1@@)--(#1@@)--(#2@@);
\fi
\else
- \CF@draw@bond@a([shift=(\CF@previous@bondangle:-.5\pgflinewidth)]#1@@)--(#1@@)--(#2@@);
+ \CF_drawbonda([shift=(\CF_previousbondangle:-.5\pgflinewidth)]#1@@)--(#1@@)--(#2@@);
\fi
\else
- \CF@draw@bond@a([shift=(\CF@previous@bondangle:-.5\pgflinewidth)]#1@@)--(#1@@)--(#2@@);
+ \CF_drawbonda([shift=(\CF_previousbondangle:-.5\pgflinewidth)]#1@@)--(#1@@)--(#2@@);
\fi
\else
- \CF@draw@bond@a(#1@@)--(#2@@);
+ \CF_drawbonda(#1@@)--(#2@@);
\fi
}%
}
- {\CF@draw@bond@a(#1@@)--(#2@@);}%
+ {\CF_drawbonda(#1@@)--(#2@@);}%
}
- {\ifCF@incycle
- \ifnum\CF@cnt@cycle=\CF@cycle@num\relax
- \ifnum\CF@cycle@joinlast=\@ne
- \CF@ifx\CF@next@tikz\CF@current@tikz
- {\CF@draw@bond@a(#1@@)--(#2@@)--%
- ([shift=(\CF@previous@bondangle+2*\CF@cycle@increment@angle:.5\pgflinewidth)]#2@@);
- }%
- {\CF@draw@bond@a(#1@@)--(#2@@);
- }%
+ {\ifCF_incycle
+ \ifnum\CF_cntcycle=\CF_cyclenum\relax
+ \ifnum\CF_cyclejoinlast=1
+ \CF_ifx\CF_nexttikz\CF_currenttikz
+ {\CF_drawbonda(#1@@)--(#2@@)--([shift=(\CF_previousbondangle+2*\CF_cycleincrementangle:.5\pgflinewidth)]#2@@);}%
+ {\CF_drawbonda(#1@@)--(#2@@);}%
\else
- \CF@draw@bond@a(#1@@)--(#2@@);
+ \CF_drawbonda(#1@@)--(#2@@);
\fi
\else
- \CF@draw@bond@a(#1@@)--(#2@@);
+ \CF_drawbonda(#1@@)--(#2@@);
\fi
\else
- \CF@draw@bond@a(#1@@)--(#2@@);
+ \CF_drawbonda(#1@@)--(#2@@);
\fi
}%
\fi
- \ifdim\CF@end@offset=\z@\else\let\CF@joinbond\z@\fi
+ \ifdim\CF_endoffset=0pt \else
+ \let\CF_joinbond\CF_zero
+ \fi
}
-\def\CF@draw@bond@a{\expandafter\draw\expandafter[\CF@current@bondstyle]}
+\def\CF_drawbonda{\CF_expafter{\draw[}\CF_currentbondstyle]}
-\def\CF@hook@drawall{% dessine tous les crochets contenus dans la sc \CF@hook@draw
- \CF@doifnotempty\CF@hook@drawlist
- {\expandafter\CF@hook@drawfirst\CF@hook@drawlist\@nil% trace un lien de crochet à crochet
- \CF@hook@drawall
+\def\CF_hookdrawall{% dessine tous les crochets contenus dans la sc \CF_hookdraw
+ \CF_doifnotempty\CF_hookdrawlist
+ {\expandafter\CF_hookdrawfirst\CF_hookdrawlist\_nil% trace un lien de crochet à crochet
+ \CF_hookdrawall
}%
}
-\def\CF@hook@drawfirst[#1,#2,#3]#4#5#6#7#8\@nil{%
- \def\CF@hook@drawlist{#8}%
+\def\CF_hookdrawfirst[#1,#2,#3]#4#5#6#7#8\_nil{%
+ \def\CF_hookdrawlist{#8}%
\begingroup
- \let\CF@joinbond\z@
- \def\CF@current@tikz{#3}%
- \def\CF@hook@startcontent{#6}\def\CF@hook@endcontent{#7}%
- \CF@if@integer{#2}%
- {\CF@draw@bond{#2}{#4}{#5}\CF@hook@startcontent\CF@hook@endcontent}%
- {\CF@bond@findcode{#2}\CF@bond@currentnum
- \CF@draw@bond\CF@bond@currentnum{#4}{#5}\CF@hook@startcontent\CF@hook@endcontent
+ \let\CF_joinbond\CF_zero
+ \def\CF_currenttikz{#3}%
+ \def\CF_hookstartcontent{#6}\def\CF_hookendcontent{#7}%
+ \CF_ifinteger{#2}%
+ {\CF_drawbond{#2}{#4}{#5}\CF_hookstartcontent\CF_hookendcontent
+ }%
+ {\CF_assignbondcode{#2}\CF_bondcurrentnum
+ \CF_drawbond\CF_bondcurrentnum{#4}{#5}\CF_hookstartcontent\CF_hookendcontent
}%
\endgroup
}
-\def\CF@extract@atom#1-#2\@nil{#2}% transforme le bound@outnode en n° de l'atome
+\def\CF_extractatom#1-#2\_nil{#2}% transforme le bound@outnode en n° de l'atome
-\expandafter\def\expandafter\CF@gobble@movearg\CF@arobas#1#2\@nil#3{%
- \expandafter\def\csname atom@\number\CF@cnt@atomnumber\endcsname{#2}%
- \CF@if@instr{#1},%
- {\CF@analyse@movearg#1\@nil#3\let\CF@movebond@coeff\empty}%
+\def\CF_gobblemovearg @#1#2\_nil#3{%
+ \expandafter\def\csname atom_\number\CF_cntatom\endcsname{#2}%
+ \CF_ifinstr{#1},%
+ {\CF_analysemovearg#1\_nil#3\let\CF_movebondcoeff\empty}%
{\def#3{#1}}%
- \CF@doifempty{#2}{\let\CF@node@strut\empty}%
+ \CF_doifempty{#2}{\let\CF_nodestrut\empty}%
}%
-\def\hflipnext{\let\CF@split@state\@ne}
+\def\hflipnext{\def\CF_flipstate{1}}
-\def\vflipnext{\let\CF@split@state\tw@}
-\let\CF@split@state\z@
+\def\vflipnext{\def\CF_flipstate{2}}
+\let\CF_flipstate\CF_zero
-\def\CF@draw@atomgroup#1#2#3{% #1=angle d'arrivée de la liaison #2=numero atome sur lequel arrive la liaison #3=groupe d'atomes
- \expandafter\let\expandafter\CF@bond@outcontent% assigne le contenu de l'atome d'où part la liaison
+\def\CF_drawatomgroup#1#2#3{% #1=angle d'arrivée de la liaison #2=numero atome sur lequel arrive la liaison #3=groupe d'atomes
+ \expandafter\let\expandafter\CF_bondoutcontent% assigne le contenu de l'atome d'où part la liaison
\csname
- \ifdefined\CF@bond@outnode
- atom@\expandafter\CF@extract@atom\CF@bond@outnode\@nil
+ \ifdefined\CF_bondoutnode
+ atom_\expandafter\CF_extractatom\CF_bondoutnode\_nil
\else
- @empty%
+ empty%
\fi
\endcsname
- \global\advance\CF@cnt@groupnumber\@ne
- \let\CF@current@atom\empty
- \global\let\CF@hook@drawlist\empty
- \CF@cnt@atomingroup\z@
- \CF@if@firsttokmatch{#3}?{\CF@draw@atomgroup@a{{}#3}}{\CF@draw@atomgroup@a{#3}}%
- \def\CF@current@atomgroup{#3}%
- \CF@remove@movearg\CF@current@atomgroup% enlève les "@{<nom>}"
- \CF@if@instr{#3}?%
- {\CF@remove@hook\CF@current@atomgroup
- \ifcat\relax\detokenize\expandafter{\romannumeral-`\.\expandafter\noexpand\CF@current@atomgroup}\relax
- \let\CF@current@atomgroup\CF@empty@node
+ \global\advance\CF_cntgroup1
+ \let\CF_currentatom\empty
+ \global\let\CF_hookdrawlist\empty
+ \CF_cntatomgroup0
+ \CF_iffirsttokmatch{#3}?
+ {\CF_drawatomgroupa{{}#3}}
+ {\CF_drawatomgroupa{#3}}%
+ \def\CF_currentatomgroup{#3}%
+ \CF_removemovearg\CF_currentatomgroup% enlève les "@{<nom>}"
+ \CF_ifinstr{#3}?%
+ {\CF_removehook\CF_currentatomgroup
+ \ifcat\relax\detokenize\expandafter{\romannumeral-`\.\expandafter\noexpand\CF_currentatomgroup}\relax
+ \let\CF_currentatomgroup\CF_emptynode
\fi
}%
{}%
- \CF@doifnotempty{#2}
- {\ifnum#2<\@ne
- \immediate\write-1{Package \CFname\space Warning: no atom found at position #2, pershaps you mispelled the optional argument of the bond.}%
+ \CF_doifnotempty{#2}
+ {\ifnum#2<1
+ \CF_warning{no atom found at position #2, pershaps you mispelled the optional argument of the bond.}%
\else
- \ifnum#2>\CF@cnt@atomingroup
- \errmessage{Package \CFname\space Error: no atom found at position #2, pershaps you mispelled the optional argument of the bond.}%
+ \ifnum#2>\CF_cntatomgroup
+ \CF_error{no atom found at position #2, pershaps you mispelled the optional argument of the bond.}%
\fi
\fi
}%
- \edef\CF@hook@atomnumber{%
- \CF@ifempty{#2}
+ \edef\CF_hookatomnumber{%
+ \CF_ifempty{#2}
{\ifdim#1pt>90pt
- \ifdim#1pt<270pt \number\CF@cnt@atomingroup\else1\fi
- \else1%
+ \ifdim#1pt<270pt
+ \number\CF_cntatomgroup
+ \else
+ 1%
+ \fi
+ \else
+ 1%
\fi
}
- {#2}%
+ {#2%
+ }%
}%
- \CF@cnt@atomnumber\CF@hook@atomnumber
- \CF@ifx\CF@current@atomgroup\CF@empty@node
- {\let\CF@node@strut\empty}
- {\CF@ifx\empty\CF@bond@outcontentsaved
- {\def\CF@node@strut{\vphantom\CF@bond@outcontent}}%
- {\def\CF@node@strut{\vphantom\CF@bond@outcontentsaved}}%
+ \CF_cntatom\CF_hookatomnumber
+ \CF_ifx\CF_currentatomgroup\CF_emptynode
+ {\let\CF_nodestrut\empty
+ }
+ {\CF_ifx\empty\CF_bondoutcontentsaved
+ {\def\CF_nodestrut{\vphantom\CF_bondoutcontent}}%
+ {\def\CF_nodestrut{\vphantom\CF_bondoutcontentsaved}}%
}%
- \edef\CF@opt@string{anchor=\ifnum\CF@last@action=\z@ base\else\ifCF@incycle center\else\ifCF@macrofixedbondlength 180+#1\else center\fi\fi\fi,at=(CF@node),\CF@node@style}% premier atome de la molécule affiché
+ \edef\CF_optstring{anchor=\ifnum\CF_lastaction=0 base\else\ifCF_incycle center\else\ifCF_macrofixedbondlength 180+#1\else center\fi\fi\fi,at=(CF_node),\CF_nodestyle}% premier atome de la molécule affiché
\loop
- \unless\ifnum\CF@cnt@atomnumber>\CF@cnt@atomingroup
- \CF@eexp@after
- {\futurelet\CF@toks@a}
- {\expandafter\expandafter\expandafter\CF@gobtonil\csname atom@\number\CF@cnt@atomnumber\endcsname\@nil}%
- \expandafter\CF@ifx\CF@arobas\CF@toks@a% l'atome courant commence par un "@"
- {\CF@three@ea\CF@gobble@movearg\csname atom@\number\CF@cnt@atomnumber\endcsname\@nil\CF@moveatom@name
- \expandafter\node\expandafter[\CF@opt@string,overlay](\CF@moveatom@name){\phantom{\CF@node@content}};%
- \let\CF@moveatom@name\empty
+ \unless\ifnum\CF_cntatom>\CF_cntatomgroup
+ \CF_eexpafter
+ {\futurelet\CF_toksa}
+ {\expandafter\expandafter\expandafter\CF_gobtonil\csname atom_\number\CF_cntatom\endcsname\_nil}%
+ \CF_ifx @\CF_toksa% l'atome courant commence par un "@"
+ {\CF_threeea\CF_gobblemovearg\csname atom_\number\CF_cntatom\endcsname\_nil\CF_moveatomname
+ \CF_expafter{\node[}\CF_optstring,overlay](\CF_moveatomname){\phantom{\CF_nodecontent}};%
+ \let\CF_moveatomname\empty
}
{}%
- \expandafter\node\expandafter[\CF@opt@string](n\number\CF@cnt@groupnumber-\number\CF@cnt@atomnumber){\CF@node@content};%
- \let\CF@node@strut\empty
- \advance\CF@cnt@atomnumber\@ne
- \edef\CF@opt@string{anchor=base \ifnum\CF@split@state=\@ne east\else west\fi,at=(n\number\CF@cnt@groupnumber-\number\numexpr\CF@cnt@atomnumber-1.base \ifnum\CF@split@state=\@ne west\else east\fi),\CF@node@style}%
+ \CF_expafter{\node[}\CF_optstring](n\number\CF_cntgroup-\number\CF_cntatom){\CF_nodecontent};%
+ \let\CF_nodestrut\empty
+ \advance\CF_cntatom1
+ \edef\CF_optstring{anchor=base \ifnum\CF_flipstate=1 east\else west\fi,at=(n\number\CF_cntgroup-\number\numexpr\CF_cntatom-1.base \ifnum\CF_flipstate=1 west\else east\fi),\CF_nodestyle}%
\repeat
- \CF@cnt@atomnumber\CF@hook@atomnumber
- \ifnum\CF@last@action=\tw@% s'il faut tracer une liaison
- \gdef\CF@cycle@anglecorrection{0}% alors c'est qu'un cycle ne peut pas commencer la molécule : annulation de la correction d'angle
- \CF@draw@bond\CF@bond@type{\CF@bond@outnode}{n\number\CF@cnt@groupnumber-\number\CF@cnt@atomnumber}\CF@previous@atomgroup\CF@current@atomgroup
+ \CF_cntatom\CF_hookatomnumber
+ \ifnum\CF_lastaction=2 % s'il faut tracer une liaison
+ \gdef\CF_cycleanglecorrection{0}% alors c'est qu'un cycle ne peut pas commencer la molécule : annulation de la correction d'angle
+ \CF_drawbond\CF_bondtype{\CF_bondoutnode}{n\number\CF_cntgroup-\number\CF_cntatom}\CF_previousatomgroup\CF_currentatomgroup
\fi
- \let\CF@last@action\@ne% met la dernière action à 1 : affichage d'un noeud
+ \def\CF_lastaction{1}% met la dernière action à 1 : affichage d'un noeud
\loop
- \ifnum\CF@cnt@atomnumber>\@ne
- \advance\CF@cnt@atomnumber-1
- \edef\CF@opt@string{anchor=base \ifnum\CF@split@state=\@ne west\else east\fi,at=(n\number\CF@cnt@groupnumber-\number\numexpr\CF@cnt@atomnumber+1.base \ifnum\CF@split@state=\@ne east\else west\fi),\CF@node@style}%
- \CF@eexp@after
- {\futurelet\CF@toks@a}
- {\expandafter\expandafter\expandafter\CF@gobtonil\csname atom@\number\CF@cnt@atomnumber\endcsname\@nil}%
- \expandafter\CF@ifx\CF@arobas\CF@toks@a% l'atome courant commence par un "@"
- {\CF@three@ea\CF@gobble@movearg\csname atom@\number\CF@cnt@atomnumber\endcsname\@nil\CF@moveatom@name
- \expandafter\node\expandafter[\CF@opt@string,overlay](\CF@moveatom@name){\phantom{\CF@node@content}};%
- \let\CF@moveatom@name\empty
+ \ifnum\CF_cntatom>1
+ \advance\CF_cntatom-1
+ \edef\CF_optstring{anchor=base \ifnum\CF_flipstate=1 west\else east\fi,at=(n\number\CF_cntgroup-\number\numexpr\CF_cntatom+1.base \ifnum\CF_flipstate=1 east\else west\fi),\CF_nodestyle}%
+ \CF_eexpafter
+ {\futurelet\CF_toksa}
+ {\expandafter\expandafter\expandafter\CF_gobtonil\csname atom_\number\CF_cntatom\endcsname\_nil}%
+ \CF_ifx @\CF_toksa% l'atome courant commence par un "@"
+ {\CF_threeea\CF_gobblemovearg\csname atom_\number\CF_cntatom\endcsname\_nil\CF_moveatomname
+ \CF_expafter{\node[}\CF_optstring,overlay](\CF_moveatomname){\phantom{\CF_nodecontent}};%
+ \let\CF_moveatomname\empty
}
{}%
- \expandafter\node\expandafter[\CF@opt@string](n\number\CF@cnt@groupnumber-\number\CF@cnt@atomnumber){\CF@node@content};%
+ \CF_expafter{\node[}\CF_optstring](n\number\CF_cntgroup-\number\CF_cntatom){\CF_nodecontent};%
\repeat
- \CF@hook@drawall
- \edef\CF@last@groupnumber{\number\CF@cnt@groupnumber}%
- \let\CF@previous@atomgroup\CF@current@atomgroup
-}
-
-\expandafter\def\expandafter\CF@keep@movearg\CF@arobas#1#2\@nil{\CF@exp@second{\def\CF@current@atom}{\CF@arobas{#1}}}
-
-\def\CF@draw@atomgroup@a#1{% transforme #1 en un groupe d'atomes
- \CF@ifempty{#1}
- {\expandafter\let\csname atom@\number\CF@cnt@atomingroup\endcsname\CF@current@atom}
- {\advance\CF@cnt@atomingroup\@ne
- \futurelet\CF@toks@a\CF@gobtonil#1\@nil
- \expandafter\CF@ifx\CF@arobas\CF@toks@a
- {\CF@keep@movearg#1\@nil
- \CF@remove@movearg@a#1\@nil\CF@after@movearg
- \CF@exp@macroarg\CF@draw@atomgroup@b{\CF@after@movearg}%
+ \CF_hookdrawall
+ \edef\CF_lastgroupnumber{\number\CF_cntgroup}%
+ \let\CF_previousatomgroup\CF_currentatomgroup
+}
+
+\def\CF_keepmovearg @#1#2\_nil{\def\CF_currentatom{@{#1}}}
+
+\def\CF_drawatomgroupa#1{% transforme #1 en un groupe d'atomes
+ \CF_ifempty{#1}
+ {\expandafter\let\csname atom_\number\CF_cntatomgroup\endcsname\CF_currentatom
+ }
+ {\advance\CF_cntatomgroup1
+ \futurelet\CF_toksa\CF_gobtonil#1\_nil
+ \CF_ifx @\CF_toksa
+ {\CF_keepmovearg#1\_nil
+ \CF_removemovearga#1\_nil\CF_aftermovearg
+ \CF_expsecond\CF_drawatomgroupb{\CF_aftermovearg}%
}%
- {\let\CF@current@atom\empty
- \CF@draw@atomgroup@b{#1}%
+ {\let\CF_currentatom\empty
+ \CF_drawatomgroupb{#1}%
}%
}%
}
-\def\CF@draw@atomgroup@b#1{%
- \CF@ifempty{#1}
- {\expandafter\let\csname atom@\number\CF@cnt@atomingroup\endcsname\CF@current@atom}
- {\futurelet\CF@toks@a\CF@gobtonil#1\@nil
- \CF@ifx\bgroup\CF@toks@a
- {\CF@eadd@tocs\CF@current@atom{\expandafter{\CF@firsttonil#1\@nil}}%
- \CF@exp@macroarg\CF@draw@atomgroup@bi{\CF@gobarg#1}%
+\def\CF_drawatomgroupb#1{%
+ \CF_ifempty{#1}
+ {\expandafter\let\csname atom_\number\CF_cntatomgroup\endcsname\CF_currentatom
+ }
+ {\futurelet\CF_toksa\CF_gobtonil#1\_nil
+ \CF_ifx\bgroup\CF_toksa
+ {\CF_eaddtomacro\CF_currentatom{\expandafter{\CF_firsttonil#1\_nil}}%
+ \CF_expsecond\CF_drawatomgroupba{\CF_gobarg#1}%
}%
- {\CF@ifx\@sptoken\CF@toks@a
- {\CF@add@tocs\CF@current@atom{ }%
- \CF@exp@macroarg\CF@draw@atomgroup@bi{\CF@after@space#1\@nil}%
+ {\CF_ifx\CF_sptoken\CF_toksa
+ {\CF_addtomacro\CF_currentatom{ }%
+ \CF_expsecond\CF_drawatomgroupba{\CF_afterspace#1\_nil}%
}%
- {\CF@eadd@tocs\CF@current@atom{\CF@firsttonil#1\@nil}%
- \CF@exp@macroarg\CF@draw@atomgroup@bi{\CF@gobarg#1}%
+ {\CF_eaddtomacro\CF_currentatom{\CF_firsttonil#1\_nil}%
+ \CF_expsecond\CF_drawatomgroupba{\CF_gobarg#1}%
}%
}%
}%
}
% enlève tous les "@{nom}" de la sc #1
-\def\CF@remove@movearg#1{%
- \CF@exp@after{\expandafter\CF@if@instr\expandafter{#1}}{\CF@arobas}%
- {\expandafter\CF@remove@movearg@a#1\@nil#1%
- \CF@remove@movearg#1%
+\def\CF_removemovearg#1{%
+ \CF_expsecond\CF_ifinstr{#1}@%
+ {\expandafter\CF_removemovearga#1\_nil#1%
+ \CF_removemovearg#1%
}%
{}%
}
% enlève le premier "@{<nom>}" de l'argument et l'assigne à #2
-\def\CF@remove@movearg@a#1\@nil#2{%
- \expandafter\def\expandafter\CF@remove@movearg@b\expandafter##\expandafter1\CF@arobas{%
- \CF@exp@second{\def#2}{\CF@gobarg##1}% mange le \relax
- \CF@remove@movearg@c\relax
+\def\CF_removemovearga#1\_nil#2{%
+ \def\CF_removemoveargb##1@{%
+ \CF_expsecond{\def#2}{\CF_gobarg##1}% mange le \relax
+ \CF_removemoveargc\relax
}%
- \def\CF@remove@movearg@c##1\@nil{\CF@eadd@tocs#2{\CF@gobtwoargs##1}}% mange le \relax et le <nom>
- \CF@remove@movearg@b\relax#1\@nil
+ \def\CF_removemoveargc##1\_nil{\CF_eaddtomacro#2{\CF_gobtwoargs##1}}% mange le \relax et le <nom>
+ \CF_removemoveargb\relax#1\_nil
}
-\def\CF@draw@atomgroup@bi#1{% transforme #1 en un groupe d'atomes
- \CF@ifempty{#1}
- {\expandafter\let\csname atom@\number\CF@cnt@atomingroup\endcsname\CF@current@atom
- \let\CF@current@atom\empty
+\def\CF_drawatomgroupba#1{% transforme #1 en un groupe d'atomes
+ \CF_ifempty{#1}
+ {\expandafter\let\csname atom_\number\CF_cntatomgroup\endcsname\CF_currentatom
+ \let\CF_currentatom\empty
}
- {\futurelet\CF@toks@a\CF@gobtonil#1\@nil
- \expandafter\CF@ifx\CF@arobas\CF@toks@a
- {\expandafter\let\csname atom@\number\CF@cnt@atomingroup\endcsname\CF@current@atom
- \let\CF@current@atom\empty
- \CF@draw@atomgroup@a{#1}%
+ {\futurelet\CF_toksa\CF_gobtonil#1\_nil
+ \CF_ifx @\CF_toksa
+ {\expandafter\let\csname atom_\number\CF_cntatomgroup\endcsname\CF_currentatom
+ \let\CF_currentatom\empty
+ \CF_drawatomgroupa{#1}%
}%
- {\CF@ifx|\CF@toks@a
- {\expandafter\let\csname atom@\number\CF@cnt@atomingroup\endcsname\CF@current@atom
- \let\CF@current@atom\empty
- \CF@exp@macroarg\CF@draw@atomgroup@a{\CF@gobarg#1}%
+ {\CF_ifx|\CF_toksa
+ {\expandafter\let\csname atom_\number\CF_cntatomgroup\endcsname\CF_currentatom
+ \let\CF_currentatom\empty
+ \CF_expsecond\CF_drawatomgroupa{\CF_gobarg#1}%
}%
- {\CF@ifx\@sptoken\CF@toks@a
- {\CF@add@tocs\CF@current@atom{ }%
- \CF@exp@macroarg\CF@draw@atomgroup@bi{\CF@after@space#1\@nil}%
+ {\CF_ifx\CF_sptoken\CF_toksa
+ {\CF_addtomacro\CF_currentatom{ }%
+ \CF_expsecond\CF_drawatomgroupba{\CF_afterspace#1\_nil}%
}%
- {\CF@ifx\bgroup\CF@toks@a
- {\CF@eadd@tocs\CF@current@atom{\expandafter{\CF@firsttonil#1\@nil}}%
- \CF@exp@macroarg\CF@draw@atomgroup@bi{\CF@gobarg#1}%
+ {\CF_ifx\bgroup\CF_toksa
+ {\CF_eaddtomacro\CF_currentatom{\expandafter{\CF_firsttonil#1\_nil}}%
+ \CF_expsecond\CF_drawatomgroupba{\CF_gobarg#1}%
}%
- {\CF@exp@macroarg\CF@ifcar@isupperletter{\CF@firsttonil#1\@nil}%
- {\expandafter\let\csname atom@\number\CF@cnt@atomingroup\endcsname\CF@current@atom
- \let\CF@current@atom\empty
- \CF@draw@atomgroup@a{#1}%
+ {\CF_expsecond\CF_ifcarisupperletter{\CF_firsttonil#1\_nil}%
+ {\expandafter\let\csname atom_\number\CF_cntatomgroup\endcsname\CF_currentatom
+ \let\CF_currentatom\empty
+ \CF_drawatomgroupa{#1}%
}%
- {\CF@ifx?\CF@toks@a
- {\CF@exp@macroarg\CF@if@firsttokmatch{\CF@gobarg#1}[% un crochet après le "?"
- {\expandafter\CF@grab@optarg\CF@gobarg#1\@nil\CF@after@hook}%
- {\expandafter\CF@grab@optarg\expandafter[\expandafter]\CF@gobarg#1\@nil\CF@after@hook}%
- \CF@exp@twomacroargs\CF@if@instr{\CF@hook@list}{\expandafter(\CF@hook@currentname)}% crochet déjà défini ?
- {\CF@exp@macroarg\CF@hook@parselist{\CF@hook@currentname}% chercher les caractéristiques du crochet sauvegardé
- \CF@edefadd@tocs\CF@hook@drawlist{%
- [\CF@hook@currentname,\CF@hook@currentlink,\CF@hook@currenttikz]{\CF@hook@savedcoord}{n\number\CF@cnt@groupnumber-\number\CF@cnt@atomingroup}}%
- \CF@eadd@tocs\CF@hook@drawlist{\expandafter{\CF@hook@savedcontent}}%
- \CF@eadd@tocs\CF@hook@drawlist{\expandafter{\CF@current@atom}}% ajoute les 4 arguments à la liste des crochets à tracer
- \global\let\CF@hook@drawlist\CF@hook@drawlist
+ {\CF_ifx?\CF_toksa
+ {\CF_expsecond\CF_iffirsttokmatch{\CF_gobarg#1}[% un crochet après le "?"
+ {\expandafter\CF_graboptarg\CF_gobarg#1\_nil\CF_afterhook}%
+ {\CF_expafter{\CF_graboptarg[]}{\CF_gobarg#1}\_nil\CF_afterhook}%
+ \CF_exptwomacroargs\CF_ifinstr{\CF_hooklist}{\expandafter(\CF_hookcurrentname)}% crochet déjà défini ?
+ {\CF_expsecond\CF_hookparselist{\CF_hookcurrentname}% chercher les caractéristiques du crochet sauvegardé
+ \CF_edefaddtomacro\CF_hookdrawlist{%
+ [\CF_hookcurrentname,\CF_hookcurrentlink,\CF_hookcurrenttikz]{\CF_hooksavedcoord}{n\number\CF_cntgroup-\number\CF_cntatomgroup}}%
+ \CF_eaddtomacro\CF_hookdrawlist{\expandafter{\CF_hooksavedcontent}}%
+ \CF_eaddtomacro\CF_hookdrawlist{\expandafter{\CF_currentatom}}% ajoute les 4 arguments à la liste des crochets à tracer
+ \global\let\CF_hookdrawlist\CF_hookdrawlist
}%
- {\CF@edefadd@tocs\CF@hook@list{(\CF@hook@currentname)|n\number\CF@cnt@groupnumber-\number\CF@cnt@atomingroup|}%
- \CF@eadd@tocs\CF@hook@list{\CF@current@atom|}%
- \global\let\CF@hook@list\CF@hook@list
+ {\CF_edefaddtomacro\CF_hooklist{(\CF_hookcurrentname)|n\number\CF_cntgroup-\number\CF_cntatomgroup|}%
+ \CF_eaddtomacro\CF_hooklist{\CF_currentatom|}%
+ \global\let\CF_hooklist\CF_hooklist
}%
- \CF@exp@macroarg\CF@draw@atomgroup@bi{\CF@after@hook}%
+ \CF_expsecond\CF_drawatomgroupba{\CF_afterhook}%
}%
- {\CF@eadd@tocs\CF@current@atom{\CF@firsttonil#1\@nil}%
- \CF@exp@macroarg\CF@draw@atomgroup@bi{\CF@gobarg#1}%
+ {\CF_eaddtomacro\CF_currentatom{\CF_firsttonil#1\_nil}%
+ \CF_expsecond\CF_drawatomgroupba{\CF_gobarg#1}%
}%
}%
}%
@@ -1359,784 +1529,906 @@
}%
}
-\def\CF@kook@defaultname{a}
-\def\CF@hook@defaultlink{-}
-\def\CF@hook@defaulttikz{}
+\def\CF_kookdefaultname{a}
+\def\CF_hookdefaultlink{-}
+\def\CF_hookdefaulttikz{}
-\def\CF@hook@parseoptarg#1,#2,#3\@nil{%
- \CF@testempty@andassign\CF@hook@currentname{#1}\CF@kook@defaultname
- \CF@testempty@andassign\CF@hook@currentlink{#2}\CF@hook@defaultlink
- \CF@testempty@andassign\CF@hook@currenttikz{#3}\CF@hook@defaulttikz
+\def\CF_hookparseoptarg#1,#2,#3\_nil{%
+ \CF_testemptyandassign\CF_hookcurrentname{#1}\CF_kookdefaultname
+ \CF_testemptyandassign\CF_hookcurrentlink{#2}\CF_hookdefaultlink
+ \CF_testemptyandassign\CF_hookcurrenttikz{#3}\CF_hookdefaulttikz
}
-\def\CF@grab@optarg[#1]#2\@nil#3{%
- \CF@hook@parseoptarg#1,,\@nil
+\def\CF_graboptarg[#1]#2\_nil#3{%
+ \CF_hookparseoptarg#1,,\_nil
\def#3{#2}%
}
-\def\CF@hook@parselist#1{% #1 est le nom du noeud à retrouver
- \def\CF@hook@parselist@a##1(#1)|##2|##3|##4\@nil{\def\CF@hook@savedcoord{##2}\def\CF@hook@savedcontent{##3}}%
- \expandafter\CF@hook@parselist@a\CF@hook@list\@nil
+\def\CF_hookparselist#1{% #1 est le nom du noeud à retrouver
+ \def\CF_hookparselista##1(#1)|##2|##3|##4\_nil{\def\CF_hooksavedcoord{##2}\def\CF_hooksavedcontent{##3}}%
+ \expandafter\CF_hookparselista\CF_hooklist\_nil
}
-\def\CF@remove@hook#1{%
- \CF@exp@macroarg\CF@if@instr{#1}?%
- {\expandafter\CF@remove@hook@a\expandafter\relax#1\@nil#1%
- \CF@remove@hook#1%
+\def\CF_removehook#1{%
+ \CF_expsecond\CF_ifinstr{#1}?%
+ {\CF_expafter{\CF_removehooka\relax}#1\_nil#1%
+ \CF_removehook#1%
}
{}%
}
-\def\CF@remove@hook@a#1?#2\@nil#3{%
- \CF@if@firsttokmatch{#2}[%
- {\CF@remove@hook@b#1?#2\@nil#3}
- {\CF@exp@second{\def#3}{\CF@gobarg#1#2}}%
+\def\CF_removehooka#1?#2\_nil#3{%
+ \CF_iffirsttokmatch{#2}[%
+ {\CF_removehookb#1?#2\_nil#3}
+ {\CF_expsecond{\def#3}{\CF_gobarg#1#2}}%
}
-\def\CF@remove@hook@b#1?[#2]#3\@nil#4{\CF@exp@second{\def#4}{\CF@gobarg#1#3}}
+\def\CF_removehookb#1?[#2]#3\_nil#4{\CF_expsecond{\def#4}{\CF_gobarg#1#3}}
-\def\Lewis{\CF@testopt{\CF@lewis@a{}}{1}}
+\def\Lewis{%
+ \CF_lewisoverlayfalse
+ \CF_testopt\CF_lewisa{}%
+}
-\def\lewis{\CF@testopt{\CF@lewis@a{,overlay}}{1}}
+\def\lewis{%
+ \CF_lewisoverlaytrue
+ \CF_testopt\CF_lewisa{}%
+}
-\def\CF@lewis@a#1[#2]{%
- \CF@valuetomacro\CF@lewis@widthdouble[0.3ex]{lewis | width}%
- \CF@valuetomacro\CF@lewis@offset[0.4ex]{lewis sep}%
- \CF@valuetomacro\CF@lewis@length[1.5ex]{lewis length}%
- \CF@valuetomacro\CF@lewis@style[]{lewis style}%
- \CF@valuetomacro\CF@lewis@dist[0.3em]{lewis dist}%
- \CF@valuetomacro\CF@lewis@radius[0.15ex]{lewis radius}%
- \CF@ifempty{#2}{\def\CF@lewis@diagcoeff{1}}{\def\CF@lewis@diagcoeff{#2}}%
- \CF@lewis@b{#1}%
+\def\CF_lewisa[#1]{%
+ \begingroup
+ \CF_doifnotempty{#1}{\setchemfig{#1}}%
+ \CF_valuetomacro\CF_lewiswidthdouble[0.3ex]{lewis | width}%
+ \CF_valuetomacro\CF_lewisoffset [0.4ex]{lewis sep}%
+ \CF_valuetomacro\CF_lewislength [1.5ex]{lewis length}%
+ \CF_valuetomacro\CF_lewisstyle []{lewis style}%
+ \CF_valuetomacro\CF_lewisdist [0.3em]{lewis dist}%
+ \CF_valuetomacro\CF_lewisradius [0.15ex]{lewis radius}%
+ \CF_valuetomacro\CF_lewisdiagcoeff [1]{lewis diag coeff}%
+ \ifCF_lewisoverlay
+ \CF_addtomacro\CF_lewisstyle{,overlay}%
+ \fi
+ \CF_lewisb
}
-\def\CF@lewis@b#1#2{\CF@lewis@c#2\@nil{#1}}
+\def\CF_lewisb#1{%
+ \CF_lewisc#1\_nil
+ \endgroup
+}
-\def\CF@lewis@c#1,#2\@nil#3{%
- \setbox\CF@lewis@box\hbox{\printatom{#2}}% mettre en dehors de tikzpicture (si \printatom ne passe pas en mode math)
- \tikzpicture[every node/.style={anchor=base,inner sep=\z@,outer sep=\z@,minimum size=\z@},baseline]%
- \CF@makeother;\CF@makeother:%
- \node(CF@lewis@anchor){};
- \def\CF@lewis@remainpos{#1}%
- \let\CF@lewis@previouspos\empty
+\def\CF_lewisc#1,#2\_nil{%
+ \setbox\CF_boxlewis\hbox{\printatom{#2}}% mettre en dehors de tikzpicture (si \printatom ne passe pas en mode math)
+ \tikzpicture[every node/.style={anchor=base,inner sep=0pt,outer sep=0pt,minimum size=0pt},baseline]%
+ \CF_makeother;\CF_makeother:%
+ \node(CF_lewis@anchor){};
+ \def\CF_lewisremainpos{#1}%
+ \let\CF_lewispreviouspos\empty
\loop
- \unless\ifx\CF@lewis@remainpos\empty
- \edef\CF@lewis@currentpos{\expandafter\CF@firsttonil\CF@lewis@remainpos\@nil}%
- \edef\CF@lewis@remainpos{\expandafter\CF@gobarg\CF@lewis@remainpos}%
- \pgfmathsetmacro\CF@lewis@x{\wd\CF@lewis@box/2+\ifcase\CF@lewis@currentpos\space1\or1\or0\or-1\or-1\or-1\or0\or1\fi*(\wd\CF@lewis@box/2)}%
- \pgfmathsetmacro\CF@lewis@y{\ht\CF@lewis@box/2+\ifcase\CF@lewis@currentpos\space0\or1\or1\or1\or0\or-1\or-1\or-1\fi*(\ht\CF@lewis@box/2\ifnum\CF@lewis@currentpos>4 +\dp\CF@lewis@box\fi)}%
- \edef\CF@lewis@xoffset{\ifcase\CF@lewis@currentpos\space1\or0.70711\or0\or-0.70711\or-1\or-0.70711\or0\or0.70711\fi}%
- \edef\CF@lewis@yoffset{\ifcase\CF@lewis@currentpos\space0\or0.70711\or1\or0.70711\or0\or-0.70711\or-1\or-0.70711\fi}%
- \ifodd\CF@lewis@currentpos\relax
- \pgfmathsetmacro\CF@lewis@current@offset{\CF@lewis@offset*\CF@lewis@diagcoeff}%%
+ \unless\ifx\CF_lewisremainpos\empty
+ \edef\CF_lewiscurrentpos{\expandafter\CF_firsttonil\CF_lewisremainpos\_nil}%
+ \edef\CF_lewisremainpos{\expandafter\CF_gobarg\CF_lewisremainpos}%
+ \pgfmathsetmacro\CF_lewisx{\wd\CF_boxlewis/2+\ifcase\CF_lewiscurrentpos\space1\or1\or0\or-1\or-1\or-1\or0\or1\fi*(\wd\CF_boxlewis/2)}%
+ \pgfmathsetmacro\CF_lewisy{\ht\CF_boxlewis/2+\ifcase\CF_lewiscurrentpos\space0\or1\or1\or1\or0\or-1\or-1\or-1\fi*(\ht\CF_boxlewis/2\ifnum\CF_lewiscurrentpos>4 +\dp\CF_boxlewis\fi)}%
+ \edef\CF_lewisxoffset{\ifcase\CF_lewiscurrentpos\space1\or0.70711\or0\or-0.70711\or-1\or-0.70711\or0\or0.70711\fi}%
+ \edef\CF_lewisyoffset{\ifcase\CF_lewiscurrentpos\space0\or0.70711\or1\or0.70711\or0\or-0.70711\or-1\or-0.70711\fi}%
+ \ifodd\CF_lewiscurrentpos\relax
+ \pgfmathsetmacro\CF_lewiscurrentoffset{\CF_lewisoffset*\CF_lewisdiagcoeff}%%
\else
- \let\CF@lewis@current@offset\CF@lewis@offset
+ \let\CF_lewiscurrentoffset\CF_lewisoffset
\fi
- \if.\expandafter\CF@firsttonil\CF@lewis@remainpos\relax\@nil
- \edef\CF@lewis@remainpos{\expandafter\CF@gobarg\CF@lewis@remainpos}%
- \CF@exp@after{\draw[fill,black,}{\CF@lewis@style#3]}%
- (\CF@lewis@x pt+\CF@lewis@xoffset*\CF@lewis@current@offset,\CF@lewis@y pt+\CF@lewis@yoffset*\CF@lewis@current@offset)circle(\CF@lewis@radius);%
+ \if.\expandafter\CF_firsttonil\CF_lewisremainpos\relax\_nil
+ \edef\CF_lewisremainpos{\expandafter\CF_gobarg\CF_lewisremainpos}%
+ \CF_expafter{\draw[fill,black,}{\CF_lewisstyle]}%
+ (\CF_lewisx pt+\CF_lewisxoffset*\CF_lewiscurrentoffset,\CF_lewisy pt+\CF_lewisyoffset*\CF_lewiscurrentoffset)circle(\CF_lewisradius);%
\else
- \if|\expandafter\CF@firsttonil\CF@lewis@remainpos\relax\@nil
- \edef\CF@lewis@remainpos{\expandafter\CF@gobarg\CF@lewis@remainpos}%
- \pgfmathsetmacro\CF@lewis@x{\CF@lewis@x pt+\CF@lewis@xoffset*\CF@lewis@current@offset}%
- \pgfmathsetmacro\CF@lewis@y{\CF@lewis@y pt+\CF@lewis@yoffset*\CF@lewis@current@offset}%
- \expandafter\draw\expandafter[\CF@lewis@style#3]%
- (\CF@lewis@x pt+\CF@lewis@length*\CF@lewis@yoffset/2 pt,\CF@lewis@y-\CF@lewis@length*\CF@lewis@xoffset/2 pt)--
- (\CF@lewis@x pt+\CF@lewis@length*\CF@lewis@yoffset/2 pt+\CF@lewis@xoffset*\CF@lewis@widthdouble,\CF@lewis@y-\CF@lewis@length*\CF@lewis@xoffset/2 pt+\CF@lewis@yoffset*\CF@lewis@widthdouble)--
- (\CF@lewis@x pt-\CF@lewis@length*\CF@lewis@yoffset/2 pt+\CF@lewis@xoffset*\CF@lewis@widthdouble,\CF@lewis@y+\CF@lewis@length*\CF@lewis@xoffset/2 pt+\CF@lewis@yoffset*\CF@lewis@widthdouble)--
- (\CF@lewis@x pt-\CF@lewis@length*\CF@lewis@yoffset/2 pt,\CF@lewis@y+\CF@lewis@length*\CF@lewis@xoffset/2 pt)--cycle;%
+ \if|\expandafter\CF_firsttonil\CF_lewisremainpos\relax\_nil
+ \edef\CF_lewisremainpos{\expandafter\CF_gobarg\CF_lewisremainpos}%
+ \pgfmathsetmacro\CF_lewisx{\CF_lewisx pt+\CF_lewisxoffset*\CF_lewiscurrentoffset}%
+ \pgfmathsetmacro\CF_lewisy{\CF_lewisy pt+\CF_lewisyoffset*\CF_lewiscurrentoffset}%
+ \CF_expafter{\draw[}\CF_lewisstyle]%
+ (\CF_lewisx pt+\CF_lewislength*\CF_lewisyoffset/2 pt,\CF_lewisy-\CF_lewislength*\CF_lewisxoffset/2 pt)--
+ (\CF_lewisx pt+\CF_lewislength*\CF_lewisyoffset/2 pt+\CF_lewisxoffset*\CF_lewiswidthdouble,\CF_lewisy-\CF_lewislength*\CF_lewisxoffset/2 pt+\CF_lewisyoffset*\CF_lewiswidthdouble)--
+ (\CF_lewisx pt-\CF_lewislength*\CF_lewisyoffset/2 pt+\CF_lewisxoffset*\CF_lewiswidthdouble,\CF_lewisy+\CF_lewislength*\CF_lewisxoffset/2 pt+\CF_lewisyoffset*\CF_lewiswidthdouble)--
+ (\CF_lewisx pt-\CF_lewislength*\CF_lewisyoffset/2 pt,\CF_lewisy+\CF_lewislength*\CF_lewisxoffset/2 pt)--cycle;%
\else
- \if:\expandafter\CF@firsttonil\CF@lewis@remainpos\relax\@nil
- \edef\CF@lewis@remainpos{\expandafter\CF@gobarg\CF@lewis@remainpos}%
- \pgfmathsetmacro\CF@lewis@x{\CF@lewis@x pt+\CF@lewis@xoffset*\CF@lewis@current@offset}%
- \pgfmathsetmacro\CF@lewis@y{\CF@lewis@y pt+\CF@lewis@yoffset*\CF@lewis@current@offset}%
- \CF@exp@after{\draw[fill,black,}{\CF@lewis@style#3]}%
- (\CF@lewis@x pt+\CF@lewis@dist*\CF@lewis@yoffset/2 pt,\CF@lewis@y-\CF@lewis@dist*\CF@lewis@xoffset/2 pt)circle(\CF@lewis@radius)%
- (\CF@lewis@x pt-\CF@lewis@dist*\CF@lewis@yoffset/2 pt,\CF@lewis@y+\CF@lewis@dist*\CF@lewis@xoffset/2 pt)circle(\CF@lewis@radius);%
+ \if:\expandafter\CF_firsttonil\CF_lewisremainpos\relax\_nil
+ \edef\CF_lewisremainpos{\expandafter\CF_gobarg\CF_lewisremainpos}%
+ \pgfmathsetmacro\CF_lewisx{\CF_lewisx pt+\CF_lewisxoffset*\CF_lewiscurrentoffset}%
+ \pgfmathsetmacro\CF_lewisy{\CF_lewisy pt+\CF_lewisyoffset*\CF_lewiscurrentoffset}%
+ \CF_expafter{\draw[fill,black,}{\CF_lewisstyle]}%
+ (\CF_lewisx pt+\CF_lewisdist*\CF_lewisyoffset/2 pt,\CF_lewisy-\CF_lewisdist*\CF_lewisxoffset/2 pt)circle(\CF_lewisradius)%
+ (\CF_lewisx pt-\CF_lewisdist*\CF_lewisyoffset/2 pt,\CF_lewisy+\CF_lewisdist*\CF_lewisxoffset/2 pt)circle(\CF_lewisradius);%
\else
- \pgfmathsetmacro\CF@lewis@x{\CF@lewis@x pt+\CF@lewis@xoffset*\CF@lewis@current@offset}%
- \pgfmathsetmacro\CF@lewis@y{\CF@lewis@y pt+\CF@lewis@yoffset*\CF@lewis@current@offset}%
- \expandafter\draw\expandafter[\CF@lewis@style#3]%
- (\CF@lewis@x pt+\CF@lewis@length*\CF@lewis@yoffset/2 pt,\CF@lewis@y-\CF@lewis@length*\CF@lewis@xoffset/2 pt)--%
- (\CF@lewis@x pt-\CF@lewis@length*\CF@lewis@yoffset/2 pt,\CF@lewis@y+\CF@lewis@length*\CF@lewis@xoffset/2 pt);%
+ \pgfmathsetmacro\CF_lewisx{\CF_lewisx pt+\CF_lewisxoffset*\CF_lewiscurrentoffset}%
+ \pgfmathsetmacro\CF_lewisy{\CF_lewisy pt+\CF_lewisyoffset*\CF_lewiscurrentoffset}%
+ \CF_expafter{\draw[}\CF_lewisstyle]%
+ (\CF_lewisx pt+\CF_lewislength*\CF_lewisyoffset/2 pt,\CF_lewisy-\CF_lewislength*\CF_lewisxoffset/2 pt)--%
+ (\CF_lewisx pt-\CF_lewislength*\CF_lewisyoffset/2 pt,\CF_lewisy+\CF_lewislength*\CF_lewisxoffset/2 pt);%
\fi
\fi
- \fi
+ \fi
\repeat
- \node[anchor=base west]at(CF@lewis@anchor){\box\CF@lewis@box};%
+ \node[anchor=base west]at(CF_lewis@anchor){\box\CF_boxlewis};%
\endtikzpicture
}
-\def\Chembelow{\begingroup\let\CF@tmp@str\CF@gobarg\CF@chembelow@a}
+\def\Chembelow{\begingroup\let\CF_temp\CF_gobarg\CF_chembelowa}
-\def\chembelow{\begingroup\let\CF@tmp@str\CF@id\CF@chembelow@a}
+\def\chembelow{\begingroup\let\CF_temp\CF_id\CF_chembelowa}
-\def\CF@chembelow@a{\CF@testopt\CF@chembelow@b\CF@stacksep}
+\def\CF_chembelowa{\CF_testopt\CF_chembelowb\CF_stacksep}
-\def\CF@chembelow@b[#1]#2#3{%
- \setbox\CF@box@boxa\hbox{\printatom{#2}}%
- \expandafter\vtop\CF@tmp@str{to\ht\CF@box@boxa}{%
+\def\CF_chembelowb[#1]#2#3{%
+ \setbox\CF_box\hbox{\printatom{#2}}%
+ \expandafter\vtop\CF_temp{to\ht\CF_box}{%
\offinterlineskip
\hbox{\printatom{#2}}%
\kern#1\relax
- \hbox to\wd\CF@box@boxa{\hss\printatom{#3}\hss}%
- \CF@tmp@str\vss
+ \hbox to\wd\CF_box{\hss\printatom{#3}\hss}%
+ \CF_temp\vss
}%
\endgroup
}
-\def\Chemabove{\begingroup\let\CF@tmp@str\CF@gobarg\CF@chemabove@a}
+\def\Chemabove{\begingroup\let\CF_temp\CF_gobarg\CF_chemabovea}
-\def\chemabove{\begingroup\let\CF@tmp@str\CF@id\CF@chemabove@a}
+\def\chemabove{\begingroup\let\CF_temp\CF_id\CF_chemabovea}
-\def\CF@chemabove@a{\CF@testopt\CF@chemabove@b\CF@stacksep}
+\def\CF_chemabovea{\CF_testopt\CF_chemaboveb\CF_stacksep}
-\def\CF@chemabove@b[#1]#2#3{%
- \setbox\CF@box@boxa\hbox{\printatom{#2}}%
- \expandafter\vbox\CF@tmp@str{to\ht\CF@box@boxa}{%
+\def\CF_chemaboveb[#1]#2#3{%
+ \setbox\CF_box\hbox{\printatom{#2}}%
+ \expandafter\vbox\CF_temp{to\ht\CF_box}{%
\offinterlineskip
- \CF@tmp@str\vss
- \hbox to\wd\CF@box@boxa{\hss\printatom{#3}\hss}%
+ \CF_temp\vss
+ \hbox to\wd\CF_box{\hss\printatom{#3}\hss}%
\kern#1\relax
\hbox{\printatom{#2}}%
}%
\endgroup
}
-\def\chemmove{\CF@testopt\CF@chemmove{}}
+\def\chemmove{\CF_testopt\CF_chemmove{}}
-\def\CF@chemmove[#1]#2{%
- \CF@doifnotempty{#2}%
- {\expandafter\tikzpicture\romannumeral\CF@ifempty{#1}%
- {\z@[overlay,remember picture,-CF]}
- {\z@[overlay,remember picture,-CF,#1]}%
+\def\CF_chemmove[#1]#2{%
+ \CF_doifnotempty{#2}%
+ {\expandafter\tikzpicture\romannumeral
+ \CF_ifempty{#1}%
+ {\CF_zero[overlay,remember picture,-CF]}
+ {\CF_zero[overlay,remember picture,-CF,#1]}%
#2
\endtikzpicture
}%
}
\def\chemnameinit#1{%
- \setbox\CF@stuff@box\hbox{#1}%
- \xdef\CF@dp@max{\the\dp\CF@stuff@box}%
+ \setbox\CF_boxstuff\hbox{#1}%
+ \xdef\CF_dpmax{\the\dp\CF_boxstuff}%
}
-\let\CF@dp@max\z@
+\let\CF_dpmax\CF_zero
-\def\CF@parse@molname#1\\#2\@nil{%
- \hbox to\CF@wd@stuffbox{\hss#1\hss}%
- \CF@doifnotempty{#2}{\CF@parse@molname#2\@nil}%
+\def\CF_parsemolname#1\\#2\_nil{%
+ \hbox to\CF_wdstuffbox{\hss#1\hss}%
+ \CF_doifnotempty{#2}{\CF_parsemolname#2\_nil}%
}
\def\chemname{%
- \CF@ifstar
- {\CF@name@dp@adjustfalse\CF@chemname@a}
- {\CF@name@dp@adjusttrue \CF@chemname@a}%
+ \CF_ifstar
+ {\CF_adjustnamedpfalse\CF_chemnamea}
+ {\CF_adjustnamedptrue \CF_chemnamea}%
}
-\def\CF@chemname@a{\CF@testopt\CF@chemname@b{1.5ex}}
+\def\CF_chemnamea{\CF_testopt\CF_chemnameb{1.5ex}}
-\def\CF@chemname@b[#1]#2#3{%
- \setbox\CF@stuff@box\hbox{#2}%
- \edef\CF@wd@stuffbox{\the\wd\CF@stuff@box}\edef\CF@dp@stuffbox{\the\dp\CF@stuff@box}%
+\def\CF_chemnameb[#1]#2#3{%
+ \setbox\CF_boxstuff\hbox{#2}%
+ \edef\CF_wdstuffbox{\the\wd\CF_boxstuff}\edef\CF_dpstuffbox{\the\dp\CF_boxstuff}%
\leavevmode
- \ifdim\CF@dp@max<\CF@dp@stuffbox\global\let\CF@dp@max\CF@dp@stuffbox\fi
+ \ifdim\CF_dpmax<\CF_dpstuffbox\global\let\CF_dpmax\CF_dpstuffbox\fi
\vtop{%
- \box\CF@stuff@box
+ \box\CF_boxstuff
\nointerlineskip
- \kern\dimexpr#1\ifCF@name@dp@adjust+\CF@dp@max-\CF@dp@stuffbox\fi\relax
- \CF@parse@molname#3\\\@nil
+ \kern\dimexpr#1\ifCF_adjustnamedp+\CF_dpmax-\CF_dpstuffbox\fi\relax
+ \CF_parsemolname#3\\\_nil
}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% S C H É M A S R É A C T I O N N E L S %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\let\CF@scheme@nest\z@
+\let\CF_schemenest\CF_zero
-\def\CF@subscheme{\CF@testopt\CF@subscheme@a{}}
-\def\CF@subscheme@a[#1]{\CF@testopt{\CF@subscheme@b[#1]}{text}}
-\def\CF@subscheme@b[#1][#2]#3{\schemestart[#1][#2]#3\schemestop}
+\def\CF_subscheme{\CF_testopt\CF_subschemea{}}
+\def\CF_subschemea[#1]{\CF_testopt{\CF_subschemeb[#1]}{text}}
+\def\CF_subschemeb[#1][#2]#3{\schemestart[#1][#2]#3\schemestop}
\def\chemleft#1#2\chemright#3{%
\leavevmode
\begingroup
- \setbox\z@\hbox{$\vcenter{\hbox{}}$}\edef\CF@delim@math@ht{\the\ht\z@}%
- \setbox\z@\hbox{#2}\edef\CF@delim@dim{\the\dimexpr(\ht\z@+\dp\z@)/\tw@}%
- \edef\CF@delim@shift{\the\dimexpr(\ht\z@-\dp\z@)/\tw@-\CF@delim@math@ht}%
- \raise\CF@delim@shift\hbox{$\left#1\vrule height\CF@delim@dim depth\CF@delim@dim width\z@\right.$}\box\z@
- \raise\CF@delim@shift\hbox{$\left.\vrule height\CF@delim@dim depth\CF@delim@dim width\z@\right#3$}%
+ \setbox0\hbox{$\vcenter{\hbox{}}$}\edef\CF_delimmathht{\the\ht0}%
+ \setbox0\hbox{#2}\edef\CF_delimdim{\the\dimexpr(\ht0+\dp0)/2}%
+ \edef\CF_delimshift{\the\dimexpr(\ht0-\dp0)/2-\CF_delimmathht}%
+ \raise\CF_delimshift\hbox{$\left#1\vrule height\CF_delimdim depth\CF_delimdim width0pt\right.$}\box0
+ \raise\CF_delimshift\hbox{$\left.\vrule height\CF_delimdim depth\CF_delimdim width0pt\right#3$}%
\endgroup
}
\def\chemright#1{%
- \immediate\write-1{Package \CFname\space Warning: "\string\chemright\string#1"ignored! No \string\chemleft\space previously found.^^J}%
+ \CF_warning{"\string\chemright\string#1" ignored! No \string\chemleft\space previously found.}%
}
\def\chemup#1#2\chemdown#3{%
\begingroup
- \setbox\z@\hbox{\printatom{#2}}\edef\CF@delim@dim{\the\dimexpr\wd\z@/\tw@}%
- \tikzpicture[every node/.style={inner sep=\z@,outer sep=\z@,minimum size=\z@},baseline]%
- \node[anchor=base west](chem@stuff){\box\z@};%
- \node[at=(chem@stuff.north),anchor=east,rotate=-90]{$\left#1\vrule height\CF@delim@dim depth\CF@delim@dim width\z@\right.$};%
- \node[at=(chem@stuff.south),anchor=west,rotate=-90]{$\left.\vrule height\CF@delim@dim depth\CF@delim@dim width\z@\right#3$};%
+ \setbox0\hbox{\printatom{#2}}\edef\CF_delimdim{\the\dimexpr\wd0/2}%
+ \tikzpicture[every node/.style={inner sep=0pt,outer sep=0pt,minimum size=0pt},baseline]%
+ \node[anchor=base west](chem@stuff){\box0};%
+ \node[at=(chem@stuff.north),anchor=east,rotate=-90]{$\left#1\vrule height\CF_delimdim depth\CF_delimdim width0pt\right.$};%
+ \node[at=(chem@stuff.south),anchor=west,rotate=-90]{$\left.\vrule height\CF_delimdim depth\CF_delimdim width0pt\right#3$};%
\endtikzpicture
\endgroup
}
\def\chemdown#1{%
- \immediate\write-1{Package \CFname\space Warning: "\string\chemdown\string#1" ignored! No \string\chemup\space previously found.^^J}%
+ \CF_warning{"\string\chemdown\string#1" ignored! No \string\chemup\space previously found.}%
}
-\def\CF@set@style#1,#2,#3\@nil#4#5#6{%
+\def\CF_setstyle#1,#2,#3\_nil#4#5#6{%
\def#4{#1}\let#5\empty\let#6\empty
- \CF@if@firsttokmatch\CF@quark{#2\relax}
+ \CF_iffirsttokmatch\CF_quark{#2\relax}
{}%
{\def#5{#2}%
- \CF@if@firsttokmatch\CF@quark{#3\relax}
+ \CF_iffirsttokmatch\CF_quark{#3\relax}
{}%
- {\CF@set@style@a#3\@nil#6}%
+ {\CF_setstylea#3\_nil#6}%
}%
}
-\def\CF@set@style@a#1,\CF@quark#2\@nil#3{\def#3{#1}}
+\def\CF_setstylea#1,\CF_quark#2\_nil#3{\def#3{#1}}
-\def\CF@and{\futurelet\CF@toks@a\CF@and@a}
+\def\CF_and{\futurelet\CF_toksa\CF_anda}
-\def\CF@and@a{%
- \CF@ifx\CF@toks@a\bgroup
- \CF@and@b
- {\CF@and@b{}}%
+\def\CF_anda{%
+ \CF_ifx\CF_toksa\bgroup
+ {\CF_andb}
+ {\CF_andb{}}%
}
-\def\CF@and@b#1{%
- \CF@set@style#1,\CF@quark,\CF@quark\@nil\CF@signspace@ante\CF@signspace@post\CF@sign@vshift
- \CF@doifempty\CF@signspace@ante{\CF@valuetomacro\CF@signspace@ante[0.5em]{+ sep left}}%
- \CF@doifempty\CF@signspace@post{\CF@valuetomacro\CF@signspace@post[0.5em]{+ sep right}}%
- \CF@doifempty\CF@sign@vshift{\CF@valuetomacro\CF@sign@vshift[0pt]{+ vshift}}%
- \raise\CF@sign@vshift\hbox{\kern\CF@signspace@ante$+$\kern\CF@signspace@post}%
+\def\CF_andb#1{%
+ \CF_setstyle#1,\CF_quark,\CF_quark\_nil\CF_signspaceante\CF_signspacepost\CF_signvshift
+ \CF_doifempty\CF_signspaceante{\CF_valuetomacro\CF_signspaceante[0.5em]{+ sep left}}%
+ \CF_doifempty\CF_signspacepost{\CF_valuetomacro\CF_signspacepost[0.5em]{+ sep right}}%
+ \CF_doifempty\CF_signvshift{\CF_valuetomacro\CF_signvshift[0pt]{+ vshift}}%
+ \raise\CF_signvshift\hbox{\kern\CF_signspaceante$+$\kern\CF_signspacepost}%
}
\def\schemestart{%
- \xdef\CF@scheme@nest{\number\numexpr\CF@scheme@nest+\@ne}%
- \CF@testopt\CF@schemestart@a{}%
-}
-
-\def\CF@schemestart@a[#1]{%
- \CF@valuetomacro\default@compound@style[]{compound style}%
- \CF@set@style#1,\CF@quark,\CF@quark\@nil\CF@arrow@angle\CF@arrow@length\CF@arrow@style
- \CF@doifempty\CF@arrow@angle{\CF@valuetomacro\CF@arrow@angle[0]{arrow angle}}%
- \CF@doifempty\CF@arrow@length{\CF@valuetomacro\CF@arrow@length[1]{arrow coeff}}%
- \CF@valuetomacro\CF@default@arrow@style[]{arrow style}%
- \CF@valuetomacro\CF@arrow@offset[1em]{arrow offset}%
- \CF@valuetomacro\CF@compound@sep[5em]{compound sep}%
- \CF@valuetomacro\CF@arrow@labelsep[3pt]{arrow label sep}%
- \CF@valuetomacro\CF@arrowhead[-CF]{arrow head}%
- \CF@eexp@second{\def\CF@arrowtip}{\expandafter\CF@gobarg\CF@arrowhead}%
- \CF@eexp@second{\CF@preadd@tocs\CF@default@arrow@style}{\useKV[chemfig]{arrow head},}%
- \CF@ifx\empty\CF@arrow@style
- {\let\CF@arrow@style\CF@default@arrow@style}
- {\CF@exp@second{\CF@preadd@tocs\CF@arrow@style}{\CF@default@arrow@style,}}% se rajoute après le style par défaut
- \CF@valuetomacro\CF@arrow@double@sep[2pt]{arrow double sep}%
- \pgfmathsetmacro\CF@arrow@double@sep{\CF@arrow@double@sep/2}%
- \CF@valuetomacro\CF@arrow@double@pos@start[0.6]{arrow double coeff}%
- \pgfmathsetmacro\CF@arrow@double@pos@start{(1-\CF@arrow@double@pos@start)/2}%
- \pgfmathsetmacro\CF@arrow@double@pos@end{1-\CF@arrow@double@pos@start}%
+ \begingroup
+ \xdef\CF_schemenest{\number\numexpr\CF_schemenest+1}%
+ \CF_testopt\CF_schemestarta{}%
+}
+
+\def\CF_schemestarta[#1]{%
+ \CF_valuetomacro\CF_defaultcompoundstyle[]{compound style}%
+ \CF_setstyle#1,\CF_quark,\CF_quark\_nil\CF_arrowangle\CF_arrowlength\CF_arrowstyle
+ \CF_doifempty\CF_arrowangle{\CF_valuetomacro\CF_arrowangle[0]{arrow angle}}%
+ \CF_doifempty\CF_arrowlength{\CF_valuetomacro\CF_arrowlength[1]{arrow coeff}}%
+ \CF_valuetomacro\CF_defaultarrowstyle[]{arrow style}%
+ \CF_valuetomacro\CF_arrowoffset[1em]{arrow offset}%
+ \CF_valuetomacro\CF_compoundsep[5em]{compound sep}%
+ \CF_valuetomacro\CF_arrowlabelsep[3pt]{arrow label sep}%
+ \CF_valuetomacro\CF_arrowhead[-CF]{arrow head}%
+ \CF_eexpsecond{\def\CF_arrowtip}{\expandafter\CF_gobarg\CF_arrowhead}%
+ \CF_eexpsecond{\CF_preaddtomacro\CF_defaultarrowstyle}{\useKV[chemfig]{arrow head},}%
+ \CF_ifx\empty\CF_arrowstyle
+ {\let\CF_arrowstyle\CF_defaultarrowstyle}
+ {\CF_expsecond{\CF_preaddtomacro\CF_arrowstyle}{\CF_defaultarrowstyle,}}% se rajoute après le style par défaut
+ \CF_valuetomacro\CF_arrowdoublesep[2pt]{arrow double sep}%
+ \pgfmathsetmacro\CF_arrowdoublesep{\CF_arrowdoublesep/2}%
+ \CF_valuetomacro\CF_arrowdoubleposstart[0.6]{arrow double coeff}%
+ \pgfmathsetmacro\CF_arrowdoubleposstart{(1-\CF_arrowdoubleposstart)/2}%
+ \pgfmathsetmacro\CF_arrowdoubleposend{1-\CF_arrowdoubleposstart}%
\ifboolKV[chemfig]{scheme debug}
- {\tikzpicture[every node/.style={draw,anchor=base,inner sep=\z@,outer sep=\z@,minimum size=1.5pt},baseline,remember picture]%
- }
- {\tikzpicture[every node/.style={anchor=base,inner sep=\z@,outer sep=\z@,minimum size=\z@},baseline,remember picture]%
- }%
- \let\merge\CF@merge
- \expandafter\let\csname+\endcsname\CF@and
- \let\arrow\CF@arrow
- \let\schemestop\CF@schemestop
- \let\subscheme\CF@subscheme
- \CF@testopt{\CF@schemestart@b[#1]}{text}%
-}
-
-\def\CF@schemestart@b[#1][#2]{%
- \ifnum\CF@scheme@nest=\@ne% la commande n'est pas imbriquée ?
- \CF@compound@cnt\z@
+ {\tikzpicture[every node/.style={draw,anchor=base,inner sep=0pt,outer sep=0pt,minimum size=1.5pt},baseline,remember picture]}
+ {\tikzpicture[every node/.style={anchor=base,inner sep=0pt,outer sep=0pt,minimum size=0pt},baseline,remember picture]}%
+ \let\merge\CF_merge
+ \expandafter\let\csname+\endcsname\CF_and
+ \let\arrow\CF_arrow
+ \let\schemestop\CF_schemestop
+ \let\subscheme\CF_subscheme
+ \CF_testopt{\CF_schemestartb}{text}%
+}
+
+\def\CF_schemestartb[#1]{%
+ \ifnum\CF_schemenest=1 % la commande n'est pas imbriquée ?
+ \CF_cntcompound0
\fi
- \edef\CF@current@nodename{c\number\CF@compound@cnt}%
- \let\CF@next@nodename\empty
- \let\CF@next@nodestyle\empty
- \let\CF@direct@arrow@list\empty
+ \edef\CF_currentnodename{c\number\CF_cntcompound}%
+ \let\CF_nextnodename\empty
+ \let\CF_nextnodestyle\empty
+ \let\CF_directarrowlist\empty
\ifboolKV[chemfig]{scheme debug}
- {\node[fill,green](\CF@current@nodename){};}
- {\node(\CF@current@nodename){};}%
- \def\CF@next@nodeanchor{#2}%
- \CF@doifempty\CF@next@nodeanchor{\def\CF@next@nodeanchor{text}}%
- \let\CF@compound\empty
- \CF@schemestart@c
+ {\node[fill,green](\CF_currentnodename){};}
+ {\node(\CF_currentnodename){};}%
+ \def\CF_nextnodeanchor{#1}%
+ \CF_doifempty\CF_nextnodeanchor{\def\CF_nextnodeanchor{text}}%
+ \let\CF_compound\empty
+ \CF_schemestartc
}
-\def\CF@schemestart@c{%
- \futurelet\CF@toks@a\CF@schemestart@e
+\def\CF_schemestartc{%
+ \futurelet\CF_toksa\CF_schemestarte
}
-\expandafter\def\expandafter\CF@schemestart@d\space{\futurelet\CF@toks@a\CF@schemestart@e}
+\expandafter\def\expandafter\CF_schemestartd\space{\futurelet\CF_toksa\CF_schemestarte}
-\def\CF@schemestart@e{% ... et l'examine :
- \CF@if@firsttokin@a{\arrow\schemestop\merge}%
+\def\CF_schemestarte{% ... et l'examine :
+ \CF_iffirsttokina{\arrow\schemestop\merge}%
{}
- {\CF@ifx\CF@toks@a\bgroup
- {\CF@add@nextarg}
- {\CF@ifx\CF@toks@a\@sptoken
- {\CF@add@tocs\CF@compound{ }%
- \CF@schemestart@d
+ {\CF_ifx\CF_toksa\bgroup
+ {\CF_addnextarg
+ }
+ {\CF_ifx\CF_toksa\CF_sptoken
+ {\CF_addtomacro\CF_compound{ }%
+ \CF_schemestartd
}
- {\afterassignment\CF@schemestart@c
- \CF@add@tocs\CF@compound
+ {\afterassignment\CF_schemestartc
+ \CF_addtomacro\CF_compound
}%
}%
}%
}
-\def\CF@add@nextarg#1{\CF@add@tocs\CF@compound{{#1}}\CF@schemestart@c}
+\def\CF_addnextarg#1{\CF_addtomacro\CF_compound{{#1}}\CF_schemestartc}
-\def\CF@display@compound#1#2{% #1 = nom et #2 = style
- \CF@doifnotempty\CF@compound
- {\global\advance\CF@compound@cnt\@ne
- \CF@ifx\default@compound@style\empty
- {\let\CF@current@nodestyle\empty}
- {\CF@exp@second{\def\CF@current@nodestyle}{\default@compound@style,}}%
- \CF@add@tocs\CF@current@nodestyle{anchor=\CF@next@nodeanchor,at=(\CF@current@nodename)}%
- \CF@ifempty{#2}%
- {\CF@doifnotempty\CF@next@nodestyle
- {\CF@eadd@tocs\CF@current@nodestyle{\expandafter,\CF@next@nodestyle}}%
+\def\CF_displaycompound#1#2{% #1 = nom et #2 = style
+ \CF_doifnotempty\CF_compound
+ {\global\advance\CF_cntcompound1
+ \CF_ifx\CF_defaultcompoundstyle\empty
+ {\let\CF_currentnodestyle\empty}
+ {\CF_expsecond{\def\CF_currentnodestyle}{\CF_defaultcompoundstyle,}}%
+ \CF_addtomacro\CF_currentnodestyle{anchor=\CF_nextnodeanchor,at=(\CF_currentnodename)}%
+ \CF_ifempty{#2}%
+ {\CF_doifnotempty\CF_nextnodestyle
+ {\CF_eaddtomacro\CF_currentnodestyle{\expandafter,\CF_nextnodestyle}}%
}
- {\CF@doifnotempty\CF@next@nodestyle
- {\immediate\write-1{Package \CFname\space Warning: two styles for the same node, first style "\CF@next@nodestyle" ignored^^J}%
+ {\CF_doifnotempty\CF_nextnodestyle
+ {\CF_warning{two styles for the same node, first style "\CF_nextnodestyle" ignored}%
}%
- \CF@add@tocs\CF@current@nodestyle{,#2}%
+ \CF_addtomacro\CF_currentnodestyle{,#2}%
}%
- \CF@ifempty{#1}
- {\edef\CF@tmp@str{\CF@ifempty\CF@next@nodename{c\number\CF@compound@cnt}{\CF@next@nodename}}%
+ \CF_ifempty{#1}
+ {\edef\CF_temp{%
+ \CF_ifempty\CF_nextnodename
+ {c\number\CF_cntcompound}
+ {\CF_nextnodename}%
+ }%
}
- {\CF@doifnotempty\CF@next@nodename
- {\immediate\write-1{Package \CFname\space Warning: two names for the same node, first name "\CF@next@nodename" ignored^^J}%
+ {\CF_doifnotempty\CF_nextnodename
+ {\CF_warning{two names for the same node, first name "\CF_nextnodename" ignored}%
}%
- \edef\CF@tmp@str{#1}%
+ \edef\CF_temp{#1}%
}%
- \expandafter\node\expandafter[\CF@current@nodestyle](\CF@tmp@str){\CF@compound};%
+ \CF_expafter{\node[}\CF_currentnodestyle](\CF_temp){\CF_compound};%
\ifboolKV[chemfig]{scheme debug}%
- {\node[draw=none,anchor=270,at=(\CF@tmp@str.90),fill=green!60,overlay,opacity=0.5]{\scriptsize\bfseries\CF@tmp@str};%
+ {\node[draw=none,anchor=270,at=(\CF_temp.90),fill=green!60,overlay,opacity=0.5]{\scriptsize\bfseries\CF_temp};%
}
{}%
- \let\CF@current@nodename\CF@tmp@str
+ \let\CF_currentnodename\CF_temp
}%
}
-\def\CF@schemestop{%
- \CF@display@compound{}{}%
- \CF@direct@arrow@list
+\def\CF_schemestop{%
+ \CF_displaycompound{}{}%
+ \CF_directarrowlist
\endtikzpicture
- \xdef\CF@scheme@nest{\number\numexpr\CF@scheme@nest-\@ne}%
+ \xdef\CF_schemenest{\number\numexpr\CF_schemenest-1}%
+ \endgroup
}
-\def\CF@analyse@arrowarg#1{\CF@analyse@arrowarg@i#1[]\@nil}
+\def\CF_analysearrowarg#1{\CF_analysearrowarga#1[]\_nil}
-\def\CF@analyse@arrowarg@i#1[#2]#3\@nil{%
- \CF@if@instr{#1}.{\CF@add@tocs\CF@tmp@str{#1[#2]}}{\CF@add@tocs\CF@tmp@str{#1.[#2]}}%
+\def\CF_analysearrowarga#1[#2]#3\_nil{%
+ \CF_ifinstr{#1}.
+ {\CF_addtomacro\CF_temp{#1[#2]}}
+ {\CF_addtomacro\CF_temp{#1.[#2]}}%
}
-\def\CF@arrow{%
- \CF@ifnextchar(%
- \CF@arrow@a
- {\CF@ifnextchar\bgroup{\CF@arrow@b(.[]--.[])}{\CF@arrow@b(.[]--.[]){}}}%
+\def\CF_arrow{%
+ \CF_ifnextchar(%
+ {\CF_arrowa
+ }
+ {\CF_ifnextchar\bgroup
+ {\CF_arrowb(.[]--.[])}
+ {\CF_arrowb(.[]--.[]){}}%
+ }%
}
-\def\CF@arrow@a(#1--#2){%
- \def\CF@tmp@str{(}%
- \CF@analyse@arrowarg{#1}%
- \CF@add@tocs\CF@tmp@str{--}%
- \CF@analyse@arrowarg{#2}%
- \CF@add@tocs\CF@tmp@str)%
- \CF@ifnextchar\bgroup{\expandafter\CF@arrow@b\CF@tmp@str}{\expandafter\CF@arrow@b\CF@tmp@str{}}%
+\def\CF_arrowa(#1--#2){%
+ \def\CF_temp{(}%
+ \CF_analysearrowarg{#1}%
+ \CF_addtomacro\CF_temp{--}%
+ \CF_analysearrowarg{#2}%
+ \CF_addtomacro\CF_temp)%
+ \CF_ifnextchar\bgroup
+ {\expandafter\CF_arrowb\CF_temp}
+ {\expandafter\CF_arrowb\CF_temp{}}%
}
-\def\CF@arrow@b(#1.#2[#3]--#4.#5[#6])#7{%
- \def\CF@current@arrowtype{#7}% nom de la flèche
- \CF@doifempty\CF@current@arrowtype{\def\CF@current@arrowtype{->}}%
- \CF@testopt{\CF@arrow@c(#1.#2[#3]--#4.#5[#6])}{}%
+\def\CF_arrowb(#1.#2[#3]--#4.#5[#6])#7{%
+ \def\CF_currentarrowtype{#7}% nom de la flèche
+ \CF_doifempty\CF_currentarrowtype{\def\CF_currentarrowtype{->}}%
+ \CF_testopt{\CF_arrowc(#1.#2[#3]--#4.#5[#6])}{}%
}
-\def\CF@arrow@c(#1.#2[#3]--#4.#5[#6])[#7]{%
- \def\CF@tmp@str{\CF@arrow@e(#1.#2[#3]--#4.#5[#6])}%
- \CF@arrow@d#7,\empty,\empty\@nil
+\def\CF_arrowc(#1.#2[#3]--#4.#5[#6])[#7]{%
+ \def\CF_temp{\CF_arrowe(#1.#2[#3]--#4.#5[#6])}%
+ \CF_arrowd#7,\empty,\empty\_nil
}
-\def\CF@arrow@d#1,#2,#3\@nil{%
- \CF@add@tocs\CF@tmp@str{{#1}}%
- \CF@eadd@tocs\CF@tmp@str{\expandafter{#2}}%
- \expandafter\CF@eadd@tocs\expandafter\CF@tmp@str\expandafter{\expandafter\expandafter\expandafter{\expandafter\CF@sanitize@lastitem#3,\empty\@nil}}%
- \CF@tmp@str
+\def\CF_arrowd#1,#2,#3\_nil{%
+ \CF_addtomacro\CF_temp{{#1}}%
+ \CF_eaddtomacro\CF_temp{\expandafter{#2}}%
+ \expandafter\CF_eaddtomacro\expandafter\CF_temp\expandafter{\expandafter\expandafter\expandafter{\expandafter\CF_sanitizelastitem#3,\empty\_nil}}%
+ \CF_temp
}
% #1, #4 : nom des nodes #2, #5 : ancres des nodes #3, #6 : styles des nodes
% #7 : angle flèche #8 : longueur flèche #9 : style tikz de la flèche
-\def\CF@arrow@e(#1.#2[#3]--#4.#5[#6])#7#8#9{%
- \let\CF@arrow@current@style\CF@arrow@style
- \if\CF@arobas\expandafter\CF@firsttonil\detokenize{#1.}\@nil% si #1 commence par @
- \if\CF@arobas\expandafter\CF@firsttonil\detokenize{#4.}\@nil
- \CF@eadd@tocs\CF@direct@arrow@list{\expandafter\CF@direct@arrow\expandafter{\CF@current@arrowtype}{#1}{#2}{#4}{#5}{#9}}%
- \let\CF@next@action\CF@schemestart@c
+\def\CF_arrowe(#1.#2[#3]--#4.#5[#6])#7#8#9{%
+ \let\CF_arrowcurrentstyle\CF_arrowstyle
+ \if @\expandafter\CF_firsttonil\detokenize{#1.}\_nil% si #1 commence par @
+ \if @\expandafter\CF_firsttonil\detokenize{#4.}\_nil
+ \CF_eaddtomacro\CF_directarrowlist{\expandafter\CF_directarrow\expandafter{\CF_currentarrowtype}{#1}{#2}{#4}{#5}{#9}}%
+ \let\CF_nextaction\CF_schemestartc
\else
- \CF@doifnotempty\CF@arrow@current@style{\CF@add@tocs\CF@arrow@current@style,}%
- \CF@doifnotempty{#9}{\CF@add@tocs\CF@arrow@current@style{#9,}}%
- \CF@display@compound{}{#3}%
- \def\CF@next@nodename{#4}%
- \CF@exp@second{\def\CF@current@nodename}{\CF@gobarg#1}%
- \let\CF@arrow@start@name\CF@current@nodename
- \let\CF@arrow@end@name\CF@next@nodename
- \CF@arrow@f{#7}{#8}{#2}{#5}%
- \def\CF@next@nodestyle{#6}%
+ \CF_doifnotempty\CF_arrowcurrentstyle{\CF_addtomacro\CF_arrowcurrentstyle,}%
+ \CF_doifnotempty{#9}{\CF_addtomacro\CF_arrowcurrentstyle{#9,}}%
+ \CF_displaycompound{}{#3}%
+ \def\CF_nextnodename{#4}%
+ \CF_expsecond{\def\CF_currentnodename}{\CF_gobarg#1}%
+ \let\CF_arrowstartname\CF_currentnodename
+ \let\CF_arrowendname\CF_nextnodename
+ \CF_arrowf{#7}{#8}{#2}{#5}%
+ \def\CF_nextnodestyle{#6}%
\fi
\else
- \CF@doifnotempty\CF@arrow@current@style{\CF@add@tocs\CF@arrow@current@style,}%
- \CF@doifnotempty{#9}{\CF@add@tocs\CF@arrow@current@style{#9,}}%
- \if\CF@arobas\expandafter\CF@firsttonil\detokenize{#2.}\@nil
- \errmessage{Package \CFname\space Error: syntax "(<name>--@<name>)" is not allowed}%
+ \CF_doifnotempty\CF_arrowcurrentstyle{\CF_addtomacro\CF_arrowcurrentstyle,}%
+ \CF_doifnotempty{#9}{\CF_addtomacro\CF_arrowcurrentstyle{#9,}}%
+ \if @\expandafter\CF_firsttonil\detokenize{#2.}\_nil
+ \CF_error{syntax "(<name>--@<name>)" is not allowed}%
\else
- \CF@display@compound{#1}{#3}%
- \edef\CF@arrow@start@name{\CF@ifempty{#1}\CF@current@nodename{#1}\CF@doifnotempty{#2}{.#2}}%
- \CF@arrow@f{#7}{#8}{#2}{#5}%
- \def\CF@next@nodename{#4}%
- \def\CF@next@nodestyle{#6}%
+ \CF_displaycompound{#1}{#3}%
+ \edef\CF_arrowstartname{%
+ \CF_ifempty{#1}
+ \CF_currentnodename
+ {#1}%
+ \CF_doifnotempty{#2}{.#2}%
+ }%
+ \CF_arrowf{#7}{#8}{#2}{#5}%
+ \def\CF_nextnodename{#4}%
+ \def\CF_nextnodestyle{#6}%
\fi
\fi
- \CF@arrow@gobspaces% mange les espaces puis exécute \CF@next@action
+ \CF_arrowgobspaces% mange les espaces puis exécute \CF_nextaction
}
-\def\CF@arrow@gobspaces{\futurelet\CF@toks@a\CF@arrow@gobspaces@a}
+\def\CF_arrowgobspaces{\futurelet\CF_toksa\CF_arrowgobspacesa}
-\def\CF@arrow@gobspaces@a{%
- \CF@ifx\@sptoken\CF@toks@a
- \CF@arrow@gobspaces@b
- \CF@next@action
+\def\CF_arrowgobspacesa{%
+ \CF_ifx\CF_sptoken\CF_toksa
+ \CF_arrowgobspacesb
+ \CF_nextaction
}
-\expandafter\def\expandafter\CF@arrow@gobspaces@b\space{\futurelet\CF@toks@a\CF@arrow@gobspaces@a}
+\expandafter\def\expandafter\CF_arrowgobspacesb\space{\futurelet\CF_toksa\CF_arrowgobspacesa}
-\def\CF@arrow@f#1#2#3#4{% #1=angle #2=longueur #3=ancre départ #4=ancre arrivée
- \def\CF@next@action{\let\CF@compound\empty\CF@schemestart@c}%
- \def\CF@arrow@current@angle{#1}\CF@doifempty\CF@arrow@current@angle{\let\CF@arrow@current@angle\CF@arrow@angle}%
- \def\CF@current@arrow@length{#2}\CF@doifempty\CF@current@arrow@length{\let\CF@current@arrow@length\CF@arrow@length}%
- \node[at=(\CF@current@nodename.\CF@ifempty{#3}\CF@arrow@current@angle{#3}),shift=(\CF@arrow@current@angle:\CF@current@arrow@length*\CF@compound@sep),cyan,fill](end@arrow@i@\number\CF@scheme@nest){};%
- \edef\CF@arrow@end@name{end@arrow@i@\number\CF@scheme@nest\CF@doifnotempty{#4}{.#4}}%
+\def\CF_arrowf#1#2#3#4{% #1=angle #2=longueur #3=ancre départ #4=ancre arrivée
+ \def\CF_nextaction{\let\CF_compound\empty\CF_schemestartc}%
+ \def\CF_arrowcurrentangle{#1}\CF_doifempty\CF_arrowcurrentangle{\let\CF_arrowcurrentangle\CF_arrowangle}%
+ \def\CF_currentarrowlength{#2}\CF_doifempty\CF_currentarrowlength{\let\CF_currentarrowlength\CF_arrowlength}%
+ \node[at=(\CF_currentnodename.\CF_ifempty{#3}\CF_arrowcurrentangle{#3}),shift=(\CF_arrowcurrentangle:\CF_currentarrowlength*\CF_compoundsep),cyan,fill](end@arrow@i@\number\CF_schemenest){};%
+ \edef\CF_arrowendname{end@arrow@i@\number\CF_schemenest\CF_doifnotempty{#4}{.#4}}%
\ifboolKV[chemfig]{scheme debug}
- {\node[at=(\CF@current@nodename.\CF@ifempty{#3}\CF@arrow@current@angle{#3}),shift=(\CF@arrow@current@angle:\CF@arrow@offset),red,fill](start@arrow){};%
- \node[at=(\CF@current@nodename.\CF@ifempty{#3}\CF@arrow@current@angle{#3}),shift=(\CF@arrow@current@angle:\CF@current@arrow@length*\CF@compound@sep-\CF@arrow@offset),red,fill](end@arrow){};%
+ {\node[at=(\CF_currentnodename.\CF_ifempty{#3}\CF_arrowcurrentangle{#3}),shift=(\CF_arrowcurrentangle:\CF_arrowoffset),red,fill](start@arrow){};%
+ \node[at=(\CF_currentnodename.\CF_ifempty{#3}\CF_arrowcurrentangle{#3}),shift=(\CF_arrowcurrentangle:\CF_currentarrowlength*\CF_compoundsep-\CF_arrowoffset),red,fill](end@arrow){};%
}
- {\node[at=(\CF@current@nodename.\CF@ifempty{#3}\CF@arrow@current@angle{#3}),shift=(\CF@arrow@current@angle:\CF@arrow@offset)](start@arrow){};%
- \node[at=(\CF@current@nodename.\CF@ifempty{#3}\CF@arrow@current@angle{#3}),shift=(\CF@arrow@current@angle:\CF@current@arrow@length*\CF@compound@sep-\CF@arrow@offset)](end@arrow){};%
+ {\node[at=(\CF_currentnodename.\CF_ifempty{#3}\CF_arrowcurrentangle{#3}),shift=(\CF_arrowcurrentangle:\CF_arrowoffset)](start@arrow){};%
+ \node[at=(\CF_currentnodename.\CF_ifempty{#3}\CF_arrowcurrentangle{#3}),shift=(\CF_arrowcurrentangle:\CF_currentarrowlength*\CF_compoundsep-\CF_arrowoffset)](end@arrow){};%
}%
- \def\CF@arrow@start@node{start@arrow}\def\CF@arrow@end@node{end@arrow}%
- \csname\expandafter\CF@grab@arrow@name\CF@current@arrowtype[\@nil\CF@three@ea\endcsname
- \expandafter\CF@grab@arrow@args\CF@current@arrowtype[]\@nil[][][][][][][][]\@nil
- \def\CF@current@nodename{end@arrow@i@\number\CF@scheme@nest}%
- \edef\CF@next@nodeanchor{\CF@ifempty{#4}{180+\CF@arrow@current@angle}{#4}}%
+ \def\CF_arrowstartnode{start@arrow}\def\CF_arrowendnode{end@arrow}%
+ \csname\expandafter\CF_grabarrowname\CF_currentarrowtype[\_nil\CF_threeea\endcsname
+ \expandafter\CF_grabarrowargs\CF_currentarrowtype[]\_nil[][][][][][][][]\_nil
+ \def\CF_currentnodename{end@arrow@i@\number\CF_schemenest}%
+ \edef\CF_nextnodeanchor{\CF_ifempty{#4}{180+\CF_arrowcurrentangle}{#4}}%
}
% trace un flèche initiée par (@nom--@nom)
% #1=type de flèche #2=nom depart #3=ancre départ #4=nom arrivée #5=ancre arrivée #6=style flèche
-\def\CF@direct@arrow#1#2#3#4#5#6{%
- \CF@exp@second{\def\CF@arrow@start@name}{\CF@gobarg#2}%
- \CF@exp@second{\def\CF@arrow@end@name}{\CF@gobarg#4}%
- \path[sloped,allow upside down](\CF@gobarg#2\ifx\empty#3\empty\else.#3\fi)--(\CF@gobarg#4\ifx\empty#5\empty\else.#5\fi)%
- coordinate[pos=0,xshift=\CF@arrow@offset](start@direct@arrow)%
- coordinate[pos=1,xshift=-\CF@arrow@offset](end@direct@arrow);%
- \def\CF@arrow@start@node{start@direct@arrow}%
- \def\CF@arrow@end@node{end@direct@arrow}%
+\def\CF_directarrow#1#2#3#4#5#6{%
+ \CF_expsecond{\def\CF_arrowstartname}{\CF_gobarg#2}%
+ \CF_expsecond{\def\CF_arrowendname}{\CF_gobarg#4}%
+ \path[sloped,allow upside down](\CF_gobarg#2\ifx\empty#3\empty\else.#3\fi)--(\CF_gobarg#4\ifx\empty#5\empty\else.#5\fi)%
+ coordinate[pos=0,xshift=\CF_arrowoffset](start@direct@arrow)%
+ coordinate[pos=1,xshift=-\CF_arrowoffset](end@direct@arrow);%
+ \def\CF_arrowstartnode{start@direct@arrow}%
+ \def\CF_arrowendnode{end@direct@arrow}%
\pgfmathanglebetweenpoints
- {\pgfpointanchor{\CF@gobarg#2}{\ifx\empty#3\empty center\else#3\fi}}% Ne pas utiliser \CF@ifempty ici !!!
- {\pgfpointanchor{\CF@gobarg#4}{\ifx\empty#5\empty center\else#5\fi}}%
- \let\CF@arrow@current@angle\pgfmathresult
- \CF@doifnotempty{#6}{\CF@add@tocs\CF@arrow@current@style{#6,}}%
- \csname\CF@grab@arrow@name#1[]\@nil\expandafter\endcsname\CF@grab@arrow@args#1[]\@nil[][][][][][][][]\@nil
-}
-
-\def\CF@merge@grab@chardir#1[#2][#3]#4\@nil{%
- \expandafter\futurelet\expandafter\CF@toks@a\expandafter\CF@gobtonil\CF@firsttonil#1>\@nil\@nil
- \ifx>\CF@toks@a\def\CF@merge@angle{0}\def\CF@merge@extreme{xmax}\def\CF@merge@sign{+}\else
- \ifx<\CF@toks@a\def\CF@merge@angle{180}\def\CF@merge@extreme{xmin}\def\CF@merge@sign{-}\else
- \ifx^\CF@toks@a\def\CF@merge@angle{90}\def\CF@merge@extreme{ymax}\def\CF@merge@sign{+}\else
- \ifx v\CF@toks@a\def\CF@merge@angle{-90}\def\CF@merge@extreme{ymin}\def\CF@merge@sign{-}%
+ {\pgfpointanchor{\CF_gobarg#2}{\ifx\empty#3\empty center\else#3\fi}}% Ne pas utiliser \CF_ifempty ici !!!
+ {\pgfpointanchor{\CF_gobarg#4}{\ifx\empty#5\empty center\else#5\fi}}%
+ \let\CF_arrowcurrentangle\pgfmathresult
+ \CF_doifnotempty{#6}{\CF_addtomacro\CF_arrowcurrentstyle{#6,}}%
+ \csname\CF_grabarrowname#1[]\_nil\expandafter\endcsname\CF_grabarrowargs#1[]\_nil[][][][][][][][]\_nil
+}
+
+\def\CF_mergegrabchardir#1[#2][#3]#4\_nil{%
+ \CF_expafter{\futurelet\CF_toksa\CF_gobtonil}{\CF_firsttonil#1>\_nil}\_nil
+ \ifx>\CF_toksa
+ \def\CF_mergeangle{0}\def\CF_mergeextreme{xmax}\def\CF_mergesign{+}%
+ \else
+ \ifx<\CF_toksa
+ \def\CF_mergeangle{180}\def\CF_mergeextreme{xmin}\def\CF_mergesign{-}%
+ \else
+ \ifx^\CF_toksa
+ \def\CF_mergeangle{90}\def\CF_mergeextreme{ymax}\def\CF_mergesign{+}%
+ \else
+ \ifx v\CF_toksa
+ \def\CF_mergeangle{-90}\def\CF_mergeextreme{ymin}\def\CF_mergesign{-}%
\fi\fi\fi\fi
- \def\CF@merge@labelup{#2}\def\CF@merge@labeldo{#3}%
+ \def\CF_mergelabelup{#2}\def\CF_mergelabeldo{#3}%
}
-\def\CF@merge#1({%
- \CF@merge@grab@chardir#1[][]\@nil
- \CF@merge@a(%
+\def\CF_merge#1({%
+ \CF_mergegrabchardir#1[][]\_nil
+ \CF_mergea(%
}
-\def\CF@merge@a#1--(#2){\CF@testopt{\CF@merge@b#1--(#2)}{}}
+\def\CF_mergea#1--(#2){\CF_testopt{\CF_mergeb#1--(#2)}{}}
-\def\CF@merge@b#1--(#2)[#3]{%
- \CF@display@compound{}{}%
- \CF@parse@mergeopt#3,\CF@quark,\CF@quark,\CF@quark\@nil
- \def\CF@merge@xmax{-16383.99999pt}\let\CF@merge@ymax\CF@merge@xmax
- \def\CF@merge@xmin{16383.99999pt}\let\CF@merge@ymin\CF@merge@xmin
- \CF@merge@parse@nodelist#1(\relax)% calcule les maxi des positions
- \pgfmathsetmacro\CF@merge@extreme@result{\csname CF@merge@\CF@merge@extreme\endcsname\CF@merge@sign\CF@merge@fromcoeff*\CF@compound@sep}%
- \CF@merge@c#1(\relax)% trace les lignes entre les noeuds précédents et la ligne de jonction
- \CF@exp@second{\def\CF@tmp@str}{\expandafter[\CF@merge@style,shorten <=0,shorten >=0,-]}%
- \if x\expandafter\CF@firsttonil\CF@merge@extreme\@nil
- \CF@add@tocs\CF@tmp@str{(\CF@merge@extreme@result pt,\CF@merge@ymax)--(\CF@merge@extreme@result pt,\CF@merge@ymin)}%
+\def\CF_mergeb#1--(#2)[#3]{%
+ \CF_displaycompound{}{}%
+ \CF_parsemergeopt#3,\CF_quark,\CF_quark,\CF_quark\_nil
+ \def\CF_mergexmax{-16383.99999pt}\let\CF_mergeymax\CF_mergexmax
+ \def\CF_mergexmin{16383.99999pt}\let\CF_mergeymin\CF_mergexmin
+ \CF_mergeparsenodelist#1(\relax)% calcule les maxi des positions
+ \pgfmathsetmacro\CF_mergeextremeresult{\csname CF_merge\CF_mergeextreme\endcsname\CF_mergesign\CF_mergefromcoeff*\CF_compoundsep}%
+ \CF_mergec#1(\relax)% trace les lignes entre les noeuds précédents et la ligne de jonction
+ \CF_expsecond{\def\CF_temp}{\expandafter[\CF_mergestyle,shorten <=0,shorten >=0,-]}%
+ \if x\expandafter\CF_firsttonil\CF_mergeextreme\_nil
+ \CF_addtomacro\CF_temp{(\CF_mergeextremeresult pt,\CF_mergeymax)--(\CF_mergeextremeresult pt,\CF_mergeymin)}%
\else
- \CF@add@tocs\CF@tmp@str{(\CF@merge@xmin,\CF@merge@extreme@result pt)--(\CF@merge@xmax,\CF@merge@extreme@result pt)}%
+ \CF_addtomacro\CF_temp{(\CF_mergexmin,\CF_mergeextremeresult pt)--(\CF_mergexmax,\CF_mergeextremeresult pt)}%
\fi
- \expandafter\draw\CF@tmp@str node[pos=\CF@merge@splitcoeff](merge@point){}% trace la ligne de jonction
- node[at=(merge@point),shift=(\CF@merge@angle:\CF@compound@sep*\CF@merge@tocoeff-\CF@arrow@offset)](end@merge){}%
- node[at=(merge@point),shift=(\CF@merge@angle:\CF@compound@sep*\CF@merge@tocoeff)](end@merge@i){};%
- \let\CF@arrow@current@angle\CF@merge@angle
- \expandafter\draw\expandafter[\CF@merge@style,shorten <=0](merge@point)--(end@merge)%
- \expandafter\CF@arrow@display@label@a\expandafter{\CF@merge@labelup}{.5}+\expandafter\CF@arrow@display@label@a\expandafter{\CF@merge@labeldo}{.5}-;%
- \def\CF@current@nodename{end@merge@i}%
- \let\CF@tmp@str\empty
- \CF@analyse@arrowarg{#2}%
- \expandafter\CF@merge@d\CF@tmp@str\@nil
-}
-
-\def\CF@merge@c(#1){%
- \if\relax\expandafter\noexpand\CF@firsttonil#1\@nil
+ \expandafter\draw\CF_temp node[pos=\CF_mergesplitcoeff](merge@point){}% trace la ligne de jonction
+ node[at=(merge@point),shift=(\CF_mergeangle:\CF_compoundsep*\CF_mergetocoeff-\CF_arrowoffset)](end@merge){}%
+ node[at=(merge@point),shift=(\CF_mergeangle:\CF_compoundsep*\CF_mergetocoeff)](end@merge@i){};%
+ \let\CF_arrowcurrentangle\CF_mergeangle
+ \CF_expafter{\draw[}\CF_mergestyle,shorten <=0](merge@point)--(end@merge)%
+ \expandafter\CF_arrowdisplaylabela\expandafter{\CF_mergelabelup}{.5}+\expandafter\CF_arrowdisplaylabela\expandafter{\CF_mergelabeldo}{.5}-;%
+ \def\CF_currentnodename{end@merge@i}%
+ \let\CF_temp\empty
+ \CF_analysearrowarg{#2}%
+ \expandafter\CF_merged\CF_temp\_nil
+}
+
+\def\CF_mergec(#1){%
+ \if\relax\expandafter\noexpand\CF_firsttonil#1\_nil
\else
- \CF@if@stop{#1}%
- {\edef\merge@current@nodename{\CF@before@stop#1\@nil}\edef\merge@current@anchor{\CF@after@stop#1\@nil}}%
- {\def\merge@current@nodename{#1}\let\merge@current@anchor\CF@merge@angle}%
- \if x\expandafter\CF@firsttonil\CF@merge@extreme\@nil
- \pgfextracty\CF@dim{\pgfpointanchor\merge@current@nodename\merge@current@anchor}%
- \expandafter\draw\expandafter[\CF@merge@style,shorten >=0,-]([shift=(\CF@merge@angle:\CF@arrow@offset)]\merge@current@nodename.\merge@current@anchor)--(\CF@merge@extreme@result pt,\CF@dim);%
+ \CF_ifdot{#1}%
+ {\edef\merge_currentnodename{\CF_beforedot#1\_nil}%
+ \edef\merge_currentanchor{\CF_afterdot#1\_nil}%
+ }%
+ {\def\merge_currentnodename{#1}%
+ \let\merge_currentanchor\CF_mergeangle
+ }%
+ \if x\expandafter\CF_firsttonil\CF_mergeextreme\_nil
+ \pgfextracty\CF_dim{\pgfpointanchor\merge_currentnodename\merge_currentanchor}%
+ \CF_expafter{\draw[}\CF_mergestyle,shorten >=0,-]([shift=(\CF_mergeangle:\CF_arrowoffset)]\merge_currentnodename.\merge_currentanchor)--(\CF_mergeextremeresult pt,\CF_dim);%
\else
- \pgfextractx\CF@dim{\pgfpointanchor\merge@current@nodename\merge@current@anchor}%
- \expandafter\draw\expandafter[\CF@merge@style,shorten >=0,-]([shift=(\CF@merge@angle:\CF@arrow@offset)]\merge@current@nodename.\merge@current@anchor)--(\CF@dim,\CF@merge@extreme@result pt);%
+ \pgfextractx\CF_dim{\pgfpointanchor\merge_currentnodename\merge_currentanchor}%
+ \CF_expafter{\draw[}\CF_mergestyle,shorten >=0,-]([shift=(\CF_mergeangle:\CF_arrowoffset)]\merge_currentnodename.\merge_currentanchor)--(\CF_dim,\CF_mergeextremeresult pt);%
\fi
- \expandafter\CF@merge@c
+ \expandafter\CF_mergec
\fi
}
-\def\CF@merge@d#1.#2[#3]\@nil{%
- \def\CF@next@nodename{#1}%
- \edef\CF@next@nodeanchor{\CF@ifempty{#2}{180+\CF@merge@angle}{#2}}%
- \def\CF@next@nodestyle{#3}%
- \let\CF@compound\empty
- \CF@schemestart@c
-}
-
-\def\CF@parse@mergeopt#1,#2,#3,#4\@nil{%
- \CF@ifempty{#1}{\def\CF@merge@fromcoeff{0.5}}{\def\CF@merge@fromcoeff{#1}}%
- \def\CF@merge@tocoeff{0.5}%
- \def\CF@merge@splitcoeff{0.5}%
- \CF@eexp@second{\def\CF@merge@style}{\useKV[chemfig]{arrow head}}%
- \CF@if@firsttokmatch\CF@quark{#2\relax}
+\def\CF_merged#1.#2[#3]\_nil{%
+ \def\CF_nextnodename{#1}%
+ \edef\CF_nextnodeanchor{%
+ \CF_ifempty{#2}
+ {180+\CF_mergeangle}
+ {#2}%
+ }%
+ \def\CF_nextnodestyle{#3}%
+ \let\CF_compound\empty
+ \CF_schemestartc
+}
+
+\def\CF_parsemergeopt#1,#2,#3,#4\_nil{%
+ \CF_ifempty{#1}
+ {\def\CF_mergefromcoeff{0.5}}
+ {\def\CF_mergefromcoeff{#1}}%
+ \def\CF_mergetocoeff{0.5}%
+ \def\CF_mergesplitcoeff{0.5}%
+ \CF_eexpsecond{\def\CF_mergestyle}{\useKV[chemfig]{arrow head}}%
+ \CF_iffirsttokmatch\CF_quark{#2\relax}
{}
- {\CF@ifempty{#2}{\def\CF@merge@tocoeff{0.5}}{\def\CF@merge@tocoeff{#2}}%
- \CF@if@firsttokmatch\CF@quark{#3\relax}
+ {\CF_ifempty{#2}
+ {\def\CF_mergetocoeff{0.5}}
+ {\def\CF_mergetocoeff{#2}}%
+ \CF_iffirsttokmatch\CF_quark{#3\relax}
{}
- {\CF@ifempty{#3}{\def\CF@merge@splitcoeff{0.5}}{\def\CF@merge@splitcoeff{#3}}%
- \CF@if@firsttokmatch\CF@quark{#4\relax}
+ {\CF_ifempty{#3}
+ {\def\CF_mergesplitcoeff{0.5}}
+ {\def\CF_mergesplitcoeff{#3}}%
+ \CF_iffirsttokmatch\CF_quark{#4\relax}
{}
- {\CF@parse@mergeopt@i#4\@nil}%
+ {\CF_parsemergeopta#4\_nil}%
}%
}%
}
-\def\CF@parse@mergeopt@i#1,\CF@quark#2\@nil{%
- \CF@ifempty{#1}{}{\CF@add@tocs\CF@merge@style{,#1}}%
+\def\CF_parsemergeopta#1,\CF_quark#2\_nil{%
+ \CF_ifempty{#1}
+ {}
+ {\CF_addtomacro\CF_mergestyle{,#1}}%
}
-\def\CF@merge@parse@nodelist(#1){%
- \if\relax\expandafter\noexpand\CF@firsttonil#1\@nil
+\def\CF_mergeparsenodelist(#1){%
+ \if\relax\expandafter\noexpand\CF_firsttonil#1\_nil
\else
- \CF@if@stop{#1}%
- {\edef\merge@current@nodename{\CF@before@stop#1\@nil}\edef\merge@current@anchor{\CF@after@stop#1\@nil}}%
- {\def\merge@current@nodename{#1}\let\merge@current@anchor\CF@merge@angle}%
- \pgfextractx\CF@dim{\pgfpointanchor\merge@current@nodename\merge@current@anchor}%
- \ifdim\CF@dim>\CF@merge@xmax\edef\CF@merge@xmax{\the\CF@dim}\fi
- \ifdim\CF@dim<\CF@merge@xmin\edef\CF@merge@xmin{\the\CF@dim}\fi
- \pgfextracty\CF@dim{\pgfpointanchor\merge@current@nodename\merge@current@anchor}%
- \ifdim\CF@dim>\CF@merge@ymax\edef\CF@merge@ymax{\the\CF@dim}\fi
- \ifdim\CF@dim<\CF@merge@ymin\edef\CF@merge@ymin{\the\CF@dim}\fi
- \expandafter\CF@merge@parse@nodelist
+ \CF_ifdot{#1}%
+ {\edef\merge_currentnodename{\CF_beforedot#1\_nil}\edef\merge_currentanchor{\CF_afterdot#1\_nil}}%
+ {\def\merge_currentnodename{#1}\let\merge_currentanchor\CF_mergeangle}%
+ \pgfextractx\CF_dim{\pgfpointanchor\merge_currentnodename\merge_currentanchor}%
+ \ifdim\CF_dim>\CF_mergexmax
+ \edef\CF_mergexmax{\the\CF_dim}%
+ \fi
+ \ifdim\CF_dim<\CF_mergexmin
+ \edef\CF_mergexmin{\the\CF_dim}%
+ \fi
+ \pgfextracty\CF_dim{\pgfpointanchor\merge_currentnodename\merge_currentanchor}%
+ \ifdim\CF_dim>\CF_mergeymax
+ \edef\CF_mergeymax{\the\CF_dim}%
+ \fi
+ \ifdim\CF_dim<\CF_mergeymin
+ \edef\CF_mergeymin{\the\CF_dim}%
+ \fi
+ \expandafter\CF_mergeparsenodelist
\fi
}
-\def\CF@grab@arrow@name#1[#2\@nil{\detokenize{CF@arrow(#1)}}
-\def\CF@grab@arrow@args#1[#2\@nil{[#2}
+\def\CF_grabarrowname#1[#2\_nil{\detokenize{CF_arrow(#1)}}
+\def\CF_grabarrowargs#1[#2\_nil{[#2}
-\def\CF@make@parameter@text#1{%
- \toks\z@{}%
- \CF@cnt@groupnumber#1\relax
- \CF@make@parameter@text@a1%
+\def\CF_makeparametertext#1{%
+ \toks0{}%
+ \CF_cntgroup#1\relax
+ \CF_makeparametertexta1%
}
-\def\CF@make@parameter@text@a#1{%
- \unless\ifnum#1>\CF@cnt@groupnumber
- \toks\z@\expandafter{\the\toks\z@[###1]}%
- \expandafter\CF@make@parameter@text@a\expandafter{\number\numexpr#1+1\expandafter}%
+\def\CF_makeparametertexta#1{%
+ \unless\ifnum#1>\CF_cntgroup
+ \toks0\expandafter{\the\toks0[###1]}%
+ \expandafter\CF_makeparametertexta\expandafter{\number\numexpr#1+1\expandafter}%
\fi
}
% #1 est le nombre d'arguments optionnels, #2 est le nom et #3 le code
\def\definearrow#1#2#3{%
\begingroup
- \CF@make@parameter@text{#1}%
+ \CF_makeparametertext{#1}%
\expandafter\endgroup
- \expandafter\def\csname\detokenize{CF@arrow(#2)}\expandafter\endcsname\the\toks\z@{#3\CF@gobtonil}%
+ \expandafter\def\csname\detokenize{CF_arrow(#2)}\expandafter\endcsname\the\toks0{#3\CF_gobtonil}%
}
-\def\CF@if@stop#1{\CF@if@stop@a#1.\@nil}
-\def\CF@if@stop@a#1.#2\@nil{\ifx\empty#2\empty\expandafter\CF@execsecond\else\expandafter\CF@execfirst\fi}
-\def\CF@before@stop#1.#2\@nil{#1}
-\def\CF@after@stop#1.#2\@nil{#2}
+\def\CF_ifdot#1{\CF_ifdota#1.\_nil}
+\def\CF_ifdota#1.#2\_nil{\ifx\empty#2\empty\expandafter\CF_execsecond\else\expandafter\CF_execfirst\fi}
+\def\CF_beforedot#1.#2\_nil{#1}
+\def\CF_afterdot#1.#2\_nil{#2}
-\def\CF@rotate@node*#1#2\@nil{\CF@if@stop{#1}{\CF@before@stop#1\@nil}{#1}}
-\def\CF@anchor@node*#1#2\@nil#3{\CF@if@stop{#1}{\CF@after@stop#1\@nil}{\CF@arrow@current@angle-#390-#1}}
+\def\CF_rotatenode*#1#2\_nil{%
+ \CF_ifdot{#1}
+ {\CF_beforedot#1\_nil}
+ {#1}%
+}
+\def\CF_anchornode*#1#2\_nil#3{%
+ \CF_ifdot{#1}
+ {\CF_afterdot#1\_nil}
+ {\CF_arrowcurrentangle-#390-#1}%
+}
% #1 = label #2 = position #3 = + ou - (au dessus ou au dessous) #4 : nom du noeud de départ
% #5 = label #6 = position #7 = + ou - (au dessus ou au dessous) #8 : nom du noeud de fin
-\def\CF@arrow@display@label#1#2#3#4#5#6#7#8{%
- \CF@doifnotempty{#1#5}
- {\path(#4)--(#8)\CF@arrow@display@label@a{#1}{#2}{#3}\CF@arrow@display@label@a{#5}{#6}{#7};}%
+\def\CF_arrowdisplaylabel#1#2#3#4#5#6#7#8{%
+ \CF_doifnotempty{#1#5}
+ {\path(#4)--(#8)\CF_arrowdisplaylabela{#1}{#2}{#3}\CF_arrowdisplaylabela{#5}{#6}{#7};}%
}
-\def\CF@arrow@display@label@a#1#2#3{%
- \CF@doifnotempty{#1}
- {\if*\expandafter\CF@firsttonil\detokenize{#1}\@nil
+\def\CF_arrowdisplaylabela#1#2#3{%
+ \CF_doifnotempty{#1}
+ {\if*\expandafter\CF_firsttonil\detokenize{#1}\_nil
\ifboolKV[chemfig]{scheme debug}
- {node[pos=#2,sloped,yshift=#3\CF@arrow@labelsep,draw,fill,cyan](shifted@node){}%
- node[draw,rotate=\CF@rotate@node#1\@nil,anchor=\CF@anchor@node#1\@nil#3,at=(shifted@node)]{\expandafter\CF@gobarg\CF@gobarg#1}%
+ {node[pos=#2,sloped,yshift=#3\CF_arrowlabelsep,draw,fill,cyan](shifted@node){}%
+ node[draw,rotate=\CF_rotatenode#1\_nil,anchor=\CF_anchornode#1\_nil#3,at=(shifted@node)]{\expandafter\CF_gobarg\CF_gobarg#1}%
}
- {node[pos=#2,sloped,yshift=#3\CF@arrow@labelsep](shifted@node){}%
- node[rotate=\CF@rotate@node#1\@nil,anchor=\CF@anchor@node#1\@nil#3,at=(shifted@node)]{\expandafter\CF@gobarg\CF@gobarg#1}%
+ {node[pos=#2,sloped,yshift=#3\CF_arrowlabelsep](shifted@node){}%
+ node[rotate=\CF_rotatenode#1\_nil,anchor=\CF_anchornode#1\_nil#3,at=(shifted@node)]{\expandafter\CF_gobarg\CF_gobarg#1}%
}%
\else
\ifboolKV[chemfig]{scheme debug}
- {node[pos=#2,sloped,yshift=#3\CF@arrow@labelsep,draw,fill,cyan](shifted@node){}%
- node[draw,pos=#2,anchor=-#390,sloped,yshift=#3\CF@arrow@labelsep]{#1}%
+ {node[pos=#2,sloped,yshift=#3\CF_arrowlabelsep,draw,fill,cyan](shifted@node){}%
+ node[draw,pos=#2,anchor=-#390,sloped,yshift=#3\CF_arrowlabelsep]{#1}%
}
- {node[pos=#2,anchor=-#390,sloped,yshift=#3\CF@arrow@labelsep]{#1}%
+ {node[pos=#2,anchor=-#390,sloped,yshift=#3\CF_arrowlabelsep]{#1}%
}
\fi
}%
}
-% pose des noeuds décalés de la dimension #1 à (\CF@arrow@start@node) et (\CF@arrow@end@node)
-\def\CF@arrow@shift@nodes#1{%
- \unless\ifdim\CF@ifempty{#1}\z@{#1}=\z@
- \edef\CF@tmp@str{%
- \noexpand\path(\CF@arrow@start@node)--(\CF@arrow@end@node)%
- node[pos=0,sloped,yshift=#1](\CF@arrow@start@node1){}node[pos=1,sloped,yshift=#1](\CF@arrow@end@node1){};}%
- \CF@tmp@str
- \edef\CF@arrow@start@node{\CF@arrow@start@node1}\edef\CF@arrow@end@node{\CF@arrow@end@node1}%
+% pose des noeuds décalés de la dimension #1 à (\CF_arrowstartnode) et (\CF_arrowendnode)
+\def\CF_arrowshiftnodes#1{%
+ \unless\ifdim\CF_ifempty{#1}\CF_zero{#1}=0pt
+ \edef\CF_temp{%
+ \noexpand\path(\CF_arrowstartnode)--(\CF_arrowendnode)%
+ node[pos=0,sloped,yshift=#1](\CF_arrowstartnode1){}node[pos=1,sloped,yshift=#1](\CF_arrowendnode1){};}%
+ \CF_temp
+ \edef\CF_arrowstartnode{\CF_arrowstartnode1}\edef\CF_arrowendnode{\CF_arrowendnode1}%
\fi
}
\definearrow3{->}{%
- \CF@arrow@shift@nodes{#3}%
- \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node)--(\CF@arrow@end@node);%
- \CF@arrow@display@label{#1}{0.5}+\CF@arrow@start@node{#2}{0.5}-\CF@arrow@end@node
+ \CF_arrowshiftnodes{#3}%
+ \CF_expafter{\draw[}\CF_arrowcurrentstyle](\CF_arrowstartnode)--(\CF_arrowendnode);%
+ \CF_arrowdisplaylabel{#1}{0.5}+\CF_arrowstartnode{#2}{0.5}-\CF_arrowendnode
}
\definearrow3{<-}{%
- \CF@arrow@shift@nodes{#3}%
- \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@end@node)--(\CF@arrow@start@node);%
- \CF@arrow@display@label{#1}{0.5}+\CF@arrow@start@node{#2}{0.5}-\CF@arrow@end@node
+ \CF_arrowshiftnodes{#3}%
+ \CF_expafter{\draw[}\CF_arrowcurrentstyle](\CF_arrowendnode)--(\CF_arrowstartnode);%
+ \CF_arrowdisplaylabel{#1}{0.5}+\CF_arrowstartnode{#2}{0.5}-\CF_arrowendnode
}
\definearrow5{-/>}{%
- \CF@arrow@shift@nodes{#3}%
- \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node)--(\CF@arrow@end@node)%
- coordinate[midway,shift=(\CF@arrow@current@angle:-1pt)](midway@i)%
- coordinate[midway,shift=(\CF@arrow@current@angle:1pt)](midway@ii)%
- coordinate[at=(midway@i),shift=(\CF@ifempty{#4}{225}{#4+180}+\CF@arrow@current@angle:\CF@ifempty{#5}{5pt}{#5})](line@start)%
- coordinate[at=(midway@i),shift=(\CF@ifempty{#4}{45}{#4}+\CF@arrow@current@angle:\CF@ifempty{#5}{5pt}{#5})](line@end)%
- coordinate[at=(midway@ii),shift=(\CF@ifempty{#4}{225}{#4+180}+\CF@arrow@current@angle:\CF@ifempty{#5}{5pt}{#5})](line@start@i)%
- coordinate[at=(midway@ii),shift=(\CF@ifempty{#4}{45}{#4}+\CF@arrow@current@angle:\CF@ifempty{#5}{5pt}{#5})](line@end@i);
+ \CF_arrowshiftnodes{#3}%
+ \CF_expafter{\draw[}\CF_arrowcurrentstyle](\CF_arrowstartnode)--(\CF_arrowendnode)%
+ coordinate[midway,shift=(\CF_arrowcurrentangle:-1pt)](midway@i)%
+ coordinate[midway,shift=(\CF_arrowcurrentangle:1pt)](midway@ii)%
+ coordinate[at=(midway@i),shift=(\CF_ifempty{#4}{225}{#4+180}+\CF_arrowcurrentangle:\CF_ifempty{#5}{5pt}{#5})](line@start)%
+ coordinate[at=(midway@i),shift=(\CF_ifempty{#4}{45}{#4}+\CF_arrowcurrentangle:\CF_ifempty{#5}{5pt}{#5})](line@end)%
+ coordinate[at=(midway@ii),shift=(\CF_ifempty{#4}{225}{#4+180}+\CF_arrowcurrentangle:\CF_ifempty{#5}{5pt}{#5})](line@start@i)%
+ coordinate[at=(midway@ii),shift=(\CF_ifempty{#4}{45}{#4}+\CF_arrowcurrentangle:\CF_ifempty{#5}{5pt}{#5})](line@end@i);
\draw(line@start)--(line@end);%
\draw(line@start@i)--(line@end@i);%
- \CF@arrow@display@label{#1}{0.5}+\CF@arrow@start@node{#2}{0.5}-\CF@arrow@end@node
+ \CF_arrowdisplaylabel{#1}{0.5}+\CF_arrowstartnode{#2}{0.5}-\CF_arrowendnode
}
\definearrow3{<->}{%
- \CF@arrow@shift@nodes{#3}%
- \expandafter\draw\expandafter[\CF@arrow@current@style,\CF@arrowtip-\CF@arrowtip](\CF@arrow@start@node)--(\CF@arrow@end@node);%
- \CF@arrow@display@label{#1}{0.5}+\CF@arrow@start@node{#2}{0.5}-\CF@arrow@end@node
+ \CF_arrowshiftnodes{#3}%
+ \CF_expafter{\draw[}\CF_arrowcurrentstyle,\CF_arrowtip-\CF_arrowtip](\CF_arrowstartnode)--(\CF_arrowendnode);%
+ \CF_arrowdisplaylabel{#1}{0.5}+\CF_arrowstartnode{#2}{0.5}-\CF_arrowendnode
}
\definearrow3{<=>}{%
- \CF@arrow@shift@nodes{#3}%
- \path[allow upside down](\CF@arrow@start@node)--(\CF@arrow@end@node)%
- node[pos=0,sloped,yshift=\CF@arrow@double@sep](\CF@arrow@start@node @u0){}%
- node[pos=0,sloped,yshift=-\CF@arrow@double@sep](\CF@arrow@start@node @d0){}%
- node[pos=1,sloped,yshift=\CF@arrow@double@sep](\CF@arrow@start@node @u1){}%
- node[pos=1,sloped,yshift=-\CF@arrow@double@sep](\CF@arrow@start@node @d1){};%
+ \CF_arrowshiftnodes{#3}%
+ \path[allow upside down](\CF_arrowstartnode)--(\CF_arrowendnode)%
+ node[pos=0,sloped,yshift=\CF_arrowdoublesep](\CF_arrowstartnode @u0){}%
+ node[pos=0,sloped,yshift=-\CF_arrowdoublesep](\CF_arrowstartnode @d0){}%
+ node[pos=1,sloped,yshift=\CF_arrowdoublesep](\CF_arrowstartnode @u1){}%
+ node[pos=1,sloped,yshift=-\CF_arrowdoublesep](\CF_arrowstartnode @d1){};%
\begingroup
- \ifboolKV[chemfig]{arrow double harpoon}{\pgfarrowharpoontrue}{}%
- \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node @u0)--(\CF@arrow@start@node @u1);%
- \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node @d1)--(\CF@arrow@start@node @d0);%
+ \ifboolKV[chemfig]{arrow double harpoon}
+ {\pgfarrowharpoontrue}
+ {}%
+ \CF_expafter{\draw[}\CF_arrowcurrentstyle](\CF_arrowstartnode @u0)--(\CF_arrowstartnode @u1);%
+ \CF_expafter{\draw[}\CF_arrowcurrentstyle](\CF_arrowstartnode @d1)--(\CF_arrowstartnode @d0);%
\endgroup
- \CF@arrow@display@label{#1}{0.5}+\CF@arrow@start@node{#2}{0.5}-\CF@arrow@end@node%
+ \CF_arrowdisplaylabel{#1}{0.5}+\CF_arrowstartnode{#2}{0.5}-\CF_arrowendnode%
}
\definearrow3{<->>}{%
- \CF@arrow@shift@nodes{#3}%
- \path[allow upside down](\CF@arrow@start@node)--(\CF@arrow@end@node)%
- node[pos=0,sloped,yshift=1pt](\CF@arrow@start@node @u0){}%
- node[pos=\CF@arrow@double@pos@start,sloped,yshift=-1pt](\CF@arrow@start@node @d0){}%
- node[pos=1,sloped,yshift=1pt](\CF@arrow@start@node @u1){}%
- node[pos=\CF@arrow@double@pos@end,sloped,yshift=-1pt](\CF@arrow@start@node @d1){};%
+ \CF_arrowshiftnodes{#3}%
+ \path[allow upside down](\CF_arrowstartnode)--(\CF_arrowendnode)%
+ node[pos=0,sloped,yshift=1pt](\CF_arrowstartnode @u0){}%
+ node[pos=\CF_arrowdoubleposstart,sloped,yshift=-1pt](\CF_arrowstartnode @d0){}%
+ node[pos=1,sloped,yshift=1pt](\CF_arrowstartnode @u1){}%
+ node[pos=\CF_arrowdoubleposend,sloped,yshift=-1pt](\CF_arrowstartnode @d1){};%
\begingroup
- \ifboolKV[chemfig]{arrow double harpoon}{\pgfarrowharpoontrue}{}%
- \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node @u0)--(\CF@arrow@start@node @u1);%
- \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node @d1)--(\CF@arrow@start@node @d0);%
+ \ifboolKV[chemfig]{arrow double harpoon}
+ {\pgfarrowharpoontrue}
+ {}%
+ \CF_expafter{\draw[}\CF_arrowcurrentstyle](\CF_arrowstartnode @u0)--(\CF_arrowstartnode @u1);%
+ \CF_expafter{\draw[}\CF_arrowcurrentstyle](\CF_arrowstartnode @d1)--(\CF_arrowstartnode @d0);%
\endgroup
- \CF@arrow@display@label{#1}{0.5}+\CF@arrow@start@node{#2}{0.5}-\CF@arrow@end@node%
+ \CF_arrowdisplaylabel{#1}{0.5}+\CF_arrowstartnode{#2}{0.5}-\CF_arrowendnode%
}
\definearrow3{<<->}{%
- \path[allow upside down](\CF@arrow@start@node)--(\CF@arrow@end@node)%
- node[pos=\CF@arrow@double@pos@start,sloped,yshift=1pt](\CF@arrow@start@node @u0){}%
- node[pos=0,sloped,yshift=-1pt](\CF@arrow@start@node @d0){}%
- node[pos=\CF@arrow@double@pos@end,sloped,yshift=1pt](\CF@arrow@start@node @u1){}%
- node[pos=1,sloped,yshift=-1pt](\CF@arrow@start@node @d1){};%
+ \path[allow upside down](\CF_arrowstartnode)--(\CF_arrowendnode)%
+ node[pos=\CF_arrowdoubleposstart,sloped,yshift=1pt](\CF_arrowstartnode @u0){}%
+ node[pos=0,sloped,yshift=-1pt](\CF_arrowstartnode @d0){}%
+ node[pos=\CF_arrowdoubleposend,sloped,yshift=1pt](\CF_arrowstartnode @u1){}%
+ node[pos=1,sloped,yshift=-1pt](\CF_arrowstartnode @d1){};%
\begingroup
- \ifboolKV[chemfig]{arrow double harpoon}{\pgfarrowharpoontrue}{}%
- \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node @u0)--(\CF@arrow@start@node @u1);%
- \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node @d1)--(\CF@arrow@start@node @d0);%
+ \ifboolKV[chemfig]{arrow double harpoon}
+ {\pgfarrowharpoontrue}
+ {}%
+ \CF_expafter{\draw[}\CF_arrowcurrentstyle](\CF_arrowstartnode @u0)--(\CF_arrowstartnode @u1);%
+ \CF_expafter{\draw[}\CF_arrowcurrentstyle](\CF_arrowstartnode @d1)--(\CF_arrowstartnode @d0);%
\endgroup
- \CF@arrow@display@label{#1}{0.5}+\CF@arrow@start@node{#2}{0.5}-\CF@arrow@end@node
+ \CF_arrowdisplaylabel{#1}{0.5}+\CF_arrowstartnode{#2}{0.5}-\CF_arrowendnode
}
\definearrow30{%
- \CF@arrow@shift@nodes{#3}%
- \CF@arrow@display@label{#1}{0.5}+\CF@arrow@start@node{#2}{0.5}-\CF@arrow@end@node
+ \CF_arrowshiftnodes{#3}%
+ \CF_arrowdisplaylabel{#1}{0.5}+\CF_arrowstartnode{#2}{0.5}-\CF_arrowendnode
}
\definearrow5{-U>}{%
- \CF@arrow@shift@nodes{#3}%
- \expandafter\draw\expandafter[\CF@arrow@current@style](\CF@arrow@start@node)--(\CF@arrow@end@node)node[midway](Uarrow@arctangent){};%
- \CF@ifempty{#4}
- {\def\CF@Uarrow@radius{0.333}}
- {\def\CF@Uarrow@radius{#4}}%
- \CF@ifempty{#5}%
- {\def\CF@Uarrow@absangle{60}}
- {\pgfmathsetmacro\CF@Uarrow@absangle{abs(#5)}}% ne prendre en compte que la valeur absolue de l'angle
- \edef\CF@tmp@str{[\CF@ifempty{#1}{draw=none}{\unexpanded\expandafter{\CF@arrow@current@style}},-]}%
- \expandafter\draw\CF@tmp@str (Uarrow@arctangent)%
- arc[radius=\CF@compound@sep*\CF@current@arrow@length*\CF@Uarrow@radius,start angle=\CF@arrow@current@angle-90,delta angle=-\CF@Uarrow@absangle]node(Uarrow@start){};
- \edef\CF@tmp@str{[\CF@ifempty{#2}{draw=none}{\unexpanded\expandafter{\CF@arrow@current@style}}]}%
- \expandafter\draw\CF@tmp@str (Uarrow@arctangent)%
- arc[radius=\CF@compound@sep*\CF@current@arrow@length*\CF@Uarrow@radius,start angle=\CF@arrow@current@angle-90,delta angle=\CF@Uarrow@absangle]node(Uarrow@end){};
- \pgfmathsetmacro\CF@tmp@str{\CF@Uarrow@radius*cos(\CF@arrow@current@angle)<0?"-":"+"}%
- \ifdim\CF@Uarrow@radius pt>\z@
- \CF@arrow@display@label{#1}{0}\CF@tmp@str{Uarrow@start}{#2}{1}\CF@tmp@str{Uarrow@end}%
+ \CF_arrowshiftnodes{#3}%
+ \CF_expafter{\draw[}\CF_arrowcurrentstyle](\CF_arrowstartnode)--(\CF_arrowendnode)node[midway](Uarrow@arctangent){};%
+ \CF_ifempty{#4}
+ {\def\CF_Uarrowradius{0.333}}
+ {\def\CF_Uarrowradius{#4}}%
+ \CF_ifempty{#5}%
+ {\def\CF_Uarrowabsangle{60}}
+ {\pgfmathsetmacro\CF_Uarrowabsangle{abs(#5)}}% ne prendre en compte que la valeur absolue de l'angle
+ \edef\CF_temp{[\CF_ifempty{#1}{draw=none}{\unexpanded\expandafter{\CF_arrowcurrentstyle}},-]}%
+ \expandafter\draw\CF_temp (Uarrow@arctangent)%
+ arc[radius=\CF_compoundsep*\CF_currentarrowlength*\CF_Uarrowradius,start angle=\CF_arrowcurrentangle-90,delta angle=-\CF_Uarrowabsangle]node(Uarrow@start){};
+ \edef\CF_temp{[\CF_ifempty{#2}{draw=none}{\unexpanded\expandafter{\CF_arrowcurrentstyle}}]}%
+ \expandafter\draw\CF_temp (Uarrow@arctangent)%
+ arc[radius=\CF_compoundsep*\CF_currentarrowlength*\CF_Uarrowradius,start angle=\CF_arrowcurrentangle-90,delta angle=\CF_Uarrowabsangle]node(Uarrow@end){};
+ \pgfmathsetmacro\CF_temp{\CF_Uarrowradius*cos(\CF_arrowcurrentangle)<0?"-":"+"}%
+ \ifdim\CF_Uarrowradius pt>0pt
+ \CF_arrowdisplaylabel{#1}{0}\CF_temp{Uarrow@start}{#2}{1}\CF_temp{Uarrow@end}%
\else
- \CF@arrow@display@label{#2}{0}\CF@tmp@str{Uarrow@start}{#1}{1}\CF@tmp@str{Uarrow@end}%
+ \CF_arrowdisplaylabel{#2}{0}\CF_temp{Uarrow@start}{#1}{1}\CF_temp{Uarrow@end}%
\fi
}
+\def\CF_grabdelim#1#2#3\_nil{\def\CF_leftdelim{#1}\def\CF_rightdelim{#2}}
+\def\CF_resetdelim{%
+ \setKVdefault[CFdelimiters]
+ {delimiters =(),
+ height =10pt,
+ depth =,
+ open xshift =0pt,
+ close xshift=,
+ indice =n}%
+}
+
+\CF_resetdelim
+
+\def\polymerdelim{\CF_ifnextchar[{\CF_polymerdelima}{\CF_polymerdelima[]}}
+\def\CF_polymerdelima[#1]#2#3{%
+ \CF_resetdelim
+ \CF_doifnotempty{#1}{\setKV[CFdelimiters]{#1}}%
+ \expandafter\expandafter\expandafter\CF_grabdelim\useKV[CFdelimiters]{delimiters}()\_nil
+ \edef\CF_delimheight{\the\dimexpr\useKV[CFdelimiters]{height}}%
+ \CF_eexpsecond\CF_ifempty{\useKV[CFdelimiters]{depth}}
+ {\let\CF_delimdepth\CF_delimheight}
+ {\edef\CF_delimdepth{\the\dimexpr\useKV[CFdelimiters]{depth}}}%
+ \edef\CF_delimhalfdim{\the\dimexpr(\CF_delimheight+\CF_delimdepth)/2}%
+ \edef\CF_delimvshift {\the\dimexpr(\CF_delimheight-\CF_delimdepth)/2}%
+ \edef\CF_leftdelimxshift{\the\dimexpr\useKV[CFdelimiters]{open xshift}}%
+ \CF_eexpsecond\CF_ifempty{\useKV[CFdelimiters]{close xshift}}
+ {\edef\CF_rightdelimxshift{\the\dimexpr-\useKV[CFdelimiters]{open xshift}}}
+ {\edef\CF_rightdelimxshift{\the\dimexpr-\useKV[CFdelimiters]{close xshift}}}%
+ \chemmove{%
+ \nulldelimiterspace0pt
+ \pgfextractx\CF_dim{\pgfpointanchor{#2}{center}}\edef\CF_leftdelimx{\the\CF_dim}%
+ \pgfextracty\CF_dim{\pgfpointanchor{#2}{center}}\edef\CF_leftdelimy{\the\CF_dim}%
+ \pgfextractx\CF_dim{\pgfpointanchor{#3}{center}}\edef\CF_rightdelimx{\the\CF_dim}%
+ \node[at={(\CF_leftdelimx+\CF_leftdelimxshift,\CF_leftdelimy+\CF_delimvshift)}]
+ {$\left\CF_leftdelim\vrule height\CF_delimhalfdim depth\CF_delimhalfdim width0pt\right.$};%
+ \node[at={(\CF_rightdelimx+\CF_rightdelimxshift,\CF_leftdelimy+\CF_delimvshift)}]
+ {$\left.\vrule height\CF_delimhalfdim depth\CF_delimhalfdim width0pt\right\CF_rightdelim
+ \CF_eexpsecond\CF_doifnotempty{\useKV[CFdelimiters]{indice}}
+ {\CF_underscore{\rlap{$\scriptstyle\useKV[CFdelimiters]{indice}$}}}
+ $};
+ }%
+}
+
+\catcode`\@11
\pgfdeclarearrow{%
name = CF,%
defaults = {%
@@ -2179,7 +2471,7 @@
\pgfmathsincos@{\pgf@sys@tonumber\pgf@ya}%
\pgf@ya\pgfmathresulty\pgf@yc% ya is the back miter
\pgf@yb\pgfmathresultx\pgf@yc% yb is the top miter
- \ifdim\pgfarrowinset=\z@
+ \ifdim\pgfarrowinset=0pt
\pgf@ya.5\pgfarrowlinewidth% easy: back miter is half linewidth
\fi
% Compute inset miter length:
@@ -2258,48 +2550,6 @@
\ifpgfarrowroundjoin j\fi%
}%
}
-
-\def\CF@grab@delim#1#2#3\@nil{\def\CF@left@delim{#1}\def\CF@right@delim{#2}}
-\def\CF@resetdelim{%
- \setKVdefault[CFdelimiters]
- {delimiters =(),
- height =10pt,
- depth =,
- open xshift =0pt,
- close xshift=,
- indice =n}%
-}
-\CF@resetdelim
-\def\polymerdelim{\CF@ifnextchar[{\polymerdelim@a}{\polymerdelim@a[]}}
-\def\polymerdelim@a[#1]#2#3{%
- \CF@resetdelim
- \CF@doifnotempty{#1}{\setKV[CFdelimiters]{#1}}%
- \expandafter\expandafter\expandafter\CF@grab@delim\useKV[CFdelimiters]{delimiters}()\@nil
- \edef\CF@delim@height{\the\dimexpr\useKV[CFdelimiters]{height}}%
- \CF@eexp@macroarg\CF@ifempty{\useKV[CFdelimiters]{depth}}
- {\let\CF@delim@depth\CF@delim@height}
- {\edef\CF@delim@depth{\the\dimexpr\useKV[CFdelimiters]{depth}}}%
- \edef\CF@delim@halfdim{\the\dimexpr(\CF@delim@height+\CF@delim@depth)/2}%
- \edef\CF@delim@vshift {\the\dimexpr(\CF@delim@height-\CF@delim@depth)/2}%
- \edef\CF@leftdelim@xshift{\the\dimexpr\useKV[CFdelimiters]{open xshift}}%
- \CF@eexp@macroarg\CF@ifempty{\useKV[CFdelimiters]{close xshift}}
- {\edef\CF@rightdelim@xshift{\the\dimexpr-\useKV[CFdelimiters]{open xshift}}}
- {\edef\CF@rightdelim@xshift{\the\dimexpr-\useKV[CFdelimiters]{close xshift}}}%
- \chemmove{%
- \nulldelimiterspace0pt
- \pgfextractx\CF@dim{\pgfpointanchor{#2}{center}}\edef\CF@leftdelim@x{\the\CF@dim}%
- \pgfextracty\CF@dim{\pgfpointanchor{#2}{center}}\edef\CF@leftdelim@y{\the\CF@dim}%
- \pgfextractx\CF@dim{\pgfpointanchor{#3}{center}}\edef\CF@rightdelim@x{\the\CF@dim}%
- \node[at={(\CF@leftdelim@x+\CF@leftdelim@xshift,\CF@leftdelim@y+\CF@delim@vshift)}]
- {$\left\CF@left@delim\vrule height\CF@delim@halfdim depth\CF@delim@halfdim width0pt\right.$};%
- \node[at={(\CF@rightdelim@x+\CF@rightdelim@xshift,\CF@leftdelim@y+\CF@delim@vshift)}]
- {$\left.\vrule height\CF@delim@halfdim depth\CF@delim@halfdim width0pt\right\CF@right@delim
- \CF@eexp@macroarg\CF@doifnotempty{\useKV[CFdelimiters]{indice}}
- {_{\rlap{$\scriptstyle\useKV[CFdelimiters]{indice}$}}}
- $};
- }%
-}
-
\CFrestorecatcode
\endinput
@@ -2403,7 +2653,7 @@ v1.0b 2011/11/29
- la commande \merge est désormais protégée entre
\schemestart et \schemestop contre des définitions par d'autres
packages.
- - \box\z@ est utilisé au lieu du maladroit \unhbox\z@
+ - \box0 est utilisé au lieu du maladroit \unhbox0
----------------------------------------------------------------------
v1.0c 2011/11/30
- la macro \+ n'est plus explicitement écrite
@@ -2425,13 +2675,13 @@ v1.0f 2012/02/24
pas correctement gérés.
----------------------------------------------------------------------
v1.0g 2012/11/16
- - correction d'un bug dans \CF@direct@arrow pour faire prendre en
+ - correction d'un bug dans \CF_directarrow pour faire prendre en
compte le style des flèche par défaut
- - correction d'un bug dans \CF@lewis@c : la boite *doit* être
+ - correction d'un bug dans \CF_lewisc : la boite *doit* être
composée en dehors de l'environnement tikzpicture pour
éviter nullfont si jamais \printatom ne passe pas en mode
math.
- - correction d'un bug dans \CF@chemfig@e : si une longueur par
+ - correction d'un bug dans \CF_chemfigc : si une longueur par
défaut est modifiée par [,<l>] au début d'une molécule
et si des cycles étaient emboités, cette longueur n'était
pas appliquée aux sous-cycles.
@@ -2443,20 +2693,20 @@ v1.0g 2012/11/16
v1.0h 2013/11/28
- \chemname admet maintenant une version étoilé qui ne tient
pas compte des profondeurs précédentes.
- - \CF@dp@max est géré globalement.
+ - \CF_dpmax est géré globalement.
- correction d'un bug dans "-U>" : le style de la flèche
n'était pris en compte pour l'arc.
- - correction d'un bug dans \CF@direct@arrow : l'angle de la
+ - correction d'un bug dans \CF_directarrow : l'angle de la
flèche n'était pas calculé
----------------------------------------------------------------------
v1.1 2015/02/13
- - correction d'un bug dans \CF@seek@submol : la macro
- \CF@remain@molecule est dépouillé de son éventuel espace
+ - correction d'un bug dans \CF_seeksubmol : la macro
+ \CF_molecule est dépouillé de son éventuel espace
en première position.
- - correction d'un bug dans \CF@arrow@f : le nom du prochain
+ - correction d'un bug dans \CF_arrowf : le nom du prochain
n?ud courant "end@arrow@i" était erroné dans le cas où une
flèche contenait un sous schéma. Ce nom doit dépendre de
- \CF@scheme@nest.
+ \CF_schemenest.
- la jonction entre deux liaisons consécutives dans l'axe peut
être activé avec \enablebondjoin et désactivé avec
\disablebondjoin (préférable, état par défaut).
@@ -2469,9 +2719,9 @@ v1.1 2015/02/13
\disablefixedbondlength le désactive.
----------------------------------------------------------------------
v1.1a 2015/02/23
- - correction d'un bug dans \CF@grab@bondoffset. Si \chemfig est
+ - correction d'un bug dans \CF_grabbondoffset. Si \chemfig est
dans l'argument d'une macro, les # sont doublés par l'action
- de \scantokens de la macro \CF@chemfig@d et il faut un
+ de \scantokens de la macro \CF_chemfigb et il faut un
argument délimité avant "(" pour absorber tous les #.
----------------------------------------------------------------------
v1.2 2015/10/08
@@ -2479,7 +2729,7 @@ v1.2 2015/10/08
- création de \setangleincrement.
- chargement de "arrows.meta" et définition de la flèche "CF"
basée sur "Stealth" et définie avec \pgfdeclarearrow.
- Les anciennes flèches "CF@full" et "CF@half" sont
+ Les anciennes flèches "CF_full" et "CF_half" sont
abandonnées puisque définies avec \pgfarrowsdeclare.
- flèche "-U>" corrigée : le placement des labels est
maintenant correct dans tous les cas. Ainsi :
@@ -2490,7 +2740,7 @@ v1.2 2015/10/08
- compatibilité, avec les limitations d'usage, avec la
librairie "externalize" : le \begin{tikzpicture} voit
désormais le \end{tikzpicture} correspondant dans la macro
- \CF@chemfig@d.
+ \CF_chemfigb.
----------------------------------------------------------------------
v1.2a 2015/10/21
- erreur de copier-coller dans le code: une adresse url était
@@ -2498,16 +2748,16 @@ v1.2a 2015/10/21
code
----------------------------------------------------------------------
v1.2b 2015/11/15
- - bug dans \CF@seek@submol qui laissait "*" dans le flux de
+ - bug dans \CF_seeksubmol qui laissait "*" dans le flux de
lecture de TeX. Un message d'erreur est également ajouté
en cas de "!" en fin de traitement.
- - correction d'un bug dans \CF@set@bondangle où l'angle [<:a>]
+ - correction d'un bug dans \CF_setbondangle où l'angle [<:a>]
n'était pas évalué par \pgfmathsetmacro.
----------------------------------------------------------------------
v1.2c 2015/11/20
- - Correction d'un bug dans \CF@set@bondangle : l'angle renvoyé
+ - Correction d'un bug dans \CF_setbondangle : l'angle renvoyé
pouvait être négatif
- - Correction d'un bug dans \CF@direct@arrow : la macro \CF@ifempty
+ - Correction d'un bug dans \CF_directarrow : la macro \CF_ifempty
n'est pas correctement développée dans l'argument de
\pgfpointanchor
----------------------------------------------------------------------
@@ -2519,7 +2769,7 @@ v1.2d 2015/12/01
----------------------------------------------------------------------
v1.2e 2017/05/20
- la macro contenant la définition d'une flèche est
- désormais "\CF@arrow(<nom>)", ainsi la macro \0 n'est plus
+ désormais "\CF_arrow(<nom>)", ainsi la macro \0 n'est plus
définie par \definearrow
- remerciements rajoutés après une suppression indue, pour ne
froisser aucune susceptibilité
@@ -2543,24 +2793,43 @@ v1.3 2018/03/08
- 6 nouveaux paramètres : "lewis radius", "arrow double sep",
"arrow double coeff", "arrow double harpoon", "cycle radius
coeff", "arrow head".
- - correction d'un bug dans \CF@parse@mergeopt qui dans certains
+ - correction d'un bug dans \CF_parsemergeopt qui dans certains
cas, envoyait vers l'affichage des caractères
- petit toilettage du code
- macro \polymerdelim (non documentée) expérimentale et encore
en phase de tests
- suppression d'un registre d'écriture de fichier
- ----------------------------------------------------------------------
+----------------------------------------------------------------------
v1.31 2018/04/05
- - correction d'un espace indésirable dans \CF@ifnextchar
- ----------------------------------------------------------------------
+ - correction d'un espace indésirable dans \CF_ifnextchar
+----------------------------------------------------------------------
v1.32 2018/08/23
- - définition de \printatom, \CF@begin@tikzpicture et
- \CF@end@tikzpicture dans le fichier t-chemfig.tex
- ----------------------------------------------------------------------
+ - définition de \printatom, \CF_begintikzpicture et
+ \CF_endtikzpicture dans le fichier t-chemfig.tex
+----------------------------------------------------------------------
v1.33 2018/10/31
- les macros définies par \definesubmol peuvent désormais avoir un ou
plusieurs arguments
- macro \polymerdelim documentée
- ----------------------------------------------------------------------
+----------------------------------------------------------------------
v1.34 2019/02/23
- - bug dans la flèche "<->" corrigé \ No newline at end of file
+ - bug dans la flèche "<->" corrigé
+----------------------------------------------------------------------
+v1.4 2019/04/18
+ - corrections de nombreux bugs
+ - caractère privé "_" et non plus "@" -> modifications à prévoir
+ notamment dans la doc avec les codes spécifiques aux flèches, ça
+ risque de couiner sur tex.stackexchange.com
+ - anciennes macros abandonnées et désormais indéfinies :
+ \setcrambond, \setatomsep, \setbondoffset, \setdoublesep,
+ \setangleincrement, \enablefixedbondlength,
+ \disablefixedbondlength, \setnodestyle, \setbondstyle,
+ \setlewis, \setlewisdist, \setstacksep, \setcompoundstyle,
+ \setarrowdefault, \setandsign, \setarrowoffset,
+ \setcompoundsep, \setarrowlabelsep, \enablebondjoin,
+ \disablebondjoin et \schemedebug
+ - l'ancienne syntaxe \chemfig[][]{} est abandonnée et n'est plus
+ acceptée, désormais c'est
+ \chemfig[<clés>=<valeurs>]{<code molécule>}
+ - l'ancienne syntaxe \lewis[<coeff>] ou \Lewis[<coeff>] n'est
+ plus acceptée au profit de \lewis[<clés>=<valeurs>] \ No newline at end of file
diff --git a/Master/texmf-dist/tex/generic/chemfig/t-chemfig.tex b/Master/texmf-dist/tex/generic/chemfig/t-chemfig.tex
index c8a9e5c28d9..5fc262beaea 100644
--- a/Master/texmf-dist/tex/generic/chemfig/t-chemfig.tex
+++ b/Master/texmf-dist/tex/generic/chemfig/t-chemfig.tex
@@ -1,5 +1,5 @@
\usemodule[tikz]%
\input chemfig.tex
-\expandafter\let\csname CF@begin@tikzpicture\endcsname\starttikzpicture
-\expandafter\let\csname CF@end@tikzpicture\endcsname\stoptikzpicture
+\expandafter\let\csname CF\string_begintikzpicture\endcsname\starttikzpicture
+\expandafter\let\csname CF\string_endtikzpicture\endcsname\stoptikzpicture
\endinput