summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-05-21 21:03:18 +0000
committerKarl Berry <karl@freefriends.org>2019-05-21 21:03:18 +0000
commit207abb781e607768591cc5d882990bb7071b2b3a (patch)
tree8cf45e8c0a41113f7f75be5817ba4b72aebed0e6 /Master/texmf-dist/tex/generic
parenta8c7dacd775b4baaab4bf638c2ee092bb6b882c8 (diff)
chemfig (21may19)
git-svn-id: svn://tug.org/texlive/trunk@51176 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic')
-rw-r--r--Master/texmf-dist/tex/generic/chemfig/chemfig.tex145
1 files changed, 78 insertions, 67 deletions
diff --git a/Master/texmf-dist/tex/generic/chemfig/chemfig.tex b/Master/texmf-dist/tex/generic/chemfig/chemfig.tex
index a7826763ca4..046428adc65 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.4} %
+\def\CFver {1.41} %
% %
-\def\CFdate {2019/04/18} %
+\def\CFdate {2019/05/21} %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
@@ -40,16 +40,35 @@
Draw molecule with an easy syntax (CT)}%
\fi
-%------------------------- Vérification etex -------------------------
+%-------------------------- Régime catcodes --------------------------
\begingroup
- \edef\CFtempa{\meaning\eTeXversion}
- \edef\CFtempb{\string\eTeXversion}
- \let\CFtemp\endgroup
- \unless\ifx\CFtempa\CFtempb
- \errmessage{Package \CFname\space Error: you are not using an eTeX engine, chemfig cannot work.}%
- \def\CFtemp{\endgroup\endinput}%
+ \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\ \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`\@12 \catcode`\#6 \catcode`\ 10 \catcode`\_11
+
+%-------------------- Vérification des prérequis ---------------------
+\def\CF_error#1{\errmessage{Package \CFname\space Error: #1.}}
+\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
+ \endgroup
+ \ifx\__tempa\__tempb\else
+ \CF_error{#2}%
+ \def\CF_temp{#3}%
+ \CFrestorecatcode\expandafter\CF_temp
\fi
-\CFtemp
+}
+\CF_checkprimitive\eTeXversion
+ {You are not using an eTeX engine, \CFname\space cannot work.}
+ {\endinput}%
+\CF_checkprimitive\expanded
+ {the \string\expanded\space primitive is not provided by your TeX engine, \CFname\space v\CFver\space cannot work: loading \CFname\space v1.4}
+ {\input chemfigold.tex\relax\endinput}%
%------------------------ Chargement simplekv ------------------------
\unless\ifdefined\skvname
@@ -64,17 +83,6 @@
\fi
\usetikzlibrary{arrows.meta}
-%-------------------------- 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\ \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`\@12 \catcode`\#6 \catcode`\ 10 \catcode`\_11
-
%--------------------------- Allocations -----------------------------
\newcount\CF_cntatomgroup
\newcount\CF_cntgroup
@@ -140,10 +148,7 @@
\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_edefaddtomacro#1#2{\CF_expsecond{\CF_addtomacro#1}{\expanded{#2}}}
\def\CF_ifnextchar#1#2#3{%
\let\CF_ifnextchartok=#1% <- espace indésirable, bugfix v1.31
\def\CF_ifnextcharcodetrue{#2}%
@@ -162,7 +167,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_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
@@ -478,8 +482,7 @@
\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}%
+ \global\toks0\expandafter{\expanded{\the\toks0\CFhash\CF_x}}%
}%
}
{}%
@@ -489,7 +492,6 @@
}%
{\scantokens\expandafter{%
\the\toks0{%
- \romannumeral
\csname CF_exec%
\ifdim\csname CF_currentangle\endcsname pt>90pt
\ifdim\csname CF_currentangle\endcsname pt<270pt
@@ -501,7 +503,7 @@
second%
\fi
\endcsname
- {0 #2}{0 #3}%
+ {#2}{#3}%
}%
}%
}%
@@ -724,20 +726,6 @@
\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]%
}
@@ -746,7 +734,7 @@
\endgroup
\begingroup
\setchemfig{#3}%
- \edef\CF_temp{%
+ \expanded{% début du tikzpicture
\unexpanded{#1}[%
remember picture,%
every node/.style={%
@@ -760,7 +748,6 @@
\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}%
@@ -1692,11 +1679,8 @@
\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
+ {\expandafter\tikzpicture\expanded{[overlay,remember picture,-CF\CF_ifempty{#1}{}{,\unexpanded{#1}}]}%
+ #2%
\endtikzpicture
}%
}
@@ -2267,10 +2251,9 @@
% 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{%
+ \expanded{%
\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
}
@@ -2371,11 +2354,9 @@
\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)%
+ \expandafter\draw\expanded{[\CF_ifempty{#1}{draw=none}{\unexpanded\expandafter{\CF_arrowcurrentstyle}},-]}(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)%
+ \expandafter\draw\expanded{[\CF_ifempty{#2}{draw=none}{\unexpanded\expandafter{\CF_arrowcurrentstyle}}]}(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
@@ -2387,13 +2368,17 @@
\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}%
+ \setKVdefault[CFdelimiters]{
+ delimiters = (),
+ height = 10pt,
+ depth = ,
+ open xshift = 0pt,
+ close xshift = ,
+ h align = true,
+ auto rotate = false,
+ rotate = 0,
+ indice = n
+ }%
}
\CF_resetdelim
@@ -2418,9 +2403,24 @@
\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)}]
+ \pgfextracty\CF_dim{\pgfpointanchor{#3}{center}}\edef\CF_rightdelimy{\the\CF_dim}%
+ \def\CF_autorotate{0}%
+ \ifboolKV[CFdelimiters]{h align}
+ {\let\CF_rightdelimy\CF_leftdelimy
+ }
+ {%
+ \ifboolKV[CFdelimiters]{auto rotate}
+ {\pgfmathatantwo{\CF_rightdelimy-\CF_leftdelimy}{\CF_rightdelimx-\CF_leftdelimx}%
+ \let\CF_autorotate\pgfmathresult
+ }
+ {\CF_eexpsecond\CF_ifempty{\useKV[CFdelimiters]{rotate}}
+ {}
+ {\edef\CF_autorotate{\useKV[CFdelimiters]{rotate}}}%
+ }%
+ }%
+ \node[at={(\CF_leftdelimx+\CF_leftdelimxshift,\CF_leftdelimy+\CF_delimvshift)},rotate=\CF_autorotate]
{$\left\CF_leftdelim\vrule height\CF_delimhalfdim depth\CF_delimhalfdim width0pt\right.$};%
- \node[at={(\CF_rightdelimx+\CF_rightdelimxshift,\CF_leftdelimy+\CF_delimvshift)}]
+ \node[at={(\CF_rightdelimx+\CF_rightdelimxshift,\CF_rightdelimy+\CF_delimvshift)},rotate=\CF_autorotate]
{$\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}$}}}
@@ -2832,4 +2832,15 @@ v1.4 2019/04/18
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
+ plus acceptée au profit de \lewis[<clés>=<valeurs>]
+----------------------------------------------------------------------
+v1.41 2019/05/21
+ - utilisation de la nouvelle primitive \expanded
+ - nouvelle clé "h align" (true par défaut) pour les délimiteurs
+ de \polymerdelim. Lorsque à false, les délimiteurs ne sont
+ plus alignés horizontalement mais positionnés aux noeuds demandés
+ - nouvelle clé "auto rotate" qui n'a de sens que si h align=false :
+ 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