connections between two molecules
If the question is how to draw connections between two molecules created with separate calls of \chemfig
then the answer is in principle an easy one. ChemFig's molecules are TikZ pictures, really, and the atoms are nodes in this sense. As such they can be named through ChemFig's @{<node name>}
syntax and connected afterwards through some \tikz[remember picture, overlay]...;
or ChemFig's wrapper \chemmove{}
.
The following example
\documentclass{article}
\usepackage{chemfig}
\begin{document}
General idea:\par
\chemfig{-[7]@{a}-[1]}
\vskip2em
\chemfig{-[1]@{b}-[7]}
\chemmove{ \draw[red,dotted] (a)--(b); }
\end{document}
gives after two compilations:
![enter image description here](https://i.stack.imgur.com/Tj7NC.png)
In your case, however, I don't think this is the best approach. In order to be able to connect the nodes they need to have unique names. If you use one node name repeatedly only the last instance is remembered:
As a consequence the method is not so nice when the nodes to be connected are hidden in repeated submols:
\documentclass{article}
\usepackage{chemfig}
\begin{document}
problem with molecules derived from submols:\par
\definesubmol{foo}{-[7]@{a}-[1]}
\definesubmol{bar}{-[1]@{b}-[7]}
\chemfig{!{foo}!{bar}!{foo}!{bar}}
\vskip2em
\chemfig{!{foo}!{bar}!{foo}!{bar}}
\chemmove{ \draw[green,dashed] (a)--(b); }
\end{document}
![enter image description here](https://i.stack.imgur.com/U8hdI.png)
Finding the right atom
This addresses your second question:
Note that the red bond (emerging from OH in C6) is not properly
placed. It should emerge from H instead than from O.
ChemFig provides a solution for this. Every bond in \chemfig{}
has an optional arguments with five parameters:
-[<direction>,<length factor>,<departure>,<arrival>,<tikz options>]
The ones interesting here are <departure>
and <arrival>
which are integers specifying the numbers of the desired departure and arrival atoms. ChemFig's manual has the following example:
\documentclass{article}
\usepackage{chemfig}
\begin{document}
\chemfig{ABCD-[:75,,2,3]EFG}\qquad
\chemfig{ABCD-[:75,,,2]EFG}\qquad
\chemfig{ABCD-[:75,,3,2]EFG}
\end{document}
![enter image description here](https://i.stack.imgur.com/ZC0pe.png)
Proposed solution
In order to get two strands of cellulose I would suggest to save one submol of two glucoses with hydrogen bonds. Here's a possible definition using the turned-glucoBeta
submol from my answer to the question you linked:
\definesubmol{bridged}{
-[:10,.7,,,glycosid]4
(
-[:-10](-[:150,0.7]-[2,0.7]OH)
-[:10]{\color{red}{O}}(-[:-8,1.2,,,bridge])
-[:-50,.75]
)
-[:-50]
(
-[:170]HO
-[6,,2,2,bridge]
OH
-[6,.7]
-[:-30]
-[:170]4(-[:-170,.475,,,glycosid])
-[:-50](-[:170]HO)
-[:10](-[:-50,.7]OH)
-[:-10]1(-[6]H)(-[:10,.7,,,glycosid]{\color{glyc}O}!{turned-glucoBeta})
-[:130]{\color{red}O}(-[:-8,1.2,,,bridge])
-[:-170]
)
-[:10](-[:-55,0.7]OH)
-[:-10]1(-[6,0.7]H)
-[:10,.7,,,glycosid]{\color{glyc}O}
!{turned-glucoBeta}
}
This submol can now be used repeatedly to get the polymer:
![enter image description here](https://i.stack.imgur.com/d1vbk.png)
The full code
\documentclass[margin=.5cm]{standalone}
\usepackage{chemfig}
\tikzset{
bridge/.style={dotted,blue} ,
glycosid/.style={glyc}
}
\colorlet{glyc}{green}
\definesubmol{turned-glucoBeta}{
-[:-10,.7,,,glycosid]4
(
-[:10](-[:-150,0.7]-[6,0.7]OH)
-[:-10]{\color{red}{O}}-[:50,.75]
)
-[:50](-[:-170]HO)
-[:-10](-[:55,0.7]OH)
-[:10]1(-[2,0.7]H)
-[:-10,.7,,,glycosid]{\color{glyc}{O}}
}
\definesubmol{bridged}{
-[:10,.7,,,glycosid]4
(
-[:-10](-[:150,0.7]-[2,0.7]OH)
-[:10]{\color{red}{O}}(-[:-8,1.2,,,bridge])
-[:-50,.75]
)
-[:-50]
(
-[:170]HO
-[6,,2,2,bridge]
OH
-[6,.7]
-[:-30]
-[:170]4(-[:-170,.475,,,glycosid])
-[:-50](-[:170]HO)
-[:10](-[:-50,.7]OH)
-[:-10]1(-[6]H)(-[:10,.7,,,glycosid]{\color{glyc}O}!{turned-glucoBeta})
-[:130]{\color{red}O}(-[:-8,1.2,,,bridge])
-[:-170]
)
-[:10](-[:-55,0.7]OH)
-[:-10]1(-[6,0.7]H)
-[:10,.7,,,glycosid]{\color{glyc}O}
!{turned-glucoBeta}
}
\begin{document}
\chemfig{!{bridged}!{bridged}!{bridged}}
\end{document}
a version showing all H, without using \chemabove or \chembelow
\setchemfig{atom style={scale=.85},atom sep=2.5em}
%
\chemname{\chemfig{C(-[2,.35,,,,draw=none]H)(-[:150]C(-[6,.35,,,,draw=none]H)(-[2,.35,,,,draw=none]H)-[:210]*6(=-=-=-))(-[:30]CH_3)-[:270]N(-[:210]H_3C)(-[:330]C(-[6,.35,,,,draw=none]H)(-[2,.35,,,,draw=none]H)-[:30]C~[:30]CH)}}
{Selegiline}
%
![enter image description here](https://i.stack.imgur.com/rCphA.png)
OR...
\setchemfig{atom style={scale=.85},atom sep=2.5em}
%
\chemname{\chemfig{C(-[2,.35,,,,draw=none]H)(-[:150]C(-[:70,.35,,,,draw=none]H_2)-[:210]*6(=-=-=-))(-[:30]CH_3)-[:270]N(-[:210]H_3C)(-[:330]C(-[:290,.37,,,,draw=none]H_2)-[:30]C~[:30]CH)}}
{Selegiline}
%
![enter image description here](https://i.stack.imgur.com/n0HMU.png)
Best Answer
You can use invisible bonds: