Git Product home page Git Product logo

Comments (6)

cgnieder avatar cgnieder commented on July 19, 2024

I get this warning from your MWE:

Package fontspec Warning: Font "TeXGyreBonum" does not contain requested
(fontspec)                Script "Math".

and a simple $K_s$ displays the same as \Ka.

This is not really a problem of chemmacros but a problem with your choice of fonts…

You can of course do

\chemsetup[acid-base]{
  eq-constant = \text{\textit{K}} ,
  K-acid = \text{s} ,
  K-base = \text{b}
}

which would use the text fonts for the constants but maybe you should rather search for a suiting math font instead that really works. However, the only one available today seems to be Fira Math.

\documentclass{article}
\usepackage{fontspec}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{unicode-math}

\usepackage[ngerman]{babel}

\setmainfont{TeX Gyre Heros}
\setsansfont{TeX Gyre Heros}
\setmonofont{TeX Gyre Cursor}
\setmathfont{Fira Math}[Scale=1.1]

\usepackage{chemmacros}

\begin{document}

\( K \) K

\bigskip

\(\pH \pOH \Ka \Kb \pKa \pKb\)

\bigskip

\pH \pOH \Ka \Kb \pKa \pKb

\end{document}

image


PS:

from chemmacros.

jnnkB avatar jnnkB commented on July 19, 2024

Hi,

Thanks a lot!

I loaded the wrong font in the previous code. I wanted to load the font 'TeX Gyre Bonum Math'. (see code below)

%!TEX TS-program = xelatex

\documentclass{article}

% Load packages for fonts
\usepackage{fontspec}

% Load math packages
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{unicode-math}

% Set language
\usepackage[ngerman]{babel}

\setmainfont{TeX Gyre Heros}
\setsansfont{TeX Gyre Heros}
\setmonofont{TeX Gyre Cursor}

\setmathfont{TeX Gyre Bonum Math}

\usepackage{chemmacros}
\begin{document}


\(\pH\)

\(\pOH\)

\(\Ka\)
$K_s$

\(\Kb\)

\(\pKa\)

\(\pKb\)

\vspace{1em}

\pH

\pOH

\Ka
$K_s$

\Kb

\pKa

\pKb


\end{document}

The output then shows the difference I meant. It partly uses the sans-serif font and partly the serif font.

image

And again thanks a lot for your notes and xunicode and xltxtra.

from chemmacros.

cgnieder avatar cgnieder commented on July 19, 2024

I am unsure what you actually want. “Somewhat ugly” is a quite subjective term. Your output looks like I expect it to look.

Do you want everything to use the math fonts? The p? The H? The OH? The subscripts? Or only part of them?

from chemmacros.

jnnkB avatar jnnkB commented on July 19, 2024

I thought that everything should use math fonts. Can you explain why the p and s/b are not using math fonts.

from chemmacros.

cgnieder avatar cgnieder commented on July 19, 2024

Well, as is documented the subscripts are in math mode but use \mathrm (maybe you want to adapt the font setting for that, it seems to fall back to the roman text font). H and OH are typeset as atoms. How this is done is determined by how you have set the formula option. By default, this is determined by the chemformula package.

All this can be set through options. The only thing that cannot be changed right now (I'll add an option for future versions) is p. Although, it can, but with a hack:

\documentclass{article}
\usepackage{fontspec}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{unicode-math}

\usepackage[ngerman]{babel}

\setmainfont{TeX Gyre Heros}
\setsansfont{TeX Gyre Heros}
\setmonofont{TeX Gyre Cursor}
\setmathfont{TeX Gyre Bonum Math}

\usepackage{chemmacros}

\chemsetup{
  formula = chemformula ,
  acid-base/K-acid = s ,
  acid-base/K-base = b ,
  chemformula/font-spec = TeX Gyre Bonum Math
}

\ExplSyntaxOn
\cs_set:Npn \chemmacros_p_style:n #1 { \chemformula_chcpd:nn {} {#1} }
\ExplSyntaxOff

\begin{document}

\(\pH \pOH \Ka \Kb \pKa \pKb\)

\bigskip

\pH \pOH \Ka \Kb \pKa \pKb

\end{document}

from chemmacros.

jnnkB avatar jnnkB commented on July 19, 2024

Thanks a lot.

from chemmacros.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.