LaTeX forum ⇒ GeneralChange 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

Postby bstex » Sun Apr 29, 2018 3:58 pm

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.

User avatar
Johannes_B
Site Moderator
Posts: 3725
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sun Apr 29, 2018 4:43 pm

Hi,
Minimal working example please.
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

Postby bstex » Sun Apr 29, 2018 4:52 pm

Sorry, here it is:

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

User avatar
Johannes_B
Site Moderator
Posts: 3725
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Mon Apr 30, 2018 6:20 am

  1. \documentclass[a4paper,11pt]{book}
  2. \usepackage{tikz}
  3. \usetikzlibrary{positioning,arrows.meta}
  4. \usepackage[version=4]{mhchem}
  5.  
  6. \begin{document}
  7.  
  8. \ExplSyntaxOn
  9. \cs_set:Npn \__mhchem_arrow_options_minLength:n { {9em} }
  10. \ExplSyntaxOff
  11. \mhchemoptions{arrows=pgf{Straight Barb[round, angle=90:1.5pt 3]}{0.1ex}}
  12. \ce{A -> B} \\
  13. \ce{C <=> D} \\
  14. \ce{E <=>[\text{testing}] F} \\
  15.  
  16. \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

Postby bstex » Mon Apr 30, 2018 8:08 am

Yes, that's it!
Thank you so much.

User avatar
cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Thu May 03, 2018 2:32 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… :shock:

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


Return to “General”

Who is online

Users browsing this forum: laniuscollurio and 2 guests