From 0196ffc747bdb1ceb5480007922d91f59deda3d4 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 8 Mar 2018 22:54:10 +0000 Subject: chemfig (8mar18) git-svn-id: svn://tug.org/texlive/trunk@46890 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/generic/chemfig/README | 10 +- .../texmf-dist/doc/generic/chemfig/chemfig-en.pdf | Bin 1038230 -> 1056676 bytes .../texmf-dist/doc/generic/chemfig/chemfig-en.tex | 1181 +++++++++----------- .../texmf-dist/doc/generic/chemfig/chemfig-fr.pdf | Bin 1066206 -> 1082107 bytes .../texmf-dist/doc/generic/chemfig/chemfig-fr.tex | 1162 +++++++++---------- 5 files changed, 1037 insertions(+), 1316 deletions(-) (limited to 'Master/texmf-dist/doc') diff --git a/Master/texmf-dist/doc/generic/chemfig/README b/Master/texmf-dist/doc/generic/chemfig/README index 071cdd14017..a460aa29e00 100644 --- a/Master/texmf-dist/doc/generic/chemfig/README +++ b/Master/texmf-dist/doc/generic/chemfig/README @@ -1,14 +1,14 @@ ___________________________________ The - ChemFig package - v1.2e + Chemfig package + v1.3 - 2017/05/20 + 2018/03/08 ___________________________________ Maintainer: Christian Tellechea -E-mail : unbonpetit@openmailbox.org +E-mail : unbonpetit@netc.fr Comments, bug reports and suggestions are welcome. Licence : Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txt @@ -30,5 +30,3 @@ le dessin selon une syntaxe simple, souple et intuitive. Le dessin est fait avec l'extension tikz. ChemFig fonctionne donc en mode dvi ou pdf. - - Christian Tellechea diff --git a/Master/texmf-dist/doc/generic/chemfig/chemfig-en.pdf b/Master/texmf-dist/doc/generic/chemfig/chemfig-en.pdf index 890311b236a..99542e6bbff 100644 Binary files a/Master/texmf-dist/doc/generic/chemfig/chemfig-en.pdf and b/Master/texmf-dist/doc/generic/chemfig/chemfig-en.pdf differ diff --git a/Master/texmf-dist/doc/generic/chemfig/chemfig-en.tex b/Master/texmf-dist/doc/generic/chemfig/chemfig-en.tex index c2dc6bd5c5f..918ad6387d7 100644 --- a/Master/texmf-dist/doc/generic/chemfig/chemfig-en.tex +++ b/Master/texmf-dist/doc/generic/chemfig/chemfig-en.tex @@ -1,98 +1,24 @@ -% __________________________________________________________________ -% | | -% | chemfig v1.2e | -% |__________________________________________________________________| -% -% This is chemfig_doc_en.tex, the LaTeX code of the chemfig English -% documentation. Translation by Theo Hopman & Nikola Castillo -% -% Maintainer : Christian Tellechea -% E-mail : unbonpetit@openmailbox.org -% Comments, bug reports and suggestions are welcome. -% Licence : Released under the LaTeX Project Public License v1.3c -% or later, see http://www.latex-project.org/lppl.txt -% Package URL: http://ctan.org/pkg/chemfig -% Copyright : Christian Tellechea 2010-2015 -% -% The "chemfig" package consists of the 8 following files: -% - chemfig.tex (this file) -% - chemfig.sty (the package file for LaTeX) -% - t-chemfig.tex (the package file for conTeXt) -% - README -% - chemfig_doc_en.tex, chemfig_doc_en.pdf (english manual) -% - chemfig_doc_fr.tex, chemfig_doc_fr.pdf (manual in french) -% -% -------------------------------------------------------------------- -% This work may be distributed and/or modified under the -% conditions of the LaTeX Project Public License, either version 1.3 -% of this license or (at your option) any later version. -% The latest version of this license is in -% -% % http://www.latex-project.org/lppl.txt -% -% and version 1.3 or later is part of all distributions of LaTeX -% version 2005/12/01 or later. -% -------------------------------------------------------------------- -% This work has the LPPL maintenance status `maintained'. -% -% The Current Maintainer of this work is Christian Tellechea -% -------------------------------------------------------------------- \documentclass[10pt]{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[a4paper,margin=2.5cm,head=17pt,headsep=3mm,footskip=10mm]{geometry} \usepackage[bottom]{footmisc} -\usepackage{libertine} -\renewcommand*\oldstylenums[1]{{\fontfamily{fxlj}\selectfont #1}} +\usepackage{libertine,amsmath,array,longtable,xspace,fancybox,boites,textcomp,enumitem,chemfig,fancyhdr} \usepackage[scaled=0.8]{luximono} -\usepackage{amsmath} -\usepackage{array} -\usepackage{longtable} -\usepackage{xspace} -\usepackage{fancybox} -\usepackage{boites} -\usepackage{textcomp} -\usepackage{enumitem} -\usepackage{chemfig} \usetikzlibrary{decorations.pathmorphing} \usetikzlibrary{decorations.markings} \usetikzlibrary{matrix} -\usepackage{siunitx} -\usepackage{emerald} -\usepackage{xstring} \usepackage[protrusion=true,expansion,final,babel=true]{microtype} -\usepackage{fancyhdr} \fancypagestyle{plain}{% - \fancyhead[L]{\colorbox{gray!40}{\rlap{\small\bfseries\CF}\kern\dimexpr\linewidth-2\fboxsep}} + \fancyhead[L]{} \fancyhead[C]{} - \fancyhead[R]{\scriptsize\slshape\leftmark\kern0.5em} - \fancyfoot[l]{\tiny\LaTeX ed by Christian \textsc{Tellechea}, the \today.} + \fancyhead[R]{} + \fancyfoot[l]{\tiny Compiled the \today.} \fancyfoot[c]{} \fancyfoot[r]{\thepage}} \renewcommand\headrulewidth{0pt} \makeatletter -\let\gobble\@gobble -\newcommand\idx{\@ifstar{\let\print@or@not\@gobble\idx@}{\let\print@or@not\@firstofone\idx@}} -\newcommand\idx@[1]{% - \ifcat\expandafter\noexpand\@car#1\@nil\relax% si sc - \expandafter\ifx\@car#1\@nil\protect - \index{#1}% - \print@or@not{#1}% - \else - \saveexpandmode\expandarg - \StrSubstitute{\string#1}{\string @}{\@empty\protect\symbol{'100}}[\temp@]% - \StrGobbleLeft\temp@1[\temp@]% - \restoreexpandmode - \expandafter\index\expandafter{\temp@ @\protect\texttt{\protect\textbackslash\temp@}}% - \print@or@not{\texttt{\string#1}}% - \fi - \else - \index{#1}% - \print@or@not{#1}% - \fi -} - \newcommand\make@car@active[1]{% \catcode`#1\active \begingroup @@ -142,7 +68,7 @@ \def\bkvz@top{\hbox to \hsize{% \vrule\@width\fboxrule\@height\fboxrule \leaders\bkvz@bottom\hfill - \ECFAugie + \sffamily \fboxsep\z@ \colorbox{black}{\kern0.25em\color{white}\footnotesize\lower0.5ex\hbox{\strut#2}\kern0.25em}% \leaders\bkvz@bottom\hfill @@ -163,7 +89,7 @@ \vskip0.5ex \boxput*(0,1) {\fboxsep\z@ - \hbox{\ECFAugie\colorbox{black}{\leavevmode\kern0.25em{\color{white}\footnotesize\strut#2}\kern0.25em}}% + \hbox{\sffamily\colorbox{black}{\leavevmode\kern0.25em{\color{white}\footnotesize\strut#2}\kern0.25em}}% }% {\fboxsep5pt \fbox{% @@ -179,7 +105,7 @@ \endgroup } -\newcommand\falseverb[1]{{\ttfamily\detokenize{#1}}} +\newcommand\falseverb[1]{{\ttfamily\detokenize\expandafter{\string#1}}} \long\def\centerverb#1{% \def\centerverb@i##1#1{##1\hfill\null\par\egroup} @@ -190,41 +116,40 @@ \@vobeyspaces \centerverb@i} +\def\CFengdate@i#1/#2/#3\@nil{\number#3\relax\ifnum#3=1 \ier{}\fi\space \ifcase#2 \or january\or february\or march\or april\or may\or june\or july\or august\or september\or october\or november\or december\fi\space#1} +\edef\CFengdate{\expandafter\CFengdate@i\CFdate\@nil} + +\DeclareRobustCommand\CF{% + \textsf{% + chem% + \if\string b\detokenize\expandafter{\f@series}% + \lower0.01em\hbox{\itshape f}\kern-0.06em + \else + \lower0.045em\hbox{\kern-0.05em \itshape f}\kern0.026em + \fi ig% + }% + \xspace +} \makeatother \usepackage[english]{babel} \def\degres{\ensuremath{{}^\circ}} - -\newcommand\CF{{\ECFAugie ChemFig}\xspace} \newcommand\TIKZ{ti\textit kz\xspace} \newcommand\molht[1]{\begingroup\parskip3.5pt\par\hfill\chemfig{#1}\hfill\null\par\endgroup} \newcommand\boxednode[2]{\fbox{$\mathrm{#1}\vphantom{M_1}$}_{#2}} \newcommand\boxedfalseverb[1]{{\fboxsep0pt\fbox{\vphantom|\falseverb{#1}}}} +\newcommand*\chevrons[1]{\textlangle\textit{#1}\textrangle} +\newcommand*\CFkey[1]{{\color{teal}\texttt{\detokenize{#1}}}} +\newcommand*\CFval[1]{{\color{teal}\textlangle\textit{#1}\textrangle}} +\newcommand*\CFkv[2]{\CFkey{#1}{\color{teal}${}={}$}\CFval{#2}} +\newcommand*\CFparam[1]{\CFkey{#1}&\ifcat\relax\detokenize\expandafter\expandafter\expandafter{\useKV[chemfig]{#1}}\relax \textlangle\textit{empty}\textrangle\else\texttt{\detokenize\expandafter\expandafter\expandafter{\useKV[chemfig]{#1}}}\fi\\} \usepackage[plainpages=false,pdfpagelabels,bookmarks=true,bookmarksopen=true,colorlinks=true,hyperfootnotes=false,filecolor=black,linkcolor=blue,urlcolor=magenta,pdfauthor={Christian TELLECHEA},pdftitle={ChemFig},pdfsubject={Draw 2D molecule with LaTeX},pdfkeywords={ChemFig},pdfcreator={LaTeX}]{hyperref} \csname @addtoreset\endcsname{section}{part} \usepackage{titlesec} -\titleformat{\part}[display] - {\normalfont\Large\filcenter\sffamily\bfseries}% - {\LARGE\MakeUppercase{\partname~\thepart}}% - {1pc}% - {\titlerule\vspace{1pc}\Huge} - -\begin{filecontents*}{chemfig_doc_en.ist} -% Fichier de style makeindex -heading_prefix "{\\bfseries\\hfill " -heading_suffix "\\hfill\\null}\\nopagebreak\n" -headings_flag 1 -symhead_positive "Symbols" -symhead_negative "Symbols" -delim_0 "\\dotfill" -delim_1 "\\dotfill" -delim_2 "\\dotfill" -\end{filecontents*} - -\usepackage{makeidx} -\makeindex +\titleformat{\part}[display]{\normalfont\filcenter\sffamily\bfseries}{}{0pt}{\Huge} + \begin{document} \begin{titlepage} \catcode`!12 @@ -236,27 +161,24 @@ delim_2 "\\dotfill" \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\par - \Large v\csname CF@ver\endcsname\par\bigskip - \footnotesize\csname CF@en@date\endcsname\par + \color{white}\sffamily\fontsize{50pt}{50pt}\selectfont\CF\par + \Large v\CFver\par\bigskip + \footnotesize\CFengdate\par \normalsize Christian Tellechea\par\vskip1.5cm \huge A \TeX{} package for drawing molecules% \end{center} \vskip4cm \begin{center} \scriptsize - \setatomsep{3em}% + \setchemfig{atom sep=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}% + {\sffamily\small Taxotere}% \end{center} \vskip1.5cm \hfill \hbox to 0pt{\hss\scriptsize - \setbondoffset{1pt} - \setatomsep{2.5em} - \setcompoundsep{5em} - \setarrowoffset{6pt} + \setchemfig{bond offset=1pt,atom sep=2.5em,compound sep=5em,arrow offset=6pt} \schemestart \chemfig{(-[:-150]R')(-[:-30]R)=[2]N-[:30]OH} \arrow{<=>[\chemfig{H^\oplus}]} @@ -279,7 +201,7 @@ delim_2 "\\dotfill" \chemfig{*6(R\rlap{$'$}-\chembelow{N}{H}-(-R)(=[2]O))} \schemestop\hss}\hfill\null \begin{center} - \ECFAugie\small The Beckmann rearrangement% + \sffamily\small The Beckmann rearrangement% \end{center} \end{titlepage} \parindent0pt\pagestyle{plain} @@ -289,59 +211,112 @@ delim_2 "\\dotfill" \setitemize{leftmargin=3em,topsep=0pt,parsep=0pt,itemsep=0pt} \part{Introduction} -\section{New in v1.2} -\paragraph{Arrow tips} The default arrow tip in \CF, called ``CF'', is now defined with the macro \verb|\pgfdeclarearrow| and is based on the «Stealth» tip. For this, th ``arrows.meta''e library is loaded. Therefore, ``CF'' and ``Stealth'' tips have the same custumization options. The arrow tip can now be defined with \verb|\setarrowdefault|. - -\exemple{Tip customization}/1) Default arrow:\par -\schemestart A\arrow B\schemestop - -2) Custom arrow:\par -\schemestart - A\arrow[,,->] B\arrow[,,-{Triangle[slant=0.5,blue,width=10pt]}] - C\arrow[,,-{CF[sharp]}] D -\schemestop\par +\section{New in v1.3} +\subsection{Key and values system} +Given the large number of parameters and the number of macros used to specify them, standardization has become necessary, both to simplify the use of \CF and to facilitate the creation of new parameters. -3) Default style modified:\par -\setarrowdefault{,,-{CF[red,open,length=15pt,line width=1pt]}} -\schemestart A\arrow B\schemestop/ - -\paragraph{Angle increment} When the angle of a bond is specified with \verb|[]| where \verb|| is an integer, the final angle is $45\times\text{n}$. From now on, the 45 default increment can be set with \verb|\setangleincrement{}| : +Most of the settings are now specified \emph{via} the macro \verb|\setchemfig| whose argument is a comma separated list of \chevrons{keys}${}={}$\chevrons{value}. Although still usable for the moment, all macros that specified one or more parameters are now obsolete. +\begin{center} + \color{red} + \textbf{Warning}: all the following obsolete macros will be deleted in a future version. +\end{center} +\begingroup +\spaceskip=0.75em plus7pt minus 7pt +\verb-\setcrambond-, \verb-\setatomsep-, \verb-\enablefixedbondlength-, \verb-\disablefixedbondlength-, \verb-\setbondoffset-, \verb-\setdoublesep-, \verb-\setangleincrement-, \verb-\setnodestyle-, \verb-\setbondstyle-, \verb-\setlewis-, \verb-\setlewisdist-, \verb-\setstacksep-, \verb-\setcompoundstyle-, \verb-\setarrowdefault-, \verb-\setandsign-, \verb-\setarrowoffset-, \verb-\setcompoundsep-, \verb-\setarrowlabelsep-, \verb-\enablebondjoin-, \verb-\disablebondjoin-, \verb-\schemedebug-.% +\endgroup -\exemple{Angle increment}/Default increment: \chemfig{-[1]-[-1]-[1]-[-1]} +Running them sends a warning message about their obsolescence in the log file. -30 increment: -\setangleincrement{30}\chemfig{-[1]-[-1]-[1]-[-1]}/ +\subsection{The syntax of the \texttt{\textbackslash chemfig} macro} +\begin{center} + \color{red} + The starred version of the macro \verb-\chemfig- is now obsolete and will no longer be supported in a future version. +\end{center} +To set a fixed bond length, use the key \CFkey{fixed length} and set it to \CFval{true}. -\paragraph{Macros \texttt{\string\chemrel} et \texttt{\string\chemsign}} These macros are now obsolete and are removed from the \CF package. To write chemical reactions, inside a \verb|\schemestart|...\verb|\schemestop| environement, use \verb|\arrow| and \verb|\+|. +On the other hand, the two optional arguments that the macro \verb-\chemfig- accepted, in order to specify parameters for tikz, are also obsolete. From now on, the two keys \CFkey{chemfig style} and \CFkey{atom style} must be preferred, see page~\pageref{arguments.optionnels}. -\paragraph{Librairy «external»} -Taking into account the limitations pointed in the documentation of the "external" librairy, the \verb|\chemfig| macro is now compatible with this librairy. +The aim is that in the long run, the macro \verb-\chemfig- accepts only \emph{a single} optional argument containing a list of parameters set via \chevrons{key}${}={}$\chevrons{value}. +\begin{center} + \color{red} + The two optional arguments that the macro \verb-\chemfig- accepts will be removed in a future version. +\end{center} -\paragraph{Starred macro \texttt{\string\setcrambond*}} -When the \verb|\setcrambond| is starred, the dashed Cram bonds are drawn with a rectangle instead of a triangle. +\subsection{Keys and their default value} +The chemfig settings, identified by their \chevrons{keys} and default \chevrons{value} are: +\begin{center} +\begin{longtable}{rl}\hline + \chevrons{clés} & \chevrons{valeurs} par défaut\\\hline\endhead + \CFparam{chemfig style} + \CFparam{atom style} + \CFparam{bond join} + \CFparam{fixed length} + \CFparam{cram rectangle} + \CFparam{cram width} + \CFparam{cram dash width} + \CFparam{cram dash sep} + \CFparam{atom sep} + \CFparam{bond offset} + \CFparam{double bond sep} + \CFparam{angle increment} + \CFparam{node style} + \CFparam{bond style} + \CFparam{lewis | width} + \CFparam{lewis sep} + \CFparam{lewis length} + \CFparam{lewis style} + \CFparam{lewis dist} + \CFparam{lewis radius} + \CFparam{cycle radius coeff} + \CFparam{stack sep} + \CFparam{scheme debug} + \CFparam{compound style} + \CFparam{compound sep} + \CFparam{arrow offset} + \CFparam{arrow angle} + \CFparam{arrow coeff} + \CFparam{arrow style} + \CFparam{arrow double sep} + \CFparam{arrow double coeff} + \CFparam{arrow double harpoon} + \CFparam{arrow label sep} + \CFparam{arrow head} + \CFparam{+ sep left} + \CFparam{+ sep right} + \CFparam{+ vshift}\hline +\end{longtable} +\end{center} -\exemple{Dashed Cram bonds}/No starred: \setcrambond{1ex}{.5pt}{.5pt}\chemfig{A>:B<:C} +The macro \verb|\resetchemfig| can be run at any time to reset all parameters to their default value. -Starred: \setcrambond*{1ex}{.5pt}{.5pt}\chemfig{A>:B<:C}/ +The following \chevrons{parameters} are new and are therefore accessible only \emph{via} the macro \verb|setchemfig|: +\begin{enumerate} + \item \CFkey{lewis radius} is the radius of a Lewis decoration disc; + \item \CFkey{arrow double sep} is the vertical spacing between the double arrows in the reaction schemes; + \item \CFkey{arrow double coeff} is the shrinkage coefficient of the small compared to the large one for the \verb|<->>| and \verb|<<->| arrows; + \item \CFkey{arrow double harpoon} is a boolean that specifies whether double arrows should be "harpoon" or not; + \item \CFkey{cycle radius coeff} represents the shrinkage coefficient of the circle or arc of a circle in the cycles; + \item \CFkey{arrow head} is the default arrowhead style. +\end{enumerate} \section{Presenting \protect\CF} To use this package, start by adding the following code to the preamble: \begin{itemize} - \item {\color{blue}\verb-\input chemfig.tex-} with $\varepsilon$\TeX\idx*\input; - \item {\color{blue}\verb-\usepackage{chemfig}-} with \LaTeX\idx*{Latex@\protect\LaTeX}\idx*\usepackage; - \item {\color{blue}\verb-\usemodule[chemfig]-} with Con\TeX t\idx*{ConTeXt@Con\protect\TeX{}t}\idx*\usemodule. + \item {\color{blue}\verb-\input chemfig.tex-} with $\varepsilon$\TeX; + \item {\color{blue}\verb-\usepackage{chemfig}-} with \LaTeX; + \item {\color{blue}\verb-\usemodule[chemfig]-} with Con\TeX t\falseverb*{ConTeXt@Con\protect\TeX{}t}. \end{itemize} -In all cases, the \TIKZ\idx*{tikz} package, if not loaded before, is loaded by \CF. +In all cases, the \TIKZ package, if not loaded before, is loaded by \CF. -The most important command for drawing molecules is \verb|\chemfig{}|\idx*\chemfig. The argument \verb|code| is a set of characters describing the structure of the molecule according to the rules which are described in this manual. +The most important command for drawing molecules is \verb|\chemfig{}|. The argument \verb|code| is a set of characters describing the structure of the molecule according to the rules which are described in this manual. Care has been taken to make it possible to draw the greatest possible number of molecular configurations, while maintaining a simple, flexible, and intuitive syntax. Despite this, the \verb-- which describes the 2D structure of the molecule increases in complexity in proportion to that of the molecule being drawn. -The command \verb|\chemfig| draws a molecule using the commands provided by the \TIKZ\idx*{tikz} package, placed inside a \verb|tikzpicture|\idx*{tikzpicture} environment. The choice of \TIKZ implies that: +The command \verb|\chemfig| draws a molecule using the commands provided by the \TIKZ package, placed inside a \verb|tikzpicture| environment. The choice of \TIKZ implies that: \begin{itemize} -\item the user has a choice of compilation method\idx*{compilation method}: pdf\LaTeX{} can be used equally well in \idx{dvi mode} (tex $\longrightarrow$ dvi $\longrightarrow$ ps $\longrightarrow$ pdf) or in \idx{pdf mode} (tex $\longrightarrow$ pdf). In effect \TIKZ, via the underlying \idx{pgf}, gives identical graphical results in the two modes; -\item the \idx{bounding box} is automatically calculated by \TIKZ and the user need not worry about any overlap with the text. However, care must be taken with alignment when the molecule is drawn in a paragraph. In the following example, we have drawn the \idx{bounding box} for the molecule: {\fboxsep0pt \fbox{\chemfig{H_3C-C(-[:-30]OH)=[:30]O}}}. \CF always places the first atom of the molecule on the \idx{baseline} of the preceding code. +\item the user has a choice of compilation method: pdf\LaTeX{} can be used equally well in \falseverb{dvi mode} (tex $\longrightarrow$ dvi $\longrightarrow$ ps $\longrightarrow$ pdf) or in \falseverb{pdf mode} (tex $\longrightarrow$ pdf). In effect \TIKZ, via the underlying \falseverb{pgf}, gives identical graphical results in the two modes; +\item the \falseverb{bounding box} is automatically calculated by \TIKZ and the user need not worry about any overlap with the text. However, care must be taken with alignment when the molecule is drawn in a paragraph. In the following example, we have drawn the \falseverb{bounding box} for the molecule: {\fboxsep0pt \fbox{\chemfig{H_3C-C(-[:-30]OH)=[:30]O}}}. \CF always places the first atom of the molecule on the \falseverb{baseline} of the preceding code. \end{itemize} \section{Acknowledgment} @@ -359,7 +334,7 @@ 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{>} \boxedfalseverb{@}}. \CF ignores all characters inside braces when splitting groups into atoms\idx*{separating atom mechanism}. +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: \renewcommand*\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}} @@ -368,7 +343,7 @@ Therefore the first group of atoms ``$\mathrm{H_3C}$'' is split into two atoms: A space is ignored when at the begining of a group of atoms. \section{Different types of bonds} -\idx*{bond!types}For \CF, bonds between two atoms are one of nine types, represented by the characters \boxedfalseverb-, \boxedfalseverb=, \boxedfalseverb~, \boxedfalseverb>, \boxedfalseverb<, \boxedfalseverb{>:}, \boxedfalseverb{<:}, \boxedfalseverb{>|} and \boxedfalseverb{<|} :\label{types.liaisons} +For \CF, bonds between two atoms are one of nine types, represented by the characters \boxedfalseverb-, \boxedfalseverb=, \boxedfalseverb~, \boxedfalseverb>, \boxedfalseverb<, \boxedfalseverb{>:}, \boxedfalseverb{<:}, \boxedfalseverb{>|} and \boxedfalseverb{<|} :\label{types.liaisons} \begin{center} \begin{tabular}{>{\centering\arraybackslash}m{1.7cm}>{\centering\arraybackslash}m{3cm}>{\centering\arraybackslash}m{2cm}m{4cm}} \hline @@ -384,9 +359,9 @@ Bond \#&Code &Result &Bond type\\\hline 9 &\verb+\chemfig{A<|B}+&\chemfig{A<|B}&left Cram, hollow\\\hline \end{tabular} \end{center} -\label{setdoublesep}The command \verb-\setdoublesep{}-\idx*{\setdoublesep} adjusts the spacing between the lines in double or triple bonds. This spacing is 2pt by default. +\label{double bond sep}The \chevrons{key} \verb-\double bond sep=- adjusts the spacing between the lines in double or triple bonds. This spacing is 2pt by default. -\label{longueur.liaison}\idx*{bond!length}We must understand that when a bond is made between two atoms, these atoms are contained within invisible rectangular boxes. The centres of these two rectangles are separated by an adjustable distance $\Delta$ called the ``interatomic distance''. Furthermore, bonds do not connect to the exact edges of the rectangles: a length $\delta$, also adjustable, separates the edges of the rectangles and the beginning and end of the bond line. The rectangular boxes are made visible in the diagram below to help understanding. +\label{longueur.liaison}We must understand that when a bond is made between two atoms, these atoms are contained within invisible rectangular boxes. The centres of these two rectangles are separated by an adjustable distance $\Delta$ called the ``interatomic distance''. Furthermore, bonds do not connect to the exact edges of the rectangles: a length $\delta$, also adjustable, separates the edges of the rectangles and the beginning and end of the bond line. The rectangular boxes are made visible in the diagram below to help understanding. \begin{center} \begin{tikzpicture}[every node/.style={anchor=base,inner sep=1.5pt,outer sep=0pt,minimum size=0pt},baseline] \node[draw] at(0,0)(aa){\huge A}; @@ -410,82 +385,80 @@ Bond \#&Code &Result &Bond type\\\hline \end{tikzpicture} \end{center} -\label{setatomsep}The macro \verb-\setatomsep{}-\idx*{\setatomsep} adjusts the interatomic distance $\Delta$. If the \verb-- is empty, it takes the default value of 3em. This command, like all other settings commands, affects all the following molecules. +\label{atom sep}The \chevrons{key} \CFkv{atom sep}{dim} adjusts the interatomic distance $\Delta$. This setting, like all other settings, affects all the following molecules. -\exemple{Interatomic distance}|\setatomsep{2em}\chemfig{A-B}\par -\setatomsep{50pt}\chemfig{A-B}| +\exemple{Interatomic distance}|\setchemfig{atom sep=2em}\chemfig{A-B}\par +\setchemfig{atom sep=50pt}\chemfig{A-B}| -\label{setbondoffset}\idx*{\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}| +\label{bond offset}The \chevrons{key} \CFkv{bond offset}{dim} sets the spacing $\delta$ between the bond line and the atom. Its default value is 2pt. +\exemple{Trimming bonds}|\setchemfig{bond offset=0pt}\chemfig{A-B}\par + \setchemfig{bond offset=5pt}\chemfig{A-B}| If one bond is followed immediately by another, then \CF inserts an empty group \verb-{}-. Around this empty group the separation $\delta$ is zero: \exemple{Empty groups}/\chemfig{A-B=-=C}/ -\label{setbondstyle}\idx*{\setbondstyle}The \verb-\setbondstyle{}- command sets the style for all the bonds drawn thereafter. The \verb-- is empty by default. To custom a single bond, see page~\pageref{perso-liaisons}. -\exemple{Style of bonds}/\setbondstyle{line width=1pt,red} +\label{bond style}The \chevrons{key} \CFkv{bond style}{tikz code} sets the style for all the bonds drawn thereafter. The \CFval{tikz code} is empty by default. To custom a single bond, see page~\pageref{perso-liaisons}. +\exemple{Style of bonds}/\setchemfig{bond style={line width=1pt,red}} \chemfig{A-B=C>|D:F}/ -\label{modif.retrait} The spacing $\delta$ for just one bond can be specified with the character \verb-#-\idx*{\protect\symbol{'043}@\protect\texttt{\protect\symbol{'043}}}. This character must be placed \emph{immediately} after the bond symbol and has one required argument between parentheses of the form ``\verb-#(,)-'', where \verb-- is the spacing $\delta$ at the beginning of the bond and \verb-- is the that at the end. If \verb-- is omitted, the spacing at the end of the bond takes the value of $\delta$ in effect at that time. One can see in the example how the shortening, set to 4pt to be more visible, is nullified for the bond arriving at ``B'', then for the one leaving ``B'', and finally for both: +\label{modif.retrait} The spacing $\delta$ for just one bond can be specified with the character \verb-#-. This character must be placed \emph{immediately} after the bond symbol and has one required argument between parentheses of the form ``\verb-#(,)-'', where \verb-- is the spacing $\delta$ at the beginning of the bond and \verb-- is the that at the end. If \verb-- is omitted, the spacing at the end of the bond takes the value of $\delta$ in effect at that time. One can see in the example how the shortening, set to 4pt to be more visible, is nullified for the bond arriving at ``B'', then for the one leaving ``B'', and finally for both: \begingroup \catcode`\#12 -\exemple{Fine adjustment of bond shortening}/\setbondoffset{4pt} +\exemple{Fine adjustment of bond shortening}/\setchemfig{bond offset=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 -By default, all atoms within groups of atoms are typeset in \idx{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}.}: +By default, all atoms within groups of atoms are typeset in \falseverb{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}| -There are settings specifically for Cram bonds\idx*{Cram representation}\idx*\setcrambond. This syntax is used: \label{setcrambond} -\centerverb/\setcrambond{}{}{}/ -\smallskip - -Any empty argument takes its default value. The three arguments are: +There are settings specifically for Cram bonds: \begin{itemize} - \item \verb-- is the size of the base of the triangle, and is 1.5pt by default; - \item \verb-- is the thickness of the dots, and is 1pt by default; - \item \verb-- is the spacing between the dots, and is 2pt by default. + \item \CFkv{cram width}{dim} is the size of the base of the triangle, and is 1.5pt by default; + \item \CFkv{cram dash width}{dim} is the thickness of the dots, and is 1pt by default; + \item \CFkv{cram dash sep}{dim} is the spacing between the dots, and is 2pt by default. \end{itemize} Here is an example where the three dimensions are changed: -\exemple{Modified Cram bonds}-\setcrambond{10pt}{0.4pt}{1pt} - \chemfig{A>B>:C>|D}- +\exemple{Modified Cram bonds}-\setchemfig{cram width=10pt, + cram dash width=0.4pt, + cram dash sep=1pt} +\chemfig{A>B>:C>|D}- \section{Bond angle} -\idx*{bond!angle}\idx*{bond!optional argument|(}Each bond takes an optional argument in brackets. This optional argument can adjust every aspect of a bond, and consists of five optional fields separated by commas. The first of these fields defines the bond angle. Angles increase counterclockwise, and are relative to the horizontal. If the angle field is empty, the angle takes its default value of 0\degres. We will see later how to change this default. +Each bond takes an optional argument in brackets. This optional argument can adjust every aspect of a bond, and consists of five optional fields separated by commas. The first of these fields defines the bond angle. Angles increase counterclockwise, and are relative to the horizontal. If the angle field is empty, the angle takes its default value of 0\degres. We will see later how to change this default. There are several ways of specifying the bond angle. \subsection{Predefined angles} -\idx*{bond!angle!predefined}When the angle field contains an integer, this represents the angle the bond makes relative to the horizontal, in multiples of 45\degres. For example, \verb-[0]- specifies an angle of 0\degres, \verb-[1]- is 45\degres, and so on. +When the angle field contains an integer, this represents the angle the bond makes relative to the horizontal, in multiples of 45\degres. For example, \verb-[0]- specifies an angle of 0\degres, \verb-[1]- is 45\degres, and so on. \exemple{Predefined angles}|\chemfig{A-B-[1]C-[3]-D-[7]E-[6]F}| These angles remain valid if the atoms are empty, and this is the case for all the features we will see below: \exemple{Predefined angles with empty groups}|\chemfig{--[1]-[3]--[7]-[6]}| -For those who find this "ugly\footnote{See \texttt{\detokenize{http://tex.stackexchange.com/questions/161796/ugly-bond-joints-in-chemfig detokenize}}}", it is now possible connect the single bonds with a slightly increased compilation time. The macro \idx\enablebondjoin{} enables this feature and \idx\disablebondjoin{} disables (better behavior, set by default). +For those who find this "ugly\footnote{See \texttt{\detokenize{http://tex.stackexchange.com/questions/161796/ugly-bond-joints-in-chemfig detokenize}}}", it is now possible connect the single bonds with a slightly increased compilation time. The boolean \chevrons{key} \CFkv{bond join}{boolean} macro enables this feature when \CFval{true} and disables it when \CFval{false}, which is the better behavior, set by default. -\exemple{Connecting bonds}/\setbondstyle{line width=3pt} +\exemple{Connecting bonds}/\setchemfig{bond style={line width=3pt}} \chemfig{-[1]-[7]} et -\enablebondjoin\chemfig{-[1]-[7]}\disablefixedbondlength/ +\setchemfig{bond join=true}\chemfig{-[1]-[7]}/ -\label{setangleincrement}The \idx\setangleincrement{} macro sets the default angle used to calculate the angle of a bond: +\label{angle increment}The \chevrons{key} \CFkv{angle increment}{angle} sets the default angle used to calculate the angle of a bond: \exemple{Set the predefined angle}/Default (45) : \chemfig{-[1]-[-1]-[1]-[-1]} -\setangleincrement{30} +\setchemfig{angle increment=30} Angle of 30 : \chemfig{-[1]-[-1]-[1]-[-1]}/ \subsection{Absolute angles} -\idx*{bond!angle!absolute}If one wishes to specify an angle in degrees relative to the horizontal, then the optional angle field must take this form: \verb-[:]-. If necessary, the \verb-- is reduced to the interval $[0,360)$: +If one wishes to specify an angle in degrees relative to the horizontal, then the optional angle field must take this form: \verb-[:]-. If necessary, the \verb-- is reduced to the interval $[0,360)$: \exemple{Absolute angles}/\chemfig{A-[:30]B=[:-75]C-[:10]D-[:90]>|[:60]-[:-20]E-[:0]~[:-75]F}/ \subsection{Relative angles}\label{angle.relatif} -\idx*{bond!angle!relative}It is often useful to specify a bond angle relative to the preceding bond. This syntax must be then be used: \verb-[::]-. The sign of the \verb-- can be omitted if it is a \verb-+-. +It is often useful to specify a bond angle relative to the preceding bond. This syntax must be then be used: \verb-[::]-. The sign of the \verb-- can be omitted if it is a \verb-+-. Here is a molecule where the first bond has an absolute angle of $-5\degres$, and the rest of the bond angles are incremented by 20\degres: \exemple{Result of relative angles}|\chemfig{A-[:-5]-[::+20]-[::20]B-[::+20]-[::20]C-[::20]}| @@ -494,7 +467,7 @@ One can ``break'' a chain of relative angles by putting an absolute or predefine \exemple{Result of relative angles followed by absolute}|\chemfig{A-[:-5]-[::20]-[::20]B-[7]-[::20]C-[::20]}| \section{Length of a bond} -\idx*{bond!length}Rather than speaking of length of a bond, we should use the term interatomic spacing. If effect, only the interatomic spacing is adjustable with \idx{\setatomsep} as we have seen on page~\pageref{longueur.liaison}. Once this parameter is set, the length of a bond depends on the content of atoms and, to a lesser extent, the angle the bond makes with the horizontal. It should be obvious that two ``slimmer'' atoms will have larger edge separations than two which are larger. This can be seen easily in the following example where an ``I'' atom is narrower than an ``M'' atom, which means that the bond between the ``I'' atoms is longer than that between the ``M'' atoms: +Rather than speaking of length of a bond, we should use the term interatomic spacing. If effect, only the interatomic spacing is adjustable with \falseverb{atom sep} as we have seen on page~\pageref{longueur.liaison}. Once this parameter is set, the length of a bond depends on the content of atoms and, to a lesser extent, the angle the bond makes with the horizontal. It should be obvious that two ``slimmer'' atoms will have larger edge separations than two which are larger. This can be seen easily in the following example where an ``I'' atom is narrower than an ``M'' atom, which means that the bond between the ``I'' atoms is longer than that between the ``M'' atoms: \exemple{Influence of the size of atoms}|\chemfig{I-I}\par \chemfig{M-M}| @@ -503,11 +476,11 @@ This aspect of the size of atoms becomes particularly acute when the atom involv It is important to note that the exponent \verb+-+ is \emph{put inside braces}. If this were not done, \CF would stop the atom on this character, which is a bond character. The atom would then be ``\verb-B^-'', which would lead to unexpected results. -It is possible to change the behavior of \CF about the interatomic spacing. Indeed, when the \verb+\chemfig+ macro is immediately followed by a star, the macro \verb-\setatomsep{}-\idx*{\setatomsep} no longer defines the distance between the centers of atoms, denoted $\Delta$, but \emph{length of the bonds}. Consequently, the bonds have fixed lengths while the distance between the centers of the atoms is variable and depends on their size. Here is the diagram on page~\pageref{longueur.liaison} and what becomes with the macro \verb|\ chemfig*|: +It is possible to change the behavior of \CF about the interatomic spacing. Indeed, when the \verb+\chemfig+ macro is immediately followed by a star, the \chevrons{key} \CFkey{atom sep}no longer defines the distance between the centers of atoms, denoted $\Delta$, but \emph{length of the bonds}. Consequently, the bonds have fixed lengths while the distance between the centers of the atoms is variable and depends on their size. Here is the diagram on page~\pageref{longueur.liaison} and what becomes with the two boolean values of key \CFkey{fixed length}: \begin{center} \begin{tabular}{c@{\kern2cm}c} - macro \verb|\chemfig|¯o \verb|\chemfig*|\\[2ex] + \CFkv{fixed length}{false}&\CFkv{fixed length}{true}\\[2ex] \begin{tikzpicture}[every node/.style={anchor=base,inner sep=1.5pt,outer sep=0pt,minimum size=0pt},baseline] \node[draw] at(0,0)(aa){\huge A}; \node[draw]at(4,0)(bb){\huge B}; @@ -550,28 +523,27 @@ It is possible to change the behavior of \CF about the interatomic spacing. Inde \end{tabular} \end{center} -In rings, even with starred \verb|\chemfig*|, the default behaviour is restored in order to draw regular polygons. +In rings, even when \CFkv{fixed length}{true}, the default behaviour is restored for the bonds of the cylce, in order to draw regular polygons. \exemple{Fixed length bonds}/\chemfig{Cl-Cl}\par -\chemfig*{Cl-Cl}/ +\setchemfig{fixed length=true}\chemfig{Cl-Cl}/ -The macro \idx\enablefixedbondlength{} enables the ``fixed bond length behaviour'', even for non starred \verb|\chemfig| while \idx\disablefixedbondlength{} goes back to the default behaviour (fixed interatomic distance). - -Especially with the default behavior, to avoid too short bonds, it is sometimes necessary to increase (or perhaps reduce) the interatomic distance. For this, the optional argument to bonds is actually made up of several comma-separated fields. As we have seen, the first field specifies the angle. The second field, if it is not empty, is a coefficient which multiplies the default interatomic distance $\Delta$. Thus, writing \verb+-[,2]+ asks that this bond have the default angle (first field is empty) and that the atoms it connects be separated by twice the default distance\idx*{bond!length}. +Especially with the default behavior, to avoid too short bonds, it is sometimes necessary to increase (or perhaps reduce) the interatomic distance. For this, the optional argument to bonds is actually made up of several comma-separated fields. As we have seen, the first field specifies the angle. The second field, if it is not empty, is a coefficient which multiplies the default interatomic distance $\Delta$. Thus, writing \verb+-[,2]+ asks that this bond have the default angle (first field is empty) and that the atoms it connects be separated by twice the default distance. \exemple{Modified bond length}/\chemfig{A^{++}_{2}-[,2]B^{-}_3}\par \chemfig{A-B-[,2]C=[,0.5]D}\par \chemfig{-=[,1.5]-[,0.75]=[:-20,2]}/ -We can change the \idx{size of molecules} by altering the font size or the argument of \idx{\setatomsep}, possibly on both \footnote{You can also use the second optional argument of \texttt{\string\chemfig}, see page~\pageref{arguments.optionnels}.}, being careful to confine these changes within a group if we want to limit the scope: +We can change the \falseverb{size of molecules} by altering the font size or the \chevrons{key} \CFkey{atom sep}, possibly on both, being careful to confine these changes within a group if we want to limit the scope: \exemple{How to modify the size of molecule}/\normalsize \chemfig{H-[:30]O-[:-30]H}\par -\setatomsep{2.5em}\chemfig{H-[:30]O-[:-30]H}\par +\setchemfig{atom sep=2.5em} +\chemfig{H-[:30]O-[:-30]H}\par \small \chemfig{H-[:30]O-[:-30]H}\par \footnotesize \chemfig{H-[:30]O-[:-30]H}\par \scriptsize \chemfig{H-[:30]O-[:-30]H}\par \tiny \chemfig{H-[:30]O-[:-30]H}/ \section{Departure and arrival atoms} -\idx*{bond!departure and arrival atoms}A group of atoms can contain several atoms. Suppose we want to connect the group ``ABCD'' to the group ``EFG'' with a bond. \CF calculates which atom of the first group and which of the second group are to be connected by looking at the angle of bond relative to the horizontal. If the angle is between (but not including) $-90\degres$ and 90\degres{} (modulo 360\degres) then the bond is made between the last atom of the first group and the first atom of the second group. In all other cases, the bond is made between the first atom of the first group and the last atom of the second group. +A group of atoms can contain several atoms. Suppose we want to connect the group ``ABCD'' to the group ``EFG'' with a bond. \CF calculates which atom of the first group and which of the second group are to be connected by looking at the angle of bond relative to the horizontal. If the angle is between (but not including) $-90\degres$ and 90\degres{} (modulo 360\degres) then the bond is made between the last atom of the first group and the first atom of the second group. In all other cases, the bond is made between the first atom of the first group and the last atom of the second group. Here are some examples where the bond is in the interval $(-90,90)$, and where the bond is made between D and E: \exemple{Default atom connections}|\chemfig{ABCD-[:75]EFG}\quad @@ -593,15 +565,15 @@ where \verb-- and \verb-- are the numbers of the desired d \chemfig{ABCD-[:75,,3,2]EFG}| \section{Customization of bonds}\label{perso-liaisons} -\idx*{bond!customization}There is a fifth and last optional argument for bonds which is found after the fourth comma: +There is a fifth and last optional argument for bonds which is found after the fourth comma: \centerverb/[,,,,]/ \smallskip -\idx*{tikz}This \verb-- is passed directly to \TIKZ when the bond is drawn. There one can put characteristics such as colour (\verb-red-), dash type (\verb-dash pattern=on 2pt off 2pt-), thickness (\verb-line width=2pt-), or even decoration if the \TIKZ decoration library has been loaded. A bond can be made invisible by writing ``\verb-draw=none-''\idx*{bond!invisible}. To set several attributes, the syntax of \TIKZ is used, separating them by a comma: +This \verb-- is passed directly to \TIKZ when the bond is drawn. There one can put characteristics such as colour (\verb-red-), dash type (\verb-dash pattern=on 2pt off 2pt-), thickness (\verb-line width=2pt-), or even decoration if the \TIKZ decoration library has been loaded. A bond can be made invisible by writing ``\verb-draw=none-''. To set several attributes, the syntax of \TIKZ is used, separating them by a comma: \exemple{Passing tikz code}|\chemfig{A-[,,,,red]B}\par - \chemfig{A-[,,,,dash pattern=on 2pt off 2pt]B}\par - \chemfig{A-[,,,,line width=2pt]B}\par - \chemfig{A-[,,,,red,line width=2pt]B}| +\chemfig{A-[,,,,dash pattern=on 2pt off 2pt]B}\par +\chemfig{A-[,,,,line width=2pt]B}\par +\chemfig{A-[,,,,red,line width=2pt]B}| Numerous \TIKZ decoration libraries are available. For example, one can use the ``\verb-pathmorphing-'' library by putting \verb-\usetikzlibrary{decorations.pathmorphing}- in the preamble in order to draw wavy bonds: \exemple{Wavy bonds}|\chemfig{A-[,3,,,decorate,decoration=snake]B}| @@ -609,7 +581,7 @@ Numerous \TIKZ decoration libraries are available. For example, one can use the Cram bonds ignore thickness and dash settings. \section{Default values} -\idx*{chemfig@\protect\texttt{\protect\string\protect\chemfig}}At the beginning of each molecule, the default values for the optional arguments are initialized. They are: +At the beginning of each molecule, the default values for the optional arguments are initialized. They are: \begin{itemize} \item 0\degres{} for the bond angle; \item 1 for the length multiplication coefficient; @@ -625,9 +597,9 @@ Thus, if the code of a molecule begins with \verb-[:20,1.5]-, then all the bonds \exemple{Overriding default values}|\chemfig{[:20,1.5]A-B-C-[:-80,0.7]D-E-F}| If something odd like \verb-[1,1.5,2,2,red,thick]- is written, then unless otherwise indicated all the bonds will have an angle of 45\degres{}, the interatomic distances will be 1.5 times the default distance, the bonds will begin and end on the second atom of each group, and the bonds will be red and thick: -\exemple{Default values}|\chemfig{[1,1.5,2,2,red,thick]ABC-DEF=GHI}|\idx*{bond!optional argument|)} +\exemple{Default values}|\chemfig{[1,1.5,2,2,red,thick]ABC-DEF=GHI}| -\section{Branches}\idx*{branched molecule} +\section{Branches} \subsection{Principle} Up to now, all the molecules have been linear, which is rare. A sub-molecule can be attached to an atom by following the atom with \verb-- in parentheses. This \verb-- is the code of the submolecule which will be attached to the atom. @@ -663,7 +635,7 @@ Because we used only relative angles, we can rotate this molecule by giving a de \exemple[70]{Rotation of a molecule}|\chemfig{[:75]R-C(=[::+60]O)-[::-60]O-[::-60]C(=[::+60]O)-[::-60]R}| \section{Connecting distant atoms} -\idx*{bond!distant atoms}We have seen how to connect atoms \emph{which are adjacent in the code}. It is often necessary to connect atoms which are not next to each other in the code. Let's call these particular bonds ``distant bonds''. +We have seen how to connect atoms \emph{which are adjacent in the code}. It is often necessary to connect atoms which are not next to each other in the code. Let's call these particular bonds ``distant bonds''. Let's take this molecule: \exemple{Branched structure}|\chemfig{A-B(-[1]W-X)(-[7]Y-Z)-C}| @@ -698,7 +670,7 @@ Several different hooks can be written after an atom. Suppose that in this unfin Then we must do this: \exemple{Multiple distant bonds}|\chemfig{A?[a]-[:-72]B-C?[a]?[b]-[:72]D-[:144]E?[a]?[b]}| -\section{Rings}\idx*{ring|(} +\section{Rings} The preceding example shows how to draw a regular polygon, but the method used is tedious because the angles depend on the number of sides of the polygon. \subsection{Syntax} @@ -714,12 +686,12 @@ Here is a 5-ring, attached to the atom ``\verb/A/'': A ring can also be drawn with one, several, or all the groups of atoms empty, as is the case for diagrams outside rings: \exemple{5-ring with empty groups}|\chemfig{*5(-=--=)}| -A ring can be incomplete\idx*{ring!unfinished}: +A ring can be incomplete: \exemple{Incomplete 5-ring}|\chemfig{*5(-B=C-D)}| If a ring has a code which contains too many bonds and atom groups for the given number of vertices, all the bonds and groups over the maximum allowed are ignored: \exemple{Truncated 5-ring}|\chemfig{A*5(-B=C-D-E=F-G=H-I)}| -It is possible to draw a circle or an arc in the inside of a ring\idx*{ring!inside arc}. To do so, the following syntax is used: +It is possible to draw a circle or an arc in the inside of a ring. To do so, the following syntax is used: \centerverb/**[,,]()/ \smallskip @@ -735,7 +707,7 @@ where each field of the optional argument takes its default value if it is empty \subsection{Angular position} \subsubsection{At the start} -\idx*{ring!angular position}As can be seen in the examples above, the rule is that the attachment atom ``\verb/A/'' is always at the south-west of the ring. Furthermore, the ring is always constructed counterclockwise, and the last bond descends vertically onto the attachment atom: +As can be seen in the examples above, the rule is that the attachment atom ``\verb/A/'' is always at the south-west of the ring. Furthermore, the ring is always constructed counterclockwise, and the last bond descends vertically onto the attachment atom: \exemple{Angular position of rings}|\chemfig{A*4(-B-C-D-)}\qquad\chemfig{A*6(------)}| If this angular position is not convenient, it is possible to specify another angle using the optional argument at the beginning of the molecule. Here is a 6-cycle which has been rotated by $+30\degres$, by $-30\degres$, and lastly by $+60\degres$: @@ -754,7 +726,7 @@ The rule remains valid, whatever the angle of the preceding bond: \chemfig{A=[:-30]*6(=-=-=-)}| \subsection{Branches on a ring} -\idx*{ring!branch}To have branches attached to the vertices of a ring, we use the syntax we have already seen: +To have branches attached to the vertices of a ring, we use the syntax we have already seen: \centerverb/()/ \smallskip @@ -775,7 +747,7 @@ We can now connect together rings with bonds: \exemple{Connected rings}|\chemfig{*6(--(-*5(----(-*4(----))-))----)}| \subsection{Nested rings} -\idx*{ring!nested}To ``glue'' two rings together, the syntax is only slightly different: the vertex is specified where the other ring is going to start. Simply follow this vertex by the usual syntax for a ring. Here for example is a 5-ring which is attached to the second vertex of a 6-ring: +To ``glue'' two rings together, the syntax is only slightly different: the vertex is specified where the other ring is going to start. Simply follow this vertex by the usual syntax for a ring. Here for example is a 5-ring which is attached to the second vertex of a 6-ring: \exemple{Nested rings}|\chemfig{A*6(-B*5(----)=-=-=)}| Note that the ring which is going to be attached to the main ring has an angular position such that two of the rings' sides coincide. In addition, the 5-ring has only four bonds ``\verb/----/''. In effect, the fifth will be useless because it is the second side of the 6-ring, which has already been drawn. @@ -796,22 +768,22 @@ We could also use a \verb-\phantom{E}- at the last vertex of the 5-ring: Some care must be taken with rings when one or more vertices are made up of groups of atoms: \exemple{Ring and groups of atoms}|\chemfig{AB*5(-CDE-F-GH-I-)}| -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\idx*{bond!departure and arrival atoms}. Here, \verb/C-F/ and \verb/F-G/ must be connected by using the optional argument\idx*{bond!optional argument} of these bonds: -\exemple{Forced departure and arrival atoms}|\chemfig{AB*5(-CDE-[,,1]F-[,,,1]GH-I-)}|\idx*{ring|)} +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-)}| -\section{Representing electron movements}\label{mecanismes-reactionnels}\idx*{electron movements|(} -Starting with \CF version 0.3, we can represent the movement of electrons in mesomeric effects or reaction mechanisms. This is done by marking the departure and arrival points of the electron movement arrow using the syntax ``\verb-@{}-''\idx*{"@}. This syntax allows a \TIKZ node to be placed and makes this node accessible outside the argument of the \verb-\chemfig- command thanks to the ``\texttt{remember picture}'' option which is passed to all the ``\idx{tikzpicture}'' environments. It is assumed that the viewer supports ``\idx{picture remembering}'' and that the compilation is done twice. +\section{Representing electron movements}\label{mecanismes-reactionnels} +Starting with \CF version 0.3, we can represent the movement of electrons in mesomeric effects or reaction mechanisms. This is done by marking the departure and arrival points of the electron movement arrow using the syntax ``\verb-@{}-''. This syntax allows a \TIKZ node to be placed and makes this node accessible outside the argument of the \verb-\chemfig- command thanks to the ``\texttt{remember picture}'' option which is passed to all the ``\falseverb{tikzpicture}'' environments. It is assumed that the viewer supports ``\falseverb{picture remembering}'' and that the compilation is done twice. Two types of diagrams can arise, so we can ask for: \begin{itemize} \item a zero size node on a bond using the syntax ``\verb-@{,}-'' placed at the beginning of the optional argument of the relevant bond, without being followed by a comma if there is a first optional argument. In this case, the node takes the name ``\verb--'' and the \verb--, which must be between 0 and 1, determines where the node is located on the bond. If ``\verb-@{}-'' is used, the \verb-- is set to 0.5 by default, which means that the node is placed halfway along the bond; \item a node on an atom using the syntax ``\verb-@{}-'' immediately before the relevant atom. In this case, the node has exactly the same footprint as the atom, but may be empty and therefore have zero dimensions. \end{itemize} -Once the \idx{\chemfig} command has drawn the molecule(s) and has placed the nodes with the syntax described above, we can connect these nodes to each other with \TIKZ instructions. These instructions are placed in the argument of the command \verb-\chemmove-\idx*{chemmove@\protect\texttt{\protect\string\protect\chemmove}|(}\footnote{Actually, the \texttt{\string\chemmove} command puts its argument in a ``\idx{tikzpicture}'' environment with the options ``\texttt{remember picture, overlay}''.} and has the following syntax if (for example) we need to connect a node named ``\verb--'' to the node named ``\verb--'': +Once the \falseverb{\chemfig} command has drawn the molecule(s) and has placed the nodes with the syntax described above, we can connect these nodes to each other with \TIKZ instructions. These instructions are placed in the argument of the command \verb-\chemmove-\footnote{Actually, the \texttt{\string\chemmove} command puts its argument in a ``\falseverb{tikzpicture}'' environment with the options ``\texttt{remember picture, overlay}''.} and has the following syntax if (for example) we need to connect a node named ``\verb--'' to the node named ``\verb--'': \centerverb|\chemmove[]{\draw[]()();}| \smallskip -The optional argument \verb-- of the \verb-\chemmove- command will be added to the argument of the \idx{tikzpicture} environment in which the links between the nodes will be drawn. The \verb-- and \verb-- instructions are describe in detail in the documentation of the \TIKZ package. +The optional argument \verb-- of the \verb-\chemmove- command will be added to the argument of the \falseverb{tikzpicture} environment in which the links between the nodes will be drawn. The \verb-- and \verb-- instructions are describe in detail in the documentation of the \TIKZ package. \subsection{Mesomeric effects} To make these concepts concrete, let's take the example of a mesomeric effect involving a double bond and non-bonding lone pair conjugate. Let's begin with the possible delocalization of electrons from the double bond. We will place a node named ``db'' (double bond) in the middle of the double bond and a node named ``a1'' on the end of the double bond. @@ -832,7 +804,7 @@ To link the nodes ``db'' and ``a1'' we have used the following syntax: \centerverb|\chemmove{\draw(db)..controls +(80:8mm) and +(145:8mm)..(a1);}| \medskip -For arrows in \verb|\chemmove|, the default tip is ``CF''.In this example we ask for an arrow (\verb/[->]/) and we use two \idx{control points}\footnote{To find all the ways of connecting two nodes with \TIKZ, read the documentation for that package.}. These will be located using polar coordinates at 80\degres{} and 8~mm from ``db'' for the first and at 145\degres{} and 8~mm from ``a1'' for the second. Though this syntax may seem complicated at first reading, one need not be alarmed because its use will usually be a matter of copying and pasting. Only the names and coordinates of the control points need be changed, as can be verified from the example below, where an arrow has been added from the lone pair (node ``dnl'' to the single bond (node ``sb''). +For arrows in \verb|\chemmove|, the default tip is ``CF''.In this example we ask for an arrow (\verb/[->]/) and we use two \falseverb{control points}\footnote{To find all the ways of connecting two nodes with \TIKZ, read the documentation for that package.}. These will be located using polar coordinates at 80\degres{} and 8~mm from ``db'' for the first and at 145\degres{} and 8~mm from ``a1'' for the second. Though this syntax may seem complicated at first reading, one need not be alarmed because its use will usually be a matter of copying and pasting. Only the names and coordinates of the control points need be changed, as can be verified from the example below, where an arrow has been added from the lone pair (node ``dnl'' to the single bond (node ``sb''). \exemple{Mesomeric effect 2}/\schemestart \chemfig{@{a1}=_[@{db}::30]-[@{sb}::-60]@{dnl}\lewis{2,X}} \arrow{<->} @@ -843,7 +815,7 @@ For arrows in \verb|\chemmove|, the default tip is ``CF''.In this example we ask \draw(db)..controls +(100:5mm) and +(145:5mm)..(a1); \draw(dnl)..controls +(90:4mm) and +(45:4mm)..(sb);}/ -For our new arrow we have set the \idx{control points} as follows: 4~mm at an angle of 90\degres{} from ``dnl'' and 4~mm at an angle of 45\degres{} from ``sb''. But we are not completely satisfied, since we would like the arrow not to touch the line segment representing the lone pair. To do this we will add some options to our arrow. +For our new arrow we have set the \falseverb{control points} as follows: 4~mm at an angle of 90\degres{} from ``dnl'' and 4~mm at an angle of 45\degres{} from ``sb''. But we are not completely satisfied, since we would like the arrow not to touch the line segment representing the lone pair. To do this we will add some options to our arrow. \exemple{Mesomeric effect 3}/\schemestart \chemfig{@{a1}=_[@{db}::30]-[@{sb}::-60]@{dnl}\lewis{2,X}} \arrow{<->} @@ -885,7 +857,7 @@ Note that the tail of the arrow does not leave correctly from our electrons; it \chemmove{\draw[shorten <=4pt,shorten >=4pt] (x1.57).. controls +(60:1cm) and +(120:1cm).. (x2);}/ -In some cases it will be easier to use Cartesian coordinated for the \idx{control points}. Here we use just one control point placed 1~cm to the right of and 1.5~cm above ``x1'': +In some cases it will be easier to use Cartesian coordinated for the \falseverb{control points}. Here we use just one control point placed 1~cm to the right of and 1.5~cm above ``x1'': \exemple{A single control point}/\chemfig{@{x1}\lewis{1:,X}} \hspace{2cm} \chemfig{@{x2}\lewis{2|,X}} @@ -895,8 +867,8 @@ In some cases it will be easier to use Cartesian coordinated for the \idx{contro All the graphics drawn by means of the command \verb|\chemmove| are superimposed and will not be included in the bounding boxes. We can see this in the preceding example. \subsection{Reaction mechanisms} -Thanks to the option \verb|remenber picture| which is passed to all the ``tikzpicture'' environments we can easily draw arrows indicating reaction mechanisms. Let's take for example the first step of the esterification reaction\idx*{charge!\protect\texttt{\protect\string\protect\oplus}}. -\exemple{Esterification: step 1}/\setatomsep{7mm} +Thanks to the option \verb|remenber picture| which is passed to all the ``tikzpicture'' environments we can easily draw arrows indicating reaction mechanisms. Let's take for example the first step of the esterification reaction. +\exemple{Esterification: step 1}/\setchemfig{atom sep=7mm} \schemestart \chemfig{R-@{dnl}\lewis{26,O}-H} \+ @@ -907,24 +879,24 @@ Thanks to the option \verb|remenber picture| which is passed to all the ``tikzpi \draw(dnl)..controls +(90:1cm)and+(north:1cm)..(atoc); \draw[shorten >=6pt](db)..controls +(north:5mm)and+(100:1cm)..(atoh);}/ -The use of the \verb|\chemabove{}{}|\idx*{\chemabove} command does not change the dimensions of the \idx{bounding box} of \verb||. For this reason we can run into some difficulty in pointing to the symbol representing the charge carried ($\oplus$ or $\ominus$). In the example above the solution is to create a control point\idx*{control points} with an angle of 110\degres{} at 1~cm from ``atoh'' and to shorten the arrow by 6pt. In the following example, the second step of the esterification reaction, we can see that the arrow can take more complicated forms without complicating the code. -\exemple{Esterification: step 2}/\setatomsep{7mm} +The use of the \verb|\chemabove{}{}| command does not change the dimensions of the \falseverb{bounding box} of \verb||. For this reason we can run into some difficulty in pointing to the symbol representing the charge carried ($\oplus$ or $\ominus$). In the example above the solution is to create a control point with an angle of 110\degres{} at 1~cm from ``atoh'' and to shorten the arrow by 6pt. In the following example, the second step of the esterification reaction, we can see that the arrow can take more complicated forms without complicating the code. +\exemple{Esterification: step 2}/\setchemfig{atom sep=7mm} \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);}/ -The rest is left as an exercise to the reader\idx*{chemmove@\protect\texttt{\protect\string\protect\chemmove}|)}\idx*{electron movements|)}\dots. +The rest is left as an exercise to the reader\dots. \section{Writing a name under a molecule}\label{chemname} -For convenience, \CF can write the name of a molecule underneath it with the command\idx*\chemname +For convenience, \CF can write the name of a molecule underneath it with the command \centerverb/\chemname[]{\chemfig{}}{}/ \smallskip -The \verb--, which is 1.5ex by default, will be inserted between the \idx{baseline} of the molecule and the top of the letters of the \verb--. The \verb-- will be centred relative to the molecule, but the \verb-- may not contain multiple paragraphs. As we see in this example: \chemname{\chemfig{H-O-H}}{\scriptsize\bfseries The water molecule: $\mathrm{\mathbf{H_2O}}$}, the \verb-- which is displayed under the molecule is taken into account only for the vertical size of the bounding box. The horizontal size of \verb-- is always zero. +The \verb--, which is 1.5ex by default, will be inserted between the \falseverb{baseline} of the molecule and the top of the letters of the \verb--. The \verb-- will be centred relative to the molecule, but the \verb-- may not contain multiple paragraphs. As we see in this example: \chemname{\chemfig{H-O-H}}{\scriptsize\bfseries The water molecule: $\mathrm{\mathbf{H_2O}}$}, the \verb-- which is displayed under the molecule is taken into account only for the vertical size of the bounding box. The horizontal size of \verb-- is always zero. -Here is a reaction with the names under the molecules\idx*{chemical reaction}: +Here is a reaction with the names under the molecules: \exemple*{Displaying names of molecules}/\schemestart \chemname{\chemfig{R-C(-[:-30]OH)=[:30]O}}{Acide carboxylique} \+ @@ -948,13 +920,13 @@ There are some limitations to this command. Suppose we switch the acid and the a \schemestop \chemnameinit{}/ -In fact, to draw the \verb-- the command \idx{\chemname} inserts 1.5ex${}+{}$\emph{the largest of the depths\footnote{In \TeX{} terms, the depth is the dimension which extends vertically below the baseline.} of the molecules thus far} below the baseline of each molecule (light grey for the examples in this manual). The command \idx{\chenameinit}\verb-{}- initializes this largest depth with the \verb--. Therefore one should: +In fact, to draw the \verb-- the command \falseverb{\chemname} inserts 1.5ex${}+{}$\emph{the largest of the depths\footnote{In \TeX{} terms, the depth is the dimension which extends vertically below the baseline.} of the molecules thus far} below the baseline of each molecule (light grey for the examples in this manual). The command \falseverb{\chenameinit}\verb-{}- initializes this largest depth with the \verb--. Therefore one should: \begin{itemize} \item write \verb-\chemnameinit{}- before using the \verb-\chemname- command in a reaction, unless the reaction begins with the deepest molecule; \item write \verb-\chemnameinit{}- after having written all the names in a chemical reaction lest the greatest depth in this reaction interfere with a future reaction. \end{itemize} -Thus the correct code uses \idx{\chemnameinit} before and after the reaction: +Thus the correct code uses \falseverb{\chemnameinit} before and after the reaction: \exemple*{Name alignment 2}/\chemnameinit{\chemfig{R-C(-[:-30]OH)=[:30]O}} \schemestart \chemname{\chemfig{R'OH}}{Alcohol} @@ -967,7 +939,7 @@ Thus the correct code uses \idx{\chemnameinit} before and after the reaction: \schemestop \chemnameinit{}/ -Finally, to write a name on multiple lines, the command \verb-\\-\idx*{\protect\symbol{'134}\protect\symbol{'134}@\protect\texttt{\protect\symbol{'134}\protect\symbol{'134}}} encountered in a \verb-- causes a line break\footnote{Conversely, the command \texttt{\textbackslash par} is forbidden and causes a compilation error.}: +Finally, to write a name on multiple lines, the command \verb-\\- encountered in a \verb-- causes a line break\footnote{Conversely, the command \texttt{\textbackslash par} is forbidden and causes a compilation error.}: \exemple*{Name on 2 lines}/\schemestart \chemname{\chemfig{R-C(-[:-30]OH)=[:30]O}}{Carboxilic\\Acid} \+ @@ -984,13 +956,13 @@ If \verb|\chemname*{}| is written, the macro does not take into account the \part{Advanced usage}\label{utilisation.avancee} \section{Separating atoms}\label{decoupage.atomes} -The \idx{separating atom mechanism} described previously extends each atom until the next capital letter or one of the characters {\ttfamily \boxedfalseverb{-} \boxedfalseverb{=} \boxedfalseverb{~} \boxedfalseverb{(} \boxedfalseverb{!} \boxedfalseverb{*} \boxedfalseverb{<} \boxedfalseverb{>} \boxedfalseverb{@}} +The \falseverb{separating atom mechanism} described previously extends each atom until the next capital letter or one of the characters {\ttfamily \boxedfalseverb{-} \boxedfalseverb{=} \boxedfalseverb{~} \boxedfalseverb{(} \boxedfalseverb{!} \boxedfalseverb{*} \boxedfalseverb{<} \boxedfalseverb{>} \boxedfalseverb{@}} In certain cases this automatic separation produces incorrect atoms which can translate into an imperfect diagram. Consider this example molecule, noting that the ``\texttt('' character is placed between braces so that \CF doesn't incorrectly create a branch: \exemple*{Alkene}/\chemfig{CH_3CH_2-[:-60,,3]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]C{(}CH_3{)}_3}/ -We find that the bond which arrives at the carbon atom in the upper right is too short. This happens because, if we apply the \CF rules for separating atoms\idx*{separating atom mechanism} to the upper right group, the atoms are split in this way: ``\texttt{\detokenize{C{(}}}'', ``\texttt{\detokenize{C}}'', ``\texttt{\detokenize{H_3{)}_3}}''. We now realize that the first atom contains a parenthesis and thus has too great a depth in math mode; we can see this by making the bounding boxes visible: +We find that the bond which arrives at the carbon atom in the upper right is too short. This happens because, if we apply the \CF rules for separating atoms to the upper right group, the atoms are split in this way: ``\texttt{\detokenize{C{(}}}'', ``\texttt{\detokenize{C}}'', ``\texttt{\detokenize{H_3{)}_3}}''. We now realize that the first atom contains a parenthesis and thus has too great a depth in math mode; we can see this by making the bounding boxes visible: \begin{center} \fboxsep=0pt \renewcommand*\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}}% @@ -1001,13 +973,13 @@ The character ``|'' forces splitting of the atom when it is encountered. Thus we \exemple*{Alkene}/\chemfig{CH_3CH_2-[:-60,,3]C(-[:-120]H_3C)=C(-[:-60]H)-[:60]C|{(CH_3)_3}}/ \section{Displaying atoms}\label{perso.affichage} -Once a molecule has been split into atoms, the macro \idx{\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 \idx{math mode} and displays its argument with the math font family ``rm''. It is defined by the following code: +Once a molecule has been split into atoms, the macro \falseverb{\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 \falseverb{math mode} and displays its argument with the math font family ``rm''. It is defined by the following code: \begin{itemize} - \item \verb|\newcommand*\printatom[1]{\ensuremath{\mathrm{#1}}}|\qquad when compiling with \LaTeX{}\idx*{Latex@\protect\LaTeX} - \item \verb|\def\printatom#1{\ifmmode\rm#1\else$\rm#1$\fi}|\qquad when compiling with $\varepsilon$\TeX{}\idx*{etex@$\protect\varepsilon$\protect\TeX} ou Con\TeX tX\idx*{ConTeXt@Con\protect\TeX{}t}. + \item \verb|\newcommand*\printatom[1]{\ensuremath{\mathrm{#1}}}|\qquad when compiling with \LaTeX{} + \item \verb|\def\printatom#1{\ifmmode\rm#1\else$\rm#1$\fi}|\qquad when compiling with $\varepsilon$\TeX{} ou Con\TeX tX. \end{itemize} -One can modify the code of this macro to customize how atoms are displayed. In the following example, we redefine \idx{\printatom} so that each atom will be enclosed in a rectangular box: +One can modify the code of this macro to customize how atoms are displayed. In the following example, we redefine \falseverb{\printatom} so that each atom will be enclosed in a rectangular box: \exemple{Redefinition of \string\printatom}/\fboxsep=1pt \renewcommand*\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}} \chemfig{H_3C-C(=[:30]O)(-[:-30]OH)}/ @@ -1016,52 +988,47 @@ 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)}/ -\section{Optional arguments}\label{arguments.optionnels} -The \idx{\chemfig} command takes two optional arguments\idx*{chemfig@\protect\texttt{\protect\string\protect\chemfig}!optional arguments}; their syntax is as follows: -\centerverb|\chemfig[][]{}| -\smallskip - -The first optional argument \verb-- contains \TIKZ instructions which will be passed to the \idx{tikzpicture} environment in which the molecule is drawn. The second optional argument \verb-- contains \TIKZ instructions which will be executed when each node\footnote{These instructions are added to the end of the argument of \texttt{every node/.style\{\}}. This argument contains by default the following instructions: ``{\ttfamily anchor=base,inner sep=0pt,outer sep=0pt,minimum size=0pt}''.} is drawn. +\section{Arguments given to tikz}\label{arguments.optionnels} +The \chevrons{key} \CFkey{chemfig style} contains \TIKZ instructions which will be passed to the \falseverb{tikzpicture} environment in which the molecule is drawn. On the other hand, the The \chevrons{key} \CFkey{atom style} contains \TIKZ instructions which will be executed when each node; these instructions are added to the end of \texttt{every node/.style\{\}}, i.e. after the fhe following instructions: ``{\ttfamily anchor=base,inner sep=0pt,outer sep=0pt,minimum size=0pt}''. With the use of the first optional argument one can, for example, choose the global colour or thickness of lines: \exemple{Style choice}/\chemfig{A-B-[2]C}\par\medskip -\chemfig[line width=1.5pt]{A-B-[2]C}\par\medskip -\chemfig[red]{A-B-[2]C}/ +\setchemfig{chemfig style={line width=1.5pt}}\chemfig{A-B-[2]C}\par\medskip +\setchemfig{chemfig style=red}\chemfig{A-B-[2]C}/ -With the second optional argument, one can choose the colour of nodes drawn by \TIKZ, change the angle of the drawing or its scale\idx*{size of molecules}: +With \CFkey{node style}, one can choose the colour of nodes drawn by \TIKZ, change the angle of the drawing or its scale: \exemple{Style choices}/\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}\par\medskip -\chemfig[][scale=0.5]{A-B-[2]C}/ +\setchemfig{atom style=red}\chemfig{A-B-[2]C}\par\medskip +\setchemfig{atom style={rotate=20}}\chemfig{A-B-[2]C}\par\medskip +\setchemfig{atom style={scale=0.5}}\chemfig{A-B-[2]C}/ \section{Vertical alignment}\label{alignement.vertical} -\idx*{vertical alignment}In some cases with condensed structural diagram of molecules having horizontal bonds, the placement of groups of atoms is incorrect. +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 \idx{baseline}: -\exemple*{Vertical placement}/\Huge\setatomsep{2em} +Careful study of the following example shows that the groups of atoms are not correctly aligned on the \falseverb{baseline}: +\exemple*{Vertical placement}/\Huge\setchemfig{atom sep=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 \idx{\vphantom} of the departure atom, but does not include it in the contents of the arrival atom; this \idx{\vphantom} is not intended to affect the following atoms. The atoms remaining in each group are aligned so that their baseline coincides with the baseline of the preceding atom. +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 \falseverb{\vphantom} of the departure atom, but does not include it in the contents of the arrival atom; this \falseverb{\vphantom} is not intended to affect the following atoms. The atoms remaining in each group are aligned so that their baseline coincides with the baseline of the preceding atom. -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 \idx{\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. +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 \falseverb{\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} +\exemple*{Vertical placement and bounding boxes}/\Huge\setchemfig{atom sep=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 \idx{\vphantom} having the same height as the first, so that the height affects the following atoms: -\exemple*{Vertical placement workaround}/\Huge\setatomsep{2em} +Since there is no satisfactory manual solution, this problem can be worked around manually by putting \emph{inside} the third atom a \falseverb{\vphantom} having the same height as the first, so that the height affects the following atoms: +\exemple*{Vertical placement workaround}/\Huge\setchemfig{atom sep=2em} \chemfig{A^1-B-{\vphantom{A^1}C}-D}\qquad \chemfig{E_1-F-{\vphantom{E_1}G}-H}/ -\label{chemskipalign}For any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thus neutralize the \idx{\vphantom}. Simply place the \idx{\chemskipalign} command in the group of atoms; the alignment will resume in the following group of atoms as if the group of atoms containing \idx{\chemskipalign} had never existed. The following example shows the effects of this instruction: the reference point of the box containing the first atom is placed at the level of the bond which arrives from the left. The bounding boxes of the atoms are drawn in the second line. +\label{chemskipalign}For any group of atoms it is possible to temporarily deactivate the alignment adjustment mechanism and thus neutralize the \falseverb{\vphantom}. Simply place the \falseverb{\chemskipalign} command in the group of atoms; the alignment will resume in the following group of atoms as if the group of atoms containing \falseverb{\chemskipalign} had never existed. The following example shows the effects of this instruction: the reference point of the box containing the first atom is placed at the level of the bond which arrives from the left. The bounding boxes of the atoms are drawn in the second line. \exemple[60]{Deactivation of the alignment mechanism}/\large \chemfig{A-.-B}\quad @@ -1071,7 +1038,7 @@ Since there is no satisfactory manual solution, this problem can be worked aroun \chemfig{A-.-B}\quad \chemfig{A-\chemskipalign.-B}/ -This command is to be used with caution lest the alignment of atoms in the next group be disrupted. In general, all will be well if the group of atoms featuring \idx{\chemskipalign} contains \emph{a single atom} whose height and depth are \emph{less} than those of the preceding and following atoms, and if the preceding and following atoms have identical heights and depths. Here is an example of the mess that results when the group of atoms contains two atoms, here ``\verb-\chemskipalign.-'' and ``\verb-B-'': +This command is to be used with caution lest the alignment of atoms in the next group be disrupted. In general, all will be well if the group of atoms featuring \falseverb{\chemskipalign} contains \emph{a single atom} whose height and depth are \emph{less} than those of the preceding and following atoms, and if the preceding and following atoms have identical heights and depths. Here is an example of the mess that results when the group of atoms contains two atoms, here ``\verb-\chemskipalign.-'' and ``\verb-B-'': \exemple{Consequence of the \string\chemskipalign command}/\large \fboxsep=0pt \renewcommand\printatom[1]{\fbox{\ensuremath{\mathrm{#1}}}} @@ -1084,18 +1051,18 @@ This feature can sometimes be useful. Suppose we want to draw the following mole \def\fulldisk{\chemskipalign\tikz\fill(0,0)circle(2pt);}% \chemfig{A-#(,0pt)\emptydisk-#(0pt,0pt)\fulldisk-#(0pt)B}% \end{center} -We can define commands which will draw the empty and full disks with \TIKZ. To ensure that these disks are at the right height, namely the height of the bond arriving at them, we will use the command \idx{\chemskipalign}. In the second line below the bonds are ``stuck'' to the disks by using the ability to change the bond shortening with the ``\verb-#-''\idx*{\protect\symbol{'043}@\protect\texttt{\protect\symbol{'043}}} character, a feature seen on page~\pageref{modif.retrait}. +We can define commands which will draw the empty and full disks with \TIKZ. To ensure that these disks are at the right height, namely the height of the bond arriving at them, we will use the command \falseverb{\chemskipalign}. In the second line below the bonds are ``stuck'' to the disks by using the ability to change the bond shortening with the ``\verb-#-'' character, a feature seen on page~\pageref{modif.retrait}. \begingroup\catcode`;12 \catcode`#12 -\exemple{Use of \string\chemskipalign\ and #}/ -\begingroup -\def\emptydisk{\chemskipalign\tikz\draw(0,0)circle(2pt);} +\exemple{Use of \string\chemskipalign\ and #}/\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 + + \section{Shifted double bonds} -\idx*{bond!shifted}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. +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. To shift the bond to the left, write ``\verb-=^-'' and to shift it to the right, write ``\verb-=_-'': \exemple{Shifted double bonds}/\chemfig{A-=-B}\par @@ -1112,7 +1079,7 @@ Shifted bonds are particularly useful in drawing skeleton diagrams of molecules \chemfig{-[:30]=_[:-30]-[:30]=_[:-30]-[:30]}/ \section{Delocalized double bonds} -\idx*{bond!delocalized}It is sometimes necessary to draw a double bond so that one line would be full and the other dashed. This feature is not hard-coded in \CF since \TIKZ, with its ``decorations.markings'' librairy makes it possible. +It is sometimes necessary to draw a double bond so that one line would be full and the other dashed. This feature is not hard-coded in \CF since \TIKZ, with its ``decorations.markings'' librairy makes it possible. \exemple*{Delocalized bonds}|\catcode`\@=11 \tikzset{ @@ -1138,9 +1105,9 @@ Shifted bonds are particularly useful in drawing skeleton diagrams of molecules \chemfig{A-[,,,,ddbond={+}]B-[,,,,ddbond={-}]C}| \section{Saving a sub-molecule}\label{definesubmol} -\idx*{save a molecule}\CF is capable of saving a \verb-- as an alias for reuse in a more compact form in the code of a molecule. This is particularly useful when the \verb-- appears several times. +\CF is capable of saving a \verb-- as an alias for reuse in a more compact form in the code of a molecule. This is particularly useful when the \verb-- appears several times. -To do this, one gives the command\idx*{\definesubmol} +To do this, one gives the command \centerverb|\definesubmol{}{}| \smallskip @@ -1150,8 +1117,8 @@ which saves the \verb// for recall in the code of the molecule via the sho \item a control sequence. \end{itemize} -In all cases, if the alias is already defined you should not overwrite it with a new definition using \idx{\definesubmol}. A warning will be issued to the user that the old alias will be overwritten by the new one. To override the definition of an alias made previously, use:\label{redefinesubmol} -\centerverb|\redefinesubmol{}{}|\idx*{\redefinesubmol} +In all cases, if the alias is already defined you should not overwrite it with a new definition using \falseverb{\definesubmol}. A warning will be issued to the user that the old alias will be overwritten by the new one. To override the definition of an alias made previously, use:\label{redefinesubmol} +\centerverb|\redefinesubmol{}{}| \smallskip Here is a code which draws the pentane molecule. An alias ``\verb/xy/'' was defined beforehand for the code \verb/CH_2/: @@ -1160,65 +1127,72 @@ 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 with the control sequence ``\verb/\xx/'' for the sub-molecule $\mathrm{CH_2}$. If we use only relative angles\idx*{bond!angle!relative}, 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: +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}| -The \idx{\definesubmol} command takes an optional argument; its syntax is as follows: +The \falseverb{\definesubmol} command takes an optional argument; its syntax is as follows: \centerverb/\definesubmol{}[]{code2}/ \medskip When the optional argument is present, the alias ``\verb-!-'' will be replaced by \verb'' if the bond which arrives at the alias comes from the right, i.e., if the angle which the arriving bond makes is between but is not equal to 90\degres{} and 270\degres{}. For all the other cases where the bond arrives from the left of vertically, the alias will be replaced by \verb--. -We will define a control sequence \verb-\Me- pour ``methyl'' so that the alias ``\verb-!\Me-'' will be replaced by ``\verb-H_3C-'' when the bond arrives from the right and by ``\verb-CH_3-'' when it arrives from the left. We can observe in the example that with this alias we need no longer worry about the angle\idx*{\definesubmol}: +We will define a control sequence \verb-\Me- pour ``methyl'' so that the alias ``\verb-!\Me-'' will be replaced by ``\verb-H_3C-'' when the bond arrives from the right and by ``\verb-CH_3-'' when it arrives from the left. We can observe in the example that with this alias we need no longer worry about the angle: \exemple{Dual alias}/\definesubmol\Me[H_3C]{CH_3} -\chemfig{*6((-!\Me)=(-!\Me)-(-!\Me)=(-!\Me)-(-!\Me)=(-!\Me)-)}/\idx*{save a molecule} +\chemfig{*6((-!\Me)=(-!\Me)-(-!\Me)=(-!\Me)-(-!\Me)=(-!\Me)-)}/ \section{Decorations} \subsection{Lewis diagrams}\label{lewis} -\idx*{Lewis diagram}The macro \idx{\lewis} allows placement of pairs of electrons, of single electrons, or of empty slots. This syntax is used: +The macro \falseverb{\lewis} allows placement of pairs of electrons, of single electrons, or of empty slots. This syntax is used: \centerverb|\lewis{...,}| \smallskip where the \verb--\dots\verb-- represent the desired positions (in multiples of 45\degres) around the \verb--. These whole numbers must be between 0 and 7. -This command can also be used inside the argument of \verb-\chemfig-\idx*{\lewis}: +This command can also be used inside the argument of \verb-\chemfig-: \exemple{The \string\lewis\ macro}|\lewis{0246,A}\par\medskip - \lewis{1357,B}\par\medskip - \chemfig{H-\lewis{26,O}-S(=[2]\lewis{13,O}) - (=[6]\lewis{57,O})-\lewis{26,O}-H}| +\lewis{1357,B}\par\medskip +\chemfig{H-\lewis{26,O}-S(=[2]\lewis{13,O}) + (=[6]\lewis{57,O})-\lewis{26,O}-H}| -If one wishes to draw two electrons instead of a line, follow the integer with a ``\verb-:-''. If one wishes to draw a single electron, follow it with a ``\verb-.-''. To draw a lacuna, follow it with a ``\verb-|-''\idx*{\lewis}: +If one wishes to draw two electrons instead of a line, follow the integer with a ``\verb-:-''. If one wishes to draw a single electron, follow it with a ``\verb-.-''. To draw a lacuna, follow it with a ``\verb-|-'': \exemple{Lewis diagrams}*\lewis{0:2:4:6:,C}\qquad\lewis{1:3:5:7:,C}\par\bigskip - \lewis{0.2.4.6.,C}\qquad\lewis{1.3.5.7.,C}\par\bigskip - \lewis{0:2.4|,X}\par\bigskip - Hydronium ion: \chemfig{H-\lewis{5|7,O^+}(-[2]H)-H}* +\lewis{0.2.4.6.,C}\qquad\lewis{1.3.5.7.,C}\par\bigskip +\lewis{0:2.4|,X}\par\bigskip +Hydronium ion: \chemfig{H-\lewis{5|7,O^+}(-[2]H)-H}* -All the decorations drawn by \idx{\lewis} are not included in the \idx{bounding box} of the atom; they are drawn afterwards. A consequence of this is seen in the two examples above, where the frame does not appear to be properly fitted to the drawing of the molecule, which extends downward slightly. This will be seen more often in this the ``Decorations'' chapter, which presents commands which do not change the bounding box. +All the decorations drawn by \falseverb{\lewis} are not included in the \falseverb{bounding box} of the atom; they are drawn afterwards. A consequence of this is seen in the two examples above, where the frame does not appear to be properly fitted to the drawing of the molecule, which extends downward slightly. This will be seen more often in this the ``Decorations'' chapter, which presents commands which do not change the bounding box. -\label{Lewis}The \idx{\Lewis} macro works the same way as \verb-\lewis- but decorations are taken into account in the bounding box. +\label{Lewis}The \falseverb{\Lewis} macro works the same way as \verb-\lewis- but decorations are taken into account in the bounding box. -This can be seen more clearly by drawing an \verb-\fbox- around decorated atoms\idx*{\lewis}: +This can be seen more clearly by drawing an \verb-\fbox- around decorated atoms: \exemple{Bounding box and the \string\lewis\ macro}*\fboxsep0pt \fbox{\lewis{0.2.4.6.,A}}\quad\fbox{\Lewis{0.2.4.6.,A}}\par\medskip \fbox{\lewis{13,B}}\quad\fbox{\Lewis{13,B}}* -\label{setlewis}Several parameters can be set with the help of the macro\idx*{\setlewis} -\centerverb|\setlewis[dim1]{}{}{}| -\smallskip - -If an argument is empty, it takes its default value. +\label{setlewis}Several parameters can be set with the help of these \chevrons{keys} \begin{itemize} - \item \verb-- is the width of the rectangle which represents the empty slot obtained whith the character ``|''; - \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. + \item \CFkv{lewis | width}{dim}is the width of the rectangle which represents the empty slot obtained whith the character ``|''; + \item \CFkv{lewis sep}{dim} is the distance between the bounding box and the decoration. It is 0.2ex by default; + \item \CFkv{lewis length}{dim} is the length of the line segment representing a pair of electrons. It is 1.5ex by default; + \item \CFkv{lewis style}{code tikz} is code which is passed directly to \TIKZ. This code is empty by default. + \item \CFkv{lewis dist}{dim}: is the distance between 2 discs drawn with "\string:. This distance is set to \CFval{0.3em} by default. + \item \CFkv{lewis radius}{dim}: is the radius of the disc drawn with "." or "\string:". Its default value is \CFval{0.15ex}. \end{itemize} -\idx*{\lewis}\exemple{Parameters for the \string\lewis\ macro}*\setlewis{4pt}{1.5em}{red} - \chemfig{A-\lewis{26,B}-C}\par\bigskip - \setlewis{}{}{line width=0.4pt} - \chemfig{A-\lewis{2|,B}-C}* +\exemple{Parameters for the \string\lewis\ macro}*\setchemfig{lewis sep=4pt,lewis length=1.5em,lewis style=red} +\chemfig{A-\lewis{26,B}-C}\bigbreak + +\setchemfig{lewis style={line width=0.4pt}} +\chemfig{A-\lewis{2|,B}-C}\bigbreak + +\Lewis{1:3:5:7:,X}\qquad\Lewis{0:2:4:6:,X}\bigbreak + +\setchemfig{lewis dist=0.2em} +\Lewis{1:3:5:7:,X}\qquad\Lewis{0:2:4:6:,X}\bigbreak + +\setchemfig{lewis dist=4pt,lewis radius=1.5pt} +\Lewis{1:3:5:7:,X}\qquad\Lewis{0:2:4:6:,X}* A problem sometimes occurs with the decorations of Lewis in the odd directions. In the example below with the atom ``O'', the decoration in position 1 seems farther from the atom than the decoration in position 4: \exemple{Odd directions}/\huge @@ -1230,41 +1204,33 @@ However, it is not the case as shown below by drawing the bounding box of the at \Lewis{1|4|,O}/ \label{opt.lewis}The impression of greater distance is due to the shape of the letter ``O'' which is farther from the one of the bounding box in the corners, that is to say, in odd directions. -To move nearer (or farther) the Lewis drawings in odd directions, the \verb-\lewis- and \verb-\Lewis- accept an optional argument that contains a factor which multiplies the gap between the bounding box and decoration Lewis set with the \idx{\setlewis} command. For the letter ``O'', it semms that 0.5 is the appropriated value: +To move nearer (or farther) the Lewis drawings in odd directions, the \verb-\lewis- and \verb-\Lewis- accept an optional argument that contains a factor which multiplies the gap between the bounding box and decoration Lewis set with the \falseverb{\setlewis} command. For the letter ``O'', it semms that 0.5 is the appropriated value: \exemple*{Optional argument of \string\lewis}/\huge \Lewis{1|4|,O}\quad \Lewis[0.5]{1|4|,O} \Lewis{0:3:,O}\quad \Lewis[2]{0:5:,O}\quad \Lewis[0]{0:5:,O}\quad \Lewis[0.5]{0:5:,O}/ -\label{setlewisdist}Finally, the \idx{\setlewisdist} macro sets the distance between the two disks representing a pair of electrons. The argument of this macro must be valid distance for \TeX{} or, if it is empty sets the default value is 0.3em: -\exemple{Distance between electrons}/\Lewis{1:3:5:7:,X}\qquad\Lewis{0:2:4:6:,X}\bigskip - -\setlewisdist{0.2em}\Lewis{1:3:5:7:,X}\qquad\Lewis{0:2:4:6:,X}\bigskip - -\setlewisdist{4pt}\Lewis{1:3:5:7:,X}\qquad\Lewis{0:2:4:6:,X}/ \subsection{Stacking characters} -The macros\label{chemabove}\idx*{\chemabove} +The macros\label{chemabove} \centerverb|\chemabove[]{}{}| -and\idx*{\chembelow} +and \centerverb|\chembelow[]{}{}| \smallskip -place the \verb-- above and below the \verb-- respectively at a vertical distance \verb--, without changing the \idx{bounding box} of \verb--. The optional argument allows, if written, to specify this dimension at each call. If the optional argument is not used, a default size will be taken: its value is 1.5pt but it can be modified with the macro \idx*{\setstacksep} - -\centerverb|\setstacksep{}| +place the \verb-- above and below the \verb-- respectively at a vertical distance \verb--, without changing the \falseverb{bounding box} of \verb--. The optional argument allows, if written, to specify this dimension at each call. If the optional argument is not used, a default size will be taken: its value is \CFval{1.5pt} but it can be modified with the \chevrons{key} \CFkv{stack sep}{dim}. These commands are independent of the macro \verb-\chemfig- and can be used either inside or outside its argument. They are especially useful in rings, if care is taken to put braces around the letters A, B, C and D in order to prevent \CF from starting a new atom on these letters: \exemple{Staking in rings}|\chemfig{*5(-\chembelow{A}{B}--\chemabove{C}{D}--)}| -They are sometimes useful for placing pseudo-exponents\idx*{ring!charge} which do not change the bounding box of the atoms, so that the bonds do not end up being too short: +They are sometimes useful for placing pseudo-exponents which do not change the bounding box of the atoms, so that the bonds do not end up being too short: \exemple{Hydronium ion}*\chemfig{H-\chemabove{\lewis{5|7,O}}{\quad\scriptstyle+}(-[2]H)-H}* -\label{Chemabove}Les commandes \idx{\Chemabove} et \idx{\Chembelow} fonctionnent de la même façon sauf que la boîte englobante \emph{tient compte} du \verb-- placé au dessus ou au dessous.% NOUVEAU +\label{Chemabove}The \falseverb{\Chemabove} and \falseverb{\Chembelow} commands work in the same way, except that the bounding box takes into account the \verb-- placed above or below. \section{Using {\protect\ttfamily\protect\textbackslash chemfig} in the {\protect\ttfamily tikzpicture} environment} -It is possible to call the \idx{\chemfig} inside a {\ttfamily\idx{tikzpicture}} environment: +It is possible to call the \falseverb{\chemfig} inside a {\ttfamily\falseverb{tikzpicture}} environment: \exemple{\textbackslash chemfig inside tikzpicture}|\begin{tikzpicture}[help lines/.style={thin,draw=black!50}] \draw[help lines] (0,0) grid (4,4); \draw(0,0) -- (2,1); @@ -1276,19 +1242,15 @@ It is possible to call the \idx{\chemfig} inside a {\ttfamily\idx{tikzpicture}} \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. -Each atom is contained in a \TIKZ node. By default these nodes have an ``inner sep'' and an ``outer sep'' equal to 0pt. They are rectangular as seen on page~\pageref{longueur.liaison}. These defaults can be overwritten with the macro \idx{\setnodestyle}, the argument of which is passed to \TIKZ and specifies the style of the nodes containing the atoms. +Each atom is contained in a \TIKZ node. By default these nodes have an ``inner sep'' and an ``outer sep'' equal to 0pt. They are rectangular as seen on page~\pageref{longueur.liaison}. These defaults can be overwritten with the \chevrons{key} \CFkey{node style}, the argument of which is passed to \TIKZ and specifies the style of the nodes containing the atoms. -In this example we specify only ``draw,inner sep=2pt'', which has the effect of drawing the outline of the nodes and separating the outline and node contents by 2pt. We also specify \verb-\setbondoffset{0pt}-\idx{\setbondoffset} so that the bonds touch the edges of the nodes. The interatomic spacing is increased to 75pt. Finally, the command \idx{\printatom} is made as simple as possible so that math mode is no longer used and spaces are thus preserved. -\exemple*{An organization chart}/\setnodestyle{draw,inner sep=2pt} -\setbondoffset{0pt} -\setatomsep{75pt} +In this example we specify only ``draw,inner sep=2pt'', which has the effect of drawing the outline of the nodes and separating the outline and node contents by 2pt. We also specify \CFkv{bond offset}{0pt} so that the bonds touch the edges of the nodes. The interatomic spacing is increased to 75pt. Finally, the command \falseverb{\printatom} is made as simple as possible so that math mode is no longer used and spaces are thus preserved. +\exemple*{An organization chart}/\setchemfig{node style={draw,inner sep=2pt},bond offset=0pt,atom sep=75pt} \renewcommand\printatom[1]{#1} \chemfig{The boss-[6]Me(-[4]Them(-[6]The others)(-[7,2]Group 1))-You(-[:-120,0.5]Him)(-[:-60,0.5]Her)}/ -Here is another organization chart where the nodes are circular and coloured cyan\idx*{\printatom}: -\exemple*{Family diagram}/\setnodestyle{draw,circle,fill=cyan,minimum size=30pt} -\setbondoffset{0pt} -\setatomsep{80pt} +Here is another organization chart where the nodes are circular and coloured cyan: +\exemple*{Family diagram}/\setchemfig{bond offset=0pt,atom sep=80pt,node style={draw,circle,fill=cyan,minimum size=25pt}} \renewcommand\printatom[1]{\textsf{#1}} \chemfig{Me(-[:-50,1.2]Brother)(-[:-10]Brother(-[:15]Niece)(-[:-35]Niece)) (-[:-155,0.8]Sister-[:-80]Nephew)(-[:95,1.25]Father(-[:-25,0.8]Uncle)(-[:-65,0.8]Aunt)) @@ -1302,10 +1264,10 @@ In addition, several possibilities --- some intuitive and others less so --- wil \subsection{Ethanal} Here we will draw the ethanal (or acetaldehyde) molecule: \chemfig{H-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O} -The best method for non-cyclic molecules is to select the longest chain. Here one could take ``\verb|H-C-C=0|'' for example. The bond \verb|C=O| is tilted to 45\degres{} by using the predefined angle ``\verb-[1]-''. This give a ``backbone'' of the molecule to which the branches merely have to be added\idx*{bond!angle!predefined}: +The best method for non-cyclic molecules is to select the longest chain. Here one could take ``\verb|H-C-C=0|'' for example. The bond \verb|C=O| is tilted to 45\degres{} by using the predefined angle ``\verb-[1]-''. This give a ``backbone'' of the molecule to which the branches merely have to be added: \exemple{Backbone of ethanal}|\chemfig{H-C-C=[1]O}| -The three hydrogen atoms still have to placed at the correct orientation with the help of predefined angles. The first is at 90\degres{} with the branch\idx*{bond!branch} ``\verb/(-[2]H)/'', the second at 270\degres{} with ``\verb/(-[6H])/'', and the one on the right at 315\degres{} with ``\verb/(-[7]H)/'': +The three hydrogen atoms still have to placed at the correct orientation with the help of predefined angles. The first is at 90\degres{} with the branch ``\verb/(-[2]H)/'', the second at 270\degres{} with ``\verb/(-[6H])/'', and the one on the right at 315\degres{} with ``\verb/(-[7]H)/'': \exemple{Ethanal}|\chemfig{H-C(-[2]H)(-[6]H)-C(-[7]H)=[1]O}| \subsection{2-amino-4-oxohexanoic acid} @@ -1314,14 +1276,14 @@ Here is the molecule to be drawn: \chemfig{-[::+30]-[::-60](=[:-90]O)-[::+60]-[: As is often the case for most molecules, there are several methods and for each several different ways of getting the result. Here we will look at four different methods. \subsubsection{Absolute angles} -\idx*{bond!angle!absolute}We will first of all draw the central chain with absolute angles. We set the default angle to $+30\degres$ with the optional argument\idx*{chemfig@\protect\texttt{\protect\string\protect\chemfig}!optional arguments}, and so only the descending bonds need to have their absolute angle set to $-30\degres$: +We will first of all draw the central chain with absolute angles. We set the default angle to $+30\degres$ with the optional argument, and so only the descending bonds need to have their absolute angle set to $-30\degres$: \exemple{Backbone (absolute angles)}|\chemfig{[:30]--[:-30]--[:-30]--[:-30]OH}| -The branches\idx*{bond!branch} ``\verb/(=[6]O)/'', ``\verb/(-[6]NH_2)/'' and ``\verb/(=[2]O)/'' still have to be added to the correct vertices: +The branches ``\verb/(=[6]O)/'', ``\verb/(-[6]NH_2)/'' and ``\verb/(=[2]O)/'' still have to be added to the correct vertices: \exemple{Molecule (absolute angles)}|\chemfig{[:30]--[:-30](=[6]O)--[:-30](-[6]NH_2)-(=[2]O)-[:-30]OH}| \subsubsection{Relative angles} -\idx*{bond!angle!relative}A more general approach uses only relative angles, in this way: +A more general approach uses only relative angles, in this way: \exemple{Structure (relative angles)}|\chemfig{[:30]--[::-60]--[::-60]--[::-60]OH}| then @@ -1329,14 +1291,14 @@ then -(=[::60]O)-[::-60]OH}| \subsubsection{Ring} -Since the angles between the bonds are 120\degres{}, it is possible to use a 6-ring, although this method is less natural. Here we take advantage of the fact that a ring can be left unfinished\idx*{ring!unfinished}. The ring must be rotated 120\degres{} so that the first vertex is to the south-east of the ring: +Since the angles between the bonds are 120\degres{}, it is possible to use a 6-ring, although this method is less natural. Here we take advantage of the fact that a ring can be left unfinished. The ring must be rotated 120\degres{} so that the first vertex is to the south-east of the ring: \exemple{Backbone (ring)}|\chemfig{[:120]NH_2*6(---=O)}| -\idx*{ring!branch}Now the branches must be added to the right vertices: +Now the branches must be added to the right vertices: \exemple{Molecule (ring)}|\chemfig{[:120]NH_2*6(-(-(=[::60]O)-[::-60]OH)--(--[::60])=O)}| \subsubsection{Nested rings} -\idx*{ring!nested}Delving deeper into the ring method, we can also consider nesting incomplete 6-rings. We could start with this backbone: +Delving deeper into the ring method, we can also consider nesting incomplete 6-rings. We could start with this backbone: \exemple{Backbone (nested rings)}|\chemfig{*6(--*6(--=O))}| And then add the bonds which leave the vertices of these rings. There are no angles to worry about because the bonds leaving the rings are the bisectors of the sides of the ring, exactly what we want here: @@ -1349,7 +1311,7 @@ A close look shows that the second line segment of the double bond to the oxygen The goal here is to represent the glucose molecule according to several different conventions. \subsubsection{Skeleton diagram} -\idx*{skeleton diagram}The code here looks like that of 2-amino-4-oxohexanoic acid. This gives almost the same structure with absolute angles, except here the default angle is $-30\degres$: +The code here looks like that of 2-amino-4-oxohexanoic acid. This gives almost the same structure with absolute angles, except here the default angle is $-30\degres$: \exemple[60]{Backbone}|\chemfig{[:-30]HO--[:30]--[:30]--[:30]-H}| Adding the branches is no problem. We use predefined absolute angles: @@ -1357,7 +1319,7 @@ Adding the branches is no problem. We use predefined absolute angles: -[:30](<:[2]OH)-(<:[6]OH)-[:30](=[2]O)-H}| \subsubsection{Fisher projection} -\idx*{Fisher projection}The goal is to get the molecule below: +The goal is to get the molecule below: \begin{center} \definesubmol{x}{(-[4]H)(-[0]OH)} \definesubmol{y}{(-[0]H)(-[4]OH)} @@ -1366,13 +1328,13 @@ Adding the branches is no problem. We use predefined absolute angles: The idea is to begin to draw the longest chain vertically by giving a default angle of ``\verb-[2]-''. Here is the skeleton, where we have added lower case letters at the end of each vertical bond: \exemple{Skeleton}|\chemfig{[2]OH-[3]-a-b-c-d-=[1]O}| -Next we define two aliases for the horizontal bonds and the atoms at their ends. Lets choose ``\verb-x-'' which we will put in place of the lower case a, c and d, and ``\verb-y-'' which will replace the letter c. Since these alias are just one character, we do not need braces and can write ``\verb-!x-'' instead of ``\verb-!{x}-''\idx*{\definesubmol}: +Next we define two aliases for the horizontal bonds and the atoms at their ends. Lets choose ``\verb-x-'' which we will put in place of the lower case a, c and d, and ``\verb-y-'' which will replace the letter c. Since these alias are just one character, we do not need braces and can write ``\verb-!x-'' instead of ``\verb-!{x}-'': \exemple{Glucose (Fisher projection)}|\definesubmol{x}{(-[4]H)(-[0]OH)} \definesubmol{y}{(-[0]H)(-[4]OH)} \chemfig{[2]OH-[3]-!x-!x-!y-!x-=[1]O}| \subsubsection{``Chair'' representation} -\idx*{chair representation}We will depict the $\alpha$-D-glucose molecule: +We will depict the $\alpha$-D-glucose molecule: \chemfig{?(-[:190]OH)-[:-50](-[:170]OH)-[:10](-[:-55,0.7]OH)-[:-10](-[6,0.7]OH)-[:130]O-[:190]?(-[:150,0.7]-[2,0.7]OH)} To do this, we will first of all draw five sides of the chair and link the first vertex to the last with a hook ``\verb-?-''. We will use the following absolute angles, running counterclockwise: $-50\degres$, $10\degres$, $-10\degres$, $130\degres$, $190\degres$. @@ -1384,19 +1346,19 @@ Now we simply add the branches inside parentheses. The angles are chosen to give -[:-10](-[6,0.7]OH)-[:130]O-[:190]?(-[:150,0.7]-[2,0.7]OH)}| \subsubsection{Haworth projection} -\idx*{Haworth projection}The goal is to depict this D-glucopyranose molecule: -{\setcrambond{2pt}{}{} +The goal is to depict this D-glucopyranose molecule: +{\setchemfig{cram width=2pt} \chemfig{HO-[2,0.5,2]?<[7,0.7](-[2,0.5]OH)-[,,,,line width=2pt](-[6,0.5]OH)>[1,0.7](-[6,0.5]OH)-[3,0.7]O-[4]?(-[2,0.3]-[3,0.5]OH)}} -First of all we will choose the longest chain, which starts at the ``HO'' group on the left and continues through fives sides of the ring. The ring will be closed with a hook. For the vertical bond which leaves from the first ``HO'' group, we need to specify that it will leave from the second atom using the optional argument. Furthermore, it will be shortened with a coefficient of 0.5. Its optional argument\idx*{chemfig@\protect\texttt{\protect\string\protect\chemfig}!optional arguments} will thus be ``\verb/[2,0.5,2]/''. +First of all we will choose the longest chain, which starts at the ``HO'' group on the left and continues through fives sides of the ring. The ring will be closed with a hook. For the vertical bond which leaves from the first ``HO'' group, we need to specify that it will leave from the second atom using the optional argument. Furthermore, it will be shortened with a coefficient of 0.5. Its optional argument will thus be ``\verb/[2,0.5,2]/''. -Next, to give the impression of perspective to the ring, the diagonal bonds will be shortened by a coefficient of 0.7. For the bold diagonal lines we will use Cram bonds, having redefined the base of the triangles to be 2pt. The bold horizontal bond needs to be drawn with a thickness of 2pt, and so its optional argument will be ``\verb/[0,,,,line width=2pt]/''. Here is the skeleton of the molecule\idx*{\setcrambond}: -\exemple{Structure}|\setcrambond{2pt}{}{} +Next, to give the impression of perspective to the ring, the diagonal bonds will be shortened by a coefficient of 0.7. For the bold diagonal lines we will use Cram bonds, having redefined the base of the triangles to be 2pt. The bold horizontal bond needs to be drawn with a thickness of 2pt, and so its optional argument will be ``\verb/[0,,,,line width=2pt]/''. Here is the skeleton of the molecule: +\exemple{Structure}|\setchemfig{cram width=2pt} \chemfig{HO-[2,0.5,2]?<[7,0.7]-[,,,, line width=2pt]>[1,0.7]-[3,0.7]O-[4]?}| -All that needs to be done now is to add the branches at the correct places, giving the right absolute angles and sometimes reducing the length to better give the illusion of perspective\idx*{\setcrambond}: -\exemple{Haworth projection}|\setcrambond{2pt}{}{} +All that needs to be done now is to add the branches at the correct places, giving the right absolute angles and sometimes reducing the length to better give the illusion of perspective: +\exemple{Haworth projection}|\setchemfig{cram width=2pt} \chemfig{HO-[2,0.5,2]?<[7,0.7](-[2,0.5]OH)-[,,,, line width=2pt](-[6,0.5]OH)>[1,0.7](-[6,0.5]OH)-[3,0.7] O-[4]?(-[2,0.3]-[3,0.5]OH)}| @@ -1408,32 +1370,32 @@ We want to draw the adrenaline molecule: We are going to use two different methods. \subsubsection{Using one ring} -First of all, we start with a 6-ring and we draw the start of the branches\idx*{ring!branch} which leave it: +First of all, we start with a 6-ring and we draw the start of the branches which leave it: \exemple[60]{Skeleton of adrenaline}|\chemfig{*6((-HO)-=-(-)=-(-HO)=)}| The branch on the right still needs to be completed using, for example, relative angles: \exemple[60]{Adrenaline, step two}|\chemfig{*6((-HO)-=-(--[::-60]-[::-60] HN-[::+60]CH_3)=-(-HO)=)}| -Then we need to add a Cram-bonded \verb-OH- and indicate that the bond which arrives at ``\verb-HN-'' does so on the second atom, i.e., ``N''. We use the fourth optional argument of the bond\idx*{chemfig@\protect\texttt{\protect\string\protect\chemfig}!optional arguments}: +Then we need to add a Cram-bonded \verb-OH- and indicate that the bond which arrives at ``\verb-HN-'' does so on the second atom, i.e., ``N''. We use the fourth optional argument of the bond: \exemple[60]{Adrenaline}|\chemfig{*6((-HO)-=-(-(<[::60]OH)-[::-60]-[::-60,,,2] HN-[::+60]CH_3)=-(-HO)=)}| \subsubsection{Using two rings} -This method is less natural, but the goal is to show here how to make a bond invisible\idx*{bond!invisible}. +This method is less natural, but the goal is to show here how to make a bond invisible. -We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-rings adjacent\idx*{ring!nested} to each other: +We could improve this code by considering that the drawing of the adrenaline molecule is made of two 6-rings adjacent to each other: \exemple[60]{Adrenaline, two-ring skeleton}|\chemfig{*6((-HO)-=*6(--HN---)-=-(-HO)=)}| -Now the first two bonds of the ring on the right need to be made invisible. To do this we use the argument that is passed to \TIKZ, specifying ``\verb-draw=none-''. These bonds will thus have this code: ``\verb/-[,,,,,draw=none]/''. To keep the code readable, we define an alias named ``\verb-&-'' for these bonds\idx*{\definesubmol}: +Now the first two bonds of the ring on the right need to be made invisible. To do this we use the argument that is passed to \TIKZ, specifying ``\verb-draw=none-''. These bonds will thus have this code: ``\verb/-[,,,,,draw=none]/''. To keep the code readable, we define an alias named ``\verb-&-'' for these bonds: \exemple[60]{Adrenaline, step two}|\definesubmol{&}{-[,,,,draw=none]} \chemfig{*6((-HO)-=*6(!&!&HN---)-=-(-HO)=)}| -The rest becomes easy; just add the branches to the right vertices\idx*{\definesubmol}: +The rest becomes easy; just add the branches to the right vertices: \exemple[60]{Adrenaline, step three}|\definesubmol{&}{-[,,,,draw=none]} \chemfig{*6((-HO)-=*6(!&!&HN(-CH_3)--(