summaryrefslogtreecommitdiff
path: root/graphics/mol2chemfig
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /graphics/mol2chemfig
Initial commit
Diffstat (limited to 'graphics/mol2chemfig')
-rw-r--r--graphics/mol2chemfig/README74
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/abstract.tex13
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/bond-lengths.tex23
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/composite.tex50
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/conclusion.tex35
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/context.tex5
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/help.tex7
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/hydrogens.tex30
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/input-modes.tex25
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/installation.tex43
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/introduction.tex43
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/output.tex53
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/polishing.tex39
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/recalculating.tex10
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/submolecules.tex46
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/tpic1.tex18
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/tpic2.tex21
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/tpic3.tex16
-rw-r--r--graphics/mol2chemfig/doc/doc-source/chapters/tutorial.tex4
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/atcc.mol49
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/caffeine-from-smiles-rotated.sh1
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/caffeine-from-smiles.sh1
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/caffeine-smi.tex2
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/caffeine-smi2.tex3
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/caffeine.mol34
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/caffeine.smi1
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/ce-submol1.tex56
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/ce-submol2.tex56
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/ce-submol3.tex56
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/crown-ether.mol81
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/cubane.mol25
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/daptomycin-u.sh1
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/daptomycin-u.tex191
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/daptomycin.mol238
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/daptomycin.tex191
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/daptomycin1.sh1
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/dcf-submol1.tex51
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/dcf-submol2.tex51
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/dcf-submol3.tex53
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein.mol63
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein1.sh2
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein2.sh3
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein3.sh3
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/doxo-from-sdf.sh1
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/doxo-raw.tex145
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/doxo-strip-h.sh1
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/doxo-stripped.tex74
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/fmnh.mol71
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/aspirin.tex8
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/caffeine.tex1
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/chemfig-settings.tex10
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green.pngbin0 -> 45165 bytes
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green1.tex9
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green2.tex14
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green3.tex12
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/morphine-f.sh1
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/morphine-f.tex40
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/morphine-k.sh1
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/morphine-k.tex44
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/morphine-n.sh1
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/morphine-n.tex40
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/morphine.mol51
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/morphine.sh1
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/morphine.tex40
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/mp.mol42
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/mp.sh1
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/mp.tex31
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/optionlist.tex115
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/phenol-add-h.sh1
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/phenol-as-submol.sh1
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/phenol-as-submol.tex12
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/phenol-from-smiles-w.sh1
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/phenol-from-smiles-wz.sh1
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/phenol-from-smiles.sh1
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/phenol-smi-terse.tex1
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/phenol-smi-wrapped.tex12
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/phenol-smi.tex10
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/phenol-with-hydrogens.tex26
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/plp.mol48
-rwxr-xr-xgraphics/mol2chemfig/doc/doc-source/examples/plp.sh2
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/plp.tex38
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/plp2.mol48
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/plp2.tex38
-rw-r--r--graphics/mol2chemfig/doc/doc-source/examples/twisted.mol13
-rw-r--r--graphics/mol2chemfig/doc/doc-source/mol2chemfig-doc.tex33
-rw-r--r--graphics/mol2chemfig/doc/doc-source/mol2chemfig.sty236
-rw-r--r--graphics/mol2chemfig/doc/doc-source/preamble.tex60
-rw-r--r--graphics/mol2chemfig/doc/mol2chemfig-doc.pdfbin0 -> 234181 bytes
-rw-r--r--graphics/mol2chemfig/lua/README78
-rwxr-xr-xgraphics/mol2chemfig/lua/mol2chemfig.lua33
-rw-r--r--graphics/mol2chemfig/lua/mol2chemfig_client.lua117
-rw-r--r--graphics/mol2chemfig/lua/mol2chemfig_dkjson.lua646
-rw-r--r--graphics/mol2chemfig/lua/mol2chemfig_jsonrpc.lua86
-rw-r--r--graphics/mol2chemfig/sampledoc/README5
-rw-r--r--graphics/mol2chemfig/sampledoc/mol2chemfig.sty236
-rw-r--r--graphics/mol2chemfig/sampledoc/penicilling.tex44
-rw-r--r--graphics/mol2chemfig/sampledoc/plp.tex38
-rw-r--r--graphics/mol2chemfig/sampledoc/plp2.tex38
-rw-r--r--graphics/mol2chemfig/sampledoc/plpa.tex38
-rw-r--r--graphics/mol2chemfig/sampledoc/plpb.tex38
-rw-r--r--graphics/mol2chemfig/sampledoc/plpn.tex38
-rw-r--r--graphics/mol2chemfig/sampledoc/sample.pdfbin0 -> 102918 bytes
-rw-r--r--graphics/mol2chemfig/sampledoc/sample.tex195
-rw-r--r--graphics/mol2chemfig/tex/mol2chemfig.sty236
104 files changed, 4970 insertions, 0 deletions
diff --git a/graphics/mol2chemfig/README b/graphics/mol2chemfig/README
new file mode 100644
index 0000000000..852ee5f125
--- /dev/null
+++ b/graphics/mol2chemfig/README
@@ -0,0 +1,74 @@
+mol2chemfig 1.4
+---------------
+
+mol2chemfig is a Python program to convert chemical structures
+from MDL molfile format or SMILES format to the TeX format defined
+by the chemfig package. Its home page is at
+
+http://chimpsky.uwaterloo.ca/mol2chemfig/
+
+This folder contains all available files for installing mol2chemfig
+on your computer.
+
+
+Licence
+-------
+
+Free (LaTeX Project Licence, see http://www.latex-project.org/lppl/)
+
+
+Requirements
+------------
+
+mol2chemfig needs a working Python version 2.x install.
+At the time of this writing, the most recent Python 2.x version is
+Python 2.7. The program should also work with other recent 2.x versions,
+however.
+
+In addition, mol2chemfig requires indigo toolkit for Python. The installation
+procedures of these prerequisites vary with your platform; in Linux,
+your package manager will likely be able to satisfy all requirements.
+Otherwise, visit python.org for Python and ggasoftware.com for indigo.
+
+To compile the code generated by mol2chemfig as part of a LaTeX document,
+you need both the chemfig package and the mol2chemfig.sty package that
+is included with this download (within the latex directory).
+
+
+Installation
+------------
+
+Once you have the prerequisites installed and working, open a shell
+window and enter
+
+cd install
+python setup.py install
+
+you will likely need administrator privileges for this to work.
+After that, you should be able to run
+
+mol2chemfig
+
+If this fails, you need to update your PATH environmental variable
+to include Python's default script directory.
+
+If installation fails, do NOT contact me - there are a myriad possible
+reasons, and most likely I can not figure them out from the other side
+of the world. Instead, go buy a beer for your resident
+Mac/Windows/Linux/WhatEver guru.
+
+
+Usage
+-----
+
+The 'latex' folder contains a sample document with several included
+mol2chemfig-generated chemfig code files. It also contains the
+mol2chemfig.sty LaTeX package that is required to compile any
+documents using mol2chemfig-generated chemfig code, including
+code generated through the mol2chemfig web interface.
+
+
+Bugs?
+-----
+
+Thought so. Please send bug reports to mpalmer@uwaterloo.ca. \ No newline at end of file
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/abstract.tex b/graphics/mol2chemfig/doc/doc-source/chapters/abstract.tex
new file mode 100644
index 0000000000..46c9600106
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/abstract.tex
@@ -0,0 +1,13 @@
+\begin{abstract}
+\noindent \mcf is a Python program that generates \TeX\ graphics of chemical structures provided in \mf or \smiles format. Its output is written in the syntax of the \chf package, which in turn is based on \tkz. Thus, both these packages are required in order to compile \mcf's output.
+%
+The program is available
+%
+\begin{inparaenum}[a)]
+\item through a web interface,
+\item for local installation, and
+\item as a command line-driven thin client.
+\end{inparaenum}
+%
+The thin client is a Lua script that is designed to work with recent TeXLive installations.
+\end{abstract}
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/bond-lengths.tex b/graphics/mol2chemfig/doc/doc-source/chapters/bond-lengths.tex
new file mode 100644
index 0000000000..d5993637e4
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/bond-lengths.tex
@@ -0,0 +1,23 @@
+\subsection{Bond lengths}
+
+You will have noticed that, in the above doxorubicin example, the removal of the hydrogens was accompanied by a reduction in length of the remaining bonds. This happened because, by default, \mcf scales all bond lengths such that the \emph{most frequently occurring} bond length is set equal to 1. In the unstripped version, the most frequent bonds were those to the explicit hydrogens. These were very short, which caused all other bonds to be unduly extended. Stripping the hydrogens restored a more proportioned appearance.
+
+There are two mechanisms with which we can explicitly change the bond lengths:
+
+\begin{enumerate}
+\item Within \mcf, you can use the \lstinline!--bond-scale! or \lstinline!-s! option, usually in combination with the \lstinline!--bond-stretch! or \lstinline!-t! option.
+
+\item Within \chf, you can set the unit bond length---that is, the length of a bond whose length is equals 1 inside the \lstinline!\chemfig! macro---with \chf's \lstinline!\setatomsep! macro.
+\end{enumerate}
+
+The \lstinline!\setatomsep! approach is straightforward; in this document, \lstinline!\setatomsep{16pt}! has been used throughout. The two \mcf options need a bit more explaining. The \lstinline!--bond-scale! or \lstinline!-s! option defines \mcf's overall behavior:
+
+\begin{itemize}
+\item With a setting of \lstinline!--bond-scale=keep!, \mcf will leave the bond lengths entirely alone; the \lstinline!--bond-stretch! option will have no effect in this case.
+
+\item With \lstinline!--bond-scale=normalize!, which is the default, all bonds will be scaled such that the most frequently occurring bond length is set to the value of the \lstinline!--bond-stretch! option, which defaults to 1.
+
+\item With \lstinline!--bond-scale=scale!, the value of \lstinline!--bond-stretch! will be used as a multiplier to the native length of each bond, as contained in the input file; no normalization will occur in this case.
+\end{itemize}
+
+Thus, the meaning of the \lstinline!--bond-stretch! option depends on the setting of the \lstinline!--bond-scale! option.
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/composite.tex b/graphics/mol2chemfig/doc/doc-source/chapters/composite.tex
new file mode 100644
index 0000000000..492c241ef5
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/composite.tex
@@ -0,0 +1,50 @@
+\subsection{Using generated code in composite figures}
+
+The \texttt{mol2chemfig} package loads \texttt{chemfig}, which in turn loads the general purpose graphics package \texttt{TikZ}. Through the latter package, we have access to the \texttt{tikzpicture} environment. Here is a \texttt{tikzpicture} that depicts two resonance structures of alanine bound to pyridoxal phosphate:
+
+\input{chapters/tpic1}
+
+The code for this graphics is
+
+\lstinputlisting{chapters/tpic1}
+
+The two structures were placed on the canvas using \tkz nodes. The \tkz nodes cannot contain \lstinline!\input! macros. Therefore, as a workaround, we render the structures as submol definitions with
+
+\lstinputlisting{plp.sh}
+
+and then reference those definitions from within the \lstinline!\chemfig! macros inside the nodes.
+
+Reactions such as the mesomeric transitions within pyridoxal phosphate should also show some electron pushing. The \chf package offers a mechanism for naming atoms and bonds in molecules; these names can then be used to attach push arrows. We can ask \mcf to generate atom and bond names for us, using the \lstinline!--markers! or \lstinline!-g! option:
+
+\lstinputlisting{mp.sh}
+
+This option adds a unique identifier to each atom and to each bond. The option value (\texttt{mp} in our example) is used as a prefix; this allows to unambiguously reference atoms in multiple molecules in the same drawing. In our example, atom 3 will be given the marker \lstinline!@{mp3}! for atom 3. The bond between atoms 3 and 4 will be labeled with \lstinline!@{mp3-4}!; in bond markers, the smaller atom number always comes first. The generated code now starts to get a wee bit tough on the eyeballs:
+
+\lstinputlisting[firstline=1,lastline=5]{mp.tex}
+
+\ldots
+
+In order to attach drawing elements to the nodes defined in the \mcf-rendered structures, we need to use a separate \lstinline!tikzpicture! environment, with the optional arguments \lstinline![remember picture, overlay]!. Inside this environment, we can use arbitrary \tkz commands to decorate our rendered structures. Here is an example:
+
+\lstinputlisting{chapters/tpic2.tex}
+
+which gives
+
+\input{chapters/tpic2}
+
+One important thing to note is that, when the overlay mechanism is used, the document has to be processed \emph{twice} by pdftex---otherwise, the overlaid elements tend to get misaligned.
+
+The \lstinline!\draw! commands used in the example for the electron push arrows employed the \lstinline!mcfpusharrow! \tkz style that is defined by the \mcf package. You can adjust this style to your own tastes with the \lstinline!\tikzset! macro.
+
+If the push-arrows are the \emph{only} drawing element you need, you can avoid the need for explicitly creating an overlaid second \lstinline!tikzpicture! environment by using macros predefined by either \chf and \mcf. The next example illustrates the use of the \lstinline!\mcfpush! macro defined by \mcf.
+
+\lstinputlisting{chapters/tpic3.tex}
+
+which gives
+
+\input{chapters/tpic3}
+
+The arguments of the \lstinline!\mcfpush! macro are, in order, the named anchor of the origin, the parameters of the first control point (departure angle:distance), and the second anchor and second control point (arrival angle:distance). Two optional arguments set the \lstinline!shorten <=! and \lstinline!shorten >=! lengths for the arrow in question, which override the global values which can be adjusted using the \lstinline!\tikzset! mechanism. The \lstinline!\mcfpush! macro uses the \lstinline!mcfpusharrow! \tkz style (see above). This style references two color definitions, which were redefined using \lstinline!colorlet! (supplied by package \lstinline!xcolor!) in this example. The background color (\lstinline!mcfbgcolor!) defaults to white; you will only want to change it when drawing on a non-white canvas. This color definition is also used when drawing crossing bonds in the foreground (see section \ref{sec:tweaking}).
+
+Note that internally the picture overlay mechanism is still used, so the need for processing the file through pdftex twice remains.
+
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/conclusion.tex b/graphics/mol2chemfig/doc/doc-source/chapters/conclusion.tex
new file mode 100644
index 0000000000..693129481a
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/conclusion.tex
@@ -0,0 +1,35 @@
+\section{Invoking \texttt{mol2chemfig} from within \LaTeX}
+
+Using the \lstinline!--shell-escape! option on Linux or its equivalents on other systems, \LaTeX\ can execute shell commands, capture the output and insert it directly into the document. We can use this with \mcf. If you have \mcf working and \LaTeX\ properly configured, the following command will insert the structure of FMNH directly into your document, without creating a separate file:
+
+\begin{verbatim}
+\mcfinput{-fw examples/fmnh.mol}
+\end{verbatim}
+
+\begin{center}
+\mcfinput{-fw examples/fmnh.mol}
+\end{center}
+
+\noindent Note, however, that with large documents and numerous formulas the overhead of running \texttt{mol2chemfig} on each formula during every compilation will add up.
+
+\section{\texttt{chemfig} settings used in this document}
+\label{sec:ChemfigSettings}
+
+Several settings are offered by \chf to control the appearance of structures in your documents. Below are the settings that were used in this document.
+
+\lstinputlisting{hand-coded-tex/chemfig-settings}
+
+\section{Conclusion}
+
+This tutorial has covered most capabilities of \mcf. There are a few more options that influence the appearance of the output; these should be pretty much self-explanatory.
+
+I hope \mcf will be useful to you. If you come across any bugs or issues, please send email to mpalmer\lstinline!@!uwaterloo.ca.
+
+\section{Acknowledgments}
+
+Christian Tellechea wrote the excellent \chf package, upon which \mcf is based. He also gave valuable advice and suggestions concerning \mcf itself. To the extent that \mcf understands chemistry, it owes this to the creators of \texttt{indigo}. An earlier version of \mcf used \texttt{rdkit}; however, after some experimentation, I found that \texttt{indigo} was better suited to my purpose. Nevertheless, I thank \texttt{rdkit}'s creator, Greg Landrum, for promptly and thoroughly answering all my questions.
+%
+My student Eric Brefo-Mensah tested the code extensively and uncovered numerous bugs (or rather, a whole plague of locusts). Further bugs were reported by Benjamin Abel, Philipp Bisson, and Vincent Liegeois.
+%
+% A big thank you to everyone.
+
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/context.tex b/graphics/mol2chemfig/doc/doc-source/chapters/context.tex
new file mode 100644
index 0000000000..f05692f986
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/context.tex
@@ -0,0 +1,5 @@
+\subsection{ConTeXt compatibility}
+
+Currently not available.
+
+%\tkz and \chf are both compatible with ConTeXt. I don't know the first thing about ConTeXt myself, but thankfully Christian Tellechea, the author of \chf, has provided a plain-\TeX\ file with macros that should allow \mcf to work with ConTeXt. This file, \mcfplain, is also included with the archive and should be installed alongside \chf.
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/help.tex b/graphics/mol2chemfig/doc/doc-source/chapters/help.tex
new file mode 100644
index 0000000000..b38ca5df9c
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/help.tex
@@ -0,0 +1,7 @@
+\section{Getting help}
+
+When you type \lstinline!mol2chemfig -h! or just \lstinline!mol2chemfig!, you will see a brief description of the program, as well as a list of all available options:%
+%
+\bigskip
+
+\lstinputlisting{optionlist}
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/hydrogens.tex b/graphics/mol2chemfig/doc/doc-source/chapters/hydrogens.tex
new file mode 100644
index 0000000000..0f1d4fdfa4
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/hydrogens.tex
@@ -0,0 +1,30 @@
+\subsection{Adding and deleting hydrogens}
+
+The next example renders an SDF file for doxorubicin, downloaded from PubChem%
+%
+\footnote{We could also just have used the \texttt{-i pubchem} option, but since we are going to reuse the file, a local copy is handy.}
+
+\lstinputlisting{doxo-from-sdf.sh}
+
+This gives us (yikes)
+
+\cfpic{doxo-raw.tex}
+
+Let's remove the explicit hydrogens with option \lstinline!--hydrogens=delete! or \lstinline!-y delete!:
+
+\lstinputlisting{doxo-strip-h.sh}
+
+This gives
+
+\cfpic{doxo-stripped.tex}
+
+It is also possible to \emph{add} hydrogens to a structure that does not supply them; for example:
+
+\lstinputlisting{phenol-add-h.sh}
+
+produces
+
+\cfpic{phenol-with-hydrogens.tex}
+
+By default, \mcf neither removes nor adds hydrogens. Note also that adding hydrogens will trigger coordinate recalculation (see section \ref{sec:recalc}).
+
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/input-modes.tex b/graphics/mol2chemfig/doc/doc-source/chapters/input-modes.tex
new file mode 100644
index 0000000000..75e60f79cd
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/input-modes.tex
@@ -0,0 +1,25 @@
+\subsection{Input modes}
+
+By default, if you type \lstinline!mol2chemfig myinput!, \mcf expects \texttt{myinput} to be the name of a file that contains a molecule's description in either \mf or \smiles format. These are widely used file formats that can be exported from any chemical drawing program that I am aware of.
+%
+If you want \texttt{myinput} to be treated verbatim, rather than as a file name, you say:
+
+\begin{lstlisting}
+mol2chemfig --input=direct 'C1=CC=C(C=C1)O'
+\end{lstlisting}
+
+or, shorter:
+
+\begin{lstlisting}
+mol2chemfig -i direct 'C1=CC=C(C=C1)O'
+\end{lstlisting}
+
+When passing a smiles string as in this example, don't forget to put quotes around it; without them, the shell will try to expand it and likely cause an error.
+
+There is also the input format 'pubchem', which makes \mcf expect a numerical identifier for the pubchem database:
+
+\begin{lstlisting}
+mol2chemfig -i pubchem 996
+\end{lstlisting}
+
+This retrieves the \texttt{SDF} file for compound no.\ 996 (which happens to be phenol) from the PubChem database and uses it as input. The \texttt{SDF} format is a superset of the \texttt{molfile} format and is understood by the program as well. Obviously, you have to be online for this input mode to work.
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/installation.tex b/graphics/mol2chemfig/doc/doc-source/chapters/installation.tex
new file mode 100644
index 0000000000..afd900f9db
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/installation.tex
@@ -0,0 +1,43 @@
+\section{Installation}
+
+There are three ways to run \mcf:
+%
+\begin{inparaenum}
+\item You can use the web interface.
+\item You can install a web client version of \mcf that is operated from the command line.
+\item You can install the entire program locally.
+\end{inparaenum}
+
+With options 1 and 2, everything you need can hopefully be installed via TeXLive by the time you read this. In contrast, with option 3, some additional handiwork is required.
+
+Update: \mcf has been on CTAN for a good while now, but as far as I can tell adoption into TeXLive has not happened, and apparently isn't going to.
+
+\subsection{\LaTeX\ requirements}
+
+In order to use the code generated by \mcf in your documents, you need
+
+\begin{enumerate}
+\item \tkz, a large and powerful general graphics package.
+
+\item \chf, which defines the code format used by \mcf and uses \tkz to render it to molecule graphics.
+
+\item The \texttt{mol2chemfig.sty} package. This is a very small package that defines some auxiliary macros for \mcf.
+\end{enumerate}
+
+\tkz and \chf are available through TeXLive, and \mcf is or will hopefully soon be, too. Note that the \mcf package will load the \chf package for you, which in turn loads \tkz. Therefore, in your documents, it is sufficient to include the clause \lstinline!\usepackage{mol2chemfig}! in order to load all three of them.
+
+\subsection{Installing the Lua web client}
+
+The web client should be installed and properly configured when you install \mcf through TeXLive; this is the preferred method. You should be able to invoke it from a shell window (or command prompt, in Windows parlance) with the command
+
+\begin{lstlisting}
+$ mol2chemfig.lua
+\end{lstlisting}
+
+If you downloaded the \mcf bundle from CTAN, no automatic installation is performed. In that case, follow the instructions in the included README file.
+
+\subsection{Local installation}
+
+For the full local install of \mcf, you need a Python base installation, and additionally the \texttt{indigo} cheminformatics toolkit. On at least some Linux distributions, \texttt{indigo} is available through the package manager. On other systems, manual download (\url{http://ggasoftware.com/download/indigo}) and installation may be required.
+
+Once you have the prerequisites installed and working, download the \mcf Python code from \url{http://chimpsky.uwaterloo.ca/mol2chemfig}, unzip in a convenient location and follow the included instructions.
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/introduction.tex b/graphics/mol2chemfig/doc/doc-source/chapters/introduction.tex
new file mode 100644
index 0000000000..ad260ca6dd
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/introduction.tex
@@ -0,0 +1,43 @@
+
+\section{A few examples}
+\label{sec:example}
+
+The following is a \smiles representation of caffeine, contained in the file \texttt{caffeine.smi}:
+
+\lstinputlisting{caffeine.smi}
+
+We can turn this into \chf code with the following command:%
+%
+\footnote{The examples in this document assume that you have installed the local version of \mcf. If you installed the web client version, you must use \lstinline!mol2chemfig.lua! wherever the listed example commands use \lstinline!mol2chemfig!.}
+
+\lstinputlisting{caffeine-from-smiles.sh}
+
+This writes the following \chf code to the target file:
+
+\lstinputlisting{caffeine-smi.tex}
+
+If we load this file with \lstinline!\input{caffeine-smi.tex}!, we get the following result%
+%
+\footnote{The appearance of the chemical formulas in this document has been tweaked using some settings that are provided by the \texttt{chemfig} package. The settings used here are listed in Section \ref{sec:ChemfigSettings}.}
+
+\cfpic{caffeine-smi.tex}
+
+which is almost what we want. We adjust the rotation of the molecule and also tweak its appearance a little:
+
+\lstinputlisting{caffeine-from-smiles-rotated.sh}
+
+With these modifications, the structure looks as follows:
+
+\cfpic{caffeine-smi2.tex}
+
+Small molecules like caffeine are fairly easy to create with \chf alone. Hand-written \chf code will look cleaner and more concise than the code generated by \mcf. For example, here is the hand-coded \chf version for caffeine that will produce the exact same graphic as the last \mcf command:
+
+\lstinputlisting{hand-coded-tex/caffeine}
+%
+In particular, the syntax for specifying rings and ring substituents in \chf is remarkably powerful and elegant. With a little practice, molecules such as this one can be hand-written with little effort, and I sincerely recommend that you learn this skill. However, if you need to depict many small molecules, or fairly large ones, a tool like \mcf will come in handy. Take, for example, the lipopeptide antibiotic daptomycin, which we in this case load from a molfile:
+
+\lstinputlisting{daptomycin1.sh}
+
+\cfpic{daptomycin}
+
+This molecule might take a little longer to code by hand \ldots
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/output.tex b/graphics/mol2chemfig/doc/doc-source/chapters/output.tex
new file mode 100644
index 0000000000..9db9450716
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/output.tex
@@ -0,0 +1,53 @@
+\subsection{Output destination and formats}
+
+By default, \mcf simply writes to the terminal (stdout). Use output redirection to send the output to a file instead:
+
+\lstinputlisting{phenol-from-smiles.sh}
+
+This writes the following \chf code to the file:
+
+\lstinputlisting{phenol-smi.tex}
+
+If we input this code directly, we will not produce a graphic; instead, we will just see the code itself, only without the line breaks. To produce a graphic, the code must be enclosed in a \lstinline!\chemfig{...}! macro. This could be done manually by copying and pasting. It is usually more convenient to use the \lstinline!-w! or \lstinline!--wrap-chemfig! option:
+
+\lstinputlisting{phenol-from-smiles-w.sh}
+
+which will produce
+
+\lstinputlisting{phenol-smi-wrapped.tex}
+
+This file can then be used with \lstinline!\input{phenol-smi-wrapped}! directly:
+
+\cfpic{phenol-smi-wrapped}
+
+Note that the following will \emph{not} work:
+
+\begin{lstlisting}
+\chemfig{\input{phenol-smi.tex}}
+\end{lstlisting}
+
+This is because the \lstinline!\chemfig{...}! command puts \TeX\ into an altogether different frame of mind, in which many other commands, including \lstinline!\input!, no longer work as usual.
+
+In addition to the option \lstinline!--wrap-chemfig! or \lstinline!-w!, there is also the option \lstinline!--submol-name! or \lstinline!-l!, which will wrap the generated code into a \lstinline!\definesubmol! macro:
+
+\lstinputlisting{phenol-as-submol.sh}
+
+%\clearpage
+
+This produces
+
+\lstinputlisting{phenol-as-submol.tex}
+
+The \lstinline!\definesubmol! macro is implemented by \chf and defines a named shortcut for a molecule or fragment. This is useful if you want to integrate the generated code into larger, manually assembled structures or drawings. We will revisit this topic below.
+
+In the file listings above, each atom appears on a separate line and is annotated by a comment with its number. The \texttt{\% ->} in the last line indicates that this bond does not create a new atom but instead connects back to atom number 4 to close a ring.
+
+The formatting and annotation in the code example above is useful if you want to manually edit the generated code. If this is not required, you can create more compact output with option \lstinline!--terse! or \lstinline!-z!:
+
+\lstinputlisting{phenol-from-smiles-wz.sh}
+
+The generated code is equivalent, but with comments and whitespace stripped out:
+
+\lstinputlisting{phenol-smi-terse}
+
+%\cfpic{phenol-smi-terse} % just checkin ... chicken?
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/polishing.tex b/graphics/mol2chemfig/doc/doc-source/chapters/polishing.tex
new file mode 100644
index 0000000000..481cde81e6
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/polishing.tex
@@ -0,0 +1,39 @@
+\subsection{Tweaking the appearance of bonds}
+\label{sec:tweaking}
+
+The plain command
+
+\lstinputlisting{morphine.sh}
+
+produces
+
+\cfpic{morphine.tex}
+
+which can be improved. First, we may want to give the double (and, if present, triple) bonds a more well-proportioned look. To do so, use option \lstinline!--fancy-bonds! or \lstinline!-f!:
+
+\lstinputlisting{morphine-f.sh}
+
+which gives
+
+\cfpic{morphine-f.tex}
+
+Note that the look of the double bonds involves some \tkz trickery; in the generated code, the double bonds are no longer represented by \lstinline!=! symbols but instead by something like \lstinline!-[:120,,,,drh]!. Also note that, for this to work, you need the current version of the \mcf \LaTeX\ package.
+
+Next, the molecule contains two bonds that cross each other, and we would like to draw the vertical one in the foreground. To specify this bond, we need the numbers of the adjoining atoms. We first can let \mcf print the atom numbers:
+
+\lstinputlisting{morphine-n.sh}
+
+which gives
+
+\cfpic{morphine-n.tex}
+
+The bond that we are looking at connects atoms 19 and 20. We now can use the \lstinline!-k! or \lstinline!--crossbond! option to put it in the foreground:
+
+\lstinputlisting{morphine-k.sh}
+
+which gives us
+
+\cfpic{morphine-k.tex}
+
+To draw crossing bonds, atom numbers and proportioned double or triple bonds, \mcf relies on several custom macros and \tkz styles defined in the \texttt{mol2chemfig.sty} package. Accordingly, the generated code becomes a bit more verbose and less \chf-like.
+
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/recalculating.tex b/graphics/mol2chemfig/doc/doc-source/chapters/recalculating.tex
new file mode 100644
index 0000000000..04a6bf428c
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/recalculating.tex
@@ -0,0 +1,10 @@
+\subsection{Recalculating coordinates}
+\label{sec:recalc}
+
+Molecules specified in \texttt{SMILES} format don't have any coordinates attached to them, so \mcf needs to calculate them; this is performed automatically. Input in \texttt{molfile} format comes with coordinates attached, and \mcf uses these by default. However, we can explicitly request \mcf to discard these coordinates and calculate new ones with the \lstinline!--recalculate-coordinates! or \lstinline!-u! option. When applied to the daptomycin example from section \ref{sec:example},
+\lstinputlisting{daptomycin-u.sh}
+
+this gives us
+
+\cfpic{daptomycin-u.tex}
+
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/submolecules.tex b/graphics/mol2chemfig/doc/doc-source/chapters/submolecules.tex
new file mode 100644
index 0000000000..c4ef14ada1
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/submolecules.tex
@@ -0,0 +1,46 @@
+\subsection{Working with sub-molecules}
+
+The \chf package supplies a nifty mechanism to assemble larger molecules from predefined fragments, or sub-molecules. The following (hand-coded) example builds aspirin from two sub-molecules:
+
+\lstinputlisting{hand-coded-tex/aspirin.tex}
+
+\cfpic{hand-coded-tex/aspirin}
+
+As a more advanced example, let us piece together the structure of Sodium Green, a fluorescent sodium indicator dye (the figure below was ripped from an information sheet by the supplier, Molecular Probes).
+
+\begin{center}
+\includegraphics[width=0.75\textwidth]{examples/hand-coded-tex/sodium-green.png}
+\end{center}
+
+The molecule contains two moieties of dichlorofluorescein, attached to a crown ether via a linker. We start with dichlorofluorescein as one submol and the crown ether-cum-linkers as the other.
+
+\lstinputlisting{dichlorofluorescein1.sh}
+
+Now, we put the two pieces together, starting with the bridging carbonyl group:
+
+\lstinputlisting{hand-coded-tex/sodium-green1}
+
+which gives us the following fabulous result:
+
+\cfpic{hand-coded-tex/sodium-green1}
+
+What went wrong here? Submol expansion is essentially string substitution. When the submol is filled in, the connection to the preceding part of the molecule is made by whatever atom happens to have been rendered first, and the last rendered atom connects to the subsequent parts of the structure. So, we need to tell \mcf the order in which to render the atoms. To identify the atoms that we want to join, we display all atom numbers in the structure.
+
+\lstinputlisting[firstline=2]{dichlorofluorescein2.sh}
+
+\cfpic{hand-coded-tex/sodium-green2}
+
+For dichlorofluorescein, we need to connect to atom 22. For the crown ether, we want to enter at atom 12 coming from the left, and leave at atom 32 on the right. To render the sub-molecules accordingly, we use the \lstinline!--entry-atom! or \lstinline!-e! as well as the \lstinline!--exit-atom! or \lstinline!-x! options:
+
+\lstinputlisting[firstline=2]{dichlorofluorescein3.sh}
+
+We put the whole molecule together:
+
+\lstinputlisting{hand-coded-tex/sodium-green3.tex}
+
+This produces
+
+\cfpic{hand-coded-tex/sodium-green3}
+
+which is what we want \ldots\ well, almost; the entry and exit amine groups of the crown ether submol now each have one surplus hydrogen. This problem cannot be fixed using \mcf but requires editing of the generated code by hand.
+
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/tpic1.tex b/graphics/mol2chemfig/doc/doc-source/chapters/tpic1.tex
new file mode 100644
index 0000000000..b6cbf60595
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/tpic1.tex
@@ -0,0 +1,18 @@
+\input{plp}
+\input{plp2}
+
+\begin{center}
+\begin{tikzpicture}%
+[>=stealth, help lines/.style={very thin,draw=black!25}, x=1cm, y=1cm]
+
+% draw grid of help lines
+\draw[help lines] (0,0) grid (12,4);
+
+% place both structures
+\node[anchor=south west, inner sep=10pt] at (0,0) (plp) {\chemfig{!{plp}}};
+\node[anchor=south west, inner sep=10pt] at (7,0) (plp2) {\chemfig{!{plp2}}};
+
+\draw[<->] (plp) -- (plp2);
+
+\end{tikzpicture}
+\end{center} \ No newline at end of file
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/tpic2.tex b/graphics/mol2chemfig/doc/doc-source/chapters/tpic2.tex
new file mode 100644
index 0000000000..6280b5af20
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/tpic2.tex
@@ -0,0 +1,21 @@
+\input{mp}
+
+\begin{center}
+\begin{tikzpicture}% first picture contains mol2chemfig structure
+[>=stealth, help lines/.style={very thin,draw=black!25}, x=1cm, y=1cm]
+
+\draw[help lines] (0,0) grid (6,3);
+\node[anchor=south west, inner sep=10pt] at (1,0) {\chemfig{!{mp}}};
+\end{tikzpicture}
+
+\begin{tikzpicture}[remember picture,overlay] % overlaid picture
+% places draws relative to nodes defined in the mol2chemfig structure
+
+% The mcfpusharrow tikz style is defined in the mol2chemfig package.
+\draw[mcfpusharrow](mp12-13) to [out=60,in=60,looseness=4] (mp11-12);
+\draw[mcfpusharrow](mp2-3) to [out=105,in=105,looseness=5] (mp3);
+
+% attach some arbitrary shapes
+\draw[semithick,blue,fill=red](mp17) -- ++(0.3,0.3) arc (-135:225:0.2);
+\end{tikzpicture}
+\end{center}
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/tpic3.tex b/graphics/mol2chemfig/doc/doc-source/chapters/tpic3.tex
new file mode 100644
index 0000000000..82567ec23c
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/tpic3.tex
@@ -0,0 +1,16 @@
+\input{mp}
+
+\colorlet{mcfpusharrowcolor}{red}
+\colorlet{mcfbgcolor}{yellow}
+\begin{center}
+\begin{tikzpicture}[help lines, x=1cm, y=1cm]
+
+\draw[help lines] (0,0) grid (6,3);
+\node[anchor=south west, inner sep=10pt] at (1,0) {\chemfig{!{mp}}};
+
+\mcfpush{mp12-13}{60:1.5em}{mp11-12}{60:1.5em}
+\mcfpush[-4pt][4pt]{mp2-3}{105:1.5em}{mp3}{105:1.5em}
+
+\end{tikzpicture}
+\end{center}
+
diff --git a/graphics/mol2chemfig/doc/doc-source/chapters/tutorial.tex b/graphics/mol2chemfig/doc/doc-source/chapters/tutorial.tex
new file mode 100644
index 0000000000..ddf8c9ef82
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/chapters/tutorial.tex
@@ -0,0 +1,4 @@
+\section{Tutorial}
+
+In the following, we will work through a series of examples to illustrate the use of some of \mcf's options. With all but the most basic examples, it will be assumed that you are familiar with \chf and its syntax. If you aren't, you can still use \mcf, but you will not be able to manually enhance the \chf output that it generates---your loss.
+
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/atcc.mol b/graphics/mol2chemfig/doc/doc-source/examples/atcc.mol
new file mode 100644
index 0000000000..f89a2c3c99
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/atcc.mol
@@ -0,0 +1,49 @@
+43232
+ Marvin 02171312492D
+
+ 21 23 0 0 1 0 999 V2000
+ 5.2962 -0.1515 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 6.7251 -0.1697 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.3278 2.3234 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 3.5008 2.4702 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.8930 1.6596 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 3.1066 0.6270 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 1.9120 1.1808 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.1255 0.3840 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 4.4955 1.0815 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 3.8280 -0.0746 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 4.5818 0.2610 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 6.0159 0.2519 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 6.0265 1.0768 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.3173 1.4984 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 6.7462 1.4802 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 6.7567 2.3051 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 7.4553 1.0586 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 7.4764 2.7085 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 8.1750 1.4620 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 8.1855 2.2869 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 3.8425 3.2211 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 1 11 1 0 0 0 0
+ 1 12 1 0 0 0 0
+ 2 12 2 0 0 0 0
+ 3 14 1 0 0 0 0
+ 5 4 1 0 0 0 0
+ 5 7 1 0 0 0 0
+ 5 9 1 0 0 0 0
+ 6 8 1 0 0 0 0
+ 6 10 1 0 0 0 0
+ 7 8 1 0 0 0 0
+ 9 11 1 0 0 0 0
+ 10 11 1 0 0 0 0
+ 12 13 1 0 0 0 0
+ 13 14 1 0 0 0 0
+ 13 15 1 0 0 0 0
+ 15 16 2 0 0 0 0
+ 15 17 1 0 0 0 0
+ 16 18 1 0 0 0 0
+ 17 19 2 0 0 0 0
+ 18 20 2 0 0 0 0
+ 19 20 1 0 0 0 0
+ 4 21 1 0 0 0 0
+ 6 4 2 0 0 0 0
+M END
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/caffeine-from-smiles-rotated.sh b/graphics/mol2chemfig/doc/doc-source/examples/caffeine-from-smiles-rotated.sh
new file mode 100755
index 0000000000..328348612c
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/caffeine-from-smiles-rotated.sh
@@ -0,0 +1 @@
+mol2chemfig -zwom -a -30 caffeine.smi > caffeine-smi2.tex \ No newline at end of file
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/caffeine-from-smiles.sh b/graphics/mol2chemfig/doc/doc-source/examples/caffeine-from-smiles.sh
new file mode 100755
index 0000000000..33899ea052
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/caffeine-from-smiles.sh
@@ -0,0 +1 @@
+mol2chemfig -zw caffeine.smi > caffeine-smi.tex \ No newline at end of file
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/caffeine-smi.tex b/graphics/mol2chemfig/doc/doc-source/examples/caffeine-smi.tex
new file mode 100644
index 0000000000..2aa7e08f8c
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/caffeine-smi.tex
@@ -0,0 +1,2 @@
+\chemfig{-[:138]N-[:84]=^[:156]N-[:228]=^[:300](-[:12]\phantom{N})-[:240](%
+=[:300]O)-[:180]N(-[:240])-[:120](=[:180]O)-[:60]N(-)-[:120]}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/caffeine-smi2.tex b/graphics/mol2chemfig/doc/doc-source/examples/caffeine-smi2.tex
new file mode 100644
index 0000000000..25a670d931
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/caffeine-smi2.tex
@@ -0,0 +1,3 @@
+\chemfig{CH_3-[:108,,1]N-[:54](-[:180,0.85,,,draw=none]\mcfcringle{1.03})%
+-[:126]N-[:198]-[:270](-[:342]\phantom{N})-[:210](=[:270]O)-[:150]N(%
+-[:210,,,2]H_3C)-[:90](=[:150]O)-[:30]N(-[:330])-[:90,,,1]CH_3}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/caffeine.mol b/graphics/mol2chemfig/doc/doc-source/examples/caffeine.mol
new file mode 100644
index 0000000000..b2d778e47e
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/caffeine.mol
@@ -0,0 +1,34 @@
+
+ Marvin 01220818012D
+
+ 14 15 0 0 0 0 999 V2000
+ 3.7321 2.0000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.0000 -1.0000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 3.7321 -1.0000 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.5443 0.8047 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.8660 0.5000 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.5443 -0.8047 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 4.5981 0.5000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 4.5981 -0.5000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 3.7321 1.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.8660 -0.5000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 6.1279 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 3.7321 -2.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.8550 1.7553 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.0000 1.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 1 9 2 0 0 0 0
+ 2 10 2 0 0 0 0
+ 3 8 1 0 0 0 0
+ 3 10 1 0 0 0 0
+ 3 12 1 0 0 0 0
+ 4 7 1 0 0 0 0
+ 4 11 1 0 0 0 0
+ 4 13 1 0 0 0 0
+ 5 9 1 0 0 0 0
+ 5 10 1 0 0 0 0
+ 5 14 1 0 0 0 0
+ 6 8 1 0 0 0 0
+ 6 11 2 0 0 0 0
+ 7 8 2 0 0 0 0
+ 7 9 1 0 0 0 0
+M END \ No newline at end of file
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/caffeine.smi b/graphics/mol2chemfig/doc/doc-source/examples/caffeine.smi
new file mode 100644
index 0000000000..fd1cc5f151
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/caffeine.smi
@@ -0,0 +1 @@
+CN1C=NC2=C1C(=O)N(C(=O)N2C)C
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/ce-submol1.tex b/graphics/mol2chemfig/doc/doc-source/examples/ce-submol1.tex
new file mode 100644
index 0000000000..361453c98e
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/ce-submol1.tex
@@ -0,0 +1,56 @@
+\definesubmol{ce1}{
+ % 9
+ -[:180]O% 8
+ -[:240]% 6
+ =_[:300]% 5
+ (
+ -[:240]% 4
+ =_[:180]% 3
+ (
+ -[:240]O% 10
+ -[:180]% 11
+ )
+ -[:120]% 2
+ (
+ -[:180,,,2]H_2N% 12
+ )
+ =_[:60]% 1
+ -% -> 6
+ )
+ -N% 7
+ -[:240]% 13
+ -[:315]% 14
+ -[:15]O% 15
+ -[:300]% 16
+ -% 17
+ -[:60]O% 18
+ -[:345]% 19
+ -[:45]% 20
+ -[:120]N% 21
+ (
+ -[:120]% 24
+ -[:180]% 37
+ -[:231.5,1.089]O% 25
+ -[:128.1,1.084]% 23
+ -[:180]% 22
+ -[:240]\phantom{N}% -> 7
+ )
+ -% 26
+ =_[:60]% 27
+ (
+ -[:120]O% 33
+ -[:180]% 34
+ )
+ -% 31
+ =_[:300]% 30
+ (
+ -[,,,1]NH_2% 32
+ )
+ -[:240]% 29
+ (
+ =_[:180]% 28
+ -[:120]% -> 26
+ )
+ -[:300]O% 35
+ -% 36
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/ce-submol2.tex b/graphics/mol2chemfig/doc/doc-source/examples/ce-submol2.tex
new file mode 100644
index 0000000000..fa9d4f44d7
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/ce-submol2.tex
@@ -0,0 +1,56 @@
+\definesubmol{ce2}{
+ \mcfatomno{9}% 9
+ -[:180]\mcfabove{O}{\mcfatomno{8}}% 8
+ -[:240]\mcfatomno{6}% 6
+ =_[:300]\mcfatomno{5}% 5
+ (
+ -[:240]\mcfatomno{4}% 4
+ =_[:180]\mcfatomno{3}% 3
+ (
+ -[:240]\mcfbelow{O}{\mcfatomno{10}}% 10
+ -[:180]\mcfatomno{11}% 11
+ )
+ -[:120]\mcfatomno{2}% 2
+ (
+ -[:180]\mcfleft{\mcfatomno{12}}{N}% 12
+ )
+ =_[:60]\mcfatomno{1}% 1
+ -\phantom{6}% -> 6
+ )
+ -\mcfright{N}{\mcfatomno{7}}% 7
+ -[:240]\mcfatomno{13}% 13
+ -[:315]\mcfatomno{14}% 14
+ -[:15]\mcfabove{O}{\mcfatomno{15}}% 15
+ -[:300]\mcfatomno{16}% 16
+ -\mcfatomno{17}% 17
+ -[:60]\mcfabove{O}{\mcfatomno{18}}% 18
+ -[:345]\mcfatomno{19}% 19
+ -[:45]\mcfatomno{20}% 20
+ -[:120]\mcfleft{\mcfatomno{21}}{N}% 21
+ (
+ -[:120]\mcfatomno{24}% 24
+ -[:180]\mcfatomno{37}% 37
+ -[:231.5,1.089]\mcfbelow{O}{\mcfatomno{25}}% 25
+ -[:128.1,1.084]\mcfatomno{23}% 23
+ -[:180]\mcfatomno{22}% 22
+ -[:240]\phantom{N}% -> 7
+ )
+ -\mcfatomno{26}% 26
+ =_[:60]\mcfatomno{27}% 27
+ (
+ -[:120]\mcfabove{O}{\mcfatomno{33}}% 33
+ -[:180]\mcfatomno{34}% 34
+ )
+ -\mcfatomno{31}% 31
+ =_[:300]\mcfatomno{30}% 30
+ (
+ -\mcfright{N}{\mcfatomno{32}}% 32
+ )
+ -[:240]\mcfatomno{29}% 29
+ (
+ =_[:180]\mcfatomno{28}% 28
+ -[:120]\phantom{26}% -> 26
+ )
+ -[:300]\mcfbelow{O}{\mcfatomno{35}}% 35
+ -\mcfatomno{36}% 36
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/ce-submol3.tex b/graphics/mol2chemfig/doc/doc-source/examples/ce-submol3.tex
new file mode 100644
index 0000000000..1821d496c5
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/ce-submol3.tex
@@ -0,0 +1,56 @@
+\definesubmol{ce3}{
+ H_2N% 12
+ -[,,2]% 2
+ =_[:60]% 1
+ -% 6
+ (
+ -[:60]O% 8
+ -% 9
+ )
+ =_[:300]% 5
+ (
+ -[:240]% 4
+ =_[:180]% 3
+ (
+ -[:240]O% 10
+ -[:180]% 11
+ )
+ -[:120]% -> 2
+ )
+ -N% 7
+ -[:240]% 13
+ -[:315]% 14
+ -[:15]O% 15
+ -[:300]% 16
+ -% 17
+ -[:60]O% 18
+ -[:345]% 19
+ -[:45]% 20
+ -[:120]N% 21
+ (
+ -[:120]% 24
+ -[:180]% 37
+ -[:231.5,1.089]O% 25
+ -[:128.1,1.084]% 23
+ -[:180]% 22
+ -[:240]\phantom{N}% -> 7
+ )
+ -% 26
+ =_[:60]% 27
+ (
+ -[:120]O% 33
+ -[:180]% 34
+ )
+ -% 31
+ =_[:300]% 30
+ (
+ -[:240]% 29
+ (
+ -[:300]O% 35
+ -% 36
+ )
+ =_[:180]% 28
+ -[:120]% -> 26
+ )
+ -[,,,1]NH_2% 32
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/crown-ether.mol b/graphics/mol2chemfig/doc/doc-source/examples/crown-ether.mol
new file mode 100644
index 0000000000..f7cf5a32e8
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/crown-ether.mol
@@ -0,0 +1,81 @@
+
+ Marvin 05211219442D
+
+ 37 39 0 0 0 0 999 V2000
+ -2.8249 2.1308 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -3.2373 1.4163 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.8248 0.7018 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.9998 0.7018 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.5873 1.4163 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.9999 2.1308 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.7623 1.4163 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.5873 2.8452 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.7623 2.8452 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -3.2373 -0.0127 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ -4.0623 -0.0127 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -4.0623 1.4163 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.1748 0.7018 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.5914 0.1185 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.2055 0.3320 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.6180 -0.3825 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 1.4430 -0.3825 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 1.8555 0.3320 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.6523 0.1185 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 3.2357 0.7018 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.8232 1.4163 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.3498 2.1308 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.4752 2.1308 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.4107 2.1308 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 1.0266 1.4272 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 3.6482 1.4163 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 4.0607 2.1308 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 4.0607 0.7018 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 4.8857 0.7018 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.2982 1.4163 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 4.8857 2.1308 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 6.1232 1.4163 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 3.6482 2.8452 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.8232 2.8452 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.2982 -0.0127 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 6.1232 -0.0127 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 1.5857 2.1308 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 1 2 2 0 0 0 0
+ 2 3 1 0 0 0 0
+ 3 4 2 0 0 0 0
+ 4 5 1 0 0 0 0
+ 5 6 2 0 0 0 0
+ 1 6 1 0 0 0 0
+ 5 7 1 0 0 0 0
+ 6 8 1 0 0 0 0
+ 8 9 1 0 0 0 0
+ 3 10 1 0 0 0 0
+ 10 11 1 0 0 0 0
+ 2 12 1 0 0 0 0
+ 7 13 1 0 0 0 0
+ 13 14 1 0 0 0 0
+ 14 15 1 0 0 0 0
+ 15 16 1 0 0 0 0
+ 16 17 1 0 0 0 0
+ 17 18 1 0 0 0 0
+ 18 19 1 0 0 0 0
+ 19 20 1 0 0 0 0
+ 20 21 1 0 0 0 0
+ 7 22 1 0 0 0 0
+ 22 23 1 0 0 0 0
+ 21 24 1 0 0 0 0
+ 23 25 1 0 0 0 0
+ 21 26 1 0 0 0 0
+ 27 26 2 0 0 0 0
+ 26 28 1 0 0 0 0
+ 28 29 2 0 0 0 0
+ 29 30 1 0 0 0 0
+ 30 31 2 0 0 0 0
+ 27 31 1 0 0 0 0
+ 30 32 1 0 0 0 0
+ 27 33 1 0 0 0 0
+ 33 34 1 0 0 0 0
+ 29 35 1 0 0 0 0
+ 35 36 1 0 0 0 0
+ 24 37 1 0 0 0 0
+ 37 25 1 0 0 0 0
+M END
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/cubane.mol b/graphics/mol2chemfig/doc/doc-source/examples/cubane.mol
new file mode 100644
index 0000000000..cd329e0eff
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/cubane.mol
@@ -0,0 +1,25 @@
+136090
+ OpenBabel01111309492D
+
+ 8 12 0 0 1 0 0 0 0 0999 V2000
+ 2.0000 -0.7000 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0
+ 2.0000 0.3000 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0
+ 3.0000 -0.7000 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0
+ 2.4000 -0.3000 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0
+ 3.0000 0.3000 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0
+ 2.4000 0.7000 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0
+ 3.4000 -0.3000 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0
+ 3.4000 0.7000 0.0000 C 0 0 3 0 0 0 0 0 0 0 0 0
+ 1 2 1 0 0 0 0
+ 1 3 1 0 0 0 0
+ 1 4 1 0 0 0 0
+ 2 5 1 0 0 0 0
+ 2 6 1 0 0 0 0
+ 3 5 1 0 0 0 0
+ 3 7 1 0 0 0 0
+ 4 6 1 0 0 0 0
+ 4 7 1 0 0 0 0
+ 5 8 1 0 0 0 0
+ 6 8 1 0 0 0 0
+ 7 8 1 0 0 0 0
+M END
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/daptomycin-u.sh b/graphics/mol2chemfig/doc/doc-source/examples/daptomycin-u.sh
new file mode 100755
index 0000000000..bd26c321ea
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/daptomycin-u.sh
@@ -0,0 +1 @@
+mol2chemfig -u -wf daptomycin.mol > daptomycin-u.tex \ No newline at end of file
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/daptomycin-u.tex b/graphics/mol2chemfig/doc/doc-source/examples/daptomycin-u.tex
new file mode 100644
index 0000000000..7bd845b685
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/daptomycin-u.tex
@@ -0,0 +1,191 @@
+\chemfig{
+ O% 5
+ =[:305.8]% 3
+ (
+ >:[:5.8]% 2
+ (
+ -[:65.8]% 4
+ -[:5.8]% 115
+ -[:59.8]% 109
+ -[:107.8]% 110
+ -[:47.8,,,,drh]% 111
+ -[:347.8]% 112
+ -[:287.8,,,,drh]% 107
+ -[:227.8]% 108
+ (
+ -[:275.8,,,1]NH% 113
+ -[:203.8,,1]% 114
+ -[:131.8,,,,dbr={73}{73}]% -> 115
+ )
+ -[:167.8,,,,drh]% -> 109
+ )
+ -[:305.8,,,1]NH% 1
+ -[:245.8,,1]% 93
+ (
+ -[:305.8]% 95
+ -[:5.8]% 96
+ -[:305.8]% 97
+ -[:5.8]% 98
+ -[:305.8]% 99
+ -[:5.8]% 100
+ -[:305.8]% 101
+ -[:5.8]% 102
+ -[:305.8]% 103
+ )
+ =[:185.8]O% 94
+ )
+ -[:245.8]\mcfbelow{N}{H}% 6
+ -[:185.8]% 7
+ (
+ <:[:245.8]% 9
+ -[:305.8]% 10
+ (
+ -[:245.8,,,2]H_2N% 12
+ )
+ =[:5.8]O% 11
+ )
+ -[:125.8]% 8
+ (
+ =[:65.8]O% 15
+ )
+ -[:185.8]\mcfbelow{N}{H}% 13
+ -[:125.8]% 14
+ (
+ -[:65.8]% 16
+ -[:125.8]% 19
+ (
+ =[:65.8]O% 21
+ )
+ -[:185.8,,,2]HO% 20
+ )
+ <:[:185.8]% 17
+ (
+ -[:265.8,,,,dbl={84}{0}]O% 22
+ )
+ -[:125.8]\mcfabove{N}{H}% 18
+ >:[:185.8]% 23
+ -[:270]% 24
+ (
+ =[:354.2]O% 26
+ )
+ -[:258.4,,,1]NH% 25
+ -[:246.8,,1]% 27
+ -[:235.2]% 28
+ (
+ =[:319.4]O% 29
+ )
+ -[:223.5]\mcfbelow{N}{H}% 30
+ -[:211.9]% 31
+ (
+ -[:296.1]% 33
+ -[:356.1]% 34
+ -[:296.1]% 35
+ -[:356.1,,,1]NH_2% 36
+ )
+ -[:200.3]% 32
+ (
+ =[:284.5]O% 37
+ )
+ -[:188.7]\mcfbelow{N}{H}% 38
+ -[:177.1]% 39
+ (
+ <[:261.3]% 43
+ -[:321.3]% 44
+ (
+ -[:261.3,,,1]OH% 46
+ )
+ =[:21.3]O% 45
+ )
+ -[:165.5]% 40
+ (
+ =[:249.7]O% 42
+ )
+ -[:153.9]\mcfbelow{N}{H}% 41
+ -[:142.3]% 47
+ (
+ <:[:226.5]% 49
+ )
+ -[:130.6]% 48
+ (
+ =[:214.8]O% 51
+ )
+ -[:119,,,2]HN% 50
+ -[:107.4,,2]% 52
+ (
+ <[:191.6]% 54
+ -[:251.6]% 55
+ (
+ -[:191.6,,,2]HO% 57
+ )
+ =[:311.6]O% 56
+ )
+ -[:95.8]% 53
+ (
+ =[:180]O% 58
+ )
+ -[:84.2,,,2]HN% 59
+ -[:72.6,,2]% 60
+ -[:61]% 61
+ (
+ =[:145.2]O% 62
+ )
+ -[:49.4]\mcfabove{N}{H}% 63
+ -[:37.7]% 64
+ (
+ <:[:121.9]% 104
+ -[:181.9,,,2]HO% 105
+ )
+ -[:26.1]% 91
+ (
+ =[:110.3]O% 92
+ )
+ -[:14.5]\mcfabove{N}{H}% 90
+ -[:2.9]% 82
+ (
+ <[:87.1]% 84
+ (
+ -[:147.1]% 86
+ -[:87.1]% 87
+ (
+ -[:147.1,,,2]HO% 89
+ )
+ =[:27.1]O% 88
+ )
+ -[:27.1]% 85
+ )
+ -[:351.3]% 81
+ (
+ =[:75.5]O% 83
+ )
+ -[:339.7]\mcfabove{N}{H}% 71
+ -[:328.1]% 69
+ (
+ -[:316.5]% 68
+ (
+ =[:40.6]O% 70
+ )
+ -[:304.8]O% 67
+ -[:293.2]% 65
+ (
+ <:[:17.4]% 66
+ )
+ -[:281.6]% -> 23
+ )
+ <[:52.3]% 72
+ -[:112.3]% 73
+ (
+ =[:172.3]O% 75
+ )
+ -[:52.3]% 74
+ -[:112.3,,,,drh]% 80
+ (
+ -[:172.3,,,2]H_2N% 106
+ )
+ -[:52.3]% 79
+ -[:352.3,,,,drh]% 78
+ -[:292.3]% 77
+ -[:232.3,,,,drh]% 76
+ (
+ -[:172.3]% -> 74
+ )
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/daptomycin.mol b/graphics/mol2chemfig/doc/doc-source/examples/daptomycin.mol
new file mode 100644
index 0000000000..7db489f00b
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/daptomycin.mol
@@ -0,0 +1,238 @@
+16134395
+ Marvin 05101211392D
+
+115118 0 0 0 0 999 V2000
+ 5.0233 3.7420 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.0233 4.5670 0.0000 C 0 0 2 0 0 0 0 0 0 0 0 0
+ 5.7378 4.9795 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 4.3088 4.9795 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.7378 5.8045 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 6.4522 4.5670 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 7.1667 4.9795 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0
+ 7.8812 4.5670 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 7.1667 5.8045 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 7.8812 6.2170 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 7.8812 7.0420 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 8.5956 5.8045 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 8.5956 4.9795 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 9.3101 4.5670 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0
+ 7.8812 3.7420 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 9.3101 3.7420 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.0246 4.9795 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.7390 4.5670 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.0246 3.3295 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.7390 3.7420 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.0246 2.5045 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.0246 5.8045 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 11.4535 4.9795 0.0000 C 0 0 2 0 0 0 0 0 0 0 0 0
+ 11.4535 5.8045 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.1680 6.2170 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.7390 6.2170 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.1680 7.0420 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.8825 7.4545 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.8825 8.2795 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 13.5969 7.0420 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 14.3114 7.4545 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 15.0259 7.0420 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 14.3114 8.2795 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 15.0259 8.6920 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 15.0259 9.5170 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 15.7403 9.9295 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 15.0259 6.2170 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 15.7403 7.4545 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 16.4548 7.0420 0.0000 C 0 0 2 0 0 0 0 0 0 0 0 0
+ 17.1693 7.4545 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 17.8838 7.0420 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 17.1693 8.2795 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 16.4548 6.2170 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 17.1693 5.8045 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 17.1693 4.9795 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 17.8837 6.2170 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 18.5983 7.4545 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0
+ 19.3127 7.0420 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 18.5983 8.2795 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 19.3127 6.2170 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 20.0272 7.4545 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 20.0272 5.8045 0.0000 C 0 0 2 0 0 0 0 0 0 0 0 0
+ 20.0272 4.9795 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 20.7417 6.2170 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 21.4562 5.8045 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 22.1706 6.2170 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 21.4562 4.9795 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 20.7417 4.5670 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 19.3127 4.5670 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 19.3127 3.7420 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 18.5983 3.3295 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 18.5983 2.5045 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 17.8838 3.7420 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 17.1693 3.3295 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0
+ 12.1680 4.5670 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0
+ 12.8824 4.9795 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.1680 3.7420 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.8824 3.3295 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.8824 2.5045 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0
+ 13.5969 3.7420 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 13.5969 2.0920 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.1680 2.0920 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.1680 1.2670 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 11.4535 0.8545 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.8824 0.8545 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.7390 1.2670 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.0246 0.8545 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.0246 0.0295 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.7390 -0.3830 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 11.4535 0.0295 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 14.3114 2.5045 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 15.0258 2.0920 0.0000 C 0 0 2 0 0 0 0 0 0 0 0 0
+ 14.3114 3.3295 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 15.0258 1.2670 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 14.3114 0.8545 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 15.7403 0.8545 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 15.7403 0.0295 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 16.4548 -0.3830 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 15.0258 -0.3830 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 15.7403 2.5045 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 15.7403 3.3295 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 15.0259 3.7420 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.7378 3.3295 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 6.4522 3.7420 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.7378 2.5045 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.0233 2.0920 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.0233 1.2670 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.7377 0.8545 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 6.4522 1.2670 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 7.1667 0.8545 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 7.1667 0.0295 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 6.4522 -0.3830 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 6.4522 -1.2080 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 17.1693 2.5045 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 17.8837 2.0920 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.1680 -0.3830 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.7955 8.1991 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.0810 7.7866 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.0810 6.9616 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 5.7955 6.5491 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 6.5100 6.9616 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 6.5100 7.7866 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 4.2964 8.0415 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 3.8115 7.3741 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 4.2964 6.7067 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 1 2 1 0 0 0 0
+ 2 3 1 0 0 0 0
+ 2 4 1 1 0 0 0
+ 4115 1 0 0 0 0
+ 3 5 2 0 0 0 0
+ 3 6 1 0 0 0 0
+ 6 7 1 0 0 0 0
+ 7 8 1 0 0 0 0
+ 7 9 1 6 0 0 0
+ 9 10 1 0 0 0 0
+ 10 11 2 0 0 0 0
+ 10 12 1 0 0 0 0
+ 8 13 1 0 0 0 0
+ 13 14 1 0 0 0 0
+ 8 15 2 0 0 0 0
+ 14 16 1 6 0 0 0
+ 14 17 1 0 0 0 0
+ 17 18 1 0 0 0 0
+ 16 19 1 0 0 0 0
+ 19 20 1 0 0 0 0
+ 19 21 2 0 0 0 0
+ 17 22 2 0 0 0 0
+ 18 23 1 0 0 0 0
+ 23 24 1 6 0 0 0
+ 24 25 1 0 0 0 0
+ 24 26 2 0 0 0 0
+ 25 27 1 0 0 0 0
+ 27 28 1 0 0 0 0
+ 28 29 2 0 0 0 0
+ 28 30 1 0 0 0 0
+ 30 31 1 0 0 0 0
+ 31 32 1 0 0 0 0
+ 31 33 1 0 0 0 0
+ 33 34 1 0 0 0 0
+ 34 35 1 0 0 0 0
+ 35 36 1 0 0 0 0
+ 32 37 2 0 0 0 0
+ 32 38 1 0 0 0 0
+ 38 39 1 0 0 0 0
+ 39 40 1 0 0 0 0
+ 40 41 1 0 0 0 0
+ 40 42 2 0 0 0 0
+ 39 43 1 6 0 0 0
+ 43 44 1 0 0 0 0
+ 44 45 2 0 0 0 0
+ 44 46 1 0 0 0 0
+ 41 47 1 0 0 0 0
+ 47 48 1 0 0 0 0
+ 47 49 1 6 0 0 0
+ 48 50 1 0 0 0 0
+ 48 51 2 0 0 0 0
+ 50 52 1 0 0 0 0
+ 52 53 1 0 0 0 0
+ 52 54 1 1 0 0 0
+ 54 55 1 0 0 0 0
+ 55 56 2 0 0 0 0
+ 55 57 1 0 0 0 0
+ 53 58 2 0 0 0 0
+ 53 59 1 0 0 0 0
+ 59 60 1 0 0 0 0
+ 60 61 1 0 0 0 0
+ 61 62 2 0 0 0 0
+ 61 63 1 0 0 0 0
+ 63 64 1 0 0 0 0
+ 23 65 1 0 0 0 0
+ 65 66 1 1 0 0 0
+ 65 67 1 0 0 0 0
+ 67 68 1 0 0 0 0
+ 68 69 1 0 0 0 0
+ 68 70 2 0 0 0 0
+ 69 71 1 0 0 0 0
+ 69 72 1 1 0 0 0
+ 72 73 1 0 0 0 0
+ 73 74 1 0 0 0 0
+ 73 75 2 0 0 0 0
+ 80 74 2 0 0 0 0
+ 76 74 1 0 0 0 0
+ 76 77 2 0 0 0 0
+ 77 78 1 0 0 0 0
+ 78 79 2 0 0 0 0
+ 79 80 1 0 0 0 0
+ 71 81 1 0 0 0 0
+ 81 82 1 0 0 0 0
+ 81 83 2 0 0 0 0
+ 82 84 1 1 0 0 0
+ 84 85 1 0 0 0 0
+ 84 86 1 0 0 0 0
+ 86 87 1 0 0 0 0
+ 87 88 2 0 0 0 0
+ 87 89 1 0 0 0 0
+ 82 90 1 0 0 0 0
+ 90 91 1 0 0 0 0
+ 91 92 2 0 0 0 0
+ 1 93 1 0 0 0 0
+ 93 94 2 0 0 0 0
+ 93 95 1 0 0 0 0
+ 95 96 1 0 0 0 0
+ 96 97 1 0 0 0 0
+ 97 98 1 0 0 0 0
+ 98 99 1 0 0 0 0
+ 99100 1 0 0 0 0
+100101 1 0 0 0 0
+101102 1 0 0 0 0
+102103 1 0 0 0 0
+ 64104 1 6 0 0 0
+104105 1 0 0 0 0
+ 64 91 1 0 0 0 0
+ 80106 1 0 0 0 0
+107108 1 0 0 0 0
+109110 1 0 0 0 0
+110111 2 0 0 0 0
+111112 1 0 0 0 0
+107112 2 0 0 0 0
+115109 1 0 0 0 0
+108109 2 0 0 0 0
+113108 1 0 0 0 0
+113114 1 0 0 0 0
+114115 2 0 0 0 0
+M END
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/daptomycin.tex b/graphics/mol2chemfig/doc/doc-source/examples/daptomycin.tex
new file mode 100644
index 0000000000..2ccf1e736f
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/daptomycin.tex
@@ -0,0 +1,191 @@
+\chemfig{
+ O% 5
+ =[:270]% 3
+ (
+ -[:210]% 2
+ (
+ <[:150]% 4
+ -[:90.4,2.094]% 115
+ -[:18]% 109
+ -[:330]% 110
+ -[:30,,,,dlh]% 111
+ -[:90]% 112
+ -[:150,,,,dlh]% 107
+ -[:210]% 108
+ (
+ -[:162]\mcfabove{N}{H}% 113
+ -[:234]% 114
+ -[:306,,,,dbl={73}{73}]% -> 115
+ )
+ -[:270,,,,dlh]% -> 109
+ )
+ -[:270,,,2]HN% 1
+ -[:330,,2]% 93
+ (
+ -[:270]% 95
+ -[:210]% 96
+ -[:270]% 97
+ -[:330]% 98
+ -[:30]% 99
+ -[:330]% 100
+ -[:270]% 101
+ -[:210]% 102
+ -[:270]% 103
+ )
+ =[:30]O% 94
+ )
+ -[:330]\mcfbelow{N}{H}% 6
+ -[:30]% 7
+ (
+ <:[:90]% 9
+ -[:30]% 10
+ (
+ -[:330,,,1]NH_2% 12
+ )
+ =[:90]O% 11
+ )
+ -[:330]% 8
+ (
+ =[:270]O% 15
+ )
+ -[:30]\mcfabove{N}{H}% 13
+ -[:330]% 14
+ (
+ <:[:270]% 16
+ -[:330]% 19
+ (
+ =[:270]O% 21
+ )
+ -[:30,,,1]OH% 20
+ )
+ -[:30]% 17
+ (
+ =[:90]O% 22
+ )
+ -[:330]\mcfbelow{N}{H}% 18
+ -[:30]% 23
+ <:[:90]% 24
+ (
+ =[:150]O% 26
+ )
+ -[:30,,,1]NH% 25
+ -[:90,,1]% 27
+ -[:30]% 28
+ (
+ =[:90]O% 29
+ )
+ -[:330]\mcfbelow{N}{H}% 30
+ -[:30]% 31
+ (
+ -[:90]% 33
+ -[:30]% 34
+ -[:90]% 35
+ -[:30,,,1]NH_2% 36
+ )
+ -[:330]% 32
+ (
+ =[:270]O% 37
+ )
+ -[:30]\mcfabove{N}{H}% 38
+ -[:330]% 39
+ (
+ <:[:270]% 43
+ -[:330]% 44
+ (
+ -[:30,,,1]OH% 46
+ )
+ =[:270]O% 45
+ )
+ -[:30]% 40
+ (
+ =[:90]O% 42
+ )
+ -[:330]\mcfbelow{N}{H}% 41
+ -[:30]% 47
+ (
+ <:[:90]% 49
+ )
+ -[:330]% 48
+ (
+ =[:30]O% 51
+ )
+ -[:270,,,2]HN% 50
+ -[:330,,2]% 52
+ (
+ <[:30]% 54
+ -[:330]% 55
+ (
+ -[:270,,,1]OH% 57
+ )
+ =[:30]O% 56
+ )
+ -[:270]% 53
+ (
+ =[:330]O% 58
+ )
+ -[:210,,,2]HN% 59
+ -[:270,,2]% 60
+ -[:210]% 61
+ (
+ =[:270]O% 62
+ )
+ -[:150]\mcfabove{N}{H}% 63
+ -[:210]% 64
+ (
+ <:[:270]% 104
+ -[:330,,,1]OH% 105
+ )
+ -[:180,1.732]% 91
+ (
+ -[:150,,,,dlhs]O% 92
+ )
+ -[:270,,,1]NH% 90
+ -[:210,,1]% 82
+ (
+ <[:270]% 84
+ (
+ -[:330]% 86
+ -[:270]% 87
+ (
+ -[:210,,,2]HO% 89
+ )
+ =[:330]O% 88
+ )
+ -[:210]% 85
+ )
+ -[:150]% 81
+ (
+ =[:90]O% 83
+ )
+ -[:210]\mcfbelow{N}{H}% 71
+ -[:150]% 69
+ (
+ -[:90]% 68
+ (
+ =[:30]O% 70
+ )
+ -[:150]O% 67
+ -[:90]% 65
+ (
+ <[:30]% 66
+ )
+ -[:150]% -> 23
+ )
+ <[:210]% 72
+ -[:270]% 73
+ (
+ =[:330]O% 75
+ )
+ -[:210]% 74
+ -[:270,,,,drh]% 80
+ (
+ -[:330,,,1]NH_2% 106
+ )
+ -[:210]% 79
+ -[:150,,,,drh]% 78
+ -[:90]% 77
+ -[:30,,,,drh]% 76
+ (
+ -[:330]% -> 74
+ )
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/daptomycin1.sh b/graphics/mol2chemfig/doc/doc-source/examples/daptomycin1.sh
new file mode 100755
index 0000000000..12314a3aec
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/daptomycin1.sh
@@ -0,0 +1 @@
+mol2chemfig -wf daptomycin.mol > daptomycin.tex \ No newline at end of file
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/dcf-submol1.tex b/graphics/mol2chemfig/doc/doc-source/examples/dcf-submol1.tex
new file mode 100644
index 0000000000..3787320606
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/dcf-submol1.tex
@@ -0,0 +1,51 @@
+\definesubmol{dcf1}{
+ O% 15
+ =[:210]% 14
+ -[:270]% 13
+ (
+ -[:330]% 18
+ )
+ =_[:210]% 12
+ -[:150]% 9
+ =_[:210]% 8
+ (
+ -[:270,1.755]% 16
+ =^[:210]% 20
+ -[:270]% 21
+ =^[:330]% 22
+ -[:30]% 23
+ =^[:90]% 24
+ (
+ -[:30]% 25
+ (
+ -[:330]\mcfright{O}{^{\mcfminus}}% 27
+ )
+ =[:90]O% 26
+ )
+ -[:150]% -> 16
+ )
+ -[:150]% 5
+ -[:210]% 4
+ =_[:150]% 3
+ (
+ -[:210]% 17
+ )
+ -[:90]% 2
+ (
+ -[:150,,,2]^{\mcfminus}O% 19
+ )
+ =_[:30]% 1
+ -[:330]% 6
+ (
+ =_[:270]% -> 5
+ )
+ -[:30]O% 7
+ -[:330]% 10
+ (
+ -[:270]% -> 9
+ )
+ =_[:30]% 11
+ (
+ -[:330]% -> 14
+ )
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/dcf-submol2.tex b/graphics/mol2chemfig/doc/doc-source/examples/dcf-submol2.tex
new file mode 100644
index 0000000000..e7a95777fe
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/dcf-submol2.tex
@@ -0,0 +1,51 @@
+\definesubmol{dcf2}{
+ \mcfright{O}{\mcfatomno{15}}% 15
+ =[:210]\mcfatomno{14}% 14
+ -[:270]\mcfatomno{13}% 13
+ (
+ -[:330]\mcfatomno{18}% 18
+ )
+ =_[:210]\mcfatomno{12}% 12
+ -[:150]\mcfatomno{9}% 9
+ =_[:210]\mcfatomno{8}% 8
+ (
+ -[:270,1.755]\mcfatomno{16}% 16
+ =^[:210]\mcfatomno{20}% 20
+ -[:270]\mcfatomno{21}% 21
+ =^[:330]\mcfatomno{22}% 22
+ -[:30]\mcfatomno{23}% 23
+ =^[:90]\mcfatomno{24}% 24
+ (
+ -[:30]\mcfatomno{25}% 25
+ (
+ -[:330]\mcfright{O}{\mcfatomno{27}}% 27
+ )
+ =[:90]\mcfright{O}{\mcfatomno{26}}% 26
+ )
+ -[:150]\phantom{16}% -> 16
+ )
+ -[:150]\mcfatomno{5}% 5
+ -[:210]\mcfatomno{4}% 4
+ =_[:150]\mcfatomno{3}% 3
+ (
+ -[:210]\mcfatomno{17}% 17
+ )
+ -[:90]\mcfatomno{2}% 2
+ (
+ -[:150]\mcfleft{\mcfatomno{19}}{O}% 19
+ )
+ =_[:30]\mcfatomno{1}% 1
+ -[:330]\mcfatomno{6}% 6
+ (
+ =_[:270]\phantom{5}% -> 5
+ )
+ -[:30]\mcfabove{O}{\mcfatomno{7}}% 7
+ -[:330]\mcfatomno{10}% 10
+ (
+ -[:270]\phantom{9}% -> 9
+ )
+ =_[:30]\mcfatomno{11}% 11
+ (
+ -[:330]\phantom{14}% -> 14
+ )
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/dcf-submol3.tex b/graphics/mol2chemfig/doc/doc-source/examples/dcf-submol3.tex
new file mode 100644
index 0000000000..33413d9eb5
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/dcf-submol3.tex
@@ -0,0 +1,53 @@
+\definesubmol{dcf3}{
+ % 22
+ =_[:150]% 21
+ -[:90]% 20
+ =_[:30]% 16
+ (
+ -[:330]% 24
+ (
+ -[:30]% 25
+ (
+ -[:330]\mcfright{O}{^{\mcfminus}}% 27
+ )
+ =[:90]O% 26
+ )
+ =_[:270]% 23
+ -[:210]% -> 22
+ )
+ -[:90,1.755]% 8
+ -[:150]% 5
+ -[:210]% 4
+ =_[:150]% 3
+ (
+ -[:210]% 17
+ )
+ -[:90]% 2
+ (
+ -[:150,,,2]^{\mcfminus}O% 19
+ )
+ =_[:30]% 1
+ -[:330]% 6
+ (
+ =_[:270]% -> 5
+ )
+ -[:30]O% 7
+ -[:330]% 10
+ =_[:30]% 11
+ -[:330]% 14
+ (
+ =[:30]O% 15
+ )
+ -[:270]% 13
+ (
+ -[:330]% 18
+ )
+ =_[:210]% 12
+ -[:150]% 9
+ (
+ =_[:210]% -> 8
+ )
+ (
+ -[:90]% -> 10
+ )
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein.mol b/graphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein.mol
new file mode 100644
index 0000000000..620c1683c8
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein.mol
@@ -0,0 +1,63 @@
+
+ Marvin 05191217082D
+
+ 27 30 0 0 0 0 999 V2000
+ -2.8481 3.3463 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -3.5626 2.9338 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -3.5626 2.1088 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.8481 1.6963 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.1337 2.1088 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.1337 2.9338 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.4192 3.3463 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.4192 1.6963 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.7047 2.1088 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.7047 2.9338 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.0097 3.3463 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.0097 1.6963 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.7242 2.1088 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.7242 2.9338 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 1.4387 3.3463 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.4192 0.2487 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -4.2771 1.6963 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 1.4387 1.6963 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -4.2771 3.3463 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0
+ -2.1337 -0.1638 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.1337 -0.9888 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.4192 -1.4013 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.7047 -0.9888 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.7047 -0.1638 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.0098 0.2487 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.0098 1.0737 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.7242 -0.1638 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0
+ 1 2 2 0 0 0 0
+ 2 3 1 0 0 0 0
+ 3 4 2 0 0 0 0
+ 4 5 1 0 0 0 0
+ 1 6 1 0 0 0 0
+ 7 6 1 0 0 0 0
+ 6 5 2 0 0 0 0
+ 5 8 1 0 0 0 0
+ 8 9 2 0 0 0 0
+ 7 10 1 0 0 0 0
+ 11 10 2 0 0 0 0
+ 10 9 1 0 0 0 0
+ 9 12 1 0 0 0 0
+ 12 13 2 0 0 0 0
+ 13 14 1 0 0 0 0
+ 11 14 1 0 0 0 0
+ 14 15 2 0 0 0 0
+ 8 16 1 0 0 0 0
+ 3 17 1 0 0 0 0
+ 13 18 1 0 0 0 0
+ 2 19 1 0 0 0 0
+ 16 20 2 0 0 0 0
+ 16 24 1 0 0 0 0
+ 20 21 1 0 0 0 0
+ 21 22 2 0 0 0 0
+ 22 23 1 0 0 0 0
+ 23 24 2 0 0 0 0
+ 24 25 1 0 0 0 0
+ 25 26 2 0 0 0 0
+ 25 27 1 0 0 0 0
+M CHG 2 19 -1 27 -1
+M END
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein1.sh b/graphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein1.sh
new file mode 100755
index 0000000000..51d2b28545
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein1.sh
@@ -0,0 +1,2 @@
+mol2chemfig -l dcf1 dichlorofluorescein.mol > dcf-submol1.tex
+mol2chemfig -l ce1 crown-ether.mol > ce-submol1.tex
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein2.sh b/graphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein2.sh
new file mode 100755
index 0000000000..ef10d00ea3
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein2.sh
@@ -0,0 +1,3 @@
+# numbered versions
+mol2chemfig -n -l dcf2 dichlorofluorescein.mol > dcf-submol2.tex
+mol2chemfig -n -l ce2 crown-ether.mol > ce-submol2.tex
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein3.sh b/graphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein3.sh
new file mode 100755
index 0000000000..2d7c788b20
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/dichlorofluorescein3.sh
@@ -0,0 +1,3 @@
+# correctly ordered versions
+mol2chemfig -e 22 -l dcf3 dichlorofluorescein.mol > dcf-submol3.tex
+mol2chemfig -e 12 -x 32 -l ce3 crown-ether.mol > ce-submol3.tex
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/doxo-from-sdf.sh b/graphics/mol2chemfig/doc/doc-source/examples/doxo-from-sdf.sh
new file mode 100755
index 0000000000..b948344b9a
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/doxo-from-sdf.sh
@@ -0,0 +1 @@
+mol2chemfig -w doxorubicin.sdf > doxo-raw.tex \ No newline at end of file
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/doxo-raw.tex b/graphics/mol2chemfig/doc/doc-source/examples/doxo-raw.tex
new file mode 100644
index 0000000000..1af8856904
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/doxo-raw.tex
@@ -0,0 +1,145 @@
+\chemfig{
+ O% 7
+ =[:300.2,1.613]% 25
+ (
+ -[:240.2,1.613]% 30
+ (
+ -[:260.2]H% 57
+ )
+ (
+ -[:340.2]H% 58
+ )
+ -[:180.2,1.613]O% 8
+ -[:240.2]H% 63
+ )
+ -[:0.2,1.613]% 14
+ (
+ <:[:240.2,1.613]O% 3
+ -[:300.2]H% 51
+ )
+ -[:90,1.68]% 15
+ (
+ -[:109.7]H% 41
+ )
+ (
+ -[:189.9]H% 42
+ )
+ -[:29.6,1.68]% 13
+ (
+ <:[:89.3,1.613]O% 1
+ >:[:149.3,1.613]% 19
+ (
+ -[:29.3]H% 45
+ )
+ -[:209.3,1.613]O% 2
+ -[:149.3,1.613]% 23
+ (
+ <[:209.3,1.613]% 29
+ (
+ -[:209.3]H% 53
+ )
+ (
+ -[:299.3]H% 54
+ )
+ -[:119.3]H% 52
+ )
+ (
+ -[:269.3]H% 50
+ )
+ -[:89.3,1.613]% 22
+ (
+ -[:29.3,1.613]% 21
+ (
+ -[:329.3,1.613]% 20
+ (
+ -[:349.3]H% 46
+ )
+ (
+ -[:69.3]H% 47
+ )
+ -[:269.3,1.613]% -> 19
+ )
+ (
+ -[:149.3]H% 48
+ )
+ <[:89.3,1.613]N% 12
+ (
+ -[:149.3]H% 56
+ )
+ -[:29.3]H% 55
+ )
+ (
+ -[:209.3]H% 49
+ )
+ <[:149.3,1.613]O% 4
+ -[:209.3]H% 59
+ )
+ (
+ -[:149.5]H% 40
+ )
+ -[:329.1,1.68]% 17
+ -[:270,1.613]% 18
+ (
+ -[:210.9,1.68]% 16
+ (
+ -[:230.6]H% 43
+ )
+ (
+ -[:310.7]H% 44
+ )
+ -[:150.4,1.68]% -> 14
+ )
+ =^[:330,1.613]% 26
+ (
+ -[:270,1.613]O% 6
+ -[:210]H% 61
+ )
+ -[:30,1.613]% 28
+ =^[:90,1.613]% 27
+ (
+ -[:150,1.613]% 24
+ (
+ =^[:210,1.613]% -> 17
+ )
+ -[:90,1.613]O% 5
+ -[:30]H% 60
+ )
+ -[:30.9,1.68]% 31
+ (
+ =[:90.7,1.613]O% 9
+ )
+ -[:330.4,1.68]% 33
+ =^[:270,1.68]% 34
+ (
+ -[:209.6,1.68]% 32
+ (
+ -[:149.1,1.68]% -> 28
+ )
+ =[:269.3,1.613]O% 10
+ )
+ -[:329.1,1.75]% 36
+ (
+ -[:269.3]H% 62
+ )
+ =^[:29.6,1.75]% 38
+ (
+ -[:329.8]H% 65
+ )
+ -[:90,1.75]% 37
+ (
+ -[:30.2]H% 64
+ )
+ =^[:150.4,1.75]% 35
+ (
+ -[:210.9,1.75]% -> 33
+ )
+ -[:90.7,1.613]O% 11
+ -[:30.7,1.613]% 39
+ (
+ -[:300.7]H% 66
+ )
+ (
+ -[:30.7]H% 67
+ )
+ -[:120.7]H% 68
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/doxo-strip-h.sh b/graphics/mol2chemfig/doc/doc-source/examples/doxo-strip-h.sh
new file mode 100755
index 0000000000..411ecf8d89
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/doxo-strip-h.sh
@@ -0,0 +1 @@
+mol2chemfig -w -y delete doxorubicin.sdf > doxo-stripped.tex \ No newline at end of file
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/doxo-stripped.tex b/graphics/mol2chemfig/doc/doc-source/examples/doxo-stripped.tex
new file mode 100644
index 0000000000..c177de0873
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/doxo-stripped.tex
@@ -0,0 +1,74 @@
+\chemfig{
+ HO% 3
+ >:[:60.2,,2]% 14
+ (
+ -[:180.2]% 25
+ (
+ -[:240.2]% 30
+ -[:180.2,,,2]HO% 8
+ )
+ =[:120.2]O% 7
+ )
+ -[:90,1.042]% 15
+ -[:29.6,1.042]% 13
+ (
+ <:[:89.3]O% 1
+ >:[:149.3]% 19
+ -[:209.3]O% 2
+ -[:149.3]% 23
+ (
+ <[:209.3]% 29
+ )
+ -[:89.3]% 22
+ (
+ -[:29.3]% 21
+ (
+ -[:329.3]% 20
+ -[:269.3]% -> 19
+ )
+ <[:89.3,,,1]NH_2% 12
+ )
+ <[:149.3,,,2]HO% 4
+ )
+ -[:329.1,1.042]% 17
+ -[:270]% 18
+ (
+ -[:210.9,1.042]% 16
+ -[:150.4,1.042]% -> 14
+ )
+ =^[:330]% 26
+ (
+ -[:270,,,1]OH% 6
+ )
+ -[:30]% 28
+ =^[:90]% 27
+ (
+ -[:150]% 24
+ (
+ =^[:210]% -> 17
+ )
+ -[:90,,,1]OH% 5
+ )
+ -[:30.9,1.042]% 31
+ (
+ =[:90.7]O% 9
+ )
+ -[:330.4,1.042]% 33
+ =^[:270,1.042]% 34
+ (
+ -[:209.6,1.042]% 32
+ (
+ -[:149.1,1.042]% -> 28
+ )
+ =[:269.3]O% 10
+ )
+ -[:329.1,1.085]% 36
+ =^[:29.6,1.085]% 38
+ -[:90,1.085]% 37
+ =^[:150.4,1.085]% 35
+ (
+ -[:210.9,1.085]% -> 33
+ )
+ -[:90.7]O% 11
+ -[:30.7]% 39
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/fmnh.mol b/graphics/mol2chemfig/doc/doc-source/examples/fmnh.mol
new file mode 100644
index 0000000000..048bc84d05
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/fmnh.mol
@@ -0,0 +1,71 @@
+
+ Marvin 09131216222D
+
+ 31 33 0 0 0 0 999 V2000
+ -0.8545 -2.2393 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.5689 -2.6518 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.5689 -3.4768 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.8545 -3.8893 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.1400 -3.4768 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.1400 -2.6518 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.5745 -2.2393 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.5745 -3.8893 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 1.2889 -3.4768 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 1.2889 -2.6518 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.0034 -2.2393 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.0034 -3.8893 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.7179 -3.4768 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.7179 -2.6518 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.5745 -1.4143 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.1620 -0.6998 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.5745 0.0147 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.1620 0.7291 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.5745 1.4436 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.6630 -0.6998 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 1.3995 0.0147 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.6630 0.7291 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 1.3995 1.4436 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.2245 1.4436 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0
+ 3.0495 1.4436 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.2245 0.6186 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0
+ 2.2245 2.2686 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0
+ -2.2834 -2.2393 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.2834 -3.8893 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 2.0034 -4.7143 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 3.4323 -2.2393 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 1 2 1 0 0 0 0
+ 1 6 2 0 0 0 0
+ 2 3 2 0 0 0 0
+ 3 4 1 0 0 0 0
+ 4 5 2 0 0 0 0
+ 7 6 1 0 0 0 0
+ 6 5 1 0 0 0 0
+ 5 8 1 0 0 0 0
+ 7 10 1 0 0 0 0
+ 8 9 1 0 0 0 0
+ 11 10 2 0 0 0 0
+ 10 9 1 0 0 0 0
+ 9 12 1 0 0 0 0
+ 11 14 1 0 0 0 0
+ 12 13 1 0 0 0 0
+ 13 14 1 0 0 0 0
+ 7 15 1 0 0 0 0
+ 15 16 1 0 0 0 0
+ 16 17 1 0 0 0 0
+ 17 18 1 0 0 0 0
+ 18 19 1 0 0 0 0
+ 16 20 1 0 0 0 0
+ 17 21 1 0 0 0 0
+ 18 22 1 0 0 0 0
+ 19 23 1 0 0 0 0
+ 23 24 1 0 0 0 0
+ 24 25 2 0 0 0 0
+ 24 26 1 0 0 0 0
+ 24 27 1 0 0 0 0
+ 2 28 1 0 0 0 0
+ 3 29 1 0 0 0 0
+ 12 30 2 0 0 0 0
+ 14 31 2 0 0 0 0
+M CHG 2 26 -1 27 -1
+M RAD 1 9 2
+M END
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/aspirin.tex b/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/aspirin.tex
new file mode 100644
index 0000000000..576c9d8a43
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/aspirin.tex
@@ -0,0 +1,8 @@
+\definesubmol{acetyl}{(=[::60]O)-[::-60]H_3C}
+\definesubmol{benzoate}{*6(-=-=-(-(=[::60]O)-[::-60]OH)=)}%
+
+\chemfig{
+ {\color{red}O} % the oxygen in the middle
+ (-[:210]!{acetyl}) % treat one submol as a branch,
+ -[:-30]!{benzoate} % the other one as the main chain
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/caffeine.tex b/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/caffeine.tex
new file mode 100644
index 0000000000..8b49661938
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/caffeine.tex
@@ -0,0 +1 @@
+\chemfig{H_3C-[:30]N**6(-(=O)-(**5(-N(-CH_3)--N-))--N(-CH_3)-(=O)-)}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/chemfig-settings.tex b/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/chemfig-settings.tex
new file mode 100644
index 0000000000..cffe37c1df
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/chemfig-settings.tex
@@ -0,0 +1,10 @@
+% reduce font size and use sans-serif
+\renewcommand{\printatom}[1]{%
+\fontsize{8pt}{10pt}\selectfont{\ensuremath{\mathsf{#1}}}}
+
+% reduce bond dimensions to match smaller fonts
+\setcrambond{2.5pt}{0.4pt}{1.0pt}
+\setbondoffset{1pt}
+\setdoublesep{2pt}
+\setatomsep{16pt}
+
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green.png b/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green.png
new file mode 100644
index 0000000000..0d8b8c9275
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green.png
Binary files differ
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green1.tex b/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green1.tex
new file mode 100644
index 0000000000..84da34dd2c
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green1.tex
@@ -0,0 +1,9 @@
+\input{dcf-submol1} % load generated submolecules ...
+\input{ce-submol1}
+
+\chemfig{ % and stitch them together
+ {\color{red}C}
+ (=[:45]O)
+ (-[:180,6]!{dcf1})
+ -[:-90]!{ce1}
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green2.tex b/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green2.tex
new file mode 100644
index 0000000000..7cea9f0df7
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green2.tex
@@ -0,0 +1,14 @@
+\input{dcf-submol2}
+\input{ce-submol2}
+\begin{center}
+\begin{tikzpicture}
+\node at(0,0){\chemfig{!{dcf2}}};
+\node at(3.0in,0){\chemfig{!{ce2}}};
+\end{tikzpicture}
+\end{center}
+%\chemfig{
+% {\color{red}C}
+% (=[:45]O)
+% (-[:180,6]!{dcf2})
+% -[:-90]!{ce2}
+%}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green3.tex b/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green3.tex
new file mode 100644
index 0000000000..501995ab65
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/hand-coded-tex/sodium-green3.tex
@@ -0,0 +1,12 @@
+\input{dcf-submol3}
+\input{ce-submol3}
+
+\chemfig{
+ {\color{red}C}
+ (=[:225]O)
+ (-[:90]!{dcf3})
+ -!{ce3}
+ -{\color{blue}C}
+ (=[:-45]O)
+ -[:90]!{dcf3}
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/morphine-f.sh b/graphics/mol2chemfig/doc/doc-source/examples/morphine-f.sh
new file mode 100755
index 0000000000..bd4b560de5
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/morphine-f.sh
@@ -0,0 +1 @@
+mol2chemfig -f -w morphine.mol > morphine-f.tex
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/morphine-f.tex b/graphics/mol2chemfig/doc/doc-source/examples/morphine-f.tex
new file mode 100644
index 0000000000..3557709128
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/morphine-f.tex
@@ -0,0 +1,40 @@
+\chemfig{
+ HO% 16
+ -[:60,,2]% 13
+ -[:120,,,,drh]% 12
+ -[:60]% 11
+ -[,,,,drh]% 8
+ -[:60]% 7
+ -% 10
+ -[:300]% 1
+ -% 6
+ -[:300,,,,drh]% 5
+ -[:240]% 4
+ (
+ -[:300,,,1]OH% 17
+ )
+ -[:180]% 3
+ -[:120]% 2
+ (
+ -[:60]% -> 1
+ )
+ (
+ -[:180]% 9
+ (
+ -[:120]% -> 8
+ )
+ -[:240,,,,drh]% 14
+ (
+ -[:327.1,1.233]O% 15
+ -[:34.8,1.174]% -> 3
+ )
+ -[:180]% -> 13
+ )
+ -[:123.3,0.928]% 19
+ -[:89.9,1.239]% 20
+ -[:30.1,1.163]N% 18
+ (
+ -[:240]% -> 10
+ )
+ -[:37.5]% 21
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/morphine-k.sh b/graphics/mol2chemfig/doc/doc-source/examples/morphine-k.sh
new file mode 100755
index 0000000000..a280f43747
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/morphine-k.sh
@@ -0,0 +1 @@
+mol2chemfig -k 19-20 -wf morphine.mol > morphine-k.tex
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/morphine-k.tex b/graphics/mol2chemfig/doc/doc-source/examples/morphine-k.tex
new file mode 100644
index 0000000000..bb75634e18
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/morphine-k.tex
@@ -0,0 +1,44 @@
+\chemfig{
+ HO% 16
+ -[:60,,2]% 13
+ -[:120,,,,drh]% 12
+ -[:60]% 11
+ -[,,,,drh]% 8
+ -[:60]% 7
+ -% 10
+ -[:300]% 1
+ -% 6
+ -[:300,,,,drh]% 5
+ -[:240]% 4
+ (
+ -[:300,,,1]OH% 17
+ )
+ -[:180]% 3
+ -[:120]% 2
+ (
+ -[:60]% -> 1
+ )
+ (
+ -[:180]% 9
+ (
+ -[:120]% -> 8
+ )
+ -[:240,,,,drh]% 14
+ (
+ -[:327.1,1.233]O% 15
+ -[:34.8,1.174]% -> 3
+ )
+ -[:180]% -> 13
+ )
+ -[:123.3,0.928]% 19
+ -[:89.9,1.239,,,draw=none]% 20
+ -[:30.1,1.163]N% 18
+ (
+ -[:240]% -> 10
+ )
+ -[:37.5]% 21
+ (
+ -[:233.4,3.026,,,draw=none]% -> 19
+ -[:89.9,1.239,,,mcfx={10}{10}]% -> 20
+ )
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/morphine-n.sh b/graphics/mol2chemfig/doc/doc-source/examples/morphine-n.sh
new file mode 100755
index 0000000000..d2c76db071
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/morphine-n.sh
@@ -0,0 +1 @@
+mol2chemfig -n -w morphine.mol > morphine-n.tex
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/morphine-n.tex b/graphics/mol2chemfig/doc/doc-source/examples/morphine-n.tex
new file mode 100644
index 0000000000..3ad8cc6d48
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/morphine-n.tex
@@ -0,0 +1,40 @@
+\chemfig{
+ \mcfleft{\mcfatomno{16}}{O}% 16
+ -[:60]\mcfatomno{13}% 13
+ =_[:120]\mcfatomno{12}% 12
+ -[:60]\mcfatomno{11}% 11
+ =_\mcfatomno{8}% 8
+ -[:60]\mcfatomno{7}% 7
+ -\mcfatomno{10}% 10
+ -[:300]\mcfatomno{1}% 1
+ -\mcfatomno{6}% 6
+ =_[:300]\mcfatomno{5}% 5
+ -[:240]\mcfatomno{4}% 4
+ (
+ -[:300]\mcfright{O}{\mcfatomno{17}}% 17
+ )
+ -[:180]\mcfatomno{3}% 3
+ -[:120]\mcfatomno{2}% 2
+ (
+ -[:60]\phantom{1}% -> 1
+ )
+ (
+ -[:180]\mcfatomno{9}% 9
+ (
+ -[:120]\phantom{8}% -> 8
+ )
+ =_[:240]\mcfatomno{14}% 14
+ (
+ -[:327.1,1.233]\mcfbelow{O}{\mcfatomno{15}}% 15
+ -[:34.8,1.174]\phantom{3}% -> 3
+ )
+ -[:180]\phantom{13}% -> 13
+ )
+ -[:123.3,0.928]\mcfatomno{19}% 19
+ -[:89.9,1.239]\mcfatomno{20}% 20
+ -[:30.1,1.163]\mcfabove{N}{\mcfatomno{18}}% 18
+ (
+ -[:240]\phantom{10}% -> 10
+ )
+ -[:37.5]\mcfatomno{21}% 21
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/morphine.mol b/graphics/mol2chemfig/doc/doc-source/examples/morphine.mol
new file mode 100644
index 0000000000..4d17710747
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/morphine.mol
@@ -0,0 +1,51 @@
+5288826
+ Marvin 05021316212D
+
+ 21 25 0 0 1 0 999 V2000
+ 11.4469 1.8931 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 11.0344 1.1786 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 11.4469 0.4641 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.2719 0.4641 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.6844 1.1786 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.2719 1.8930 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.2094 2.6076 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 9.7969 1.8931 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.2094 1.1786 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 11.0344 2.6075 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 8.9719 1.8930 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 8.5594 1.1786 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 8.9719 0.4641 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 9.7969 0.4641 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.6513 -0.0886 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 8.5594 -0.2504 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.6844 -0.2504 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ 11.4469 3.3220 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.6145 1.8189 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 10.6166 2.8411 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 12.1014 3.8242 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 2 3 1 0 0 0 0
+ 3 4 1 0 0 0 0
+ 4 5 1 0 0 0 0
+ 5 6 2 0 0 0 0
+ 1 6 1 0 0 0 0
+ 1 10 1 0 0 0 0
+ 2 1 1 0 0 0 0
+ 9 2 1 0 0 0 0
+ 7 8 1 0 0 0 0
+ 7 10 1 0 0 0 0
+ 14 9 2 0 0 0 0
+ 8 9 1 0 0 0 0
+ 8 11 2 0 0 0 0
+ 11 12 1 0 0 0 0
+ 12 13 2 0 0 0 0
+ 13 14 1 0 0 0 0
+ 14 15 1 0 0 0 0
+ 3 15 1 0 0 0 0
+ 13 16 1 0 0 0 0
+ 4 17 1 0 0 0 0
+ 10 18 1 0 0 0 0
+ 2 19 1 0 0 0 0
+ 18 20 1 0 0 0 0
+ 20 19 1 0 0 0 0
+ 18 21 1 0 0 0 0
+M END
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/morphine.sh b/graphics/mol2chemfig/doc/doc-source/examples/morphine.sh
new file mode 100755
index 0000000000..e0b0319867
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/morphine.sh
@@ -0,0 +1 @@
+mol2chemfig -w morphine.mol > morphine.tex
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/morphine.tex b/graphics/mol2chemfig/doc/doc-source/examples/morphine.tex
new file mode 100644
index 0000000000..ba80f885ba
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/morphine.tex
@@ -0,0 +1,40 @@
+\chemfig{
+ HO% 16
+ -[:60,,2]% 13
+ =_[:120]% 12
+ -[:60]% 11
+ =_% 8
+ -[:60]% 7
+ -% 10
+ -[:300]% 1
+ -% 6
+ =_[:300]% 5
+ -[:240]% 4
+ (
+ -[:300,,,1]OH% 17
+ )
+ -[:180]% 3
+ -[:120]% 2
+ (
+ -[:60]% -> 1
+ )
+ (
+ -[:180]% 9
+ (
+ -[:120]% -> 8
+ )
+ =_[:240]% 14
+ (
+ -[:327.1,1.233]O% 15
+ -[:34.8,1.174]% -> 3
+ )
+ -[:180]% -> 13
+ )
+ -[:123.3,0.928]% 19
+ -[:89.9,1.239]% 20
+ -[:30.1,1.163]N% 18
+ (
+ -[:240]% -> 10
+ )
+ -[:37.5]% 21
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/mp.mol b/graphics/mol2chemfig/doc/doc-source/examples/mp.mol
new file mode 100644
index 0000000000..5dcb270ade
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/mp.mol
@@ -0,0 +1,42 @@
+
+ Marvin 10271217122D
+
+ 17 20 0 0 0 0 999 V2000
+ -1.2670 -1.7089 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.9814 -2.1214 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.9814 -2.9464 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.2670 -3.3589 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.5525 -2.9464 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.5525 -2.1214 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.5525 -0.4714 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.2670 -0.8839 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.1620 -1.7089 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 0.1620 -0.8839 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.9814 -0.4714 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.6959 -0.8839 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.6959 -1.7089 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.2670 0.7661 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.9814 0.3536 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.5525 0.3536 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.2670 1.5911 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 2 3 2 0 0 0 0
+ 3 4 1 0 0 0 0
+ 4 5 2 0 0 0 0
+ 5 6 1 0 0 0 0
+ 6 9 1 0 0 0 0
+ 1 6 2 0 0 0 0
+ 7 10 1 0 0 0 0
+ 9 10 2 0 0 0 0
+ 8 1 1 0 0 0 0
+ 1 2 1 0 0 0 0
+ 13 2 1 0 0 0 0
+ 11 12 1 0 0 0 0
+ 12 13 2 0 0 0 0
+ 15 11 1 0 0 0 0
+ 11 8 2 0 0 0 0
+ 8 7 1 0 0 0 0
+ 7 16 2 0 0 0 0
+ 14 15 2 0 0 0 0
+ 14 16 1 0 0 0 0
+ 14 17 1 0 0 0 0
+M END
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/mp.sh b/graphics/mol2chemfig/doc/doc-source/examples/mp.sh
new file mode 100755
index 0000000000..4e9ab919ec
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/mp.sh
@@ -0,0 +1 @@
+mol2chemfig -f -l mp -g mp -a 270 mp.mol > mp.tex
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/mp.tex b/graphics/mol2chemfig/doc/doc-source/examples/mp.tex
new file mode 100644
index 0000000000..9b94d693ef
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/mp.tex
@@ -0,0 +1,31 @@
+\definesubmol{mp}{
+ @{mp17}%
+ -[@{mp14-17}:180]@{mp14}%
+ -[@{mp14-15}:120,,,,dlh]@{mp15}%
+ -[@{mp11-15}:180]@{mp11}%
+ -[@{mp11-12}:120]@{mp12}%
+ -[@{mp12-13}:180,,,,dlh]@{mp13}%
+ -[@{mp2-13}:240]@{mp2}%
+ -[@{mp2-3}:180,,,,dlh]@{mp3}%
+ -[@{mp3-4}:240]@{mp4}%
+ -[@{mp4-5}:300,,,,dlh]@{mp5}%
+ -[@{mp5-6}]@{mp6}%
+ -[@{mp6-9}:300]@{mp9}%
+ -[@{mp9-10},,,,dlh]@{mp10}%
+ -[@{mp7-10}:60]@{mp7}%
+ (
+ -[@{mp7-16},,,,dlh]@{mp16}%
+ -[@{mp14-16}:60]% -> 14
+ )
+ -[@{mp7-8}:120]@{mp8}%
+ (
+ -[@{mp8-11}:60,,,,dlh]% -> 11
+ )
+ -[@{mp1-8}:180]@{mp1}%
+ (
+ -[@{mp1-6}:240,,,,dlh]% -> 6
+ )
+ (
+ -[@{mp1-2}:120]% -> 2
+ )
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/optionlist.tex b/graphics/mol2chemfig/doc/doc-source/examples/optionlist.tex
new file mode 100644
index 0000000000..44a957117e
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/optionlist.tex
@@ -0,0 +1,115 @@
+mol2chemfig v. 1.4, by Eric Brefo-Mensah and Michael Palmer
+mol2chemfig generates chemfig code from molfiles. Usage example:
+
+mol2chemfig --angle=45 --aromatic-circles somefile.mol
+
+Options:
+-h, --help Print help message and exit (Default:
+ False)
+
+-b, --version Print program version and exit (Default:
+ False)
+
+-i, --input How to interpret the argument. With 'file',
+ mol2chemfig expects a filename. With
+ 'direct', the argument is intrepreted
+ directly; don't forget to put quotes around
+ it. With 'pubchem', the argument is treated
+ as an identifier for the PubChem database.
+ (Default: file)
+
+-z, --terse Remove all whitespace and comments from the
+ output. If you can still read it
+ afterwards, Bill Gates wants your resume
+ (Default: False)
+
+-r, --strict Abide by Indigo's chemical structure
+ validation. If true, mol2chemfig will fail
+ if Indigo reports that something is wrong
+ with the molecule, like a carbon with five
+ bonds. If false, mol2chemfig will ignore
+ such errors (Default: True)
+
+-d, --indent Number of spaces to use for indenting
+ molecule branches in generated code.
+ Without effect when 'terse' option is
+ passed. Affects only the generated tex
+ code, not the rendered molecule (Default:
+ 4)
+
+-u, --recalculate-coordinates Discard existing coordinate and calculate
+ new ones from covalent structure. For
+ smiles input, this is performed implicitly
+ (Default: False)
+
+-a, --angle Rotate molecule counterclockwise by this
+ angle (Default: 0.0)
+
+-v, --relative-angles Use relative bond angles (Default: False)
+
+-p, --flip Flip the structure horizontally (Default:
+ False)
+
+-q, --flop Flip the structure vertically (Default:
+ False)
+
+-c, --show-carbons Show element symbol for carbon atoms
+ (Default: False)
+
+-m, --show-methyls Show element symbols for methyl groups
+ (implied if show-carbons is True) (Default:
+ False)
+
+-y, --hydrogens How to deal with explicit hydrogen atoms.
+ One of 'keep', 'add' or 'delete'. Note that
+ 'add' will also trigger calculation of new
+ coordinates for the entire molecule. Option
+ 'keep' does nothing (Default: keep)
+
+-o, --aromatic-circles Draw circles instead of double bonds inside
+ aromatic rings (Default: False)
+
+-f, --fancy-bonds Draw fancier double and triple bonds
+ (Default: False)
+
+-g, --markers Give each atom and each bond a unique
+ marker that can be used for attaching
+ electron movement arrows. With value 'a',
+ atom 2 will be labeled @{a2}, and its bond
+ to atom 5 @{a2-5}. (Default: None)
+
+-n, --atom-numbers Show the molfile number of each atom next
+ to it. When this option is set, charges and
+ implicit hydrogens will not be shown
+ (Default: False)
+
+-s, --bond-scale How to scale the lengths of bonds (one of
+ 'keep', 'scale', or 'normalize') (Default:
+ normalize)
+
+-t, --bond-stretch Used as scaling factor (with --bond-
+ scale=scale) or average (with --bond-
+ scale=normalize) for bond lengths (Default:
+ 1.0)
+
+-w, --wrap-chemfig Wrap generated code into \chemfig{...}
+ command (Default: False)
+
+-l, --submol-name If a name is given, wrap generated code
+ into chemfig \definesubmol{name}{...}
+ command (Default: None)
+
+-e, --entry-atom Number of first atom to be rendered.
+ Relevant only if generated code is to be
+ used as sub-molecule (Default: None)
+
+-x, --exit-atom Number of last atom to be rendered.
+ Relevant only if generated code is to be
+ used as sub-molecule (Default: None)
+
+-k, --cross-bond Specify bonds that should be drawn on top
+ of others they cross over. Give the start
+ and the end atoms. Example for one bond:
+ --cross-bond=5-6 Example for two bonds:
+ --crossbond=4-8,12-13 (Default: None)
+
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/phenol-add-h.sh b/graphics/mol2chemfig/doc/doc-source/examples/phenol-add-h.sh
new file mode 100755
index 0000000000..5701daf90e
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/phenol-add-h.sh
@@ -0,0 +1 @@
+mol2chemfig -y add -w -i direct 'C1=CC=C(C=C1)O' > phenol-with-hydrogens.tex \ No newline at end of file
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/phenol-as-submol.sh b/graphics/mol2chemfig/doc/doc-source/examples/phenol-as-submol.sh
new file mode 100755
index 0000000000..59f11e2cf2
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/phenol-as-submol.sh
@@ -0,0 +1 @@
+mol2chemfig -l phenol -i direct 'C1=CC=C(C=C1)O' > phenol-as-submol.tex \ No newline at end of file
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/phenol-as-submol.tex b/graphics/mol2chemfig/doc/doc-source/examples/phenol-as-submol.tex
new file mode 100644
index 0000000000..b51ef95581
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/phenol-as-submol.tex
@@ -0,0 +1,12 @@
+\definesubmol{phenol}{
+ HO% 7
+ -[,,2]% 4
+ =^[:300]% 3
+ -% 2
+ =^[:60]% 1
+ -[:120]% 6
+ =^[:180]% 5
+ (
+ -[:240]% -> 4
+ )
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/phenol-from-smiles-w.sh b/graphics/mol2chemfig/doc/doc-source/examples/phenol-from-smiles-w.sh
new file mode 100755
index 0000000000..6f25cbdde4
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/phenol-from-smiles-w.sh
@@ -0,0 +1 @@
+mol2chemfig -w -i direct 'C1=CC=C(C=C1)O' > phenol-smi-wrapped.tex \ No newline at end of file
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/phenol-from-smiles-wz.sh b/graphics/mol2chemfig/doc/doc-source/examples/phenol-from-smiles-wz.sh
new file mode 100755
index 0000000000..97c218a62f
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/phenol-from-smiles-wz.sh
@@ -0,0 +1 @@
+mol2chemfig -zw -i direct 'C1=CC=C(C=C1)O' > phenol-smi-terse.tex \ No newline at end of file
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/phenol-from-smiles.sh b/graphics/mol2chemfig/doc/doc-source/examples/phenol-from-smiles.sh
new file mode 100755
index 0000000000..5e1df1db25
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/phenol-from-smiles.sh
@@ -0,0 +1 @@
+mol2chemfig -i direct 'C1=CC=C(C=C1)O' > phenol-smi.tex \ No newline at end of file
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/phenol-smi-terse.tex b/graphics/mol2chemfig/doc/doc-source/examples/phenol-smi-terse.tex
new file mode 100644
index 0000000000..3793a018c5
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/phenol-smi-terse.tex
@@ -0,0 +1 @@
+\chemfig{HO-[,,2]=^[:300]-=^[:60]-[:120]=^[:180](-[:240])}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/phenol-smi-wrapped.tex b/graphics/mol2chemfig/doc/doc-source/examples/phenol-smi-wrapped.tex
new file mode 100644
index 0000000000..c6f70ef10e
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/phenol-smi-wrapped.tex
@@ -0,0 +1,12 @@
+\chemfig{
+ HO% 7
+ -[,,2]% 4
+ =^[:300]% 3
+ -% 2
+ =^[:60]% 1
+ -[:120]% 6
+ =^[:180]% 5
+ (
+ -[:240]% -> 4
+ )
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/phenol-smi.tex b/graphics/mol2chemfig/doc/doc-source/examples/phenol-smi.tex
new file mode 100644
index 0000000000..0bc164867d
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/phenol-smi.tex
@@ -0,0 +1,10 @@
+ HO% 7
+ -[,,2]% 4
+ =^[:300]% 3
+ -% 2
+ =^[:60]% 1
+ -[:120]% 6
+ =^[:180]% 5
+ (
+ -[:240]% -> 4
+ )
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/phenol-with-hydrogens.tex b/graphics/mol2chemfig/doc/doc-source/examples/phenol-with-hydrogens.tex
new file mode 100644
index 0000000000..c831a20d4b
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/phenol-with-hydrogens.tex
@@ -0,0 +1,26 @@
+\chemfig{
+ H% 8
+ -[:180]% 1
+ =_[:240]% 2
+ (
+ -[:300]H% 9
+ )
+ -[:180]% 3
+ (
+ -[:240]H% 10
+ )
+ =_[:120]% 4
+ (
+ -[:180]O% 7
+ -[:120]H% 13
+ )
+ -[:60]% 5
+ (
+ -[:120]H% 11
+ )
+ =_% 6
+ (
+ -[:300]% -> 1
+ )
+ -[:60]H% 12
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/plp.mol b/graphics/mol2chemfig/doc/doc-source/examples/plp.mol
new file mode 100644
index 0000000000..09f686e869
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/plp.mol
@@ -0,0 +1,48 @@
+
+ Marvin 09131213202D
+
+ 21 21 0 0 0 0 999 V2000
+ -3.2411 0.2063 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -3.9555 -0.2062 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -3.9555 -1.0313 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -3.2411 -1.4438 0.0000 N 0 3 0 0 0 0 0 0 0 0 0 0
+ -2.5266 -1.0313 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.5266 -0.2062 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.8121 -1.4438 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.8121 0.2063 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0
+ -4.6700 0.2063 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -5.3845 -0.2062 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ -6.2095 -0.2062 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0
+ -7.0345 -0.2062 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ -6.2095 -1.0312 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0
+ -6.2095 0.6188 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0
+ -3.2411 1.0313 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.5266 1.4438 0.0000 N 0 3 0 0 0 0 0 0 0 0 0 0
+ -2.5266 2.2688 0.0000 C 0 5 0 0 0 0 0 0 0 0 0 0
+ -1.8121 2.6813 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -3.2411 2.6813 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.8121 3.5063 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.0977 2.2688 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0
+ 1 2 1 0 0 0 0
+ 1 6 2 0 0 0 0
+ 2 3 2 0 0 0 0
+ 3 4 1 0 0 0 0
+ 4 5 2 0 0 0 0
+ 5 6 1 0 0 0 0
+ 5 7 1 0 0 0 0
+ 6 8 1 0 0 0 0
+ 2 9 1 0 0 0 0
+ 9 10 1 0 0 0 0
+ 10 11 1 0 0 0 0
+ 11 12 2 0 0 0 0
+ 11 13 1 0 0 0 0
+ 11 14 1 0 0 0 0
+ 1 15 1 0 0 0 0
+ 15 16 2 0 0 0 0
+ 16 17 1 0 0 0 0
+ 17 18 1 0 0 0 0
+ 17 19 1 0 0 0 0
+ 18 20 2 0 0 0 0
+ 18 21 1 0 0 0 0
+M CHG 7 4 1 8 -1 13 -1 14 -1 16 1 17 -1 21 -1
+M END
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/plp.sh b/graphics/mol2chemfig/doc/doc-source/examples/plp.sh
new file mode 100755
index 0000000000..a351f09bc3
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/plp.sh
@@ -0,0 +1,2 @@
+mol2chemfig -f --submol-name plp plp.mol > plp.tex
+mol2chemfig -f --submol-name plp2 plp2.mol > plp2.tex \ No newline at end of file
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/plp.tex b/graphics/mol2chemfig/doc/doc-source/examples/plp.tex
new file mode 100644
index 0000000000..6dd82a1146
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/plp.tex
@@ -0,0 +1,38 @@
+\definesubmol{plp}{
+ % 7
+ -[:150]% 5
+ -[:210,,,,drhs]\mcfbelowright{N}{H}{^{\mcfplus}}% 4
+ -[:150]% 3
+ -[:90,,,,drh]% 2
+ (
+ -[:150]% 9
+ -[:210]O% 10
+ -[:180]P% 11
+ (
+ -[:270]\mcfright{O}{^{\mcfminus}}% 13
+ )
+ (
+ -[:90]\mcfright{O}{^{\mcfminus}}% 14
+ )
+ =[:180]O% 12
+ )
+ -[:30]% 1
+ (
+ -[:330,,,,drh]% 6
+ (
+ -[:30]\mcfright{O}{^{\mcfminus}}% 8
+ )
+ -[:270]% -> 5
+ )
+ -[:90]% 15
+ -[:30,,,1,dlhs]NH^{\mcfplus}% 16
+ -[:90,,1]\mcfabove{C}{_{\mcfminus}}% 17
+ (
+ -[:150]% 19
+ )
+ -[:30]% 18
+ (
+ =[:90]O% 20
+ )
+ -[:330]\mcfright{O}{^{\mcfminus}}% 21
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/plp2.mol b/graphics/mol2chemfig/doc/doc-source/examples/plp2.mol
new file mode 100644
index 0000000000..8d1459f4fd
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/plp2.mol
@@ -0,0 +1,48 @@
+
+ Marvin 09131213192D
+
+ 21 21 0 0 0 0 999 V2000
+ -3.2411 0.2063 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -3.9555 -0.2062 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -3.9555 -1.0313 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -3.2411 -1.4438 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.5266 -1.0313 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.5266 -0.2062 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.8121 -1.4438 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.8121 0.2063 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0
+ -4.6700 0.2063 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -5.3845 -0.2062 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ -6.2095 -0.2062 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0
+ -7.0345 -0.2062 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ -6.2095 -1.0312 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0
+ -6.2095 0.6188 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0
+ -3.2411 1.0313 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.5266 1.4438 0.0000 N 0 3 0 0 0 0 0 0 0 0 0 0
+ -2.5266 2.2688 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.8121 2.6813 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -3.2411 2.6813 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.8121 3.5063 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.0977 2.2688 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0
+ 1 2 1 0 0 0 0
+ 1 6 1 0 0 0 0
+ 2 3 2 0 0 0 0
+ 3 4 1 0 0 0 0
+ 4 5 1 0 0 0 0
+ 5 6 2 0 0 0 0
+ 5 7 1 0 0 0 0
+ 6 8 1 0 0 0 0
+ 2 9 1 0 0 0 0
+ 9 10 1 0 0 0 0
+ 10 11 1 0 0 0 0
+ 11 12 2 0 0 0 0
+ 11 13 1 0 0 0 0
+ 11 14 1 0 0 0 0
+ 1 15 2 0 0 0 0
+ 15 16 1 0 0 0 0
+ 16 17 2 0 0 0 0
+ 17 18 1 0 0 0 0
+ 17 19 1 0 0 0 0
+ 18 20 2 0 0 0 0
+ 18 21 1 0 0 0 0
+M CHG 5 8 -1 13 -1 14 -1 16 1 21 -1
+M END
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/plp2.tex b/graphics/mol2chemfig/doc/doc-source/examples/plp2.tex
new file mode 100644
index 0000000000..c0d352a655
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/plp2.tex
@@ -0,0 +1,38 @@
+\definesubmol{plp2}{
+ % 7
+ -[:150]% 5
+ -[:210]\mcfbelow{N}{H}% 4
+ -[:150]% 3
+ -[:90,,,,drh]% 2
+ (
+ -[:150]% 9
+ -[:210]O% 10
+ -[:180]P% 11
+ (
+ -[:270]\mcfright{O}{^{\mcfminus}}% 13
+ )
+ (
+ -[:90]\mcfright{O}{^{\mcfminus}}% 14
+ )
+ =[:180]O% 12
+ )
+ -[:30]% 1
+ (
+ -[:330]% 6
+ (
+ -[:30]\mcfright{O}{^{\mcfminus}}% 8
+ )
+ -[:270,,,,drh]% -> 5
+ )
+ -[:90,,,,drh]% 15
+ -[:30,,,1]NH^{\mcfplus}% 16
+ =[:90,,1]% 17
+ (
+ -[:150]% 19
+ )
+ -[:30]% 18
+ (
+ =[:90]O% 20
+ )
+ -[:330]\mcfright{O}{^{\mcfminus}}% 21
+}
diff --git a/graphics/mol2chemfig/doc/doc-source/examples/twisted.mol b/graphics/mol2chemfig/doc/doc-source/examples/twisted.mol
new file mode 100644
index 0000000000..0dca2407ae
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/examples/twisted.mol
@@ -0,0 +1,13 @@
+
+ Marvin 01131309442D
+
+ 4 4 0 0 0 0 999 V2000
+ -1.6058 0.4862 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.7808 0.4862 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -0.7808 -0.3388 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.6058 -0.3388 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 1 2 1 0 0 0 0
+ 3 4 1 0 0 0 0
+ 3 1 1 0 0 0 0
+ 2 4 1 0 0 0 0
+M END
diff --git a/graphics/mol2chemfig/doc/doc-source/mol2chemfig-doc.tex b/graphics/mol2chemfig/doc/doc-source/mol2chemfig-doc.tex
new file mode 100644
index 0000000000..fe6b0c971d
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/mol2chemfig-doc.tex
@@ -0,0 +1,33 @@
+\documentclass[letterpaper,11pt]{article}
+
+\input{preamble}
+
+\title{\mcf Documentation}
+\author{Version 1.4}
+
+\begin{document}
+
+\maketitle
+
+\input{chapters/abstract}
+
+\tableofcontents
+
+%\clearpage
+
+\input{chapters/introduction}
+\input{chapters/installation}
+\input{chapters/context}
+\input{chapters/help}
+\input{chapters/tutorial}
+\input{chapters/input-modes}
+\input{chapters/output}
+\input{chapters/hydrogens}
+\input{chapters/bond-lengths}
+\input{chapters/polishing}
+\input{chapters/recalculating}
+\input{chapters/submolecules}
+\input{chapters/composite}
+\input{chapters/conclusion}
+
+\end{document}
diff --git a/graphics/mol2chemfig/doc/doc-source/mol2chemfig.sty b/graphics/mol2chemfig/doc/doc-source/mol2chemfig.sty
new file mode 100644
index 0000000000..2de1613f91
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/mol2chemfig.sty
@@ -0,0 +1,236 @@
+% auxiliary package for mol2chemfig
+\ProvidesPackage{mol2chemfig}[2014/03/24 v1.4]
+
+\RequirePackage{xcolor, chemfig, twoopt, ifmtarg}
+\usetikzlibrary{decorations}
+
+% \setbondstyle is defined by chemfig. Here, we wrap it
+% in order to also save the bond style in a tikz key.
+\let\mcf@setbondstyle\setbondstyle
+\renewcommand{\setbondstyle}[1]{%
+ \mcf@setbondstyle{#1}%
+ \tikzset{mcfbond/.style={#1}}%
+}
+
+% this macro (by Christian Tellechea) draws circles in aromatic rings.
+\def\mcfcringle#1{%
+\tikz\draw[mcfbond](0,0)circle(\CF@atom@sep*#1*0.66667*\CF@cycle@inraduiscoeff);}
+
+% auxiliary macros for rendering double and triple bonds
+
+% tikz decoration to render parallel bond strokes
+\pgfdeclaredecoration{mcfsecondstroke}{initial}{
+ \state{initial}[width=\pgfdecoratedpathlength-1sp]{
+ \pgfmoveto{\pgfpointorigin}
+ }
+ \state{final}{
+ \pgflineto{\pgfpointorigin}
+ }
+}
+
+% the complete sines definition is taken from http://tex.stackexchange.com/questions/25678/
+\pgfdeclaredecoration{complete sines}{initial}
+{
+ \state{initial}[
+ width=+0pt,
+ next state=sine,
+ persistent precomputation={\pgfmathsetmacro\matchinglength{
+ \pgfdecoratedinputsegmentlength / int(\pgfdecoratedinputsegmentlength/\pgfdecorationsegmentlength)}
+ \setlength{\pgfdecorationsegmentlength}{\matchinglength pt}
+ }] {}
+ \state{sine}[width=\pgfdecorationsegmentlength]{
+ \pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
+ \pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
+ \pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
+ \pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
+}
+ \state{final}{}
+}
+
+% color definitions
+\colorlet{mcfbgcolor}{white} % adjust when drawing on a non-white canvas
+\colorlet{mcfpusharrowcolor}{black}
+\colorlet{mcfatomnocolor}{blue}
+
+\tikzset{ % set styles
+ % wavy bonds. Slightly modified from http://www.texdev.net/tag/chemfig/
+ mcfwavy/.style =
+ {
+ decorate,
+ decoration =
+ {
+ complete sines,
+ post length = 0 pt,
+ pre length = 0 pt,
+ % Use chemfig's atom spacing
+ segment length = \the\dimexpr\csname CF@atom@sep\endcsname/6\relax,
+ amplitude = \the\dimexpr\csname CF@atom@sep\endcsname/10\relax
+ }
+ },
+ % this style is used by the \mcfelmove macro
+ mcfpusharrow/.style = {
+ ->,
+ mcfpusharrowcolor,
+ >=stealth,
+ shorten <=3pt,
+ shorten >=2pt,
+ preaction={draw=mcfbgcolor, -,line width=1.5pt}
+ },
+ %
+ mcfbond/.style = {}, % the chemfig default bond style is empty, too.
+ %
+ % one bond crossing before another - gets a white backdrop
+ % as wide as doublesep
+ mcfbgcolor/.style={white},
+ %
+ mcfx/.style 2 args={%
+ preaction={
+ draw,
+ mcfbgcolor,
+ line width=\CF@double@sep,
+ shorten <= {#1*\CF@double@sep/100},
+ shorten >= {#2*\CF@double@sep/100}
+ },
+ mcfbond
+ },
+ %
+ mcfcrossbond/.style={% for backwards compatibility only
+ mcfx={100}{100}
+ },
+ %
+ secondbond/.style 2 args={
+ shorten <= {#1*\CF@double@sep/100},
+ shorten >= {#2*\CF@double@sep/100},
+ mcfbond
+ },
+ %
+ secondfgbond/.style 2 args={
+ preaction={draw,-,mcfbgcolor,line width=\CF@double@sep},
+ secondbond={#1}{#2}
+ },
+ %
+ secondleft/.style 2 args={
+ secondbond={#1}{#2},
+ decoration={mcfsecondstroke,raise=\CF@double@sep},
+ decorate
+ },
+ %
+ secondright/.style 2 args={
+ secondbond={#1}{#2},
+ decoration={mcfsecondstroke,raise=-\CF@double@sep},
+ decorate
+ },
+ %
+ secondfgleft/.style 2 args={
+ secondfgbond={#1}{#2},
+ decoration={mcfsecondstroke,raise=\CF@double@sep},
+ decorate
+ },
+ %
+ secondfgright/.style 2 args={
+ secondfgbond={#1}{#2},
+ decoration={mcfsecondstroke,raise=-\CF@double@sep},
+ decorate
+ },
+ %
+ dbl/.style 2 args={
+ preaction={draw,secondleft={#1}{#2}}
+ },
+ %
+ dbr/.style 2 args={
+ preaction={draw,secondright={#1}{#2}}
+ },
+ %
+ trpl/.style 2 args={
+ preaction={draw,secondleft={#1}{#2}},
+ preaction={draw,secondright={#1}{#2}}
+ },
+ %
+ dblx/.style n args={4}{
+ preaction={draw,secondfgleft={#1}{#2}},
+ mcfx={#3}{#4}
+ },
+ %
+ dbrx/.style n args={4}{
+ preaction={draw,secondfgright={#1}{#2}},
+ mcfx={#3}{#4}
+ },
+ %
+ trplx/.style n args={4}{
+ preaction={draw,secondfgleft={#1}{#2}},
+ preaction={draw,secondfgright={#1}{#2}},
+ mcfx={#3}{#4}
+ },
+ %
+ drh/.style={dbr={58}{58}},
+ dlh/.style={dbl={58}{58}},
+ drhs/.style={dbr={58}{0}},
+ dlhs/.style={dbl={58}{0}},
+ drhe/.style={dbr={0}{58}},
+ dlhe/.style={dbl={0}{58}},
+ drn/.style={dbr={0}{0}},
+ dln/.style={dbl={0}{0}}
+}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Conveniences for drawing push arrows
+% the \mcfelmove command is adapted from the
+% myChemistry package by Clemens Niederberger
+
+\newcommand{\mcfelmove}[5][]{%
+\node at (0,0) {% dummy wrapper node
+\chemmove{\draw[mcfpusharrow,#1](#2).. controls +(#3) and +(#5)..(#4);%
+}};}
+
+% and, since the most common use for tikz code
+% is arrow shortening and lengthening: a command streamlined for that.
+
+\newcommandtwoopt{\mcfpush}[6][][]{% we use empties to keep same defaults
+\@ifmtarg{#2}{
+ \@ifmtarg{#1}{\mcfelmove{#3}{#4}{#5}{#6}}
+ {\mcfelmove[shorten <=#1]{#3}{#4}{#5}{#6}}
+}{% #2 not empty
+ \@ifmtarg{#1}{\mcfelmove[shorten >=#2]{#3}{#4}{#5}{#6}}
+ {\mcfelmove[shorten <=#1, shorten >=#2]{#3}{#4}{#5}{#6}}
+}}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Stacking atoms horizontally and vertically
+\newlength{\mcfvspace}
+\setlength{\mcfvspace}{1.5pt}
+
+\newcommand{\mcfabove}[2]{\chemabove[\mcfvspace]{#1}{#2}}
+\newcommand{\mcfbelow}[2]{\chembelow[\mcfvspace]{#1}{#2}}
+
+\newlength{\mcf@boxwidth}
+\newlength{\mcf@boxheight}
+
+\newcommand{\mcf@box}[3][l]{
+\settowidth{\mcf@boxwidth}{\printatom{#2}}
+\settoheight{\mcf@boxheight}{\printatom{#2}}
+\makebox[\mcf@boxwidth][#1]{\raisebox{0pt}[\mcf@boxheight][0pt]{\printatom{#3}}}}
+
+\newcommand{\mcfleft}[2]{\mcf@box[r]{#2}{#1#2}}
+\newcommand{\mcfright}[2]{\mcf@box{#1}{#1#2}}
+
+\newcommand{\mcfaboveright}[3]{\mcfabove{#1}{\mcf@box{#2}{#2#3}}}
+\newcommand{\mcfbelowright}[3]{\mcfbelow{#1}{\mcf@box{#2}{#2#3}}}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Formatting of charges and atom numbers
+
+% Charges - could for example be defined as \oplus and \ominus
+\newcommand{\mcfplus}{+}
+\newcommand{\mcfminus}{-}
+
+% atom numbers (used when option atom-numbers is selected)
+\newcommand{\mcfatomno}[1]%
+{\raisebox{2pt}{\color{mcfatomnocolor}{\ensuremath{\mathsf{_{#1}}}}}}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% a little help with direct processing of mol2chemfig commands
+\newcommand{\mcfinput}[1]{\@@input|"mol2chemfig #1"}
+
+
diff --git a/graphics/mol2chemfig/doc/doc-source/preamble.tex b/graphics/mol2chemfig/doc/doc-source/preamble.tex
new file mode 100644
index 0000000000..a4a0fee312
--- /dev/null
+++ b/graphics/mol2chemfig/doc/doc-source/preamble.tex
@@ -0,0 +1,60 @@
+\usepackage{
+ graphicx,
+ listings,
+ paralist,
+ textcomp,
+ xspace
+}
+
+% use postscript fonts
+\usepackage{courier,times}
+\usepackage[scaled=0.92]{helvet}
+\usepackage{sansmath}
+
+\usepackage[x11names]{xcolor}
+\usepackage[margin=1.0in]{geometry}
+
+% load mol2chemfig custom macros
+\usepackage{mol2chemfig}
+
+% set default input path
+\makeatletter
+\def\input@path{{examples/}}
+\makeatother
+
+% import live settings
+\input{hand-coded-tex/chemfig-settings}
+
+\newlength{\fspc}
+\setlength{\fspc}{5pt}
+
+% customize code listings
+\lstset{backgroundcolor=\color{LightSteelBlue1},
+ basicstyle=\ttfamily\small,
+ xleftmargin=\fspc,
+ framexleftmargin=\fspc,
+ framextopmargin=\fspc,
+ frame=single,
+ framerule=0pt,
+ linewidth=\linewidth,
+ breaklines=true,
+ breakatwhitespace=true,
+ showstringspaces=false,
+}
+
+\newcommand{\mcf}{\texttt{mol2chemfig}\xspace}
+\newcommand{\chf}{\texttt{chemfig}\xspace}
+\newcommand{\mf}{\texttt{molfile}\xspace}
+\newcommand{\smiles}{\texttt{SMILES}\xspace}
+\newcommand{\tkz}{\texttt{TiKZ}\xspace}
+\newcommand{\rdkit}{\texttt{rdkit}\xspace}
+\newcommand{\mcfplain}{\texttt{mol2chemfig.tex}\xspace}
+
+\setlength{\parskip}{0.25\baselineskip}
+\setlength{\parindent}{0pt}
+
+% structures need a little space
+\newcommand{\cfpic}[1]{\bigskip \par \input{#1} \par \bigskip}
+
+% use hyperlinks
+\usepackage[colorlinks,linkcolor=Blue3,urlcolor=Blue3]{hyperref}
diff --git a/graphics/mol2chemfig/doc/mol2chemfig-doc.pdf b/graphics/mol2chemfig/doc/mol2chemfig-doc.pdf
new file mode 100644
index 0000000000..f11c215602
--- /dev/null
+++ b/graphics/mol2chemfig/doc/mol2chemfig-doc.pdf
Binary files differ
diff --git a/graphics/mol2chemfig/lua/README b/graphics/mol2chemfig/lua/README
new file mode 100644
index 0000000000..1f3a74e081
--- /dev/null
+++ b/graphics/mol2chemfig/lua/README
@@ -0,0 +1,78 @@
+mol2chemfig
+-----------------------------------------------------------------
+Purpose: Generation of chemfig code from molecular structures
+specified in molfile or smiles format
+
+Licence: LPPL (free)
+
+Author: Michael Palmer (mpalmer@uwaterloo.ca)
+
+Licence: Latex Project Licence (free)
+
+Version: 1.4
+-----------------------------------------------------------------
+This package contains mol2chemfig.lua, the Lua web client version
+of mol2chemfig. It is used from the command line but calls the
+mol2chemfig server for every request. It expects to be run by
+Lua interpreter that is embedded within the luatex executable.
+
+Requirements:
+
+* LuaTeX (available through TeXLive) or another Lua
+ interpreter is required to run the program
+
+* The chemfig LaTeX package is required to compile the
+ chemfig code generated by mol2chemfig
+-------------------------------------------------------------
+Installation:
+
+1. The preferred installation method is through TeXLive. When
+the script and its prerequisites are installed in this way,
+no additional installation or configuration should be
+necesseary; it should be possible to run "mol2chemfig.lua"
+from a shell window.
+
+Update: The preferred method WOULD be through TeXLive, if
+TeXLive actually had coopted mol2chemfig. This, however,
+does not seem to have happened. So, manual install is
+the only option.
+
+2. If you want to install it manually, you need to ensure that
+both mol2chemfig.lua and your Lua interpreter are in your
+shell's path. Moreover, your Lua interpreter must be able to
+find the auxiliary Lua files (mol2chemfig_client.lua,
+mol2chemfig_dkjson.lua, and mol2chemfig_jsonrpc.lua) also
+included in this package.
+
+LuaTeX's embedded interpreter will use the kpathsea library
+to locate required Lua modules. The directories that it
+will search through are configured in the LUAINPUTS variable
+inside your system's texmf.cnf configuration file.
+
+If you want the script to be run not by luatex but by your
+system's default Lua interpreter, you must change the first
+line in mol2chemfig.lua from
+
+#!/usr/bin/env texlua
+
+to
+
+#!/usr/bin/env lua
+
+and also delete or comment out the line
+
+kpse.set_program_name('luatex')
+
+Moreover, you must ensure that the three other .lua files
+in this package can be located by your lua interpreter.
+-------------------------------------------------------------
+Stand-alone version of mol2chemfig
+
+A full locally installable version (as well as the source
+code) of the mol2chemfig program is available at
+
+http://chimpsky.uwaterloo.ca/mol2chemfig
+
+The full program requires Python and the indigo
+cheminformatics library for Python. See the docs
+for additional details. \ No newline at end of file
diff --git a/graphics/mol2chemfig/lua/mol2chemfig.lua b/graphics/mol2chemfig/lua/mol2chemfig.lua
new file mode 100755
index 0000000000..c6bf991651
--- /dev/null
+++ b/graphics/mol2chemfig/lua/mol2chemfig.lua
@@ -0,0 +1,33 @@
+#!/usr/bin/env texlua
+
+--[[
+ mol2chemfig.lua by Michael Palmer, University of Waterloo
+ -------------------------------------------------------------------------
+ Purpose: Generation of chemfig code from molecular structures specified
+ in molfile or smiles format
+
+ Licence: LPPL (free)
+ -------------------------------------------------------------------------
+ This script acts as a thin client; it passes off all work to a server
+ installation of the mol2chemfig program. Therefore, you need to be
+ online for this program to work.
+
+ The server is accessed using the IP address instead of the URL, which
+ saves a DNS lookup. However, if things don't work, the IP might have
+ changed. In that case, you might try this URL:
+
+ server_address = "http://chimpsky.uwaterloo.ca/mol2chemfig/luabackend"
+
+ The "kpse.set_program_name('luatex')" call causes the use of kpathsea to
+ locate imported modules. The mol2chemfig-client.lua module should then be
+ found if installed along the LUAINPUTS path that is set in your texmf.cnf
+ configuration file.
+ -------------------------------------------------------------------------
+ send bug reports and lots of money to mpalmer@uwaterloo.ca
+]]--
+
+server_address = "http://129.97.80.65/mol2chemfig/luabackend"
+
+kpse.set_program_name('luatex')
+
+require('mol2chemfig_client.lua')
diff --git a/graphics/mol2chemfig/lua/mol2chemfig_client.lua b/graphics/mol2chemfig/lua/mol2chemfig_client.lua
new file mode 100644
index 0000000000..da0756f6a1
--- /dev/null
+++ b/graphics/mol2chemfig/lua/mol2chemfig_client.lua
@@ -0,0 +1,117 @@
+-- Command-line-driven web client for mol2chemfig.
+local client_version = "1.1"
+
+local jsonrpc = require("mol2chemfig_jsonrpc")
+local os = require("os")
+local io = require("io")
+
+local server = jsonrpc.proxy(server_address) -- server_address must be in scope
+
+local progname = arg[0]
+
+local server_info, error = server.info(progname, client_version)
+
+if error then
+ io.stderr:write("Error: ", error)
+ os.exit()
+end
+
+-- if we get here, the server responds as expected.
+
+function printhelp()
+ print (server_info['help_text'])
+ os.exit()
+end
+
+-- Split input into options and arguments. Only arguments
+-- at the end are accepted.
+
+local arguments = {}
+local i = #arg
+
+if i == 0 then -- no input at all
+ printhelp()
+end
+
+noargs = server_info['noarg_shortopts']
+
+-- separate options and arguments
+while i > 0 and arg[i]:sub(1,1) ~= '-' do
+ local j = i - 1
+
+ if j == 0 or
+ arg[j]:sub(1,1) ~= '-' or
+ arg[j]:sub(2,2) == '-' or
+ string.find(noargs, arg[j]:sub(2,2))
+ then
+ table.insert(arguments,#arguments+1,arg[i])
+ table.remove(arg, i)
+ end
+
+ i = j
+end
+
+-- what remains in arg after removing arguments are options
+local user_options = table.concat(arg, ' ')
+
+
+-- first, see whether the user requests help or the program version.
+local version_opts = server_info['version_opts']
+local s
+
+for i,s in ipairs(version_opts) do
+ if string.find(user_options, s) then
+ print(server_info['version_text'])
+ print("On your system, the client is installed in: " .. progname)
+ os.exit()
+ end
+end
+
+local help_opts = server_info['help_opts']
+
+for i,s in ipairs(help_opts) do
+ if string.find(user_options, s) then
+ printhelp()
+ end
+end
+
+-- if we get here, the user should have provided exactly one argument.
+
+if #arguments ~= 1 then
+ print ('Please provide exactly one argument (must come last, after any options)')
+ os.exit()
+end
+
+-- have exactly one argument. read it directly, or treat it as a file name?
+
+local direct_input = false
+local direct_opts = server_info['direct_opts']
+
+for i,s in ipairs(direct_opts) do
+ if string.find(user_options, s) then
+ direct_input = true
+ end
+end
+
+local data
+
+if direct_input == false then
+ f = io.open(arguments[1])
+ if f then
+ data = f:read("*all")
+ else
+ print ("File '" .. arguments[1] .. "' not found")
+ os.exit()
+ end
+else
+ data = arguments[1]
+end
+
+-- process options and data
+local result, error = server.process(progname, user_options, data)
+
+if error then
+ io.stderr:write(error .. '\n')
+else
+ print(result)
+end \ No newline at end of file
diff --git a/graphics/mol2chemfig/lua/mol2chemfig_dkjson.lua b/graphics/mol2chemfig/lua/mol2chemfig_dkjson.lua
new file mode 100644
index 0000000000..6a53a48e95
--- /dev/null
+++ b/graphics/mol2chemfig/lua/mol2chemfig_dkjson.lua
@@ -0,0 +1,646 @@
+ --[==[
+
+modified by M. Palmer from:
+
+David Kolf's JSON module for Lua 5.1/5.2 (Version 2.1)
+
+In this abridged version, the lpeg library is never used, and the
+corresponding settings and functions have been removed. The remainder
+of the code remains unchanged.
+
+------
+
+This module writes no global values, not even the module table.
+Import it using
+
+ json = require ("dkjsonmod")
+
+Exported functions and values:
+
+`json.encode (object [, state])`
+--------------------------------
+
+Create a string representing the object. `Object` can be a table,
+a string, a number, a boolean, `nil`, `json.null` or any object with
+a function `__tojson` in its metatable. A table can only use strings
+and numbers as keys and its values have to be valid objects as
+well. It raises an error for any invalid data types or reference
+cycles.
+
+`state` is an optional table with the following fields:
+
+ - `indent`
+ When `indent` (a boolean) is set, the created string will contain
+ newlines and indentations. Otherwise it will be one long line.
+ - `keyorder`
+ `keyorder` is an array to specify the ordering of keys in the
+ encoded output. If an object has keys which are not in this array
+ they are written after the sorted keys.
+ - `level`
+ This is the initial level of indentation used when `indent` is
+ set. For each level two spaces are added. When absent it is set
+ to 0.
+ - `buffer`
+ `buffer` is an array to store the strings for the result so they
+ can be concatenated at once. When it isn't given, the encode
+ function will create it temporary and will return the
+ concatenated result.
+ - `bufferlen`
+ When `bufferlen` is set, it has to be the index of the last
+ element of `buffer`.
+ - `tables`
+ `tables` is a set to detect reference cycles. It is created
+ temporary when absent. Every table that is currently processed
+ is used as key, the value is `true`.
+
+When `state.buffer` was set, the return value will be `true` on
+success. Without `state.buffer` the return value will be a string.
+
+`json.decode (string [, position [, null]])`
+--------------------------------------------
+
+Decode `string` starting at `position` or at 1 if `position` was
+omitted.
+
+`null` is an optional value to be returned for null values. The
+default is `nil`, but you could set it to `json.null` or any other
+value.
+
+The return values are the object or `nil`, the position of the next
+character that doesn't belong to the object, and in case of errors
+an error message.
+
+Two metatables are created. Every array or object that is decoded gets
+a metatable with the `__jsontype` field set to either `array` or
+`object`. If you want to provide your own metatables use the syntax
+
+ json.decode (string, position, null, objectmeta, arraymeta)
+
+`<metatable>.__jsonorder`
+-------------------------
+
+`__jsonorder` can overwrite the `keyorder` for a specific table.
+
+`<metatable>.__jsontype`
+------------------------
+
+`__jsontype` can be either `"array"` or `"object"`. This is mainly useful
+for tables that can be empty. (The default for empty tables is
+`"array"`).
+
+`<metatable>.__tojson (self, state)`
+------------------------------------
+
+You can provide your own `__tojson` function in a metatable. In this
+function you can either add directly to the buffer and return true,
+or you can return a string. On errors nil and a message should be
+returned.
+
+`json.null`
+-----------
+
+You can use this value for setting explicit `null` values.
+
+`json.version`
+--------------
+
+Set to `"dkjson 2.1"`.
+
+`json.quotestring (string)`
+---------------------------
+
+Quote a UTF-8 string and escape critical characters using JSON
+escape sequences. This function is only necessary when you build
+your own `__tojson` functions.
+
+`json.addnewline (state)`
+-------------------------
+
+When `state.indent` is set, add a newline to `state.buffer` and spaces
+according to `state.level`.
+
+LPeg support
+------------
+
+(removed)
+
+You can contact the author by sending an e-mail to 'kolf' at the
+e-mail provider 'gmx.de'.
+
+---------------------------------------------------------------------
+
+*Copyright (C) 2010, 2011 David Heiko Kolf*
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+--]==]
+
+-- global dependencies:
+local pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset =
+ pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset
+local error, require, pcall = error, require, pcall
+local floor, huge = math.floor, math.huge
+local strrep, gsub, strsub, strbyte, strchar, strfind, strlen, strformat =
+ string.rep, string.gsub, string.sub, string.byte, string.char,
+ string.find, string.len, string.format
+local concat = table.concat
+
+if _VERSION == 'Lua 5.1' then
+ local function noglobals (s,k,v) error ("global access: " .. k, 2) end
+ setfenv (1, setmetatable ({}, { __index = noglobals, __newindex = noglobals }))
+end
+local _ENV = nil -- blocking globals in Lua 5.2
+
+local json = { version = "dkjson 2.1" }
+
+pcall (function()
+ -- Enable access to blocked metatables.
+ -- Don't worry, this module doesn't change anything in them.
+ local debmeta = require "debug".getmetatable
+ if debmeta then getmetatable = debmeta end
+end)
+
+json.null = setmetatable ({}, {
+ __tojson = function () return "null" end
+})
+
+local function isarray (tbl)
+ local max, n, arraylen = 0, 0, 0
+ for k,v in pairs (tbl) do
+ if k == 'n' and type(v) == 'number' then
+ arraylen = v
+ if v > max then
+ max = v
+ end
+ else
+ if type(k) ~= 'number' or k < 1 or floor(k) ~= k then
+ return false
+ end
+ if k > max then
+ max = k
+ end
+ n = n + 1
+ end
+ end
+ if max > 10 and max > arraylen and max > n * 2 then
+ return false -- don't create an array with too many holes
+ end
+ return true, max
+end
+
+local escapecodes = {
+ ["\""] = "\\\"", ["\\"] = "\\\\", ["\b"] = "\\b", ["\f"] = "\\f",
+ ["\n"] = "\\n", ["\r"] = "\\r", ["\t"] = "\\t"
+}
+
+local function escapeutf8 (uchar)
+ local value = escapecodes[uchar]
+ if value then
+ return value
+ end
+ local a, b, c, d = strbyte (uchar, 1, 4)
+ a, b, c, d = a or 0, b or 0, c or 0, d or 0
+ if a <= 0x7f then
+ value = a
+ elseif 0xc0 <= a and a <= 0xdf and b >= 0x80 then
+ value = (a - 0xc0) * 0x40 + b - 0x80
+ elseif 0xe0 <= a and a <= 0xef and b >= 0x80 and c >= 0x80 then
+ value = ((a - 0xe0) * 0x40 + b - 0x80) * 0x40 + c - 0x80
+ elseif 0xf0 <= a and a <= 0xf7 and b >= 0x80 and c >= 0x80 and d >= 0x80 then
+ value = (((a - 0xf0) * 0x40 + b - 0x80) * 0x40 + c - 0x80) * 0x40 + d - 0x80
+ else
+ return ""
+ end
+ if value <= 0xffff then
+ return strformat ("\\u%.4x", value)
+ elseif value <= 0x10ffff then
+ -- encode as UTF-16 surrogate pair
+ value = value - 0x10000
+ local highsur, lowsur = 0xD800 + floor (value/0x400), 0xDC00 + (value % 0x400)
+ return strformat ("\\u%.4x\\u%.4x", highsur, lowsur)
+ else
+ return ""
+ end
+end
+
+local function fsub (str, pattern, repl)
+ -- gsub always builds a new string in a buffer, even when no match
+ -- exists. First using find should be more efficient when most strings
+ -- don't contain the pattern.
+ if strfind (str, pattern) then
+ return gsub (str, pattern, repl)
+ else
+ return str
+ end
+end
+
+local function quotestring (value)
+ -- based on the regexp "escapable" in https://github.com/douglascrockford/JSON-js
+ value = fsub (value, "[%z\1-\31\"\\\127]", escapeutf8)
+ if strfind (value, "[\194\216\220\225\226\239]") then
+ value = fsub (value, "\194[\128-\159\173]", escapeutf8)
+ value = fsub (value, "\216[\128-\132]", escapeutf8)
+ value = fsub (value, "\220\143", escapeutf8)
+ value = fsub (value, "\225\158[\180\181]", escapeutf8)
+ value = fsub (value, "\226\128[\140-\143\168\175]", escapeutf8)
+ value = fsub (value, "\226\129[\160-\175]", escapeutf8)
+ value = fsub (value, "\239\187\191", escapeutf8)
+ value = fsub (value, "\239\191[\176\191]", escapeutf8)
+ end
+ return "\"" .. value .. "\""
+end
+json.quotestring = quotestring
+
+local function addnewline2 (level, buffer, buflen)
+ buffer[buflen+1] = "\n"
+ buffer[buflen+2] = strrep (" ", level)
+ buflen = buflen + 2
+ return buflen
+end
+
+function json.addnewline (state)
+ if state.indent then
+ state.bufferlen = addnewline2 (state.level or 0,
+ state.buffer, state.bufferlen or #(state.buffer))
+ end
+end
+
+local encode2 -- forward declaration
+
+local function addpair (key, value, prev, indent, level, buffer, buflen, tables, globalorder)
+ local kt = type (key)
+ if kt ~= 'string' and kt ~= 'number' then
+ return nil, "type '" .. kt .. "' is not supported as a key by JSON."
+ end
+ if prev then
+ buflen = buflen + 1
+ buffer[buflen] = ","
+ end
+ if indent then
+ buflen = addnewline2 (level, buffer, buflen)
+ end
+ buffer[buflen+1] = quotestring (key)
+ buffer[buflen+2] = ":"
+ return encode2 (value, indent, level, buffer, buflen + 2, tables, globalorder)
+end
+
+encode2 = function (value, indent, level, buffer, buflen, tables, globalorder)
+ local valtype = type (value)
+ local valmeta = getmetatable (value)
+ valmeta = type (valmeta) == 'table' and valmeta -- only tables
+ local valtojson = valmeta and valmeta.__tojson
+ if valtojson then
+ if tables[value] then
+ return nil, "reference cycle"
+ end
+ tables[value] = true
+ local state = {
+ indent = indent, level = level, buffer = buffer,
+ bufferlen = buflen, tables = tables, keyorder = globalorder
+ }
+ local ret, msg = valtojson (value, state)
+ if not ret then return nil, msg end
+ tables[value] = nil
+ buflen = state.bufferlen
+ if type (ret) == 'string' then
+ buflen = buflen + 1
+ buffer[buflen] = ret
+ end
+ elseif value == nil then
+ buflen = buflen + 1
+ buffer[buflen] = "null"
+ elseif valtype == 'number' then
+ local s
+ if value ~= value or value >= huge or -value >= huge then
+ -- This is the behaviour of the original JSON implementation.
+ s = "null"
+ else
+ s = tostring (value)
+ end
+ buflen = buflen + 1
+ buffer[buflen] = s
+ elseif valtype == 'boolean' then
+ buflen = buflen + 1
+ buffer[buflen] = value and "true" or "false"
+ elseif valtype == 'string' then
+ buflen = buflen + 1
+ buffer[buflen] = quotestring (value)
+ elseif valtype == 'table' then
+ if tables[value] then
+ return nil, "reference cycle"
+ end
+ tables[value] = true
+ level = level + 1
+ local metatype = valmeta and valmeta.__jsontype
+ local isa, n
+ if metatype == 'array' then
+ isa = true
+ n = value.n or #value
+ elseif metatype == 'object' then
+ isa = false
+ else
+ isa, n = isarray (value)
+ end
+ local msg
+ if isa then -- JSON array
+ buflen = buflen + 1
+ buffer[buflen] = "["
+ for i = 1, n do
+ buflen, msg = encode2 (value[i], indent, level, buffer, buflen, tables, globalorder)
+ if not buflen then return nil, msg end
+ if i < n then
+ buflen = buflen + 1
+ buffer[buflen] = ","
+ end
+ end
+ buflen = buflen + 1
+ buffer[buflen] = "]"
+ else -- JSON object
+ local prev = false
+ buflen = buflen + 1
+ buffer[buflen] = "{"
+ local order = valmeta and valmeta.__jsonorder or globalorder
+ if order then
+ local used = {}
+ n = #order
+ for i = 1, n do
+ local k = order[i]
+ local v = value[k]
+ if v then
+ used[k] = true
+ buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder)
+ prev = true -- add a seperator before the next element
+ end
+ end
+ for k,v in pairs (value) do
+ if not used[k] then
+ buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder)
+ if not buflen then return nil, msg end
+ prev = true -- add a seperator before the next element
+ end
+ end
+ else -- unordered
+ for k,v in pairs (value) do
+ buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder)
+ if not buflen then return nil, msg end
+ prev = true -- add a seperator before the next element
+ end
+ end
+ if indent then
+ buflen = addnewline2 (level - 1, buffer, buflen)
+ end
+ buflen = buflen + 1
+ buffer[buflen] = "}"
+ end
+ tables[value] = nil
+ else
+ return nil, "type '" .. valtype .. "' is not supported by JSON."
+ end
+ return buflen
+end
+
+function json.encode (value, state)
+ state = state or {}
+ local oldbuffer = state.buffer
+ local buffer = oldbuffer or {}
+ local ret, msg = encode2 (value, state.indent, state.level or 0,
+ buffer, state.bufferlen or 0, state.tables or {}, state.keyorder)
+ if not ret then
+ error (msg, 2)
+ elseif oldbuffer then
+ state.bufferlen = ret
+ return true
+ else
+ return concat (buffer)
+ end
+end
+
+local function loc (str, where)
+ local line, pos, linepos = 1, 1, 1
+ while true do
+ pos = strfind (str, "\n", pos, true)
+ if pos and pos < where then
+ line = line + 1
+ linepos = pos
+ pos = pos + 1
+ else
+ break
+ end
+ end
+ return "line " .. line .. ", column " .. (where - linepos)
+end
+
+local function unterminated (str, what, where)
+ return nil, strlen (str) + 1, "unterminated " .. what .. " at " .. loc (str, where)
+end
+
+local function scanwhite (str, pos)
+ while true do
+ pos = strfind (str, "%S", pos)
+ if not pos then return nil end
+ if strsub (str, pos, pos + 2) == "\239\187\191" then
+ -- UTF-8 Byte Order Mark
+ pos = pos + 3
+ else
+ return pos
+ end
+ end
+end
+
+local escapechars = {
+ ["\""] = "\"", ["\\"] = "\\", ["/"] = "/", ["b"] = "\b", ["f"] = "\f",
+ ["n"] = "\n", ["r"] = "\r", ["t"] = "\t"
+}
+
+local function unichar (value)
+ if value < 0 then
+ return nil
+ elseif value <= 0x007f then
+ return strchar (value)
+ elseif value <= 0x07ff then
+ return strchar (0xc0 + floor(value/0x40),
+ 0x80 + (floor(value) % 0x40))
+ elseif value <= 0xffff then
+ return strchar (0xe0 + floor(value/0x1000),
+ 0x80 + (floor(value/0x40) % 0x40),
+ 0x80 + (floor(value) % 0x40))
+ elseif value <= 0x10ffff then
+ return strchar (0xf0 + floor(value/0x40000),
+ 0x80 + (floor(value/0x1000) % 0x40),
+ 0x80 + (floor(value/0x40) % 0x40),
+ 0x80 + (floor(value) % 0x40))
+ else
+ return nil
+ end
+end
+
+local function scanstring (str, pos)
+ local lastpos = pos + 1
+ local buffer, n = {}, 0
+ while true do
+ local nextpos = strfind (str, "[\"\\]", lastpos)
+ if not nextpos then
+ return unterminated (str, "string", pos)
+ end
+ if nextpos > lastpos then
+ n = n + 1
+ buffer[n] = strsub (str, lastpos, nextpos - 1)
+ end
+ if strsub (str, nextpos, nextpos) == "\"" then
+ lastpos = nextpos + 1
+ break
+ else
+ local escchar = strsub (str, nextpos + 1, nextpos + 1)
+ local value
+ if escchar == "u" then
+ value = tonumber (strsub (str, nextpos + 2, nextpos + 5), 16)
+ if value then
+ local value2
+ if 0xD800 <= value and value <= 0xDBff then
+ -- we have the high surrogate of UTF-16. Check if there is a
+ -- low surrogate escaped nearby to combine them.
+ if strsub (str, nextpos + 6, nextpos + 7) == "\\u" then
+ value2 = tonumber (strsub (str, nextpos + 8, nextpos + 11), 16)
+ if value2 and 0xDC00 <= value2 and value2 <= 0xDFFF then
+ value = (value - 0xD800) * 0x400 + (value2 - 0xDC00) + 0x10000
+ else
+ value2 = nil -- in case it was out of range for a low surrogate
+ end
+ end
+ end
+ value = value and unichar (value)
+ if value then
+ if value2 then
+ lastpos = nextpos + 12
+ else
+ lastpos = nextpos + 6
+ end
+ end
+ end
+ end
+ if not value then
+ value = escapechars[escchar] or escchar
+ lastpos = nextpos + 2
+ end
+ n = n + 1
+ buffer[n] = value
+ end
+ end
+ if n == 1 then
+ return buffer[1], lastpos
+ elseif n > 1 then
+ return concat (buffer), lastpos
+ else
+ return "", lastpos
+ end
+end
+
+local scanvalue -- forward declaration
+
+local function scantable (what, closechar, str, startpos, nullval, objectmeta, arraymeta)
+ local len = strlen (str)
+ local tbl, n = {}, 0
+ local pos = startpos + 1
+ if what == 'object' then
+ setmetatable (tbl, objectmeta)
+ else
+ setmetatable (tbl, arraymeta)
+ end
+ while true do
+ pos = scanwhite (str, pos)
+ if not pos then return unterminated (str, what, startpos) end
+ local char = strsub (str, pos, pos)
+ if char == closechar then
+ return tbl, pos + 1
+ end
+ local val1, err
+ val1, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta)
+ if err then return nil, pos, err end
+ pos = scanwhite (str, pos)
+ if not pos then return unterminated (str, what, startpos) end
+ char = strsub (str, pos, pos)
+ if char == ":" then
+ if val1 == nil then
+ return nil, pos, "cannot use nil as table index (at " .. loc (str, pos) .. ")"
+ end
+ pos = scanwhite (str, pos + 1)
+ if not pos then return unterminated (str, what, startpos) end
+ local val2
+ val2, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta)
+ if err then return nil, pos, err end
+ tbl[val1] = val2
+ pos = scanwhite (str, pos)
+ if not pos then return unterminated (str, what, startpos) end
+ char = strsub (str, pos, pos)
+ else
+ n = n + 1
+ tbl[n] = val1
+ end
+ if char == "," then
+ pos = pos + 1
+ end
+ end
+end
+
+scanvalue = function (str, pos, nullval, objectmeta, arraymeta)
+ pos = pos or 1
+ pos = scanwhite (str, pos)
+ if not pos then
+ return nil, strlen (str) + 1, "no valid JSON value (reached the end)"
+ end
+ local char = strsub (str, pos, pos)
+ if char == "{" then
+ return scantable ('object', "}", str, pos, nullval, objectmeta, arraymeta)
+ elseif char == "[" then
+ return scantable ('array', "]", str, pos, nullval, objectmeta, arraymeta)
+ elseif char == "\"" then
+ return scanstring (str, pos)
+ else
+ local pstart, pend = strfind (str, "^%-?[%d%.]+[eE]?[%+%-]?%d*", pos)
+ if pstart then
+ local number = tonumber (strsub (str, pstart, pend))
+ if number then
+ return number, pend + 1
+ end
+ end
+ pstart, pend = strfind (str, "^%a%w*", pos)
+ if pstart then
+ local name = strsub (str, pstart, pend)
+ if name == "true" then
+ return true, pend + 1
+ elseif name == "false" then
+ return false, pend + 1
+ elseif name == "null" then
+ return nullval, pend + 1
+ end
+ end
+ return nil, pos, "no valid JSON value at " .. loc (str, pos)
+ end
+end
+
+function json.decode (str, pos, nullval, objectmeta, arraymeta)
+ objectmeta = objectmeta or {__jsontype = 'object'}
+ arraymeta = arraymeta or {__jsontype = 'array'}
+ return scanvalue (str, pos, nullval, objectmeta, arraymeta)
+end
+
+
+return json
diff --git a/graphics/mol2chemfig/lua/mol2chemfig_jsonrpc.lua b/graphics/mol2chemfig/lua/mol2chemfig_jsonrpc.lua
new file mode 100644
index 0000000000..66c8ce7211
--- /dev/null
+++ b/graphics/mol2chemfig/lua/mol2chemfig_jsonrpc.lua
@@ -0,0 +1,86 @@
+-----------------------------------------------------------------------------
+-- modified by Michael Palmer from:
+
+-- JSONRPC4Lua: JSON RPC client calls over http for the Lua language.
+-- json.rpc Module.
+-- Author: Craig Mason-Jones
+-- Homepage: http://json.luaforge.net/
+-- Version: 0.9.40
+-- This module is released under the MIT License (MIT).
+--
+-- REQUIREMENTS:
+-- Lua socket 2.0 (http://www.cs.princeton.edu/~diego/professional/luasocket/)
+-- mol2chemfig_dkjson.lua
+-- compat-5.1 if using Lua 5.0.
+-----------------------------------------------------------------------------
+
+-----------------------------------------------------------------------------
+-- Imports and dependencies
+-----------------------------------------------------------------------------
+local json = require("mol2chemfig_dkjson")
+local http = require("socket.http")
+local assert = assert
+local require = require
+local string = string
+local table = table
+local setmetatable = setmetatable
+local unpack = unpack
+
+local base = _G
+
+module("mol2chemfig_jsonrpc")
+
+
+-----------------------------------------------------------------------------
+-- PUBLIC functions
+-----------------------------------------------------------------------------
+
+function proxy(url)
+ local serverProxy = {}
+ local proxyMeta = {
+ __index = function(t, key)
+ return function(...)
+ return call(url, key, unpack(arg))
+ end
+ end
+ }
+ setmetatable(serverProxy, proxyMeta)
+ return serverProxy
+end
+
+
+function call(url, method, ...)
+ assert(method,'method param is nil to call')
+ local JSONRequestArray = {
+ id = "httpRequest",
+ method = method,
+ params = arg
+ }
+ local httpResponse, result, code
+ local jsonRequest = json.encode(JSONRequestArray)
+ local ltn12 = require('ltn12')
+ local resultChunks = {}
+ httpResponse, code = http.request(
+ { url = url,
+ sink = ltn12.sink.table(resultChunks),
+ method = 'POST',
+ headers = {
+ ['content-type']='text/plain',
+ ['content-length']=string.len(jsonRequest)
+ },
+ source = ltn12.source.string(jsonRequest)
+ }
+ )
+ httpResponse = table.concat(resultChunks)
+ -- Check the http response code
+ if (code~=200) then
+ return nil, "HTTP ERROR: " .. code
+ end
+ -- And decode the httpResponse and check the JSON RPC result code
+ result = json.decode( httpResponse )
+ if result.result then
+ return result.result, nil
+ else
+ return nil, result.error
+ end
+end
diff --git a/graphics/mol2chemfig/sampledoc/README b/graphics/mol2chemfig/sampledoc/README
new file mode 100644
index 0000000000..68f0b38d61
--- /dev/null
+++ b/graphics/mol2chemfig/sampledoc/README
@@ -0,0 +1,5 @@
+The document in this directory, sample.tex, is intended for
+study and practice.
+
+After installing mol2chemfig.sty and several standard packages
+loaded by sample.tex, the file should compile on your computer.
diff --git a/graphics/mol2chemfig/sampledoc/mol2chemfig.sty b/graphics/mol2chemfig/sampledoc/mol2chemfig.sty
new file mode 100644
index 0000000000..2de1613f91
--- /dev/null
+++ b/graphics/mol2chemfig/sampledoc/mol2chemfig.sty
@@ -0,0 +1,236 @@
+% auxiliary package for mol2chemfig
+\ProvidesPackage{mol2chemfig}[2014/03/24 v1.4]
+
+\RequirePackage{xcolor, chemfig, twoopt, ifmtarg}
+\usetikzlibrary{decorations}
+
+% \setbondstyle is defined by chemfig. Here, we wrap it
+% in order to also save the bond style in a tikz key.
+\let\mcf@setbondstyle\setbondstyle
+\renewcommand{\setbondstyle}[1]{%
+ \mcf@setbondstyle{#1}%
+ \tikzset{mcfbond/.style={#1}}%
+}
+
+% this macro (by Christian Tellechea) draws circles in aromatic rings.
+\def\mcfcringle#1{%
+\tikz\draw[mcfbond](0,0)circle(\CF@atom@sep*#1*0.66667*\CF@cycle@inraduiscoeff);}
+
+% auxiliary macros for rendering double and triple bonds
+
+% tikz decoration to render parallel bond strokes
+\pgfdeclaredecoration{mcfsecondstroke}{initial}{
+ \state{initial}[width=\pgfdecoratedpathlength-1sp]{
+ \pgfmoveto{\pgfpointorigin}
+ }
+ \state{final}{
+ \pgflineto{\pgfpointorigin}
+ }
+}
+
+% the complete sines definition is taken from http://tex.stackexchange.com/questions/25678/
+\pgfdeclaredecoration{complete sines}{initial}
+{
+ \state{initial}[
+ width=+0pt,
+ next state=sine,
+ persistent precomputation={\pgfmathsetmacro\matchinglength{
+ \pgfdecoratedinputsegmentlength / int(\pgfdecoratedinputsegmentlength/\pgfdecorationsegmentlength)}
+ \setlength{\pgfdecorationsegmentlength}{\matchinglength pt}
+ }] {}
+ \state{sine}[width=\pgfdecorationsegmentlength]{
+ \pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
+ \pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
+ \pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
+ \pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
+}
+ \state{final}{}
+}
+
+% color definitions
+\colorlet{mcfbgcolor}{white} % adjust when drawing on a non-white canvas
+\colorlet{mcfpusharrowcolor}{black}
+\colorlet{mcfatomnocolor}{blue}
+
+\tikzset{ % set styles
+ % wavy bonds. Slightly modified from http://www.texdev.net/tag/chemfig/
+ mcfwavy/.style =
+ {
+ decorate,
+ decoration =
+ {
+ complete sines,
+ post length = 0 pt,
+ pre length = 0 pt,
+ % Use chemfig's atom spacing
+ segment length = \the\dimexpr\csname CF@atom@sep\endcsname/6\relax,
+ amplitude = \the\dimexpr\csname CF@atom@sep\endcsname/10\relax
+ }
+ },
+ % this style is used by the \mcfelmove macro
+ mcfpusharrow/.style = {
+ ->,
+ mcfpusharrowcolor,
+ >=stealth,
+ shorten <=3pt,
+ shorten >=2pt,
+ preaction={draw=mcfbgcolor, -,line width=1.5pt}
+ },
+ %
+ mcfbond/.style = {}, % the chemfig default bond style is empty, too.
+ %
+ % one bond crossing before another - gets a white backdrop
+ % as wide as doublesep
+ mcfbgcolor/.style={white},
+ %
+ mcfx/.style 2 args={%
+ preaction={
+ draw,
+ mcfbgcolor,
+ line width=\CF@double@sep,
+ shorten <= {#1*\CF@double@sep/100},
+ shorten >= {#2*\CF@double@sep/100}
+ },
+ mcfbond
+ },
+ %
+ mcfcrossbond/.style={% for backwards compatibility only
+ mcfx={100}{100}
+ },
+ %
+ secondbond/.style 2 args={
+ shorten <= {#1*\CF@double@sep/100},
+ shorten >= {#2*\CF@double@sep/100},
+ mcfbond
+ },
+ %
+ secondfgbond/.style 2 args={
+ preaction={draw,-,mcfbgcolor,line width=\CF@double@sep},
+ secondbond={#1}{#2}
+ },
+ %
+ secondleft/.style 2 args={
+ secondbond={#1}{#2},
+ decoration={mcfsecondstroke,raise=\CF@double@sep},
+ decorate
+ },
+ %
+ secondright/.style 2 args={
+ secondbond={#1}{#2},
+ decoration={mcfsecondstroke,raise=-\CF@double@sep},
+ decorate
+ },
+ %
+ secondfgleft/.style 2 args={
+ secondfgbond={#1}{#2},
+ decoration={mcfsecondstroke,raise=\CF@double@sep},
+ decorate
+ },
+ %
+ secondfgright/.style 2 args={
+ secondfgbond={#1}{#2},
+ decoration={mcfsecondstroke,raise=-\CF@double@sep},
+ decorate
+ },
+ %
+ dbl/.style 2 args={
+ preaction={draw,secondleft={#1}{#2}}
+ },
+ %
+ dbr/.style 2 args={
+ preaction={draw,secondright={#1}{#2}}
+ },
+ %
+ trpl/.style 2 args={
+ preaction={draw,secondleft={#1}{#2}},
+ preaction={draw,secondright={#1}{#2}}
+ },
+ %
+ dblx/.style n args={4}{
+ preaction={draw,secondfgleft={#1}{#2}},
+ mcfx={#3}{#4}
+ },
+ %
+ dbrx/.style n args={4}{
+ preaction={draw,secondfgright={#1}{#2}},
+ mcfx={#3}{#4}
+ },
+ %
+ trplx/.style n args={4}{
+ preaction={draw,secondfgleft={#1}{#2}},
+ preaction={draw,secondfgright={#1}{#2}},
+ mcfx={#3}{#4}
+ },
+ %
+ drh/.style={dbr={58}{58}},
+ dlh/.style={dbl={58}{58}},
+ drhs/.style={dbr={58}{0}},
+ dlhs/.style={dbl={58}{0}},
+ drhe/.style={dbr={0}{58}},
+ dlhe/.style={dbl={0}{58}},
+ drn/.style={dbr={0}{0}},
+ dln/.style={dbl={0}{0}}
+}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Conveniences for drawing push arrows
+% the \mcfelmove command is adapted from the
+% myChemistry package by Clemens Niederberger
+
+\newcommand{\mcfelmove}[5][]{%
+\node at (0,0) {% dummy wrapper node
+\chemmove{\draw[mcfpusharrow,#1](#2).. controls +(#3) and +(#5)..(#4);%
+}};}
+
+% and, since the most common use for tikz code
+% is arrow shortening and lengthening: a command streamlined for that.
+
+\newcommandtwoopt{\mcfpush}[6][][]{% we use empties to keep same defaults
+\@ifmtarg{#2}{
+ \@ifmtarg{#1}{\mcfelmove{#3}{#4}{#5}{#6}}
+ {\mcfelmove[shorten <=#1]{#3}{#4}{#5}{#6}}
+}{% #2 not empty
+ \@ifmtarg{#1}{\mcfelmove[shorten >=#2]{#3}{#4}{#5}{#6}}
+ {\mcfelmove[shorten <=#1, shorten >=#2]{#3}{#4}{#5}{#6}}
+}}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Stacking atoms horizontally and vertically
+\newlength{\mcfvspace}
+\setlength{\mcfvspace}{1.5pt}
+
+\newcommand{\mcfabove}[2]{\chemabove[\mcfvspace]{#1}{#2}}
+\newcommand{\mcfbelow}[2]{\chembelow[\mcfvspace]{#1}{#2}}
+
+\newlength{\mcf@boxwidth}
+\newlength{\mcf@boxheight}
+
+\newcommand{\mcf@box}[3][l]{
+\settowidth{\mcf@boxwidth}{\printatom{#2}}
+\settoheight{\mcf@boxheight}{\printatom{#2}}
+\makebox[\mcf@boxwidth][#1]{\raisebox{0pt}[\mcf@boxheight][0pt]{\printatom{#3}}}}
+
+\newcommand{\mcfleft}[2]{\mcf@box[r]{#2}{#1#2}}
+\newcommand{\mcfright}[2]{\mcf@box{#1}{#1#2}}
+
+\newcommand{\mcfaboveright}[3]{\mcfabove{#1}{\mcf@box{#2}{#2#3}}}
+\newcommand{\mcfbelowright}[3]{\mcfbelow{#1}{\mcf@box{#2}{#2#3}}}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Formatting of charges and atom numbers
+
+% Charges - could for example be defined as \oplus and \ominus
+\newcommand{\mcfplus}{+}
+\newcommand{\mcfminus}{-}
+
+% atom numbers (used when option atom-numbers is selected)
+\newcommand{\mcfatomno}[1]%
+{\raisebox{2pt}{\color{mcfatomnocolor}{\ensuremath{\mathsf{_{#1}}}}}}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% a little help with direct processing of mol2chemfig commands
+\newcommand{\mcfinput}[1]{\@@input|"mol2chemfig #1"}
+
+
diff --git a/graphics/mol2chemfig/sampledoc/penicilling.tex b/graphics/mol2chemfig/sampledoc/penicilling.tex
new file mode 100644
index 0000000000..a3e8d69f67
--- /dev/null
+++ b/graphics/mol2chemfig/sampledoc/penicilling.tex
@@ -0,0 +1,44 @@
+\chemfig{
+ O% 2
+ =[:45.1]% 12
+ -[:0.2,1.008]N% 6
+ -[:90]% 8
+ (
+ -[:18]S% 1
+ -[:306]% 9
+ (
+ -[:36]% 13
+ )
+ (
+ -[:324]% 14
+ )
+ -[:234]% 10
+ (
+ <:[:288]% 15
+ (
+ =[:348]O% 4
+ )
+ -[:228,,,2]HO% 3
+ )
+ -[:162]\phantom{N}% -> 6
+ )
+ -[:179.8,1.008]% 11
+ (
+ -[:270,1.008]% -> 12
+ )
+ <[:134.9]\mcfabove{N}{H}% 7
+ -[:209.8]% 16
+ (
+ =[:269.8]O% 5
+ )
+ -[:149.8]% 17
+ -[:209.8]% 18
+ -[:149.8]% 19
+ -[:209.8,,,,dlh]% 21
+ -[:269.8]% 23
+ -[:329.8,,,,dlh]% 22
+ -[:29.8]% 20
+ (
+ -[:89.8,,,,dlh]% -> 18
+ )
+}
diff --git a/graphics/mol2chemfig/sampledoc/plp.tex b/graphics/mol2chemfig/sampledoc/plp.tex
new file mode 100644
index 0000000000..6dd82a1146
--- /dev/null
+++ b/graphics/mol2chemfig/sampledoc/plp.tex
@@ -0,0 +1,38 @@
+\definesubmol{plp}{
+ % 7
+ -[:150]% 5
+ -[:210,,,,drhs]\mcfbelowright{N}{H}{^{\mcfplus}}% 4
+ -[:150]% 3
+ -[:90,,,,drh]% 2
+ (
+ -[:150]% 9
+ -[:210]O% 10
+ -[:180]P% 11
+ (
+ -[:270]\mcfright{O}{^{\mcfminus}}% 13
+ )
+ (
+ -[:90]\mcfright{O}{^{\mcfminus}}% 14
+ )
+ =[:180]O% 12
+ )
+ -[:30]% 1
+ (
+ -[:330,,,,drh]% 6
+ (
+ -[:30]\mcfright{O}{^{\mcfminus}}% 8
+ )
+ -[:270]% -> 5
+ )
+ -[:90]% 15
+ -[:30,,,1,dlhs]NH^{\mcfplus}% 16
+ -[:90,,1]\mcfabove{C}{_{\mcfminus}}% 17
+ (
+ -[:150]% 19
+ )
+ -[:30]% 18
+ (
+ =[:90]O% 20
+ )
+ -[:330]\mcfright{O}{^{\mcfminus}}% 21
+}
diff --git a/graphics/mol2chemfig/sampledoc/plp2.tex b/graphics/mol2chemfig/sampledoc/plp2.tex
new file mode 100644
index 0000000000..c0d352a655
--- /dev/null
+++ b/graphics/mol2chemfig/sampledoc/plp2.tex
@@ -0,0 +1,38 @@
+\definesubmol{plp2}{
+ % 7
+ -[:150]% 5
+ -[:210]\mcfbelow{N}{H}% 4
+ -[:150]% 3
+ -[:90,,,,drh]% 2
+ (
+ -[:150]% 9
+ -[:210]O% 10
+ -[:180]P% 11
+ (
+ -[:270]\mcfright{O}{^{\mcfminus}}% 13
+ )
+ (
+ -[:90]\mcfright{O}{^{\mcfminus}}% 14
+ )
+ =[:180]O% 12
+ )
+ -[:30]% 1
+ (
+ -[:330]% 6
+ (
+ -[:30]\mcfright{O}{^{\mcfminus}}% 8
+ )
+ -[:270,,,,drh]% -> 5
+ )
+ -[:90,,,,drh]% 15
+ -[:30,,,1]NH^{\mcfplus}% 16
+ =[:90,,1]% 17
+ (
+ -[:150]% 19
+ )
+ -[:30]% 18
+ (
+ =[:90]O% 20
+ )
+ -[:330]\mcfright{O}{^{\mcfminus}}% 21
+}
diff --git a/graphics/mol2chemfig/sampledoc/plpa.tex b/graphics/mol2chemfig/sampledoc/plpa.tex
new file mode 100644
index 0000000000..977dfc3f51
--- /dev/null
+++ b/graphics/mol2chemfig/sampledoc/plpa.tex
@@ -0,0 +1,38 @@
+\definesubmol{plpa}{
+ @{a7}%
+ -[@{a5-7}:150]@{a5}%
+ -[@{a4-5}:210,,,,drhs]@{a4}\mcfbelowright{N}{H}{^{\mcfplus}}%
+ -[@{a3-4}:150]@{a3}%
+ -[@{a2-3}:90,,,,drh]@{a2}%
+ (
+ -[@{a2-9}:150]@{a9}%
+ -[@{a9-10}:210]@{a10}O%
+ -[@{a10-11}:180]@{a11}P%
+ (
+ -[@{a11-13}:270]@{a13}\mcfright{O}{^{\mcfminus}}%
+ )
+ (
+ -[@{a11-14}:90]@{a14}\mcfright{O}{^{\mcfminus}}%
+ )
+ =[@{a11-12}:180]@{a12}O%
+ )
+ -[@{a1-2}:30]@{a1}%
+ (
+ -[@{a1-6}:330,,,,drh]@{a6}%
+ (
+ -[@{a6-8}:30]@{a8}\mcfright{O}{^{\mcfminus}}%
+ )
+ -[@{a5-6}:270]% -> 5
+ )
+ -[@{a1-15}:90]@{a15}%
+ -[@{a15-16}:30,,,1,dlhs]@{a16}NH^{\mcfplus}%
+ -[@{a16-17}:90,,1]@{a17}\mcfabove{C}{_{\mcfminus}}%
+ (
+ -[@{a17-19}:150]@{a19}%
+ )
+ -[@{a17-18}:30]@{a18}%
+ (
+ =[@{a18-20}:90]@{a20}O%
+ )
+ -[@{a18-21}:330]@{a21}\mcfright{O}{^{\mcfminus}}%
+}
diff --git a/graphics/mol2chemfig/sampledoc/plpb.tex b/graphics/mol2chemfig/sampledoc/plpb.tex
new file mode 100644
index 0000000000..a59331c074
--- /dev/null
+++ b/graphics/mol2chemfig/sampledoc/plpb.tex
@@ -0,0 +1,38 @@
+\definesubmol{plpb}{
+ @{b7}%
+ -[@{b5-7}:150]@{b5}%
+ -[@{b4-5}:210]@{b4}\mcfbelow{N}{H}%
+ -[@{b3-4}:150]@{b3}%
+ -[@{b2-3}:90,,,,drh]@{b2}%
+ (
+ -[@{b2-9}:150]@{b9}%
+ -[@{b9-10}:210]@{b10}O%
+ -[@{b10-11}:180]@{b11}P%
+ (
+ -[@{b11-13}:270]@{b13}\mcfright{O}{^{\mcfminus}}%
+ )
+ (
+ -[@{b11-14}:90]@{b14}\mcfright{O}{^{\mcfminus}}%
+ )
+ =[@{b11-12}:180]@{b12}O%
+ )
+ -[@{b1-2}:30]@{b1}%
+ (
+ -[@{b1-6}:330]@{b6}%
+ (
+ -[@{b6-8}:30]@{b8}\mcfright{O}{^{\mcfminus}}%
+ )
+ -[@{b5-6}:270,,,,drh]% -> 5
+ )
+ -[@{b1-15}:90,,,,drh]@{b15}%
+ -[@{b15-16}:30,,,1]@{b16}NH^{\mcfplus}%
+ =[@{b16-17}:90,,1]@{b17}%
+ (
+ -[@{b17-19}:150]@{b19}%
+ )
+ -[@{b17-18}:30]@{b18}%
+ (
+ =[@{b18-20}:90]@{b20}O%
+ )
+ -[@{b18-21}:330]@{b21}\mcfright{O}{^{\mcfminus}}%
+}
diff --git a/graphics/mol2chemfig/sampledoc/plpn.tex b/graphics/mol2chemfig/sampledoc/plpn.tex
new file mode 100644
index 0000000000..a3fabff9f8
--- /dev/null
+++ b/graphics/mol2chemfig/sampledoc/plpn.tex
@@ -0,0 +1,38 @@
+\chemfig{
+ \mcfatomno{7}% 7
+ -[:150]\mcfatomno{5}% 5
+ -[:210]\mcfbelow{N}{\mcfatomno{4}}% 4
+ -[:150]\mcfatomno{3}% 3
+ =_[:90]\mcfatomno{2}% 2
+ (
+ -[:150]\mcfatomno{9}% 9
+ -[:210]\mcfbelow{O}{\mcfatomno{10}}% 10
+ -[:180]\mcfright{P}{\mcfatomno{11}}% 11
+ (
+ -[:270]\mcfright{O}{\mcfatomno{13}}% 13
+ )
+ (
+ -[:90]\mcfright{O}{\mcfatomno{14}}% 14
+ )
+ =[:180]\mcfleft{\mcfatomno{12}}{O}% 12
+ )
+ -[:30]\mcfatomno{1}% 1
+ (
+ =[:90]\mcfatomno{15}% 15
+ -[:30]\mcfright{N}{\mcfatomno{16}}% 16
+ =[:90]\mcfatomno{17}% 17
+ (
+ -[:150]\mcfatomno{19}% 19
+ )
+ -[:30]\mcfatomno{18}% 18
+ (
+ -[:330]\mcfright{O}{\mcfatomno{21}}% 21
+ )
+ =[:90]\mcfright{O}{\mcfatomno{20}}% 20
+ )
+ -[:330]\mcfatomno{6}% 6
+ (
+ -[:30]\mcfright{O}{\mcfatomno{8}}% 8
+ )
+ =_[:270]\phantom{5}% -> 5
+}
diff --git a/graphics/mol2chemfig/sampledoc/sample.pdf b/graphics/mol2chemfig/sampledoc/sample.pdf
new file mode 100644
index 0000000000..93c3f5c66a
--- /dev/null
+++ b/graphics/mol2chemfig/sampledoc/sample.pdf
Binary files differ
diff --git a/graphics/mol2chemfig/sampledoc/sample.tex b/graphics/mol2chemfig/sampledoc/sample.tex
new file mode 100644
index 0000000000..28bccc62ca
--- /dev/null
+++ b/graphics/mol2chemfig/sampledoc/sample.tex
@@ -0,0 +1,195 @@
+\documentclass[11pt,letterpaper]{article}
+
+% the mol2chemfig package requires and loads the chemfig package,
+% which must be installed on your system. chemfig is available
+% through TeXLive, MikTeX or from CTAN.
+\usepackage{mol2chemfig}
+
+% reduce LaTeX's very wide page margins to 1 inch all around
+\usepackage[margin=1in]{geometry}
+
+% use postscript fonts
+\usepackage{courier,times}
+\usepackage[scaled=0.92]{helvet}
+\usepackage{sansmath}
+
+\usepackage{url,listings,textcomp}
+\newcommand{\tb}{\textbackslash}
+\newcommand{\rarr}{\ensuremath{\rightarrow}}
+
+\lstMakeShortInline{\$}
+
+\lstset{%
+ basicstyle=\ttfamily,
+ showstringspaces=false,
+ escapechar=\&
+}
+
+\title{Sample \LaTeX\ document for \texttt{mol2chemfig}}
+
+\author{}\date{}
+
+\begin{document}
+
+\maketitle
+
+\noindent This sample document illustrates the use of \texttt{mol2chemfig} in conjunction with the \texttt{chemfig} package. This document should compile as is on any system that has a working installation of the \texttt{chemfig} package. A local installation of the \texttt{mol2chemfig} program is not required to compile it, but it \emph{is} required to run the example commands that were used to generate the code. As an alternative to local installation, you can use the web interface at \url{chimpsky.uwaterloo.ca/mol2chemfig}.
+
+In any case, you will need the \texttt{mol2chemfig} \LaTeX\ package in order to compile the generated \LaTeX\ code. A copy of the package should be in the same directory as this source file.
+
+\section*{The structure of penicillin G}
+
+The \texttt{chemfig} code contained in the file \texttt{penicilling.tex} was generated from the molfile with the command:
+
+\begin{verbatim}
+mol2chemfig -wf penicilling.mol > penicilling.tex
+\end{verbatim}
+
+\noindent With \texttt{chemfig}'s default settings, the structure comes out as follows:
+
+\bigskip
+
+\begin{center}
+\input{penicilling}
+\end{center}
+
+\noindent This is a little bit out of proportion to the surrounding text. We can easily adjust the appearance by tweaking some of the settings provided by \texttt{chemfig}:
+
+% these settings adjust the appearance of formulas rendered
+% by chemfig - comment out to see chemfig's defaults
+\setcrambond{2.5pt}{0.4pt}{1.0pt}%
+\setbondoffset{1pt}%
+\setdoublesep{2pt}%
+\setatomsep{16pt}%
+
+\begin{lstlisting}
+% bond styling
+\setcrambond{2.5pt}{0.4pt}{1.0pt}
+\setbondoffset{1pt}
+\setdoublesep{2pt}
+\setatomsep{16pt}
+% print atoms with smaller font and in sans-serif
+\renewcommand{\printatom}[1]%
+{\fontsize{8pt}{10pt}\selectfont{\ensuremath{\mathsf{#1}}}}%
+\end{lstlisting}
+
+% print atoms with smaller font and in sans-serif
+\renewcommand{\printatom}[1]{\fontsize{8pt}{10pt}\selectfont{\ensuremath{\mathsf{#1}}}}%
+
+\clearpage
+
+\noindent After these settings have been adjusted, the same structure now appears as follows:
+
+\bigskip
+
+\begin{center}
+\input{penicilling}
+\end{center}
+
+\noindent We will leave these settings in effect for the remainder of this document.
+
+\section*{Incorporating rendered structures into composite graphics}
+
+The \texttt{mol2chemfig} package loads \texttt{chemfig}, which in turn loads the general purpose graphics package \texttt{TikZ}. Through the latter package, we have access to the \texttt{tikzpicture} environment. Here is a \texttt{tikzpicture} that depicts two resonance structures of alanine bound to pyridoxal phosphate:
+
+% load submol definitions - generated with
+% mol2chemfig -f -l plp plp.mol > plp.tex
+% and
+% mol2chemfig -f -l plp2 plp2.mol > plp2.tex
+\input{plp}
+\input{plp2}
+
+\begin{center}
+
+\begin{tikzpicture}%
+[>=stealth, help lines/.style={very thin,draw=black!25}, x=1cm, y=1cm]
+
+% draw grid of help lines - useful while editing
+\draw[help lines] (0,0) grid (12,4);
+
+% place both structures
+\node[anchor=south west, inner sep=10pt] at (0,0) (plp) {\chemfig{!{plp}}};
+\node[anchor=south west, inner sep=10pt] at (7,0) (plp2) {\chemfig{!{plp2}}};
+
+\draw[<->] (plp) -- (plp2);
+
+\end{tikzpicture}
+
+\end{center}
+
+\noindent Note that the $\input$ macro cannot be used inside a $\node$ in the \texttt{tikzpicture} environment. As a workaround, the two structures were rendered as $\submol$ definitions, which were $\input$ outside the \texttt{tikzpicture} environment and then referenced from within the $\node$ macros.
+
+Of course, to be complete and valid, the scheme above should also include arrows that indicate the electron movements underlying the resonance effect. This is possible in \texttt{chemfig} but will in this case require manual annotation of the generated code. So that we can find our way through the code, we can first render the structure to be annotated with atom numbers and display it:
+
+\begin{verbatim}
+mol2chemfig -wn plp2.mol > plpn.tex
+\end{verbatim}
+
+\begin{center}
+\input{plpn}
+\end{center}
+
+This tells us that we need to draw electron movement arrows from nitrogen 4 to the adjacent bond to carbon 3, from bond 2\rarr{}3 to bond 1\rarr{}2, and from bond 1\rarr{}15 to bond 15\rarr{}16.
+
+The mechanism provided by \texttt{chemfig} for drawing push arrows is based on named handles for bonds and atoms. Since version 1.4, \texttt{mol2chemfig} allows you to automatically generate named handles for each atom and bond, using the $--markers$ or $-g$ option:
+
+\begin{verbatim}
+mol2chemfig -f -l plpa -g a plp.mol > plpa.tex
+mol2chemfig -f -l plpb -g b plp2.mol > plpb.tex
+\end{verbatim}
+
+\input{plpa}
+\input{plpb}
+
+This option adds a unique identifier to each atom and to each bond. The option value (\texttt{a} and \texttt{b} in our example) is used as a prefix; this allows to unambiguously reference atoms in multiple molecules in the same drawing. In our first example, atom 3 will be given the marker \lstinline!@{a3}! for atom 3. The bond between atoms 3 and 4 will be labeled with \lstinline!@{a3-4}!; in bond markers, the smaller atom number always precedes the larger one. The generated code now gets a wee bit harsh on the eyeballs:
+
+\lstinputlisting[firstline=1,lastline=6]{plpa.tex}
+\lstinline! ...!
+
+\noindent We can now reference the handles to attach the electron movement arrows. Note that, for this to work, the document has to be processed \emph{twice} by \texttt{pdflatex}, since the commands internally use a PDF overlay mechanism; otherwise, the arrows may be misplaced.
+
+The $\mcfpush$ macro that is used to place the arrows is defined in the \texttt{mol2chemfig} package and is explained in the source code of this document; it is a convenience wrapper around the $\chemmove$ command provided by \texttt{chemfig}.
+
+\begin{center}
+
+\colorlet{mcfpusharrowcolor}{red} % set color for push arrows
+
+\begin{tikzpicture}%
+[>=stealth, help lines/.style={very thin,draw=black!25}, x=1cm, y=1cm]
+
+\draw[help lines] (0,0) grid (12,4);
+
+% place structures
+\node[anchor=south west, inner sep=10pt] at (0,0) (plpa) {\chemfig{!{plpa}}};
+\node[anchor=south west, inner sep=10pt] at (7,0) (plpb) {\chemfig{!{plpb}}};
+
+% horizontal arrow
+\draw[<->] (plpa) -- (plpb);
+
+% enclosing brackets
+\draw[semithick] (0.25,0) -- ++(-0.25,0) -- ++(0,4) -- ++(0.25,0);
+\draw[semithick] (11.75,0) -- ++(0.25,0) -- ++(0,4) -- ++(-0.25,0);
+
+% electron movement arrows. The \mcfpush macro is a convenience
+% wrapper around the \chemmove macro provided by chemfig. The
+% syntax of \mcfpush is
+% \mcfpush{handle1}{angle1:distance1}{handle2}{angle2:distance2}
+% where angles and distances place the control points of the
+% arrow's bezier curve.
+% Two optional arguments specify lengths by which to shorten the
+% arrow at the start and end, respectively. These default to 3pt
+% and 2pt, respectively.
+\mcfpush{a3-4}{70:4mm}{a4}{100:4mm}
+\mcfpush{a1-2}{-30:4mm}{a2-3}{10:4mm}
+\mcfpush{a15-16}{-20:4mm}{a1-15}{0:4mm}
+\mcfpush{a17}{-20:4mm}{a16-17}{-20:4mm}
+
+\mcfpush{b4}{100:4mm}{b3-4}{70:4mm}
+\mcfpush{b2-3}{10:4mm}{b1-2}{-30:4mm}
+\mcfpush[4pt][3pt]{b1-15}{0:4mm}{b15-16}{-20:4mm}
+\mcfpush{b16-17}{-20:4mm}{b17}{-20:4mm}
+\end{tikzpicture}
+
+\end{center}
+
+\end{document} \ No newline at end of file
diff --git a/graphics/mol2chemfig/tex/mol2chemfig.sty b/graphics/mol2chemfig/tex/mol2chemfig.sty
new file mode 100644
index 0000000000..2de1613f91
--- /dev/null
+++ b/graphics/mol2chemfig/tex/mol2chemfig.sty
@@ -0,0 +1,236 @@
+% auxiliary package for mol2chemfig
+\ProvidesPackage{mol2chemfig}[2014/03/24 v1.4]
+
+\RequirePackage{xcolor, chemfig, twoopt, ifmtarg}
+\usetikzlibrary{decorations}
+
+% \setbondstyle is defined by chemfig. Here, we wrap it
+% in order to also save the bond style in a tikz key.
+\let\mcf@setbondstyle\setbondstyle
+\renewcommand{\setbondstyle}[1]{%
+ \mcf@setbondstyle{#1}%
+ \tikzset{mcfbond/.style={#1}}%
+}
+
+% this macro (by Christian Tellechea) draws circles in aromatic rings.
+\def\mcfcringle#1{%
+\tikz\draw[mcfbond](0,0)circle(\CF@atom@sep*#1*0.66667*\CF@cycle@inraduiscoeff);}
+
+% auxiliary macros for rendering double and triple bonds
+
+% tikz decoration to render parallel bond strokes
+\pgfdeclaredecoration{mcfsecondstroke}{initial}{
+ \state{initial}[width=\pgfdecoratedpathlength-1sp]{
+ \pgfmoveto{\pgfpointorigin}
+ }
+ \state{final}{
+ \pgflineto{\pgfpointorigin}
+ }
+}
+
+% the complete sines definition is taken from http://tex.stackexchange.com/questions/25678/
+\pgfdeclaredecoration{complete sines}{initial}
+{
+ \state{initial}[
+ width=+0pt,
+ next state=sine,
+ persistent precomputation={\pgfmathsetmacro\matchinglength{
+ \pgfdecoratedinputsegmentlength / int(\pgfdecoratedinputsegmentlength/\pgfdecorationsegmentlength)}
+ \setlength{\pgfdecorationsegmentlength}{\matchinglength pt}
+ }] {}
+ \state{sine}[width=\pgfdecorationsegmentlength]{
+ \pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
+ \pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
+ \pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
+ \pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
+}
+ \state{final}{}
+}
+
+% color definitions
+\colorlet{mcfbgcolor}{white} % adjust when drawing on a non-white canvas
+\colorlet{mcfpusharrowcolor}{black}
+\colorlet{mcfatomnocolor}{blue}
+
+\tikzset{ % set styles
+ % wavy bonds. Slightly modified from http://www.texdev.net/tag/chemfig/
+ mcfwavy/.style =
+ {
+ decorate,
+ decoration =
+ {
+ complete sines,
+ post length = 0 pt,
+ pre length = 0 pt,
+ % Use chemfig's atom spacing
+ segment length = \the\dimexpr\csname CF@atom@sep\endcsname/6\relax,
+ amplitude = \the\dimexpr\csname CF@atom@sep\endcsname/10\relax
+ }
+ },
+ % this style is used by the \mcfelmove macro
+ mcfpusharrow/.style = {
+ ->,
+ mcfpusharrowcolor,
+ >=stealth,
+ shorten <=3pt,
+ shorten >=2pt,
+ preaction={draw=mcfbgcolor, -,line width=1.5pt}
+ },
+ %
+ mcfbond/.style = {}, % the chemfig default bond style is empty, too.
+ %
+ % one bond crossing before another - gets a white backdrop
+ % as wide as doublesep
+ mcfbgcolor/.style={white},
+ %
+ mcfx/.style 2 args={%
+ preaction={
+ draw,
+ mcfbgcolor,
+ line width=\CF@double@sep,
+ shorten <= {#1*\CF@double@sep/100},
+ shorten >= {#2*\CF@double@sep/100}
+ },
+ mcfbond
+ },
+ %
+ mcfcrossbond/.style={% for backwards compatibility only
+ mcfx={100}{100}
+ },
+ %
+ secondbond/.style 2 args={
+ shorten <= {#1*\CF@double@sep/100},
+ shorten >= {#2*\CF@double@sep/100},
+ mcfbond
+ },
+ %
+ secondfgbond/.style 2 args={
+ preaction={draw,-,mcfbgcolor,line width=\CF@double@sep},
+ secondbond={#1}{#2}
+ },
+ %
+ secondleft/.style 2 args={
+ secondbond={#1}{#2},
+ decoration={mcfsecondstroke,raise=\CF@double@sep},
+ decorate
+ },
+ %
+ secondright/.style 2 args={
+ secondbond={#1}{#2},
+ decoration={mcfsecondstroke,raise=-\CF@double@sep},
+ decorate
+ },
+ %
+ secondfgleft/.style 2 args={
+ secondfgbond={#1}{#2},
+ decoration={mcfsecondstroke,raise=\CF@double@sep},
+ decorate
+ },
+ %
+ secondfgright/.style 2 args={
+ secondfgbond={#1}{#2},
+ decoration={mcfsecondstroke,raise=-\CF@double@sep},
+ decorate
+ },
+ %
+ dbl/.style 2 args={
+ preaction={draw,secondleft={#1}{#2}}
+ },
+ %
+ dbr/.style 2 args={
+ preaction={draw,secondright={#1}{#2}}
+ },
+ %
+ trpl/.style 2 args={
+ preaction={draw,secondleft={#1}{#2}},
+ preaction={draw,secondright={#1}{#2}}
+ },
+ %
+ dblx/.style n args={4}{
+ preaction={draw,secondfgleft={#1}{#2}},
+ mcfx={#3}{#4}
+ },
+ %
+ dbrx/.style n args={4}{
+ preaction={draw,secondfgright={#1}{#2}},
+ mcfx={#3}{#4}
+ },
+ %
+ trplx/.style n args={4}{
+ preaction={draw,secondfgleft={#1}{#2}},
+ preaction={draw,secondfgright={#1}{#2}},
+ mcfx={#3}{#4}
+ },
+ %
+ drh/.style={dbr={58}{58}},
+ dlh/.style={dbl={58}{58}},
+ drhs/.style={dbr={58}{0}},
+ dlhs/.style={dbl={58}{0}},
+ drhe/.style={dbr={0}{58}},
+ dlhe/.style={dbl={0}{58}},
+ drn/.style={dbr={0}{0}},
+ dln/.style={dbl={0}{0}}
+}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Conveniences for drawing push arrows
+% the \mcfelmove command is adapted from the
+% myChemistry package by Clemens Niederberger
+
+\newcommand{\mcfelmove}[5][]{%
+\node at (0,0) {% dummy wrapper node
+\chemmove{\draw[mcfpusharrow,#1](#2).. controls +(#3) and +(#5)..(#4);%
+}};}
+
+% and, since the most common use for tikz code
+% is arrow shortening and lengthening: a command streamlined for that.
+
+\newcommandtwoopt{\mcfpush}[6][][]{% we use empties to keep same defaults
+\@ifmtarg{#2}{
+ \@ifmtarg{#1}{\mcfelmove{#3}{#4}{#5}{#6}}
+ {\mcfelmove[shorten <=#1]{#3}{#4}{#5}{#6}}
+}{% #2 not empty
+ \@ifmtarg{#1}{\mcfelmove[shorten >=#2]{#3}{#4}{#5}{#6}}
+ {\mcfelmove[shorten <=#1, shorten >=#2]{#3}{#4}{#5}{#6}}
+}}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Stacking atoms horizontally and vertically
+\newlength{\mcfvspace}
+\setlength{\mcfvspace}{1.5pt}
+
+\newcommand{\mcfabove}[2]{\chemabove[\mcfvspace]{#1}{#2}}
+\newcommand{\mcfbelow}[2]{\chembelow[\mcfvspace]{#1}{#2}}
+
+\newlength{\mcf@boxwidth}
+\newlength{\mcf@boxheight}
+
+\newcommand{\mcf@box}[3][l]{
+\settowidth{\mcf@boxwidth}{\printatom{#2}}
+\settoheight{\mcf@boxheight}{\printatom{#2}}
+\makebox[\mcf@boxwidth][#1]{\raisebox{0pt}[\mcf@boxheight][0pt]{\printatom{#3}}}}
+
+\newcommand{\mcfleft}[2]{\mcf@box[r]{#2}{#1#2}}
+\newcommand{\mcfright}[2]{\mcf@box{#1}{#1#2}}
+
+\newcommand{\mcfaboveright}[3]{\mcfabove{#1}{\mcf@box{#2}{#2#3}}}
+\newcommand{\mcfbelowright}[3]{\mcfbelow{#1}{\mcf@box{#2}{#2#3}}}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Formatting of charges and atom numbers
+
+% Charges - could for example be defined as \oplus and \ominus
+\newcommand{\mcfplus}{+}
+\newcommand{\mcfminus}{-}
+
+% atom numbers (used when option atom-numbers is selected)
+\newcommand{\mcfatomno}[1]%
+{\raisebox{2pt}{\color{mcfatomnocolor}{\ensuremath{\mathsf{_{#1}}}}}}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% a little help with direct processing of mol2chemfig commands
+\newcommand{\mcfinput}[1]{\@@input|"mol2chemfig #1"}
+
+