LaTeX forum ⇒ General ⇒ Change variable of a package Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
bstex
Posts: 59
Joined: Mon Oct 23, 2017 10:22 am

Change variable of a package

Hi.
I'm using mhchem and I'd like to change the default length of the variable \__mhchem_arrow_options_minLength:n
(It's on the line 1015 of the mhchem.sty file.)

What should I type in my preamble after \usepackage[version=4]{mhchem} to change this length?
The developer of this package told me that there is no public API, so I could experiment with this variable.
Thank you very much.

Johannes_B
Site Moderator
Posts: 3725
Joined: Thu Nov 01, 2012 4:08 pm
Hi,
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

bstex
Posts: 59
Joined: Mon Oct 23, 2017 10:22 am
Sorry, here it is:

\documentclass[a4paper,11pt]{book}\usepackage{tikz}\usetikzlibrary{positioning,arrows.meta}\usepackage[version=4]{mhchem} \begin{document} \mhchemoptions{arrows=pgf{Straight Barb[round, angle=60:1.5pt 3]}{0.1ex}}\ce{A -> B} \\\ce{C <=> D} \\\ce{E <=>[\text{testing}] F} \\ \end{document}

Johannes_B
Site Moderator
Posts: 3725
Joined: Thu Nov 01, 2012 4:08 pm
\documentclass[a4paper,11pt]{book}    \usepackage{tikz}    \usetikzlibrary{positioning,arrows.meta}    \usepackage[version=4]{mhchem}     \begin{document} \ExplSyntaxOn\cs_set:Npn \__mhchem_arrow_options_minLength:n  { {9em} }\ExplSyntaxOff    \mhchemoptions{arrows=pgf{Straight Barb[round, angle=90:1.5pt 3]}{0.1ex}}    \ce{A -> B} \\    \ce{C <=> D} \\    \ce{E <=>[\text{testing}] F} \\     \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

bstex
Posts: 59
Joined: Mon Oct 23, 2017 10:22 am
Yes, that's it!
Thank you so much.

cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm
Oh wow! According to expl3 conventions \__mhchem_arrow_options_minLength:n is an internal function with one brace argument. According to \show and the MWE it is used as a length or skip variable. It really should be named something like

\l__mhchem_arrow_options_minLength_dim

and be set internally with \dim_set:Nn \l__mhchem_arrow_options_minLength_dim {2em} or similarly. But looking at the code this is just the tip of the iceberg of wrongly named and used expl3 code…

at the very least mhchem should provide an interface for setting the “variable” \__mhchem_arrow_options_minLength:n.
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim