3

This is a follow-up question on a question I asked a few days ago (Chemmacros: Adjusting the properties of the coupling constant J)

I am using the fonts libertine and beramono together with the chammacros package to typeset experimental data. When I do so, there are two things I have noticed:

The coupling constant J is displayed in the math font of latin modern roman. This also applies to the frequency - both value and unit. I believe this is because the coupling constant is typeset in a math environment?

Is there a way to change this?

Obviously, one suggestion would be to change the math font, e.g. to euler vm font. However, this font uses upright letters, and I would like to follow the convention and have an italic coupling constant J.

Any suggestions how to overcome this issue? I suppose the easiest way would be to redefine J in eulervm fonts to be italic, because everything else would be fine automatically, however, I don't know how to do that. Of course a more general solution would be appreciated. Am I right in assuming this will be not possible with the standard options of the package?

Here is a MWE, illustrating my problem:

     \documentclass[a4paper,10pt,bibliography=totoc,listof=totoc]{scrreprt}
     \usepackage{chemmacros}
     \usepackage{siunitx}
     \chemsetup[nmr]{delta=(ppm),pos-number=side,use-equal,format = \bfseries,list=true}       
     \sisetup{separate-uncertainty,per-mode=symbol,detect-all,range-phrase=--}
     \usepackage[T1]{fontenc}
     \usepackage[utf8]{inputenc}
     \usepackage{libertine}
     \usepackage[scaled=.83]{beramono}
     \ExplSyntaxOn  %Defining Coupling Constant J with Subscript
     \cs_set_protected:Npn \__chemmacros_nmr_coupling:w (#1;#2)
      {
      \tl_set:Nn \l__chemmacros_nmr_coupling_bonds_tl { #1 \! }
      \tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl
      {
      \c_math_subscript_token
       { \chemmacros_chemformula:n { #2 } }
      }
      \__chemmacros_nmr_coupling_aux_i:w
      }
      \ExplSyntaxOff

      \begin{document}

      \begin{experimental}

      \NMR(400)[C6D6] \val{2.01} (d, \J(2;CH)[Hz]{25.0}, \#{24},  \pos{5})

      \end{experimental}


      \end{document}

1 Answers1

2

The coupling constant J is displayed in the math font of latin modern roman. This also applies to the frequency - both value and unit. I believe this is because the coupling constant is typeset in a math environment?

That's true, it is typeset in math. And I believe it should be since it is a variable. As for the number and the unit: they're typeset with the help of the siunitx package. What you need to find IMHO is a suiting math font, e.g., \usepackage[libertine]{newtxmath}.

The example below chooses some settings and makes a few refinements in the macros that are used for the typesetting of the different parts of the NMR data. It looks like this:

enter image description here

\documentclass[a4paper,10pt,bibliography=totoc,listof=totoc]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{libertine}
\usepackage[scaled=.83]{beramono}

% you can delete this line if you don't use libertine with oldstyle figures:
\expandafter\def\csname libertine@figurestyle\endcsname{LF}
\usepackage[libertine]{newtxmath}
% you can delete this line if you don't use libertine with oldstyle figures:
\expandafter\def\csname libertine@figurestyle\endcsname{OsF}

\usepackage{chemmacros}
\chemsetup[nmr]{
  delta = (ppm) ,
  pos-number = side ,
  use-equal,
  format = \bfseries,
  list=true
}
\usepackage{siunitx}
\sisetup{
  separate-uncertainty ,
  per-mode = symbol ,
  range-phrase = -- ,
  detect-mode = false ,
  detect-weight = true ,
  mode = text ,
  text-rm = \libertineLF % use libertine with lining figures
}

\ExplSyntaxOn
\cs_set_protected:Npn \__chemmacros_nmr_coupling:w (#1;#2)
  {
    \tl_set:Nn \l__chemmacros_nmr_coupling_bonds_tl { #1 \! }
    \tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl
      {
        \c_math_subscript_token
          { \chemmacros_chemformula:n { #2 } }
      }
    \__chemmacros_nmr_coupling_aux_i:w
  }
\cs_set_protected:Npn \chemmacros_nmr_number:n #1
  {
    $ #1 $ \, % put the number in math-mode for lining figures
    \chemmacros_atom:V \g__chemmacros_nmr_element_tl
  }
\cs_set:Npn \chemmacros_nmr_position:n #1
  {
    \chemmacros_chemformula:V \g__chemmacros_nmr_element_tl
    \tl_use:N \l__chemmacros_nmr_position_tl
    $ #1 $ % put the number in math-mode for lining figures
  }
\ExplSyntaxOff

\begin{document}

\begin{experimental}
  \NMR(400)[C6D6] \val{2.01} (d, \J(2;CH)[Hz]{25.0}, \#{24}, \pos{5})
\end{experimental}

\end{document}
cgnieder
  • 66,645
  • I just tried to run your example, but got an error like:

    ! Undefined control sequence. \LaTeX3 error: Erroneous variable \l__chemmacros_nmr_position_tl...

    – Vlad030691 Jan 27 '14 at 18:22
  • Ok, found out it is something with the last setup you're making, so the nmr position: \cs_set:Npn \chemmacros_nmr_position:n #1 { \chemmacros_chemformula:V \g__chemmacros_nmr_element_tl \tl_use:N \l__chemmacros_nmr_position_tl $ #1 $ % put the number in math-mode for lining figures } – Vlad030691 Jan 27 '14 at 18:30
  • 1
    @Vlad030691 that variable has been introduced with the last update. You don't really need it in your setup. It simply holds a dash so you can exchange \tl_use:N \l__chemmacros_nmr_position_tl with - – cgnieder Jan 27 '14 at 18:41