TeX - LaTeX Asked on December 27, 2020
I have observed a Command setbondstyle undefined error while using the mol2chemfig package with the following mwe:
documentclass[preview,border=7pt,active,tightpage]{standalone}
usepackage{booktabs}
%usepackage{chemfig}
usepackage{mol2chemfig}
usepackage{filecontents}
usepackage[scaled]{helvet}
begin{filecontents}{anthracene_aromatic_rings.tex}
chemfig{ % 5
-[:210,0.96]% 1
-[:270,0.96]% 2
(
-[:210.9]% 8
-[:150.4]% 12
-[:90]% 11
-[:29.6]% 7
-[:329.1]% -> 1
-[:209.1,0.99,,,draw=none]mcfcringle{1.28}% (o)
)
(
-[:30,0.96,,,draw=none]mcfcringle{1.25}% (o)
)
-[:330,0.96]% 6
-[:30,0.96]% 4
-[:90,0.96]% 3
(
-[:150,0.96]% -> 5
)
-[:30.9]% 9
(
-[:270.2,0.99,,,draw=none]mcfcringle{1.29}% (o)
)
-[:330.4]% 13
-[:270]% 14
-[:209.6]% 10
(
-[:149.1]% -> 4
)
}
end{filecontents}
begin{filecontents}{methane.tex}
chemfig{ H% 2
-[:210]% 1
(
-[:210]H% 3
)
(
-[:300]H% 5
)
-[:120]H% 4
}
end{filecontents}
% sans serif font
renewcommandfamilydefault{sfdefault}
% define formulae
defanthracene{mathrm{C_{14}H_{10}}}
defmethane{mathrm{CH_{4}}}
begin{document}
begin{center}
begin{tabular}[]{lp{1.5cm}}
toprule
textbf{Formula} & textbf{Structure}
midrule%
%$methane$ & begin{minipage}{1cm} input{methane.tex} end{minipage} [2mm]%
$anthracene$ & begin{minipage}{1cm} input{anthracene_aromatic_rings.tex} end{minipage} [2mm]%
bottomrule
end{tabular}
end{center}
end{document}
A successful compile is observed if one comments usepackage{mol2chemfig}
and the line in the table for anthracene (which calls some of the macros contained in mol2chemfig
).
I verified my chemfig
package installation (managed through console) and removed a copy of chemfig.sty
that was in my texmf tree.
For installation of mol2chemfig
, I simply downloaded the mol2chemfig.sty
and placed it in my texmf tree manually, doing FNDB after depositing files.
Could there be an accessory file that I do not have in which setbondstyle
is defined?
Perhaps I should be calling a supplementary package?
I am the mol2chemfig author and apologize for not having fixed this yet, even though it was pointed out to me a while ago. As a quick fix, you can just comment out or delete the entire block
letmcf@setbondstylesetbondstyle
renewcommand{setbondstyle}[1]{%
mcf@setbondstyle{#1}%
tikzset{mcfbond/.style={#1}}%
}
inside mol2chemfig.sty
.
Edit: OK, so there are additional problems here that I cannot solve. In the newer versions of chemfig
, the former CF@atom@sep
and CF@cycle@inraduiscoeff
have been replaced with CF_atomsep
and CF_cycleradiuscoeff
, but simply making those substitutions in mol2fchemfig
does not work. There may be some catcode trickery involved that is beyond me. I will ask the chemfig
author for help with this and hopefully have an update soon. In the meantime, the only solution seems to be to use an ancient version of chemfig
.
Second edit: I just tested this on my system, and it worked.
1) I downloaded the old version (1.2d) of chemfig.tex
which I posted at https://pastebin.com/uJWRDXuj earlier and saved it as cf-pastebin.tex
into an empty directory.
2) Into the same directory, I saved a copy of mol2chemfig.sty
under the name mol2chemfigfix.sty
. I edited the first couple of lines of that file to use cf-pastebin.tex
directly:
% auxiliary package for mol2chemfig
ProvidesPackage{mol2chemfigfix} % use the modified mol2chemfig package
RequirePackage{xcolor, twoopt, ifmtarg, tikz} % load tikz as a prereq for chemfig
input{cf-pastebin.tex} % load this directly, don't mess with chemfig.sty
defprintatom#1{ensuremath{mathrm{#1}}}% printatom pour LaTeX.
expandafterdefcsname CFstring_begintikzpictureendcsname{begin{tikzpicture}}%
expandafterdefcsname CFstring_endtikzpictureendcsname{end{tikzpicture}}%
usetikzlibrary{decorations}
I then used the following MWE (also saved into the same directory):
documentclass[border=2pt]{standalone}
usepackage{mol2chemfigfix}
% minimal example that exercises all CF@... macros used by mol2chemfig
begin{document}
chemfig{
-[:210,0.96]% 1
-[:270,0.96]% 2
(
-[:210.9]% 8
-[:150.4](-[:210]
-[:150,,,,drhs]
)
-[:90]% 11
-[:29.6]% 7
-[:329.1]% -> 1
-[:209.1,0.99,,,draw=none]mcfcringle{1.28}% (o)
)
}
end{document}
This gives no errors and produces the expected output. Since it does not invoke chemfig.sty
at all, I hope this will work for you also.
Correct answer by Michael Palmer on December 27, 2020
I have a problem with the chemfig
and mol2chemfig
packages. When I try to set the bond length using the statement setatomsep{2.25 em}
I get the following error message:
`Undefined control sequence. setatomsep`.
I tried to fix the problem following the steps provided by @Michel Palmer, but I did not manage to solve the problem: the MWE gives a lot of errors, the first one is Undefined control sequence
. So, I am wondering, in which directory do I have to save files cf-pastebin.tex
, mol2chemfigfix.sty
? Maybe I did not place those files in the right directory...
Answered by davide06 on December 27, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP