\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?