diff options
author | Karl Berry <karl@freefriends.org> | 2020-03-05 00:51:13 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-03-05 00:51:13 +0000 |
commit | 2a4d9a46e5888f5a36b37046111771100f1424ab (patch) | |
tree | f4c3b352213ce4a4a4a1b0dbe8b1be8540e6a400 /Master/texmf-dist/tex | |
parent | 4403fe41026a6b23d05d36c6aa758f648bb8a154 (diff) |
chemfig (4mar20)
git-svn-id: svn://tug.org/texlive/trunk@54092 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/chemfig/chemfig.tex | 396 |
1 files changed, 308 insertions, 88 deletions
diff --git a/Master/texmf-dist/tex/generic/chemfig/chemfig.tex b/Master/texmf-dist/tex/generic/chemfig/chemfig.tex index 046428adc65..10e9b1224ec 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.41} % +\def\CFver {1.5} % % % -\def\CFdate {2019/05/21} % +\def\CFdate {2020/03/05} % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -17,7 +17,7 @@ % Package URL: https://www.ctan.org/pkg/chemfig | % Bug tracker: https://framagit.org/unbonpetit/chemfig/issues | % Repository : https://framagit.org/unbonpetit/chemfig/tree/master | -% Copyright : Christian Tellechea 2010-2019 | +% Copyright : Christian Tellechea 2010-2020 | % Licence : Released under the LaTeX Project Public License v1.3c | % or later, see http://www.latex-project.org/lppl.txt | % Files : 1) chemfig.tex | @@ -53,6 +53,7 @@ %-------------------- Vérification des prérequis --------------------- \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_checkprimitive#1#2#3{% Vérifie que #1 est une primitive et sinon, émet le message #2 et exécute #3 \begingroup \edef\__tempa{\meaning#1}\edef\__tempb{\string#1}\expandafter @@ -104,6 +105,8 @@ \newbox\CF_boxlewis \newbox\CF_box \newbox\CF_boxstuff +\newbox\CF_testbox +\newbox\CF_chargebox \newtoks\CF_substtoks @@ -124,6 +127,11 @@ \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_ifinsidetikz{\ifdefined\pgfpictureid\expandafter\CF_execfirst\else\expandafter\CF_execsecond\fi} +\def\CF_ifzerodim#1{% + \setbox\CF_testbox\hbox{\printatom{#1}}% + \CF_ifnum{1\ifdim\wd\CF_testbox=\CF_zero0\fi\ifdim\ht\CF_testbox=\CF_zero0\fi\ifdim\dp\CF_testbox=\CF_zero0\fi=1000 } +} \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{} @@ -167,7 +175,6 @@ \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_warning#1{\immediate\write-1{Package \CFname\space Warning: #1^^J}} \def\CF_ifinteger#1{% \begingroup \afterassignment\CF_afterinteger @@ -206,10 +213,10 @@ \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}} +\def\CF_valuetomacro[#1]#2[#3]#4{% #1=trousseau #2= macro #3=valeur défaut #4=clé + \CF_eexpsecond{\def#2}{\useKV[#1]{#4}}% + \CF_ifx#2\empty + {\def#2{#3}} {}% } @@ -405,6 +412,8 @@ \CF_makeother\|\CF_makeother\#\CF_makeother\@% } +\def\printatom#1{\ifmmode\rm#1\else$\rm#1$\fi} + \def\CF_nodecontent{\CF_expsecond\printatom{\csname atom_\number\CF_cntatom\endcsname\CF_nodestrut}} \def\chemskipalign{% @@ -413,8 +422,6 @@ \let\CF_nodestrut\empty } -\def\CF_emptynode{{}} - \def\definesubmol{\CF_definesubmoltrue\def_submol} \def\redefinesubmol{\CF_definesubmolfalse\def_submol} @@ -532,12 +539,18 @@ {\CF_eaddtomacro#2{\expandafter{\CF_firsttonil#1\_nil}}% \CF_expsecond\CF_seeknodea{\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% - }% + {\CF_ifx!\CF_toksa% Bugfix v1.5 + {\def\CF_seeksubmloltemp{#1}% + \CF_seeksubmola + \CF_expsecond\CF_seeknodea\CF_seeksubmloltemp#2#3% + } + {\CF_iffirsttokina{-=(*<>~}% + {\def#3{#1}% + }% + {\CF_eaddtomacro#2{\CF_firsttonil#1\_nil}% + \CF_expsecond\CF_seeknodea{\CF_gobarg#1}#2#3% + }% + } }% }% }% @@ -693,29 +706,35 @@ \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 +\def\CF_seeksubmol#1#2{% cherche et remplace ! au début de #1. #1=code #2=macro recevant le résultat + \def\CF_seeksubmloltemp{#1}% + \CF_seeksubmola + \let#2\CF_seeksubmloltemp +} + +\def\CF_seeksubmola{% + \CF_expsecond{\def\CF_seeksubmloltemp}{\romannumeral-`\.\expandafter\noexpand\CF_seeksubmloltemp}% + \CF_expsecond\CF_iffirsttokmatch{\CF_seeksubmloltemp}!% + {\CF_eexpsecond{\def\CF_seeksubmloltemp}{\expandafter\CF_gobarg\CF_seeksubmloltemp}% enlève le "!" + \CF_ifx\empty\CF_seeksubmloltemp {\CF_error{no submol name found after "!"}} {}% - \ifcat\relax\CF_threeea\noexpand\expandafter\CF_firsttonil\CF_molecule*\_nil - \expandafter\CF_seeksubmola\CF_molecule\_nil + \ifcat\relax\CF_threeea\noexpand\expandafter\CF_firsttonil\CF_seeksubmloltemp*\_nil + \expandafter\CF_seeksubmolb\CF_seeksubmloltemp\_nil \else - \expandafter\CF_seeksubmolb\CF_molecule\_nil + \expandafter\CF_seeksubmolc\CF_seeksubmloltemp\_nil \fi - \CF_seeksubmol + \CF_seeksubmola }% {}% } -\def\CF_seeksubmola#1{\CF_seeksubmolc#1\relax} +\def\CF_seeksubmolb#1{\CF_seeksubmold#1\relax} -\def\CF_seeksubmolb#1{\expandafter\CF_seeksubmolc\csname CF__#1\endcsname\relax}% nom de la sous molécule +\def\CF_seeksubmolc#1{\expandafter\CF_seeksubmold\csname CF__#1\endcsname\relax}% nom de la sous molécule -\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_seeksubmold#1#2\_nil{%#1=macro de la sous molécule #2=reste du code commençant par \relax + \CF_expsecond{\CF_eexpsecond{\def\CF_seeksubmloltemp}}{\expandafter#1\CF_gobarg#2}% supprime le \relax puis ajoute la macro au début et la 2-développe } \def\CF_insertemptygroup#1{% insère {} au début de la sc #1 @@ -734,6 +753,12 @@ \endgroup \begingroup \setchemfig{#3}% + \CF_ifinsidetikz + {\pgfinterruptpicture + \let\CF_atendofchemfig\endpgfinterruptpicture + } + {\let\CF_atendofchemfig\relax + }% \expanded{% début du tikzpicture \unexpanded{#1}[% remember picture,% @@ -750,7 +775,6 @@ }% \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}% @@ -760,17 +784,17 @@ \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_valuetomacro[chemfig]\CF_crambasewidth [1.5ex]{cram width}% + \CF_valuetomacro[chemfig]\CF_cramdashlength [1pt]{cram dash width}% + \CF_valuetomacro[chemfig]\CF_cramdashsep [2pt]{cram dash sep}% + \CF_valuetomacro[chemfig]\CF_atomsep [3em]{atom sep}% espacement des atomes liés + \CF_valuetomacro[chemfig]\CF_bondoffset [2pt]{bond offset}% + \CF_valuetomacro[chemfig]\CF_doublesep [2pt]{double bond sep}% + \CF_valuetomacro[chemfig]\CF_angleincrement [45]{angle increment}% + \CF_valuetomacro[chemfig]\CF_nodestyle []{node style}% + \CF_valuetomacro[chemfig]\CF_bondstyle []{bond style}% + \CF_valuetomacro[chemfig]\CF_stacksep [1.5pt]{stack sep}% + \CF_valuetomacro[chemfig]\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 @@ -794,6 +818,7 @@ \CF_expsecond\CF_chemfigc{\CF_molecule}% %\endgroup <-- rajouté par \CF_chemfigd #2% fin du tikzpicture + \CF_atendofchemfig \endgroup \let\CF_flipstate\CF_zero } @@ -813,7 +838,7 @@ \fi \let\CF_currentangle\CF_defaultangle \def\CF_molecule{#1}% - \CF_seeksubmol% alias en premier ? + \CF_expsecond\CF_seeksubmol\CF_molecule\CF_molecule% 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 @@ -824,7 +849,7 @@ \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 + \CF_expsecond\CF_seeksubmol\CF_molecule\CF_molecule \fi \edef\CF_defaultstringangle{:\CF_defaultangle}% \let\CF_currentlength\CF_defaultlength @@ -859,8 +884,7 @@ \CF_ifx\CF_molecule\empty {\let\CF_nextaction\endgroup } - {\CF_seeksubmol - \CF_expsecond\CF_seeknode{\CF_molecule}\CF_currentatomgroup\CF_molecule + {\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-% @@ -959,9 +983,9 @@ \CF_cntcycle0 \edef\CF_hookcycle{\CF_bondoutnode}% \let\CF_hookatomgroup\CF_previousatomgroup - \CF_ifx\CF_hookatomgroup\CF_emptynode + \CF_ifzerodim\CF_hookatomgroup {\def\CF_cyclejoinlast{1}}% joindre le dernier - {\def\CF_cyclejoinlast{0}} + {\def\CF_cyclejoinlast{0}}% \CF_incycletrue \ifnum\CF_lastaction=3 \pgfmathsetmacro\CF_initcycleangle{360/\CF_lastcyclenum-180}% c'est un cycle dans un cycle @@ -1052,29 +1076,26 @@ }% } +\def\CF_distancebetweenpoints#1#2#3#4#5{% + \pgfextractx\CF_dim{\pgfpointanchor{#1}{#2}}\edef\CF_dimax{\the\CF_dim}% + \pgfextracty\CF_dim{\pgfpointanchor{#1}{#2}}\edef\CF_dimay{\the\CF_dim}% + \pgfextractx\CF_dim{\pgfpointanchor{#3}{#4}}\edef\CF_dimbx{\the\CF_dim}% + \pgfextracty\CF_dim{\pgfpointanchor{#3}{#4}}\edef\CF_dimby{\the\CF_dim}% + \pgfmathsetmacro#5{veclen(\CF_dimbx-\CF_dimax,\CF_dimby-\CF_dimay)}% +} + \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)}% + \CF_distancebetweenpoints{#1}{center}{#2}{center}\CF_vectorlen \pgfmathsetmacro\CF_normx{(\CF_dimay-\CF_dimby)/\CF_vectorlen}% \pgfmathsetmacro\CF_normy{(\CF_dimbx-\CF_dimax)/\CF_vectorlen}% } \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}% - }% + \CF_doifempty#1{% + \CF_ifzerodim{#2} + {\def#1{0pt}} + {\edef#1{\CF_bondoffset}}% + }% } \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 @@ -1209,7 +1230,7 @@ \else \CF_ifx\CF_previoustikz\CF_currenttikz {\def\CF_joinbond{1}% - \CF_ifx\CF_previousatomgroup\CF_emptynode + \CF_ifzerodim\CF_previousatomgroup {\CF_ifx\CF_previousbondangle\empty% si début molécule {\CF_drawbonda(#1@@)--(#2@@); } @@ -1321,7 +1342,7 @@ \CF_ifinstr{#3}?% {\CF_removehook\CF_currentatomgroup \ifcat\relax\detokenize\expandafter{\romannumeral-`\.\expandafter\noexpand\CF_currentatomgroup}\relax - \let\CF_currentatomgroup\CF_emptynode + \let\CF_currentatomgroup\empty \fi }% {}% @@ -1350,7 +1371,7 @@ }% }% \CF_cntatom\CF_hookatomnumber - \CF_ifx\CF_currentatomgroup\CF_emptynode + \CF_ifzerodim\CF_currentatomgroup {\let\CF_nodestrut\empty } {\CF_ifx\empty\CF_bondoutcontentsaved @@ -1552,12 +1573,195 @@ \def\CF_removehookb#1?[#2]#3\_nil#4{\CF_expsecond{\def#4}{\CF_gobarg#1#3}} +\def\setcharge#{\setKV[charge]} +\def\resetcharge{% + \setKVdefault[charge]{% + debug = false,% trace les contours des noeuds + macro atom = \printatom,%macro qui prendra comme argument l'atome recevant la charge + circle = false,% false => noeud atome = rectangle + macro charge = ,% macro attendue (\printatom ou \ensuremath, par exemple) qui prendra comme argument la charge + extra sep = 1.5pt,% séparation additionnelle entre le noeud (cercle ou rectangle) et la position des charges + overlay = true,% charges en "surimpression" + shortcuts = true,% raccourcis \. \: \| et \" actifs pour Lewis + lewisautorot = true,% rotation auto charge Lewis + .radius = 0.15ex,% rayon du point + :sep = 0.3em,% séparation des deux points + .style = {fill=black},% style des points + "length = 1.5ex,% longueur rectangle + "width = .3ex,% largeur rectangle + "style = {black,line width=0.4pt},% style rectangle + |style = {black,line width=0.4pt},% style ligne + }% +} +\resetcharge +\def\chargedot{\CF_testopt\chargedot_a{}} +\def\chargedot_a[#1]{% + \begingroup + \setKV[charge]{#1}% + \CF_valuetomacro[charge]\CF_dotradius[0.15ex]{.radius}% + \CF_eexpsecond{\tikz\draw[}{\useKV[charge]{.style}}](0,0)circle(\CF_dotradius);% + \endgroup +} +\def\chargeddot{\CF_testopt\chargeddot_a{}} +\def\chargeddot_a[#1]{% + \begingroup + \setKV[charge]{#1}% + \CF_valuetomacro[charge]\CF_dotsep [0.5ex] {:sep}% + \CF_valuetomacro[charge]\CF_dotradius[.15ex]{.radius}% + \ifboolKV[charge]{lewisautorot} + {\pgfmathsetmacro\CF_lewisrot{90+\chargeangle}} + {\def\CF_lewisrot{0}}% + \pgfmathsetmacro\CF_halfsep{\CF_dotsep/2}% + \tikzpicture[anchor=center,rotate=\CF_lewisrot]% + \CF_eexpsecond{\draw[}{\useKV[charge]{.style}}]% + (-\CF_halfsep pt,0)circle(\CF_dotradius)% + (\CF_halfsep pt,0)circle(\CF_dotradius);% + \endtikzpicture + \endgroup +} +\def\chargerect{\CF_testopt\chargerect_a{}} +\def\chargerect_a[#1]{% + \begingroup + \setKV[charge]{#1}% + \CF_valuetomacro[charge]\CF_rectlength[1.5ex]{"length}% + \CF_valuetomacro[charge]\CF_rectwidth [0.3ex]{"width}% + \ifboolKV[charge]{lewisautorot} + {\pgfmathsetmacro\CF_lewisrot{90+\chargeangle}} + {\def\CF_lewisrot{0}}% + \pgfmathsetmacro\CF_halfwidth{\CF_rectwidth/2}% + \pgfmathsetmacro\CF_halflength{\CF_rectlength/2}% + \tikzpicture[anchor=center,rotate=\CF_lewisrot]% + \CF_eexpsecond{\draw[}{\useKV[charge]{"style}}](-\CF_halflength pt,-\CF_halfwidth pt)rectangle(\CF_halflength pt,\CF_halfwidth pt);% + \endtikzpicture + \endgroup +} +\def\chargeline{\CF_testopt\chargeline_a{}} +\def\chargeline_a[#1]{% + \begingroup + \setKV[charge]{#1}% + \CF_valuetomacro[charge]\CF_linelength[1.5ex]{"length}% + \ifboolKV[charge]{lewisautorot} + {\pgfmathsetmacro\CF_lewisrot{90+\chargeangle}} + {\def\CF_lewisrot{0}}% + \pgfmathsetmacro\CF_halflength{\CF_linelength/2}% + \tikzpicture[anchor=center,rotate=\CF_lewisrot]% + \CF_eexpsecond{\draw[}{\useKV[charge]{|style}}](-\CF_halflength pt,0)--(\CF_halflength pt,0);% + \endtikzpicture + \endgroup +} +\def\CF_enableshortcuts{% + \let\CF_saveddot \.\let\.\chargedot + \let\CF_savedddot\:\let\:\chargeddot + \let\CF_savedrect\"\let\"\chargerect + \let\CF_savedline\|\let\|\chargeline + \let\enableshortcuts\relax + \let\disableshortcuts\CF_disableshortcuts +} +\def\CF_disableshortcuts{% + \let\.\CF_saveddot + \let\:\CF_savedddot + \let\"\CF_savedrect + \let\|\CF_savedline + \let\enableshortcuts\CF_enableshortcuts + \let\disableshortcuts\relax +} +\def\charge{% + \begingroup + \catcode`\: 12 + \charge_a{true}% +} +\def\Charge{% + \begingroup + \catcode`\: 12 + \charge_a{false}% +} +\def\charge_a#1#2{% #1=TF #2=liste emplacements + \CF_testopt{\charge_b{#1}}{}#2\_nil +} +\def\charge_b#1[#2]#3\_nil{% + \charge_c{#1}[#2]{#3}% +} +\def\charge_c#1[#2]#3#4{% #1=TF pour overlay, #2= réglages, #3=liste d'emplacements, #4=atome + \setcharge{overlay=#1,#2}% + \setbox\CF_chargebox\hbox{\useKV[charge]{macro atom}{#4}}% + \CF_ifinsidetikz + {\pgfinterruptpicture + \let\CF_atendofcharge\endpgfinterruptpicture + } + {\let\CF_atendofcharge\relax + }% + \expanded{\noexpand + \tikzpicture[every node/.style={% + \ifboolKV[charge]{debug}{draw=red,}{}% + anchor=base,% + inner sep=0pt,% + outer sep=0pt,% + minimum size=0pt},% + baseline]}% + \expanded{\noexpand + \node[% + \ifboolKV[charge]{circle}{circle,}{}% + \ifboolKV[charge]{debug}{draw=green,}{}% + anchor=base% + ]}% + (atombox)at(0,0)% + {\copy\CF_chargebox};% noeud contenant l'atome + \expanded{\noexpand + \node[% + \ifboolKV[charge]{circle}{circle,}{}% + \ifboolKV[charge]{debug}{draw=blue,}{}% + anchor=base,% + inner sep=\useKV[charge]{extra sep},% + overlay% + ]}% + (atom)at(0,0){% + \vrule width0pt height\ht\CF_chargebox depth\dp\CF_chargebox + \vrule width\wd\CF_chargebox height\CF_zero depth\CF_zero};% noeud pour placer les charges + \let\enableshortcuts\relax + \let\disableshortcuts\relax + \ifboolKV[charge]{shortcuts}\CF_enableshortcuts{}% l'atome n'est _PAS_ concerné par les racourcis + \charge_d#3,\CF_quark=% + \endtikzpicture + \CF_atendofcharge + \endgroup +} +\def\charge_d#1={% + \CF_ifx\CF_quark{#1}% + {} + {\expandafter\charge_e\expanded{\skv_removelastspaces{#1}}=}% +} +\def\charge_e#1={% + \CF_ifinstr{#1}[ + {\charge_f#1=} + {\charge_f#1[]=}% +} +\def\charge_f#1[#2]={% + \CF_ifinstr{#1}: + {\charge_g#1[#2]=} + {\charge_g#1:0pt[#2]=}% +} +\def\charge_g#1:#2[#3]=#4,{% #1=angle, #2=offset, #3=code tikz charge, #4=charge + \CF_eexpsecond\CF_ifinteger{\skv_removeextremespaces{#1}} + {\pgfmathsetmacro\chargeangle{mod(#1,360)}% + } + {\pgfmathanglebetweenpoints{\pgfpointanchor{atom}{center}}{\pgfpointanchor{atom}{\skv_removeextremespaces{#1}}}% + \let\chargeangle\pgfmathresult% incorrect si (atom.center==atom.#1) && (extra sep==0) TODO: mettre un warning ? + }% + \edef\CF_offset{\the\dimexpr#2+0pt}% + \CF_distancebetweenpoints{atom}{center}{atom}{\skv_removeextremespaces{#1}}\CF_chargedistance + \CF_eexpafter{\node[anchor=center,}{\ifboolKV[charge]{overlay}{overlay,}{}}#3]% + at([shift=(\chargeangle:\CF_chargedistance pt+\CF_offset)]atom.center){\useKV[charge]{macro charge}{#4}};% + \charge_d +} + \def\Lewis{% + \CF_warning{\string\Lewis\space is unmaintained and is likely to be removed in a near future. Please, use \string\Charge.}% \CF_lewisoverlayfalse \CF_testopt\CF_lewisa{}% } \def\lewis{% + \CF_warning{\string\lewis\space is unmaintained and is likely to be removed in a near future. Please, use \string\charge.}% \CF_lewisoverlaytrue \CF_testopt\CF_lewisa{}% } @@ -1565,13 +1769,13 @@ \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}% + \CF_valuetomacro[chemfig]\CF_lewiswidthdouble[0.3ex]{lewis | width}% + \CF_valuetomacro[chemfig]\CF_lewisoffset [0.4ex]{lewis sep}% + \CF_valuetomacro[chemfig]\CF_lewislength [1.5ex]{lewis length}% + \CF_valuetomacro[chemfig]\CF_lewisstyle []{lewis style}% + \CF_valuetomacro[chemfig]\CF_lewisdist [0.3em]{lewis dist}% + \CF_valuetomacro[chemfig]\CF_lewisradius [0.15ex]{lewis radius}% + \CF_valuetomacro[chemfig]\CF_lewisdiagcoeff [1]{lewis diag coeff}% \ifCF_lewisoverlay \CF_addtomacro\CF_lewisstyle{,overlay}% \fi @@ -1585,6 +1789,12 @@ \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) + \CF_ifinsidetikz + {\pgfinterruptpicture + \let\CF_atendoflewis\endpgfinterruptpicture + } + {\let\CF_atendoflewis\relax + }% \tikzpicture[every node/.style={anchor=base,inner sep=0pt,outer sep=0pt,minimum size=0pt},baseline]% \CF_makeother;\CF_makeother:% \node(CF_lewis@anchor){}; @@ -1637,6 +1847,7 @@ \repeat \node[anchor=base west]at(CF_lewis@anchor){\box\CF_boxlewis};% \endtikzpicture + \CF_atendoflewis } \def\Chembelow{\begingroup\let\CF_temp\CF_gobarg\CF_chembelowa} @@ -1778,9 +1989,9 @@ \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}}% + \CF_doifempty\CF_signspaceante{\CF_valuetomacro[chemfig]\CF_signspaceante[0.5em]{+ sep left}}% + \CF_doifempty\CF_signspacepost{\CF_valuetomacro[chemfig]\CF_signspacepost[0.5em]{+ sep right}}% + \CF_doifempty\CF_signvshift{\CF_valuetomacro[chemfig]\CF_signvshift[0pt]{+ vshift}}% \raise\CF_signvshift\hbox{\kern\CF_signspaceante$+$\kern\CF_signspacepost}% } @@ -1791,23 +2002,23 @@ } \def\CF_schemestarta[#1]{% - \CF_valuetomacro\CF_defaultcompoundstyle[]{compound style}% + \CF_valuetomacro[chemfig]\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_doifempty\CF_arrowangle{\CF_valuetomacro[chemfig]\CF_arrowangle[0]{arrow angle}}% + \CF_doifempty\CF_arrowlength{\CF_valuetomacro[chemfig]\CF_arrowlength[1]{arrow coeff}}% + \CF_valuetomacro[chemfig]\CF_defaultarrowstyle[]{arrow style}% + \CF_valuetomacro[chemfig]\CF_arrowoffset[1em]{arrow offset}% + \CF_valuetomacro[chemfig]\CF_compoundsep[5em]{compound sep}% + \CF_valuetomacro[chemfig]\CF_arrowlabelsep[3pt]{arrow label sep}% + \CF_valuetomacro[chemfig]\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}% + \CF_valuetomacro[chemfig]\CF_arrowdoublesep[2pt]{arrow double sep}% \pgfmathsetmacro\CF_arrowdoublesep{\CF_arrowdoublesep/2}% - \CF_valuetomacro\CF_arrowdoubleposstart[0.6]{arrow double coeff}% + \CF_valuetomacro[chemfig]\CF_arrowdoubleposstart[0.6]{arrow double coeff}% \pgfmathsetmacro\CF_arrowdoubleposstart{(1-\CF_arrowdoubleposstart)/2}% \pgfmathsetmacro\CF_arrowdoubleposend{1-\CF_arrowdoubleposstart}% \ifboolKV[chemfig]{scheme debug} @@ -2843,4 +3054,13 @@ v1.41 2019/05/21 les délimiteurs sont automatiquement inclinés - nouvelle clé "rotate" qui n'a de sens que si halign=false ET auto rotate=false : l'inclinaison des délimiteurs peut être - choisie
\ No newline at end of file + choisie +---------------------------------------------------------------------- +v1.5 2020/03/05 + - nouvelles macros \charge et \Charge. Les macros \lewis et \Lewis + sont obsolètes et amenées à disparaitre à moyen terme (au moins + 9 mois), soit fin 2020 + - prise en compte de la dimension d'un groupe d'atome pour tracer + des liaisons jointives + - bug corrigé dans \CF_seeknode + - ajout d'une section dans le manuel (placement des atomes)
\ No newline at end of file |