# Add non-bounding group to a molecule using chemfig

I would like to obtain the following result:

I am workint with Overleaf and stuck in the following MWE:

\documentclass{article}
\usepackage{chemfig}
\begin{document}
\chemfig{
-[:+30]  % C1
-[::-60] % C2
(-[::-60] -[::+45] NH_2)
-[::+45, 3]
}
\end{document}


I think that Overleaf doesn't load the latest version of chemfig package, since I tried to code the brackets with no success (and then I don't display the corresponding piece of code in the MWE). Is it possible to get the brackets by any other means? What about the *HCl floating above the NH2?

So the request is to not use \polymerdelim. I have come up with a solution thanks to Heiko Oberdiek and this. The approach is to use a TikZ matrix that will have only one cell (which will be the chemfig). The square brackets needed to be shifted inside which made the positioning of the subscript n to be manually adjusted.

\documentclass{article}
\usepackage{chemfig, tikz}
\usetikzlibrary{matrix}

\newsavebox\ourFormula
\sbox\ourFormula{
\chemfig[atom sep = 1.5em]{
-[@{opening,0.75}:30]                       % Left opening bracket
-[:+30]                                     % C1
-[::-60]                                    % C2
(
-[::-60] -[::+45] NH_2                    % NH_2
\raisebox{2em}{\hspace{-2em}$\bullet$ HCI} % HCI
)
-[::+45, 3]
-[@{closing,0.25}:+15]                      % Right closing bracket
}
}
\begin{document}
\begin{tikzpicture}[
every left delimiter/.style={xshift=20pt},
every right delimiter/.style={xshift=-20pt}
]
\node (matrix) [left delimiter = {[}, right delimiter = {]}] {
\usebox\ourFormula\\
};
\node [ xshift=48pt, yshift=-25pt] {$n$};
\end{tikzpicture}
\end{document}


Original Answer: The brackets can be easily obtained using the \polymerdelim marco (it also takes care of the right subscript n). Now, the challenge is to have the •HCI above NH_2. The way I did it is by using \raisebox{vertical distance}{text}. This made the •HCI to be positioned top right with respect to NH_2. The solution is to use \hspace{negative distance} to pull it over to the left and have them vertically aligned.

In the case you wanted to change the code, make sure to compile it twice.

\documentclass{article}
\usepackage{chemfig}
\begin{document}
\chemfig[atom sep = 1.5em]{
-[@{opening,0.75}:30]                       % Left opening bracket
-[:+30]                                     % C1
-[::-60]                                    % C2
(
-[::-60] -[::+45] NH_2                    % NH_2
\raisebox{2em}{\hspace{-2em}$\bullet$ HCI} % HCI
)
-[::+45, 3]
-[@{closing,0.25}:+15]                      % Right closing bracket
}
% Now, we can put everything inside the brackets and have n as our indice.
\polymerdelim[height=30pt, delimiters={[]}, indice=n]{opening}{closing}
\end{document}

• Thank you @M.AlJumaily for the solution. I appreciate the way you placed the HCI group. However, as I mentioned in the question, I found out that Overleaf runs the version of chemfig previous to that which defines the macro \polymerdelim. Do you thing that there is another way of placing the brackets? – Brasil Aug 28 '19 at 22:24
• See the edit please. – M. Al Jumaily Aug 28 '19 at 23:22
• Thank you very much, @M.AlJumaily! – Brasil Aug 28 '19 at 23:24
• You are very welcome @Brasil – M. Al Jumaily Aug 28 '19 at 23:25