From d39570760243435ff2cd4ac49aed5fb6fd43646a Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 21 Nov 2010 23:54:10 +0000 Subject: chemfig 0.3 (22nov10) git-svn-id: svn://tug.org/texlive/trunk@20523 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/chemfig/README | 4 +- .../doc/latex/chemfig/chemfig_doc_en.pdf | Bin 856679 -> 940038 bytes .../doc/latex/chemfig/chemfig_doc_en.tex | 676 +++++++++++++++--- .../doc/latex/chemfig/chemfig_doc_fr.pdf | Bin 868662 -> 938923 bytes .../doc/latex/chemfig/chemfig_doc_fr.tex | 770 +++++++++++++++++---- Master/texmf-dist/tex/latex/chemfig/chemfig.sty | 701 +++++++++++++------ 6 files changed, 1741 insertions(+), 410 deletions(-) diff --git a/Master/texmf-dist/doc/latex/chemfig/README b/Master/texmf-dist/doc/latex/chemfig/README index de30c302cb0..d8e340533a6 100644 --- a/Master/texmf-dist/doc/latex/chemfig/README +++ b/Master/texmf-dist/doc/latex/chemfig/README @@ -2,9 +2,9 @@ ___________________________________ The ChemFig package - v0.2 + v0.3 - 2010/08/31 + 2010/11/21 ___________________________________ Maintainer: Christian Tellechea diff --git a/Master/texmf-dist/doc/latex/chemfig/chemfig_doc_en.pdf b/Master/texmf-dist/doc/latex/chemfig/chemfig_doc_en.pdf index 5d254c43086..9cb9bdd3963 100644 Binary files a/Master/texmf-dist/doc/latex/chemfig/chemfig_doc_en.pdf and b/Master/texmf-dist/doc/latex/chemfig/chemfig_doc_en.pdf differ diff --git a/Master/texmf-dist/doc/latex/chemfig/chemfig_doc_en.tex b/Master/texmf-dist/doc/latex/chemfig/chemfig_doc_en.tex index df1233816e0..3b6b069ee05 100644 --- a/Master/texmf-dist/doc/latex/chemfig/chemfig_doc_en.tex +++ b/Master/texmf-dist/doc/latex/chemfig/chemfig_doc_en.tex @@ -3,7 +3,7 @@ % | | % | ChemFig Documentation | % | | -% | August 31, 2010 | +% | November 21, 2010 | % | | % |_________________________________________________________________| % @@ -18,7 +18,7 @@ % Copyright : Christian Tellechea 2010 % % The "chemfig" package consists of the 6 following files: -% chemfig.sty (this file) +% chemfig.sty % README % chemfig_doc_en.tex, chemfig_doc_en.pdf (english manual) % chemfig_doc_fr.tex, chemfig_doc_fr.pdf (french manual) @@ -41,7 +41,7 @@ \documentclass[10pt]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} -\usepackage[a4paper,margin=2.5cm]{geometry} +\usepackage[a4paper,margin=2.5cm,head=5mm,headsep=5mm,footskip=10mm]{geometry} \usepackage[bottom]{footmisc} \usepackage{lmodern} \usepackage{amsmath} @@ -54,7 +54,7 @@ \usepackage{chemfig} \usetikzlibrary{decorations.pathmorphing} \usepackage{emerald} -\usepackage[protrusion=true,expansion,final,verbose=true,babel=true]{microtype} +\usepackage[protrusion=true,expansion,final,babel=true]{microtype} \usepackage{fancyhdr} \fancyhead[L]{\small\bfseries\CF} \fancyhead[C]{} @@ -64,8 +64,6 @@ \fancyfoot[r]{\thepage} \makeatletter -\verbtocs\@diese|#| -\verbtocs\@@diese|##| \newcommand\disable@lig[1]{% \catcode`#1\active @@ -86,6 +84,7 @@ \bgroup \obeylines\frenchspacing \let\do\@makeother\dospecials + \@makeother:% \@vobeyspaces \disable@lig,\disable@lig-% \exemple@@ @@ -93,7 +92,8 @@ \newcommand\exemple@@[1]{% \def\@tempa##1#1{% - \xdef\left@content{##1}\egroup + \xdef\left@content{##1}% + \egroup \begingroup \endlinechar\m@ne\everyeof{\relax}\catcode`\^^M=10 \@makeother:\@makeother~\@makeother!\@makeother?\@makeother;% @@ -104,9 +104,12 @@ \@tempa } -\newcommand\exemple@@@{% +\begingroup +\catcode`#=12 +\gdef\exemple@@@% +{% \begingroup - \StrSubstitute\left@content{\@diese\@diese}\@diese[\left@content]% + \StrSubstitute\left@content{##}#[\left@content]% \if@exstar \edef\part@left{\the\dimexpr\linewidth-2\fboxsep-2\fboxrule}% \let\part@right\part@left @@ -129,8 +132,10 @@ \vskip5pt\relax\ttfamily\footnotesize\left@content \vskip3pt\hrule\vskip3pt \everypar{{\color{lightgray}\rlap{\vrule height0.1pt width\part@right depth0.1pt}}}% - \par - \hfill\normalfont\right@content\hfill\null}% + \par\normalfont + \subst@in\right@content\par\def + \subst@in\right@content\def{\hfill\null\par\hfill}% + \hfill\right@content\hfill\null}% \else \parbox[c]\part@left{\vskip5pt\relax\ttfamily\footnotesize\left@content}% \parbox[c]\part@right{% @@ -144,6 +149,20 @@ \vskip7.5pt\relax \endgroup } +\endgroup + +\long\def\if@instr#1#2{% + \long\def\if@instr@i##1#2##2\@nil{\ifx\@empty##2\@empty\expandafter\@secondoftwo\else\expandafter\@firstoftwo\fi}% + \if@instr@i#1\relax#2\@nil +} + +\long\def\subst@in#1#2#3{% + \long\def\subst@in@i##1#2##2\@nil{##1#3##2}% + \expandafter\if@instr\expandafter{#1}{#2}% + {\expandafter\expandafter\expandafter\def\expandafter\expandafter\expandafter#1\expandafter\expandafter\expandafter{\expandafter\subst@in@i#1\@nil}% + \subst@in#1{#2}{#3}% + }\relax +} \long\def\grab@toks#1\relax{\gdef\right@content{#1}} @@ -178,42 +197,110 @@ {1pc}% {\titlerule\vspace{1pc}\Huge} +\newcommand*\nouveau[1][0pt]{\leavevmode\llap{\footnotesize\itshape\bfseries\color{red}New\kern\dimexpr15pt+#1\relax}} + \begin{document} \begin{titlepage} + \catcode`!12 \begin{tikzpicture}[remember picture,overlay] - \filldraw[blue](current page.south west) rectangle ([yshift=2.5cm]current page.center); - \filldraw[black](current page.north west) rectangle ([yshift=2.5cm]current page.east); + \filldraw[blue!75](current page.south west) rectangle ([yshift=2cm,xshift=-3cm]current page.center); + \shade [left color=blue!75,right color=white]([yshift=2cm,xshift=-3cm]current page.center) rectangle ([xshift=3cm]current page.south); + \filldraw[black](current page.north west) rectangle ([yshift=7cm]current page.east); + \shade[top color=black,bottom color=blue]([yshift=7cm]current page.east)rectangle([yshift=2.5cm]current page.west); + \filldraw[black!55!blue!100]([yshift=2.5cm]current page.east)rectangle([yshift=2cm]current page.west); \end{tikzpicture} \begin{center} - \color{white}\ECFAugie\fontsize{50pt}{50pt}\selectfont\CF\ v\csname CF@ver\endcsname\par\medskip + \color{white}\ECFAugie\fontsize{50pt}{50pt}\selectfont\CF\par + \Large v\csname CF@ver\endcsname\par\bigskip \footnotesize\csname CF@en@date\endcsname\par \normalsize Christian Tellechea\par\vskip1.5cm - \huge A \LaTeX{} package for drawing molecules + \huge A \LaTeX{} package for drawing molecules% \end{center} \vskip4cm + \begin{center} + \scriptsize + \setatomsep{3em}% + \chemfig{-[::-30](-[5])(-[7])-[::+60]-[::-60]O-[::+60](=[::-45]O)-[::+90]HN>:[::-60](-[::+60]**6(------))-[::-30](<:[2]OH)-[::-60](=[6]O)-[::+60]O>:[::-60]*7(---?(<[::-120]OH)-(<|[1]CH_3)(<:[::-90]CH_3)-(-[1](<[::+80]HO)-[0](=[::+60]O)-[7](<|[::+130]CH_3)(-[::+75](<|[2]OH)-[::-60]-[::-60](<[::+30]O-[::-90])-[::-60](<[::+90])(<:[::+30]O-[7](-[6]CH_3)=[0]O)-[::-60])-[6]-[5,1.3]?(<:[7]O-[5](=[::-60]O)-[6]**6(------)))=(-[2]CH_3)-)}% + \par + {\ECFAugie\small Taxotere}% + \end{center} + \vskip1.5cm \hfill - \chemfig{-[::-30](-[5])(-[7])-[::+60]-[::-60]O-[::+60](=[::-45]O)-[::+90]HN>:[::-60](-[::+60]**6(------))-[::-30](<:[2]OH)-[::-60](=[6]O)-[::+60]O>:[::-60]*7(---?(<[::-120]OH)-(<|[1]CH_3)(<:[::-90]CH_3)-(-[1](<[::+80]HO)-[0](=[::+60]O)-[7](<|[::+130]CH_3)(-[::+75](<|[2]OH)-[::-60]-[::-60](<[::+30]O-[::-90])-[::-60](<[::+90])(<:[::+30]O-[7](-[6]CH_3)=[0]O)-[::-60])-[6]-[5,1.3]?(<:[7]O-[5](=[::-60]O)-[6]**6(------)))=(-[2]CH_3)-)}% - \hfill\null\par\bigskip - {\hfill\ECFAugie\small Taxotere\hfill\null}% + \hbox to 0pt{\hss + \scriptsize + \setbondoffset{1pt} + \setatomsep{2em} + \chemfig{(-[:-150]R')(-[:-30]R)=[2]N-[:30]OH}% + \kern-1em + \chemrel[\chemfig{\chemabove{H}{\kern10pt\oplus}}]{<>}% + \kern-0.5em + \chemfig{(-[@{a0}:-150]R')(-[:-30]R)=[2]@{a1}N-[@{b0}:30]@{b1}\chemabove{O}{\oplus}H_2}% + \chemmove[red,-stealth,shorten <=2pt]{% + \draw(a0)..controls +(135:2mm) and +(215:4mm).. (a1); + \draw(b0)..controls +(120:2mm) and +(180:3mm).. ([yshift=7pt]b1.180); + } + \kern-1.5em + \chemrel[\chemfig{{-}H_2O}]{<>}% + $\left[\begin{tabular}{c} + \chemfig{R'-N=@{a1}\chemabove{C}\oplus-R}\\ + \tikz\draw[stealth-stealth](0,3mm)--(0,-3mm);\\ + \chemfig{R'-\chemabove{N}\oplus~C-R} + \end{tabular}\right]$% + \chemrel[\chemfig{H_2@{a0}\lewis{0:2:,O}}]{<>}% + \chemmove[red,-stealth,shorten <=3pt]{% + \draw(a0)..controls+(90:10mm)and+(45:10mm)..([yshift=6pt]a1.45); + }% + \chemfig{*6(R\rlap{$'$}-N=(-R)-\chemabove{O}\oplus H_2)}% + \chemrel[\chemfig{{-}\chemabove{H}{\kern10pt\oplus}}]{<>}% + \chemfig{*6(R\rlap{$'$}-N=(-R)-OH)}% + \chemrel{-stealth}% + \chemfig{*6(R\rlap{$'$}-\chembelow{N}{H}-(-R)(=[2]O))}\par\bigskip + \hss}\hfill\null + \begin{center} + \ECFAugie\small The Beckmann rearrangement% + \end{center} \end{titlepage} \parindent0pt\pagestyle{fancy} \tableofcontents \parskip\medskipamount -\newpage +\vspace{2cm} + +\fbox{\vbox{\hsize\dimexpr\linewidth-2\fboxrule-2\fboxsep\relax\noindent\color{red}\bfseries The translation of the new features is not done yet, but should be available within a few weeks. The corresponding text, still in french, is gray in this manual. I apologize for the inconvenience.}} +\vspace{2cm} \setitemize{leftmargin=3em,topsep=0pt,parsep=0pt,itemsep=0pt} \part{Introduction} +\begingroup\color{gray}% !!! Nouveau +\section{Nouveautés de la version 0.3} +\nouveau Suite à des demandes d'utilisateurs et des lacunes qui devaient de toutes façons être comblées, voici les nouveautés de la version 0.3 : +\begin{enumerate} + \item Amélioration de la commande \verb-\definesubmol- qui accepte les séquences de contrôle comme alias. On peut aussi choisir un alias dont la substitution est différente selon l'orientation de la liaison qui lui arrive dessus. Voir page~\pageref{definesubmol}; + \item Le caractère ``\verb-|-'' force la fin d'un atome. Si on écrit ``D|ef'' alors, \CF verra deux atomes ``D'' et ``ef''. Lire page~\pageref{decoupage.atomes}; + \item Le caractère ``\verb-#-'' est reconnu lorsqu'il suit un caractère de liaison. Il doit être suivi d'un argument entre parenthèses qui contient le retrait de début et de fin qui s'appliqueront à cette liaison. Voir page~\pageref{modif.retrait}. + \item La macro \verb-\chemfig- admet des arguments optionnels qui seront passés à l'environnement ``tikzpicture'' dans lequel elle est dessinée. Lire page~\pageref{arguments.optionnels}; + \item Mise en place de la représentation des mouvement d'électrons et des mécanismes réactionnels avec la syntaxe ``\verb-@{}-'' devant un atome ou + ``\verb-@{,}-'' au tout début de l'argument d'une liaison.\par + Cette syntaxe permet de placer un nœud (au sens de \TIKZ) qui deviendra l'extrémité des flèches dessinées. Le tracé des flèches est fait par la macro \verb-\chemmove- dont l'argument optionnel devient celui de l'environnement ``tikzpicture'' dans lequel sont faites les flèches. Lire page~\pageref{mecanismes-reactionnels}; + \item Pour le mécanisme d'alignement vertical des atomes sur une même horizontale, la commande \verb-\chemskipalign- permet d'ignorer ce mécanisme pour le groupe d'atomes dans lequel elle est écrite. Voir page~\pageref{chemskipalign}; + \item La commande \verb-\chemname- permet d'afficher un nom sous une molécule. La commande \verb-\chemnameinit- initialise l'alignement des noms. Lire page~\pageref{chemname}; + \item les dessins des décorations qu'effectue la commande \verb-\lewis- ont été améliorés; + \item Corrections de bugs et optimisation du code. +\end{enumerate} +\endgroup% !!! fin + \section{Foreword} This package has seen the light of day thanks to the assistance of Christophe \textsc{Casseau}, who had the idea after being confronted with the complexity of the syntax of the \href{http://www.ctan.org/tex-archive/help/Catalogue/entries/ppchtex.html}{\texttt{\textbf{ppchtex}}} package. -Throughout the writing of the code, he helped me find interesting features. He always encouraged me to write more advanced features even though I was sometimes (nearly always?) reluctant; if \CF has the features it does, it is in large part thanks to him. I thank him as well for his testing of beta versions of this package, and for his contributions to the writing of this manual. +Throughout the writing of the code, he helped me find interesting features. He always encouraged me to write more advanced features even though I was sometimes (nearly always?) reluctant; if \CF has the features it does, it is in large part thanks to him. I thank him as well for his testing of beta versions of this package, and for his contributions to the writing of this manual.\medskip -\hfill\begin{minipage}{0.8\linewidth}% +\begingroup +\leftskip0.1\linewidth +\rightskip0.1\linewidth \itshape\small -Experience shows that is it has been difficult to combine drawing of molecules with the typographic quality of a program like \LaTeX, leaving little choice for the user who wishes to have a vector format for these drawings. After having abandoned the \emph{ppchtex} package (developed for con\TeX t and available under \LaTeX) because of the complexity of its syntax, I turned to the world of programs outside \LaTeX. The difficulty in this case is finding a compromise between quality and price. After many unsuccessful attempts I found the only option was a new package, and I would like to thank Christian \textsc{Tellechea} for bringing it to life. To meet my requirements, \CF needed to be easy to use but still have advanced features, something well nigh impossible. Yet he was able to put together a very flexible \TeX{} code which makes it a pleasure for me to write my molecules. I hope it will be the same for you readers looking for a package useful in the field of chemistry. +Experience shows that is it has been difficult to combine drawing of molecules with the typographic quality of a program like \LaTeX, leaving little choice for the user who wishes to have a vector format for these drawings. After having abandoned the \emph{ppchtex} package (developed for con\TeX t and available under \LaTeX) because of the complexity of its syntax, I turned to the world of programs outside \LaTeX. The difficulty in this case is finding a compromise between quality and price. After many unsuccessful attempts I found the only option was a new package, and I would like to thank Christian \textsc{Tellechea} for bringing it to life. To meet my requirements, \CF needed to be easy to use but still have advanced features, something well nigh impossible. Yet he was able to put together a very flexible \TeX{} code which makes it a pleasure for me to write my molecules. I hope it will be the same for you readers looking for a package useful in the field of chemistry.\smallskip -\hfill Christophe \textsc{Casseau}% -\end{minipage}\hfill\null\bigskip +\hfill Christophe \textsc{Casseau}\kern0.1\linewidth +\endgroup\medskip Finally, I wish to warmly thank Theo \textsc{Hopman} for offering to translate this manual into English. @@ -406,10 +493,11 @@ Drawing a molecule consists inherently of connecting groups of atoms with lines. {\fboxsep1pt However, in this molecule \molht{H_3C-C(-[:-30]OH)=[:30]O} -there are four groups of atoms: ``$\mathrm{H_3C}$'', ``C'', ``O'' and ``OH''. For reasons which we shall see later, \CF splits each group into single atoms. Each atom extends up to the next capital letter or one of these special characters: {\ttfamily \boxedfalseverb{-} \boxedfalseverb{=} \boxedfalseverb{~} \boxedfalseverb{(} \boxedfalseverb{!} \boxedfalseverb{*} \boxedfalseverb{<} \boxedfalseverb{>}}. \CF ignores all characters inside braces when splitting groups into atoms. +there are four groups of atoms: ``$\mathrm{H_3C}$'', ``C'', ``O'' and ``OH''. For reasons which we shall see later, \CF splits each group into single atoms. Each atom extends up to the next capital letter or one of these special characters: {\ttfamily \boxedfalseverb{-} \boxedfalseverb{=} \boxedfalseverb{~} \boxedfalseverb{(} \boxedfalseverb{!} \boxedfalseverb{*} \boxedfalseverb{<} \boxedfalseverb{>} \boxedfalseverb{@}}. \CF ignores all characters inside braces when splitting groups into atoms. -Therefore the first group of atoms "$\mathrm{H_3C}$" is split into two atoms: $\boxednode{H_3}{}$ and $\boxednode C{}$. In terms of chemistry, of course, these are not real atoms; $\mathrm{H_3}$, for example, consists of three hydrogen atoms. In what follows the word atom refers to \CF's definition. Thus \CF sees the preceding molecule as follows: -\molht{\boxednode{H_3}{}\boxednode{C}{}-[,1.75]\boxednode{C}{}(-[:-30,1.5]\boxednode{O}{}\boxednode{H}{})=[:30,1.5]\boxednode{O}{}}} +Therefore the first group of atoms ``$\mathrm{H_3C}$'' is split into two atoms: $\boxednode{H_3}{}$ and $\boxednode C{}$. In terms of chemistry, of course, these are not real atoms; $\mathrm{H_3}$, for example, consists of three hydrogen atoms. In what follows the word atom refers to \CF's definition. Thus \CF sees the preceding molecule as follows: +\renewcommand*\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}} +\molht{H_3C-[,1.75]C(=[:30,1.5]O)(-[:-30,1.5]OH)}} \section{Different types of bonds} As we have already seen (see page~\pageref{types.liaisons}), bonds can be one of nine types, each corresponding to the characters \boxedfalseverb-, \boxedfalseverb=, \boxedfalseverb~, \boxedfalseverb>, \boxedfalseverb<, \boxedfalseverb{>:}, \boxedfalseverb{<:}, \boxedfalseverb{>|} and \boxedfalseverb{<|}. @@ -443,7 +531,7 @@ As we have already seen (see page~\pageref{types.liaisons}), bonds can be one of \exemple{Interatomic distance}|\setatomsep{2em}\chemfig{A-B}\par \setatomsep{50pt}\chemfig{A-B}| -\label{setbondoffset}The command \verb-\setbondoffset{}- sets the spacing $\delta$ between the bond line and the atom: +\label{setbondoffset}The command \verb-\setbondoffset{}- sets the spacing $\delta$ between the bond line and the atom. If the \verb-- is empty, $\delta$ takes the default value of 2pt. \exemple{Trimming bonds}|\setbondoffset{0pt}\chemfig{A-B}\par \setbondoffset{5pt}\chemfig{A-B}| @@ -451,6 +539,18 @@ If one bond is followed immediately by another, then \CF inserts an empty group \exemple{Empty groups}/\chemfig{A-B=-=C}\par \chemfig{A>B><>|,)-'', où \verb-- représente l'espacement $\delta$ au début de la liaison et \verb-- celui de la fin. Si \verb-- est omis, l'espacement en fin de liaison prend la valeur de $\delta$ en vigueur à ce moment. On peut observer sur cet exemple comment le retrait, réglé à 4pt pour être plus visible, est rendu nul pour la liaison arrivant sur ``B'', puis partant de ``B'' et enfin pour les deux à la fois : +\begingroup +\catcode`\#12 +\exemple{Réglage fin du retrait des liaisons}/\setbondoffset{4pt} +\chemfig{A-B-C}\par +\chemfig{A-#(,0pt)B-C}\par +\chemfig{A-B-#(0pt)C}\par +\chemfig{A-#(,0pt)B-#(0pt)C}/ +\endgroup +\endgroup% !!! fin + By default, all atoms within groups of atoms are typeset in math mode (spaces are ignored). They may therefore contain math mode specific commands such as subscripts or superscripts\footnote{There is a problem with the placement of groups of atoms containing exponents or subscripts. See page~\pageref{alignement.vertical}.}: \exemple{Math mode}|\chemfig{A_1B^2-C _ 3 ^ 4}| @@ -578,7 +678,7 @@ In this example, the sub-molecule ``\verb/-[1]W-X/'' will be attached to atom `` There can be several sub-molecules which are to be attached to the same atom. Just have several parentheses containing the code for each sub-molecule: \exemple{Multiple branches}|\chemfig{A-B(-[1]W-X)(-[6]Y-[7]Z)-C}| -The code of each sub-molecule can define its own default values, which will be valid throughout the whole sub-molecule. Here a sub-molecule ``\verb/[:60]-D-E/'' is attached to atom ``B'', with a default angle of 60\degres{} absolute. A second sub-molecule ``\verb/[::-60,1.5]-X-Y/"'' is attached to ``B'' with a default bond angle 60\degres{} less than that of the preceding bond (which will be the one between ``A'' and ``B'') and with an interatomic distance 1.5 times the default value: +The code of each sub-molecule can define its own default values, which will be valid throughout the whole sub-molecule. Here a sub-molecule ``\verb/[:60]-D-E/'' is attached to atom ``B'', with a default angle of 60\degres{} absolute. A second sub-molecule ``\verb/[::-60,1.5]-X-Y/'' is attached to ``B'' with a default bond angle 60\degres{} less than that of the preceding bond (which will be the one between ``A'' and ``B'') and with an interatomic distance 1.5 times the default value: \exemple{Default values in branches}|\chemfig{A-B([:60]-D-E)([::-30,1.5]-X-Y)-C}| Observe what happens if, at the beginning of the main molecule, one writes ``\verb/[:-45]/'': @@ -739,9 +839,193 @@ Some care must be taken with rings when one or more vertices are made up of grou In order for the ring to have a regular shape, it is necessary to override the \CF mechanism which automatically calculates the departure and arrival atoms of bonds. Here, \verb/C-F/ and \verb/F-G/ must be connected by using the optional argument of these bonds: \exemple{Forced departure and arrival atoms}|\chemfig{AB*5(-CDE-[,,1]F-[,,,1]GH-I-)}| + +\begingroup\color{gray}% !!! Nouveau +\section{Représentation des déplacements d'électrons}\label{mecanismes-reactionnels} +\nouveau Depuis la version 0.3 de \CF, on peut représenter les déplacements d'électrons des effets mésomères ou des mécanismes réactionnels. Cela est rendu possible en marquant le point de départ et le point d'arrivée de la flèche que l'on utilise pour indiquer la migration des électrons à l'aide de la syntaxe ``\verb-@{}-''. Cette syntaxe permet de poser un nœud (au sens de \TIKZ) en rendant ce nœud accessible en dehors de l'argument de la commande \verb-\chemfig- grâce à l'option ``\texttt{remember picture}'' qui est passée à tous les environnements ``tikzpicture''. Cela suppose que le visualiseur prenne en charge le ``picture remembering'' et que la compilation soit lancée deux fois. + +Deux cas de figure peuvent se présenter, on peut poser : +\begin{itemize} + \item un nœud de dimension nulle sur une liaison en utilisant la syntaxe ``\verb-@{,}-'' placée immédiatement au début de l'argument optionnel de la liaison concernée sans être suivi d'une virgule s'il y a un premier argument optionnel. Dans ce cas, le nœud portera le nom ``\verb--'' et le \verb--, compris entre 0 et 1, déterminera où le nœud se situera sur la liaison. Si on utilise ``\verb-@{}-'', le \verb-- prend la valeur de 0.5 par défaut ce qui signifie que le nœud est posé au milieu de la liaison; + \item un nœud sur un atome en utilisant la syntaxe ``\verb-@{}-'' immédiatement avant l'atome concerné. Dans ce cas, le nœud a exactement le même encombrement que l'atome, il peut notamment être vide et donc avoir des dimensions nulles. +\end{itemize} +Une fois que la commande \verb-\chemfig- a dessiné la (ou les) molécule(s) et a posé les nœuds avec la syntaxe décrite ci dessus, on peut relier ces nœuds entre eux avec les instructions de \TIKZ. Ces instructions seront placées dans l'argument de la commande \verb-\chemmove-\footnote{En réalité, la commande \texttt{\string\chemmove} met son argument dans un environnement ``tikzpicture'' avec les options ``\texttt{remember picture,overlay}''.} et auront la syntaxe suivante si par exemple, on doit relier un nœud portant le nom ``\verb--'' au nœud portant le nom ``\verb--'' : +\centerverb|\chemmove[]{\draw[]()();}| +\smallskip + +L'argument optionnel \verb-- de la commande \verb-\chemmove- sera ajouté à l'argument de l'environnement tikzpicture dans lequel seront tracées les liaisons entre les nœuds. Les instructions \verb-- et \verb-- sont exhaustivement décrites dans la documentation de l'extension \TIKZ. + +\subsection{Effets mésomères} +Pour fixer les idées prenons l'exemple d'un effet mésomère impliquant une double liaison et un doublet non liant conjugués. Commençons par la possible délocalisation des électrons de la double liaison. On va poser un nœud nommé ``db'' (double bond) au milieu de la double liaison et un nœud nommé ``a1'' sur l'extrémité de la double liaison. + +\exemple{Effet mésomère 1}/\chemfig{@{a1}=_[@{db}::30]-[::-60]\lewis{2,X}} +\chemrel{<->} +\chemfig{\chemabove{\vphantom{X}}{\ominus}-[::30]=_[::-60] +\chemabove{X}{\scriptstyle\oplus}} +\chemmove{\draw[->](db).. controls +(80:8mm) and +(145:8mm).. (a1);}/ + +Comme on l'a dit, on remarque qu'il n'y pas de virgule derrière le nœud posé dans les arguments optionnels d'une liaison; On écrit ``\verb|=_[@{db}::30]|'' et non pas ``\verb|=_[@{db},::30]|'' comme on serait tenté de le faire.\\ +Pour relier les nœuds ``db'' et ``a1'', nous avons utilisé la syntaxe suivante : +\centerverb|\chemmove{\draw[->](db)..controls +(80:8mm) and +(145:8mm)..(a1);}| +\medskip + +Dans cet exemple nous demandons une flèche (\verb/[->]/) et nous utilisons 2 points de contrôle\footnote{Pour connaître toutes les façons de relier deux nœuds avec \TIKZ, lire la documentation de ce package.}. Ceux-ci seront situés en coordonnées polaires à 80\degres{} et 8~mm de ``db'' pour le premier et à 145\degres{} et 8~mm de ``a1'' pour le second. Il ne faut pas être effrayé par cette syntaxe qui peut paraître compliquée en première lecture car son utilisation se réduit dans la plupart des cas à un simple copier-coller dans lequel on modifie juste le nom des nœuds et les coordonnées polaires des points de contrôle. Ce que nous allons vérifier tout de suite avec l'ajout d'une flèche partant du doublet non liant (nœud ``dnl'') vers la liaison simple (nœud ``sb''). +\exemple{Effet mésomère 2}/\chemfig{@{a1}=_[@{db}::30]-[@{sb}::-60]@{dnl}\lewis{2,X}} +\chemrel{<->} +\chemfig{\chemabove{\vphantom{X}}{\ominus}-[::30]=_[::-60] +\chemabove{X}{\scriptstyle\oplus}} +\chemmove{\draw[->](db)..controls +(80:8mm) and +(145:8mm)..(a1);} +\chemmove{\draw[->](dnl)..controls +(90:4mm) and +(45:4mm)..(sb);}/ + +Pour notre nouvelle flèche nous avons fixé les points de contrôle comme suit : un angle de 90\degres{} à 4~mm de ``dnl'' et un angle de 45\degres{} à 4~mm de ``sb''. Mais nous ne sommes pas entièrement satisfaits car nous aimerions que la flèche ne touche pas le trait représentant le doublet non liant. Pour cela nous allons ajouter quelques options à notre flèche. +\exemple{Effet mésomère 3}/\chemfig{@{a1}=_[@{db}::30]-[@{sb}::-60]@{dnl}\lewis{2,X}} +\chemrel{<->} +\chemfig{\chemabove{\vphantom{X}}{\ominus}-[::30]=_[::-60] +\chemabove{X}{\scriptstyle\oplus}} +\chemmove{\draw[->](db).. controls +(80:8mm) and +(145:8mm).. (a1);} +\chemmove{\draw[->, shorten <=3pt, shorten >= 1pt] + (dnl).. controls +(90:4mm) and +(70:6mm).. (sb);}/ + +L'option ``\verb|shorten <=3pt|'' indique que le point de départ de la flèche doit être raccourci de 3~pt de même ``\verb|shorten >=2pt|'' indique que le point d'arrivé doit être raccourci de 2~pt. + +On peut utiliser toute la puissance des instructions de \TIKZ pour modifier le dessin de la flèche. Ici, nous changeons l'extrémité de la flèche partant de la double liaison, non plus écrite ``\verb|->|'' mais ``\verb|-stealth|'', nous la dessinons en pointillés d'épaisseur fine et rouge. Nous rajoutons également la lettre $\pi$ au dessus de la flèche en son milieu : +\exemple{Effet mésomère 4}/\chemfig{@{a1}=_[@{db}::30]-[@{sb}::-60]@{dnl}\lewis{2,X}} +\chemrel{<->} +\chemfig{\chemabove{\vphantom{X}}{\ominus}-[::30]=_[::-60] +\chemabove{X}{\scriptstyle\oplus}} +\chemmove{\draw[-stealth,thin,dash pattern= on 2pt off 2pt,red] + (db).. controls +(80:8mm) and +(145:8mm).. + node[sloped,above] {$\pi$} (a1);} +\chemmove{\draw[->, shorten <=3pt, shorten >= 1pt] + (dnl).. controls +(90:4mm) and +(70:6mm).. (sb);}/ + +Dans l'exemple suivant nous allons voir comment indiquer la position de l'ancre de départ ou d'arrivée. Si nous écrivons +\exemple{Ancre de départ et d'arrivée 1}/\chemfig{@{x1}\lewis{1:,X}} +\hspace{2cm} +\chemfig{@{x2}\lewis{2|,X}} +\chemmove{\draw[->,shorten >=4pt] + (x1).. controls +(90:1cm) and +(90:1cm).. (x2);}/ + +Nous constatons que l'ancre de départ de notre flèche ne pointe pas correctement sur nos électrons. La flèche part du milieu du bord supérieur du nœud. En effet, nous avons choisi un angle de départ de 90\degres{} et tikz fait donc partir la flèche de l’ancre ``x1.90'' qui correspond à l’intersection de la demi droite partant du centre du nœud ``x1'' et faisant un angle avec l’horizontale de 90\degres{} avec le bord du nœud qui est un rectangle. Pour obtenir le départ de la flèche d’où nous voulons, nous devons spécifier sa position. Après quelques tâtonnements, c’est ``x1.57'' : +\exemple{Ancres de départ et d'arrivée 2}/\chemfig{@{x1}\lewis{1:,X}} +\hspace{2cm} +\chemfig{@{x2}\lewis{2|,X}} +\chemmove{\draw[->,shorten <=4pt,shorten >=4pt] + (x1.57).. controls +(60:1cm) and +(120:1cm).. (x2);}/ + +Dans certains cas il sera plus facile d'utiliser les coordonnées cartésiennes pour les points de contrôle. Ici, nous n'utilisons qu'un seul point de contrôle situé à 1~cm horizontalement de ``x1'' et 1,5~cm verticalement : +\exemple{Un seul point de contrôle}/\chemfig{@{x1}\lewis{1:,X}} +\hspace{2cm} +\chemfig{@{x2}\lewis{2|,X}} +\chemmove{\draw[->,shorten <=4pt,shorten >=4pt] + (x1.57).. controls +(1cm,1.5cm).. (x2);}/ + +Dans ce cas nous plaçons un point de contrôle à 1~cm horizontalement et 2~cm verticalement de ``x1''. Tous les objets graphiques dessinées par l’intermédiaire de la commande \verb|\chemmove| sont faits en surimpression et ne seront pas comptés dans les boîtes englobantes. On peut le constater sur l’exemple précédent. + +\subsection{Mécanismes réactionnels} +Grâce à l'option \verb|remenber picture| qui est passée à tous les environnements ``tikzpicture'' nous pouvons facilement dessiner les flèches indiquant les mécanismes réactionnels. Prenons comme exemple la première étape de la réaction d'estérification. +\exemple{Estérification: étape 1}/\setatomsep{7mm} +\setchemrel{}{}{5mm} +\chemfig{R-@{dnl}\lewis{26,O}-H} +\chemsign{+} +\chemfig{R-@{atoc}C([6]-OH)=[@{db}]O} +\chemrel[\chemfig{@{atoh}\chemabove{H}{\scriptstyle\oplus}}]{<>} +\chemmove[->,shorten <=2pt]{ + \draw[shorten >=2pt](dnl).. controls +(90:1cm) and +(north:1cm).. (atoc); + \draw[shorten >=6pt](db).. controls +(north:5mm) and +(100:1cm).. (atoh);}/ + +L'utilisation de la commande \verb|\chemabove{}{}| ne change pas les dimensions de la boite englobante du \verb||. Pour cette raison on peut rencontrer certaines difficultés pour pointer sur le matériel indiquant la charge portée ($\oplus$ ou $\ominus$). Dans l'exemple ci-dessus la solution est de créer un point de contrôle avec un angle de 110\degres{} à 1~cm de ``atoh'' et de raccourcir la flèche de 6pt. Dans l'exemple suivant, seconde étape de la réaction d'estérification, on peut voir que la flèche peut prendre des formes plus compliquées sans forcément surcharger le code. +\exemple{Estérification: étape 2}/\setatomsep{7mm} +\setchemrel{}{}{5mm} +\chemfig{R-O-C(-[2]R)(-[6]OH)-@{dnl}\lewis{26,O}H}\hspace{1cm} +\chemfig{@{atoh}\chemabove{H}{\scriptstyle\oplus}} +\chemmove{\draw[->,shorten <=2pt, shorten >=7pt] + (dnl).. controls +(south:1cm) and +(north:1.5cm).. (atoh);}/ + +Nous laissons le soin au lecteur d'écrire la suite\ldots + +\section{Écrire un nom sous une molécule}\label{chemname} +\nouveau Pour plus de commodité, \CF permet d'écrire le nom d'une molécule sous celle-ci avec la commande +\centerverb/\chemname[]{\chemfig{}}{}/ +\smallskip + +La \verb--, qui vaut 1.5ex par défaut, sera insérée verticalement entre la ligne de base de la molécule et le haut des lettres du \verb--. Le \verb-- sera centré par rapport à la molécule mais ce \verb-- ne peut pas contenir plusieurs paragraphes. Comme on le voit sur cet exemple : \chemname{\chemfig{H-O-H}}{\scriptsize\bfseries La molécule d'eau : $\mathrm{\mathbf{H_2O}}$}, le \verb-- qui est affiché sous la molécule est pris en compte dans la boîte englobante mais uniquement en ce qui concerne sa dimension \emph{verticale}. L'encombrement horizontal du \verb-- est toujours nul. + +Voici une réaction avec les noms sous les molécules : +\exemple*{Affichage du nom des molécules}/ +\chemname{\chemfig{R-C(-[:-30]OH)=[:30]O}}{Acide carboxylique} +\chemsign{+} +\chemname{\chemfig{R'OH}}{Alcool} +\chemrel{->} +\chemname{\chemfig{R-C(-[:-30]OR')=[:30]O}}{Ester} +\chemsign{+} +\chemname{\chemfig{H_2O}}{Eau} +/ + +Il y a quelques contraintes avec cette commande. Pour en pendre conscience, mettons que l'on ait inversé l'acide et l'alcool dans le membre de gauche : +\exemple*{Alignement des noms 1}/ +\chemname{\chemfig{R'OH}}{Alcool} +\chemsign{+} +\chemname{\chemfig{R-C(-[:-30]OH)=[:30]O}}{Acide carboxylique} +\chemrel{->} +\chemname{\chemfig{R-C(-[:-30]OR')=[:30]O}}{Ester} +\chemsign{+} +\chemname{\chemfig{H_2O}}{Eau} +/ + +En fait, au dessous de la ligne de base de chaque molécule (en gris clair sur les exemples de ce manuel), pour écrire le \verb--, la commande \verb-\chemname- insère 1.5ex${}+{}$\emph{la plus grande des profondeurs\footnote{En langage \TeX{}, la profondeur est la dimension qui s'étend verticalement sous la ligne de base.} des molécules rencontrées}. La macro \verb-\chemnameinit{}- initialise cette plus grande profondeur avec le contenu de l'\verb--. Il convient donc : +\begin{itemize} + \item d'écrire \verb-\chemnameinit{}- avant d'impliquer cette commande dans une réaction, sauf si cette réaction commence par la plus profonde molécule; + \item d'écrire \verb-\chemnameinit{}- après avoir écrit tous les noms d'une réaction chimique afin d'éviter que la plus grande profondeur trouvée dans cette réaction n'interfère dans une réaction future. +\end{itemize} + +Le code correct est donc d'utiliser \verb-\chemnameinit- avant et après la réaction : +\exemple*{Alignement des noms 2}/ +\chemnameinit{\chemfig{R-C(-[:-30]OH)=[:30]O}} +\chemname{\chemfig{R'OH}}{Alcool} +\chemsign{+} +\chemname{\chemfig{R-C(-[:-30]OH)=[:30]O}}{Acide carboxylique} +\chemrel{->} +\chemname{\chemfig{R-C(-[:-30]OR')=[:30]O}}{Ester} +\chemsign{+} +\chemname{\chemfig{H_2O}}{Eau} +\chemnameinit{} +/ + +Enfin, pour écrire un nom sur plusieurs lignes, la commande \verb-\\- rencontrée dans un \verb-- effectue un retour à la ligne\footnote{Par contre, la commande \texttt{\textbackslash par} est interdite et provoquera une erreur à la compilation.} : +\exemple*{Nom sur 2 lignes}/ +\chemname{\chemfig{R-C(-[:-30]OH)=[:30]O}}{Acide\\carboxylique} +\chemsign{+} +\chemname{\chemfig{R'OH}}{Alcool} +\chemrel{->} +\chemname{\chemfig{R-C(-[:-30]OR')=[:30]O}}{Ester} +\chemsign{+} +\chemname{\chemfig{H_2O}}{Eau} +\chemnameinit{} +/ +\endgroup% !!!fin \newpage \part{Advanced usage}\label{utilisation.avancee} +\begingroup\color{gray}% !!! Nouveau +\section{Découpage des atomes}\label{decoupage.atomes} +\nouveau Le mécanisme de découpage des atomes, déjà décrit auparavant, fait s'étendre chaque atome jusqu'à la prochaine lettre majuscule ou l'un des caractères {\ttfamily \boxedfalseverb{-} \boxedfalseverb{=} \boxedfalseverb{~} \boxedfalseverb{(} \boxedfalseverb{!} \boxedfalseverb{*} \boxedfalseverb{<} \boxedfalseverb{>} \boxedfalseverb{@}} + +Dans certains cas, ce découpage automatique produit des atomes incorrects ce qui peut se traduire par un affichage imparfait. Prenons cette molécule par exemple où l'on remarquera que le caractère ``\texttt('' est mis entre accolade de façon à éviter que \CF ne comprenne à tort qu'une ramification est créée : + +\exemple*{Alcène}/\chemfig{CH_3CH_2-[:-60,,3]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]C{(}CH_3{)}_3}/ + +On constate que la liaison qui arrive sur l'atome de carbone en haut à droite est trop courte. Cela se produit car, si l'on applique les règles de découpage de \CF dans le groupe d'atomes en haut à droite, les atomes sont découpés de cette façon : ``\texttt{\detokenize{C{(}}}'', ``\texttt{\detokenize{C}}'', ``\texttt{\detokenize{H_3{)}_3}}''. On comprend alors qu'en mode math, le premier atome qui contient une parenthèse ait une profondeur trop importante comme on le voit en rendant visibles les boites contenant les atomes : +\begin{center} +\fboxsep=0pt +\renewcommand*\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}}% +\chemfig{CH_3CH_2-[:-60,,3]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]C{(}CH_3{)}_3}% +\end{center} +Le caractère ``|'' force la coupure de l'atome en cours lorsqu'il est rencontré. Ainsi, on peut écrire \texttt{C\textcolor{red}{|}\detokenize{{(CH_3)_3}}} pour faire en sorte que \CF ne découpe que 2 atomes ici : ``\texttt{\detokenize{C}}'' et ``\texttt{\detokenize{{(CH_3)_3}}}. Le problème de la liaison trop courte est ainsi résolu : + +\exemple*{Alcène}/\chemfig{CH_3CH_2-[:-60,,3]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]C|{(CH_3)_3}}/ +\endgroup% !!! fin + \section{Displaying atoms}\label{perso.affichage} Once a molecule has been split into atoms, the macro \verb-\printatom- is called internally by \CF in order to display each atom. Its sole argument is the code of the atom to be displayed (e.g. ``\verb-H_3-''). By default, this macro enters math mode and displays its argument with the math font family ``rm''. It is defined by the following code: @@ -756,6 +1040,90 @@ Here is how to redefine it to use the ``sf'' font family of math mode: \exemple{Atoms displayed with ``sf'' font family}/\renewcommand*\printatom[1]{\ensuremath{\mathsf{##1}}} \chemfig{H_3C-C(=[:30]O)(-[:-30]OH)}/ +\begingroup\color{gray}% !!! Nouveau +\section{Arguments optionnels}\label{arguments.optionnels} +\nouveau La commande \verb-\chemfig- admet deux arguments optionnels et sa syntaxe complète est la suivante : +\centerverb|\chemfig[][]{}| +\smallskip + +Le premier argument optionnel \verb-- contient des instructions \TIKZ qui seront passées à l'environnement tikzpicture dans lequel est dessinée la molécule. Le deuxième argument optionnel \verb-- contient des instructions \TIKZ qui seront exécutées lors du dessin de chaque nœud\footnote{Ces instructions sont ajoutées à la fin de l'argument de \texttt{every node/.style\{\}}. Cet argument contient par défaut les instructions suivantes : ``{\ttfamily anchor=base,inner sep=0pt,outer sep=0pt,minimum size=0pt}''.}. + +Par l'intermédiaire du premier argument optionnel, on peut choisir par exemple la couleur générale ou l'épaisseur des lignes : +\exemple{Choix du style}/\chemfig{A-B-[2]C}\par\medskip +\chemfig[line width=1.5pt]{A-B-[2]C}\par\medskip +\chemfig[red]{A-B-[2]C}/ + +Avec le second argument optionnel, on peut choisir la couleur des nœud dessinés par \TIKZ, et même modifier l'inclinaison du dessin : +\exemple{Choix des styles}/\chemfig{A-B-[2]C}\par\medskip +\chemfig[][red]{A-B-[2]C}\par\medskip +\chemfig[dash pattern=on 1pt off 2pt][red]{A-B-[2]C}\par\medskip +\chemfig[][rotate=20]{A-B-[2]C}/ +\endgroup% !!! fin + +\section{Vertical alignment}\label{alignement.vertical} +In some cases with condensed structural diagram of molecules having horizontal bonds, the placement of groups of atoms is incorrect. + +Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline: +\exemple*{Vertical placement}/\Huge\setatomsep{2em} +\chemfig{A^1-B-C-D}\qquad +\chemfig{E_1-F-G-H}/ + +Surprisingly, the second atom is correctly aligned while the last two undergo a vertical shift which seems to be the results of the different height of the bounding box of the atoms ``\verb-A^1-'' and ``\verb-E_1''-. + +In order to understand this phenomenon, we need to consider how \CF places groups of atoms relative to each other. Let us limit ourselves to the case of horizontal bonds in order to simplify terminology, although the algorithm is the same for other bonds. A horizontal bond leaves from the middle of the right side of the bounding box of the departure atom of this bond. The arrival atom is positioned in such a way that the middle of the left side of its bounding box is at the end of the bond. It follows that the vertical placement of the arrival atom depends on the height of the departure atom. To limit this phenomenon, \CF adds to each arrival atom the \verb-\vphantom- of the departure atom, but does not include it in the contents of the arrival atom; this \verb-\vphantom- is not intended to affect the following atoms. +\begingroup\color{gray}% !!! nouveau +Les atomes qui restent dans chaque groupe sont alignés de telle sorte que leur ligne de base coïncide avec la ligne de base de l'atome précédent. +\endgroup%!!! fin + +The defective alignment can thus be explained. The atoms ``\verb-B-'' and ``\verb-F-'' are aligned correctly as they reflect the height of the atoms before them because of their \verb-\vphantom-. For the atoms ``\verb-C-'' and ``\verb-F-'', the heights of the immediately preceding atoms are taken into account, but those of the atoms ``\verb-A^1-'' and ``\verb-E_1-'' are ignored! It follows that these atoms are a little too high or too low, depending on the height of these bonds. + +We can show this by making visible the bounding boxes of the atoms; one sees clearly that the atoms ``\verb-B-'' and ``\verb-F-'' have bounding boxes that reflect the heights of the immediately preceding atoms: +\exemple*{Vertical placement and bounding boxes}/\Huge\setatomsep{2em} +\fboxsep=0pt +\renewcommand\printatom[1]{\fbox{\ensuremath{\mathrm##1}}} +\chemfig{A^1-B-C-D}\qquad +\chemfig{E_1-F-G-H}/ + +Since there is no satisfactory manual solution, this problem can be worked around manually by putting \emph{inside} the third atom a \verb-\vphantom- having the same height as the first, so that the height affects the following atoms: +\exemple*{Vertical placement workaround}/\Huge\setatomsep{2em} +\chemfig{A^1-B-{\vphantom{A^1}C}-D}\qquad +\chemfig{E_1-F-{\vphantom{E_1}G}-H}/ + +\begingroup\color{gray}% !!! Nouveau +\nouveau \label{chemskipalign}Il est possible pour n'importe quel groupe d'atomes de désactiver momentanément le mécanisme d'ajustement d'alignement et neutraliser le \verb-\vphantom-. Il suffit pour cela de placer dans le groupe d'atomes la commande \verb-\chemskipalign- : l'alignement reprendra au groupe d'atomes suivant comme si le groupe d'atome contenant \verb-\chemskipalign- n'avait pas existé. On peut se rendre compte sur l'exemple suivant de l'effet de cette instruction qui a pour effet de placer le point de référence de la boîte contenant le premier atome au niveau de la liaison qui arrive de gauche. Les boîtes englobant les atomes ont été dessinées à la seconde ligne : + +\exemple[60]{Désactivation du mécanisme d'alignement}/\large +\chemfig{A-.-B}\quad +\chemfig{A-\chemskipalign.-B}\par\bigskip +\fboxsep=0pt +\renewcommand\printatom[1]{\fbox{\ensuremath{\mathrm{##1}}}} +\chemfig{A-.-B}\quad +\chemfig{A-\chemskipalign.-B}/ + +Cette commande est à utiliser avec précaution car l'alignement des atomes dans le groupe d'atomes à venir peut être perturbé. En règle générale, tout se passera bien si le groupe d'atomes dans lequel figure \verb-\chemskipalign- contient \emph{un seul atome} dont la hauteur et la profondeur sont \emph{inférieures} à celles de l'atome qui précède et qui suit, et si les atomes qui précèdent et suivent ont leur profondeur et hauteur égales. Voici par exemple la mésaventure qui arrive lorsque le groupe d'atomes contient 2 atomes, ici ``\verb-\chemskipalign.-'' et ``\verb-B-'' : +\exemple{Conséquence de la commande \string\chemskipalign}/\large +\fboxsep=0pt +\renewcommand\printatom[1]{\fbox{\ensuremath{\mathrm{##1}}}} +\chemfig{A-\chemskipalign.B-C}/ + +Cette fonctionnalité peut parfois s'avérer utile. Mettons que l'on veuille dessiner la molécule +\begin{center} + \catcode`;12 + \def\emptydisk{\chemskipalign\tikz\draw(0,0)circle(2pt);}% + \def\fulldisk{\chemskipalign\tikz\fill(0,0)circle(2pt);}% + \chemfig{A-#(,0pt)\emptydisk-#(0pt,0pt)\fulldisk-#(0pt)B}% +\end{center} +On peut définir les commandes qui vont dessiner les disques vides et pleins avec \TIKZ. Afin que ces disques soit à la bonne hauteur, c'est-à-dire à la hauteur de la liaison qui leur arrive dessus, on se servira de la commande \verb-\chemskipalign-. Pour que, à la deuxième ligne de l'exemple ci dessous, les liaisons ``collent'' aux disques, nous utiliserons la possibilité de modifier le retrait d'une liaison avec le caractère ``\verb-#-'', fonctionnalité qui a été vue à la page~\pageref{modif.retrait}.% ########## Ne pas traduire ce passage, merci ########## Pour les utilisateurs ayant chargé le package babel avec l'option ``frenchb'', il est nécessaire de désactiver le caractère actif ``\verb-;-'' qui marque la fin d'une instruction \TIKZ et qui sinon ne serait pas reconnu en tant que tel. C'est pourquoi on se place dans un groupe où l'on écrit l'instruction \verb-\shorthandoff{;}- : +\begingroup\catcode`;12 \catcode`#12 +\exemple{Utilisation de \string\chemskipalign\ et #}/ +\begingroup +\def\emptydisk{\chemskipalign\tikz\draw(0,0)circle(2pt);} +\def\fulldisk{\chemskipalign\tikz\fill(0,0)circle(2pt);} +\chemfig{A-\emptydisk-\fulldisk-B}\par +\chemfig{A-#(,0pt)\emptydisk-#(0pt,0pt)\fulldisk-#(0pt)B} +\endgroup/\endgroup +\endgroup% !!! fin + \section{Shifted double bonds} All double bonds are made up of two line segments, and these segments are drawn on either side of the imaginary line along which a single bond would be drawn. It is possible to shift a double bond so that one of the line segments lies on the imaginary line. The other segment is then shifted above or below the bond. Actually, it is more correct to say ``left'' or ``right'' of the imaginary line, as the bond is traversed in the direction of drawing. @@ -803,9 +1171,16 @@ To do this, one gives the command \centerverb|\definesubmol{}{}| \smallskip -which saves the \verb// for recall in the code of the molecule via the shortcut ``\verb/!{name}/''. All alphanumeric characters\footnote{Actually all the characters that can be put between \texttt{\string\csname...\string\endcsname} are allowed.} are accepted for the \verb//. The \verb// can itself contain other aliases. +which saves the \verb// for recall in the code of the molecule via the shortcut ``\verb/!{name}/''. +\begingroup\color{gray}% !!! Nouveau +Ce \verb-- peut être : +\begin{itemize} + \item une suite de caractères : tous les caractères alphanumériques pouvant se trouver entre \texttt{\string\csname} et \texttt{\string\endcsname} sont acceptés; + \item \nouveau[30pt] une séquence de contrôle. +\end{itemize} -A previous definition can be overwritten by\label{redefinesubmol} +Dans tous les cas, si l'alias est déjà défini il est déconseillé de l'écraser avec une nouvelle définition faite avec \verb-\definesubmol-, d'ailleurs, un ``warning'' sera émis avertissant l'utilisateur que cet alias sera écrasé par le nouveau. Pour écraser la définition d'un alias faite au préalable, il faut utiliser :\label{redefinesubmol} +\endgroup% !!! fin \centerverb|\redefinesubmol{}{}| \smallskip @@ -815,9 +1190,21 @@ Here is a code which draws the pentane molecule. An alias ``\verb/xy/'' was defi In this case the technique is not very interesting because ``\verb/!{xy}/'' is just as long to type as the code it replaces. -But in certain cases, this feature saves a lot of space in the code of the molecule and increases readability. In the following example, we draw the complete structural diagram of butane. We will define an alias ``\verb/CH2/'' for the sub-molecule $\mathrm{CH_2}$. If we use only relative angles, it is possible to rotate the entire molecule to any given angle by using the optional global angle parameter which specifies the default bond angle of the main molecule. It is set to 15\degres{} here: -\exemple{Butane}|\definesubmol{CH2}{C(-[::+90]H)(-[::-90]H)} - \chemfig{[:15]H-!{CH2}-!{CH2}-!{CH2}-!{CH2}-H}| +But in certain cases, this feature saves a lot of space in the code of the molecule and increases readability. In the following example, we draw the complete structural diagram of butane. We will define an alias with the control sequence ``\verb/\xx/'' for the sub-molecule $\mathrm{CH_2}$. If we use only relative angles, it is possible to rotate the entire molecule to any given angle by using the optional global angle parameter which specifies the default bond angle of the main molecule. It is set to 15\degres{} here: +\exemple{Butane}|\definesubmol\xx{C(-[::+90]H)(-[::-90]H)} +\chemfig{[:15]H-!\xx-!\xx-!\xx-!\xx-H}| + +\begingroup\color{gray}% !!! Nouveau +\nouveau La commande \verb-\definesubmol- admet un argument optionnel et sa syntaxe complète est la suivante : +\centerverb/\definesubmol{}[]{code2}/ +\medskip + +Dans la cas où l'argument optionnel est présent, l'alias ``\verb-!-'' sera remplacé par \verb'' si la liaison qui arrive sur l'alias vient de droite, c'est à dire si l'angle que fait la liaison arrivant est compris entre 90\degres{} et 270\degres{}, ces valeurs étant non comprises. Pour tous les autres cas où la liaison arrive de gauche ou verticalement, l'alias sera remplacé par \verb--. + +On va définir une séquence de contrôle \verb-\Me- pour ``méthyl'' de telle sorte que l'alias ``\verb-!\Me-'' soit remplacé par ``\verb-H_3C-'' lorsque la liaison arrive de droite et par ``\verb-CH_3-'' lorsqu'elle arrive de droite. Avec cet alias, on peut observer sur l'exemple que l'on n'a plus à s'occuper de l'angle (que dans certaines molécules complexes on ne connait même pas) : +\exemple{Alias dual}/\definesubmol\Me[H_3C]{CH_3} +\chemfig{*6((-!\Me)=(-!\Me)-(-!\Me)=(-!\Me)-(-!\Me)=(-!\Me)-)}/ +\endgroup% !!! fin \section{Decorations} \subsection{Lewis diagrams}\label{lewis} @@ -852,7 +1239,7 @@ This can be seen more clearly by drawing an \verb-\fbox- around decorated atoms: If an argument is empty, it takes its default value. \begin{itemize} - \item \verb-- is the distance between the bounding box and the decoration. It is 1.5pt by default; + \item \verb-- is the distance between the bounding box and the decoration. It is 0.2ex by default; \item \verb-- is the length of the line segment representing a pair of electrons. It is 1.5ex by default; \item \verb-- is code which is passed directly to \TIKZ. This code is empty by default. \end{itemize} @@ -922,36 +1309,6 @@ It is possible to call the \verb-\chemfig- inside a \verb-tikzpicture- environme \node[draw,red,anchor=base] at(3,2){\chemfig{X>[2,,,,blue]Y}}; \end{tikzpicture}| -\section{Vertical alignment}\label{alignement.vertical} -In some cases with condensed structural diagram of molecules having horizontal bonds, the placement of groups of atoms is incorrect. - -Careful study of the following example shows that the groups of atoms are not correctly aligned on the baseline: -\exemple*{Vertical placement}/\Huge\setatomsep{2em} -\chemfig{A^1-B-C-D}\qquad -\chemfig{E_1-F-G-H}/ - -Surprisingly, the second atom is correctly aligned while the last two undergo a vertical shift which seems to be the results of the different height of the bounding box of the atoms ``\verb-A^1-'' and ``\verb-E_1''-. - -In order to understand this phenomenon, we need to consider how \CF places groups of atoms relative to each other. Let us limit ourselves to the case of horizontal bonds in order to simplify terminology, although the algorithm is the same for other bonds. A horizontal bond leaves from the middle of the right side of the bounding box of the departure atom of this bond. The arrival atom is positioned in such a way that the middle of the left side of its bounding box is at the end of the bond. It follows that the vertical placement of the arrival atom depends on the height of the departure atom. To limit this phenomenon, \CF adds to each arrival atom the \verb-\vphantom- of the departure atom, but does not include it in the contents of the arrival atom; this \verb-\vphantom- is not intended to affect the following atoms. - -The defective alignment can thus be explained. The atoms ``\verb-B-'' and ``\verb-F-'' are aligned correctly as they reflect the height of the atoms before them because of their \verb-\vphantom-. For the atoms ``\verb-C-'' and ``\verb-F-'', the heights of the immediately preceding atoms are taken into account, but those of the atoms ``\verb-A^1-'' and ``\verb-E_1-'' are ignored! It follows that these atoms are a little too high or too low, depending on the height of these bonds. - -We can show this by making visible the bounding boxes of the atoms; one sees clearly that the atoms ``\verb-B-'' and ``\verb-F-'' have bounding boxes that reflect the heights of the immediately preceding atoms: -\bgroup -\makeatletter -\def\CF@display@chem#1{\fbox{\ensuremath{\mathrm{#1}}}} -\makeatother -\exemple*{Vertical placement and bounding boxes}/\Huge\setatomsep{2em} -\fboxsep=0pt -\chemfig{A^1-B-C-D}\qquad -\chemfig{E_1-F-G-H}/ -\egroup - -Since there is no satisfactory manual solution, this problem can be worked around manually by putting \emph{inside} the third atom a \verb-\vphantom- having the same height as the first, so that the height affects the following atoms: -\exemple*{Vertical placement workaround}/\Huge\setatomsep{2em} -\chemfig{A^1-B-{\vphantom{A^1}C}-D}\qquad -\chemfig{E_1-F-{\vphantom{E_1}G}-H}/ - \section{Beyond chemistry}\label{style.noeuds} At heart \CF is a tool for drawing graphs, and this tool has been programmed to adapt it for chemistry. In some ways it is possible to return \CF to its roots to draw organization charts or other diagrams represented by graphs. @@ -1144,7 +1501,8 @@ The commands created by \CF are: \verb-\chemfig-& draws the molecule whose design is described by the \verb--\\ \verb-\printatom- & displays the atoms within the molecules. It can be redefined to customize the ouput. See page~\pageref{perso.affichage}\\ \verb-\setnodestyle{