I'm likely ignoring something fundamental here and was hoping for some hints. Please see the inset mwe.
Towards having a library of chemfig symbols, I see value in being able to point to a particular symbol (stored in an external .tex file) via the \input{}
command, the obvious construct being: \chemfig[][]{\input{<chemfig symbol library path>/{<symbol name>}}}
.
\documentclass[preview,border=7pt,active,tightpage]{standalone}
\usepackage{booktabs}
\usepackage{chemfig}
\usepackage{filecontents}
\usepackage[scaled]{helvet}
%\begin{filecontents}{methane.tex}
%H% 2
% -[:210]% 1
% (
% -[:210]H% 3
% )
% (
% -[:300]H% 5
% )
% -[:120]H% 4
%\end{filecontents}
% representation without comments
\begin{filecontents}{methane.tex}
H
-[:210]
(
-[:210]H
)
(
-[:300]H
)
-[:120]H
\end{filecontents}
\DeclareRobustCommand{\robustinputcommand}{\input{methane.tex}}
% sans serif font
\renewcommand\familydefault{\sfdefault}
% define formulae
\def\methane{\mathrm{CH_{4}}}
\begin{document}
\begin{center}
\begin{tabular}[]{lp{1.5cm}}
\toprule
\textbf{Formula} & \textbf{Structure}\\
\midrule%
%$\methane$ & \begin{minipage}[]{1cm} \chemfig{\input{methane.tex}} \end{minipage} \\ [2mm]% gives error
%$\methane$ & \begin{minipage}[]{1cm} \chemfig{\protect\input{methane.tex}} \end{minipage} \\ [2mm]% gives error
%$\methane$ & \begin{minipage}[]{1cm} \chemfig{\robustinputcommand} \end{minipage} \\ [2mm]% gives error
\bottomrule
\end{tabular}
\end{center}
\end{document}
Here is the error I observe consistently:
! Undefined control sequence.
<everyeof> \_nil
I have tried a few approaches, particularly those described here. These are commented in the mwe.
Note that the construct: \input{<full file path>}
(document level call) and \chemfig[][]{<content defining symbol>}
(generic structure of external document) works fine, but this does not immediately allow one to apply formatting e.g. [scale=0.5]
as optional argument of \chemfig
at the document level - something there is clear value in being able to do.