Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I’m typesetting a text with some math and Greek letters. LaTeX handles Greek letters just fine in math mode but I can’t get it to display the character ‘β’ using either direct input or the \b macro provided by the chemmacros package.

Here's a minimal example:

\documentclass{minimal}
\usepackage{fontspec}
\usepackage[greek=textgreek]{chemmacros}

\begin{document}    
\iupac{\b-carotene} % doesn't work

\iupac{β-carotene} % doesn't work

β % doesn't work

\Chembeta % doesn't work

$\beta$ % works fine
\end{document}

I’m compiling the document with lualatex.


Update

Using a different font (namely, Linux Libertine or Times New Roman) solves the problem. Does that mean the Latin Modern family has no support for upright Greek letters?

share|improve this question
1  
Here, your MWE is fine (\b, \Chembeta and $beta$) except with β character (no error and no glyph!). –  Paul Gaborit Oct 11 '12 at 0:07
1  
\iupac{\b-carotene} works for me. May be you should go for update? –  Harish Kumar Oct 11 '12 at 0:08
    
I get three betas like the others with TeX Live 2012. Not sure if I like the italics in β-carotene though. Maybe an upright beta from the Computer Modern Math font would look better? –  Christian Oct 11 '12 at 0:13
    
It may be that the aux file got in the way during testing, since I was playing with many configurations and fonts. I'm indeed looking for the upright beta. I'm updating the question to include the option [greek=textgreek] in the chemmacros package, which should display an upright beta. –  rberaldo Oct 11 '12 at 0:18
    
There are evident problems with textgreek in LuaLaTeX with fontspec, as, for example, \textbeta gets redefined. –  egreg Oct 11 '12 at 7:28
show 1 more comment

2 Answers 2

up vote 4 down vote accepted

upgreek works fine both with XeLaTeX and LuaLaTeX. Apparently it isn't clear from chemmacros' documentation though that setting the option greek=upgreek does not load upgreek and greek=textgreek does not load textgreek! The option exists to prevent chemmacros from choosing between upgreek or textgreek automatically if either of them or both are loaded by the user. Using either option without loading the appropriate package usually throws an error like

! Undefined control sequence.
<argument> \textbeta 

l.9 \iupac{\b-carotene}

However, when fontspec is loaded, too, the code silently fails with Latin Modern. (I should probably add some checking whether the needed packages are loaded.)

\documentclass{article}
\usepackage{fontspec}
\usepackage{upgreek}% needs no be loaded
\usepackage{chemmacros}[2014/01/24]
\usepackage{newunicodechar}
\newunicodechar{β}{\chembeta}

\begin{document}    
\iupac{\b-carotene} % works

\iupac{β-carotene} % works

β % works

\chembeta % works

$\beta$ % works fine
\end{document}

enter image description here

share|improve this answer
add comment

A problem is that \textbeta gets redefined, so the definition performed by textgreek is lost. Moreover, the Latin Modern fonts don't support Greek.

Here is a hack, I guess there are better ways to do it.

\documentclass{article}

\usepackage[LGR]{fontenc}
\usepackage{chemmacros}
\protected\def\Chembeta{\text{\fontencoding{LGR}\fontfamily{cmr}\selectfont b}}

\usepackage{fontspec}

\usepackage{newunicodechar}
\newunicodechar{β}{\Chembeta}

\begin{document}

\iupac{\b-carotene} % works

\iupac{β-carotene} % works

β % works

\Chembeta % works

$\beta$ % works
\end{document}

enter image description here

A more complete setting, for the Latin Modern fonts only can be obtained generalizing and streamlining the above hack:

\documentclass{article}

\usepackage[LGR]{fontenc}
\usepackage{chemmacros}
\usepackage{newunicodechar}
\usepackage{fontspec}

\ExplSyntaxOn
\cs_set_protected:Npn \egchemmacros_lgr_greek:n #1
 {
  \mbox{\fontencoding{LGR}\fontfamily{cmr}\selectfont#1}
 }
\cs_set_protected:Npn \Chemalpha{\egchemmacros_lgr_greek:n{a}}
\cs_set_protected:Npn \Chembeta{\egchemmacros_lgr_greek:n{b}}
\cs_set_protected:Npn \Chemgamma{\egchemmacros_lgr_greek:n{g}}
\cs_set_protected:Npn \Chemdelta{\egchemmacros_lgr_greek:n{d}}
\cs_set_protected:Npn \Chemepsilon{\egchemmacros_lgr_greek:n{e}}
\cs_set_protected:Npn \Chemeta{\egchemmacros_lgr_greek:n{h}}
\cs_set_protected:Npn \Chemkappa{\egchemmacros_lgr_greek:n{k}}
\cs_set_protected:Npn \Chemmu{\egchemmacros_lgr_greek:n{m}}
\cs_set_protected:Npn \Chemnu{\egchemmacros_lgr_greek:n{n}}
\cs_set_protected:Npn \Chempi{\egchemmacros_lgr_greek:n{p}}
\cs_set_protected:Npn \Chemrho{\egchemmacros_lgr_greek:n{r}}
\cs_set_protected:Npn \Chemsigma{\egchemmacros_lgr_greek:n{s}}
\cs_set_protected:Npn \Chemomega{\egchemmacros_lgr_greek:n{w}}
\cs_set_protected:Npn \ChemDelta{\egchemmacros_lgr_greek:n{D}}

\newunicodechar{α}{\bool_if:NTF \l_chemmacros_inside_iupac_bool {\Chemalpha}{α}}
\newunicodechar{β}{\bool_if:NTF \l_chemmacros_inside_iupac_bool {\Chembeta}{β}}
\newunicodechar{γ}{\bool_if:NTF \l_chemmacros_inside_iupac_bool {\Chemgamma}{γ}}
\newunicodechar{δ}{\bool_if:NTF \l_chemmacros_inside_iupac_bool {\Chemdelta}{δ}}
\newunicodechar{ε}{\bool_if:NTF \l_chemmacros_inside_iupac_bool {\Chemepsilon}{ε}}
\newunicodechar{η}{\bool_if:NTF \l_chemmacros_inside_iupac_bool {\Chemeta}{η}}
\newunicodechar{κ}{\bool_if:NTF \l_chemmacros_inside_iupac_bool {\Chemkappa}{κ}}
\newunicodechar{μ}{\bool_if:NTF \l_chemmacros_inside_iupac_bool {\Chemmu}{μ}}
\newunicodechar{ν}{\bool_if:NTF \l_chemmacros_inside_iupac_bool {\Chemnu}{ν}}
\newunicodechar{π}{\bool_if:NTF \l_chemmacros_inside_iupac_bool {\Chempi}{π}}
\newunicodechar{ρ}{\bool_if:NTF \l_chemmacros_inside_iupac_bool {\Chemrho}{ρ}}
\newunicodechar{σ}{\bool_if:NTF \l_chemmacros_inside_iupac_bool {\Chemsigma}{σ}}
\newunicodechar{ω}{\bool_if:NTF \l_chemmacros_inside_iupac_bool {\Chemomega}{ω}}
\newunicodechar{Δ}{\bool_if:NTF \l_chemmacros_inside_iupac_bool {\ChemDelta}{Δ}}
\ExplSyntaxOff

\begin{document}

\iupac{\b-carotene} % works

\iupac{β-carotene} % works

β % doesn't work - Latin Modern has no beta

\Chembeta % works

$\beta$ % works fine

\iupac{αβγδεηκμνπρσωΔ} % works

\iupac{\a\b\g\d\k\m\n\w}
\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.