Comments (6)
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}
PS:
- you don't need
xunicode
, see https://tex.stackexchange.com/a/78767/5049 xltxtra
can cause problems, see https://tex.stackexchange.com/a/80028/5049
from chemmacros.
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.
And again thanks a lot for your notes and xunicode and xltxtra.
from chemmacros.
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.
I thought that everything should use math fonts. Can you explain why the p and s/b are not using math fonts.
from chemmacros.
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.
Thanks a lot.
from chemmacros.
Related Issues (20)
- How to change the color of the oxidation numbers in chemmacros? HOT 1
- error while using siuntx's range-phrase command option HOT 1
- spectroscopy/NMR should accept alphanumerical input HOT 1
- iupac command and ligatures HOT 4
- Compilation error : undefined control sequence HOT 1
- Extra dash appears sometimes in IUPAC names after \{element} macros. HOT 2
- Clash with beamerswitch HOT 3
- \listofschemes not working in combination with the book class HOT 1
- Inconsistent counter representation and "chapter gap" in \listofschemes HOT 1
- Orbitals look weird. HOT 4
- Stereochemistry: \cip locants should not be printed in italics HOT 2
- Problem with chemmacros and KOMA-Script HOT 2
- Warning for \isotope command HOT 1
- Phases pos=sub HOT 2
- \theequation influences Reactions tag HOT 7
- Conflic between mhchem and chemmacros
- Why not directly require `amsmath` instead of `bm`? HOT 1
- with hyperref: failed to patch \hyper@refstepcounter HOT 2
- Chinese bracket cause "chemmacros" work wrong
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chemmacros.