TransWikia.com

Change the font within chemacros iupac environment?

TeX - LaTeX Asked on June 20, 2021

I am using cfr-lm as the font in my thesis, as I really like the look of the old style numbers in body text, and I have a LOT of numbers in my thesis. I’m also using the chemmacros/chemformula combination.

However, I find they (or at least typceface’s this implementation of them), don’t work very well in chemical formulas or names. Now there are two easy fixes for this with chemformula, however I can’t find an equivalent for chemmacros nomenclature module.

It looks like all I’d have to do is add a plstyle to the start of every iupac{ command, but I’m not sure how to do that, or if that is possible without breaking other things.

documentclass{article}
usepackage{cfr-lm}
usepackage{chemmacros}

begin{document}
iupac{(1textit{R},2textit{R})-trans-1,2-Cyclohexanedicarboxylate} Old style

iupac{plstyle(1textit{R},2textit{R})-trans-1,2-Cyclohexanedicarboxylate} Lining

iupac{2,2':6',2''-terpyridine} Old style

iupac{plstyle 2,2':6',2''-terpyridine} Lining


end{document}

Now, I could do something like newcommandiupacl[1]{iupac{plstyle #1}} but then I’m going to be forever hunting down instances of iupac and having to change them as I copy in text from older papers, so I’m keeping that as a backup if there isn’t an easy way to change the font within the iupac environment.

One Answer

I don't see an official interface---you could make a feature request---but something like this should work:

documentclass{article}
usepackage{cfr-lm,color}
usepackage{chemmacros}
ExplSyntaxOn
chemmacros_define_keys:nn {nomenclature}
  {
    iupac-format .code:n  = 
      {
         #1
      } ,
  }
RenewDocumentCommand iupac {O{iupac-format=plstyle}m} { chemmacros_iupac:nn {#1} {#2} }  
ExplSyntaxOff

begin{document}


iupac{(1textit{R},2textit{R})-trans-1,2-Cyclohexanedicarboxylate} Old style

iupac{plstyle(1textit{R},2textit{R})-trans-1,2-Cyclohexanedicarboxylate} Lining

iupac{2,2':6',2''-terpyridine} Old style

iupac{plstyle 2,2':6',2''-terpyridine} Lining

1234567
end{document}

Instead of using the default of the optional argument, you could also put the option before the #1, then it would be always executed.

enter image description here

Correct answer by Ulrike Fischer on June 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP