GeneralChange variable of a package

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

Change variable of a package

Post by bstex »

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.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Change variable of a package

Post by Johannes_B »

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: 69
Joined: Mon Oct 23, 2017 10:22 am

Change variable of a package

Post by bstex »

Sorry, here it is:

Code: Select all

\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}
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Change variable of a package

Post by Johannes_B »

Code: Select all

\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: 69
Joined: Mon Oct 23, 2017 10:22 am

Change variable of a package

Post by bstex »

Yes, that's it!
Thank you so much.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Change variable of a package

Post by cgnieder »

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.
site moderator & package author
Post Reply