0

I am trying to get the hepparticles/hepnames packages to work with XeLaTeX. I am using Libertine as serif font and Biolinum as sans font. The particle names are somehow rendered in the wrong font.

The HEP packages insert glyphs for particle names used in high-energy physics. They should (I think) use the current font and style, but which font they actually use is inconsistent. In the MWEs below, I used a simple particle name (B) for comparison of a normal rendering of the letter B and the particle name inserted with the \PB macro, which should be identical.

I tried different orders for the loading of the packages:

fontspec loaded before HEP packages

\documentclass{minimal}

\usepackage{fontspec}
\setmainfont{Linux Libertine}
\setsansfont{Linux Biolinum}

\usepackage{hepparticles}
\usepackage{hepnames}

\begin{document}

    \begin{tabular}{p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}}
        ~  & Normal & textsf       & textit       & textsf+textit         \\
        B  & B      & \textsf{B}   & \textit{B}   & \textit{\textsf{B}}   \\
        PB & \PB    & \textsf{\PB} & \textit{\PB} & \textit{\textsf{\PB}} \\
    \end{tabular}

\end{document}

The normal glyph uses the wrong font, the sf glyph uses the wrong font and serifs, but the italic versions are both correct:

enter image description here

fontspec loaded after HEP packages

\documentclass{minimal}

\usepackage{hepparticles}
\usepackage{hepnames}

\usepackage{fontspec}
\setmainfont{Linux Libertine}
\setsansfont{Linux Biolinum}

\begin{document}

    \begin{tabular}{p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}}
        ~  & Normal & textsf       & textit       & textsf+textit         \\
        B  & B      & \textsf{B}   & \textit{B}   & \textit{\textsf{B}}   \\
        PB & \PB    & \textsf{\PB} & \textit{\PB} & \textit{\textsf{\PB}} \\
    \end{tabular}

\end{document}

All glyphs use the correct style, but all have the wrong font except the serif-italic glyph.

enter image description here

Next I used the libertine/biolinum packages instead of fontspec, and compiled the file with pdflatex as well for comparison:

font packages loaded after HEP packages

\documentclass{minimal}

\usepackage{hepparticles}
\usepackage{hepnames}

\usepackage{libertineRoman}
\usepackage{biolinum}

\begin{document}

    \begin{tabular}{p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}}
        ~  & Normal & textsf       & textif       & textsf+textit         \\
        B  & B      & \textsf{B}   & \textit{B}   & \textit{\textsf{B}}   \\
        PB & \PB    & \textsf{\PB} & \textit{\PB} & \textit{\textsf{\PB}} \\
    \end{tabular}

\end{document}

pdflatex

All glyphs have correct style and wrong font:

enter image description here

xelatex

All glyphs use the correct style, but all have the wrong font except the serif-italic glyph.

enter image description here

font packages loaded before HEP packages

\documentclass{minimal}

\usepackage{libertineRoman}
\usepackage{biolinum}

\usepackage{hepparticles}
\usepackage{hepnames}

\begin{document}

    \begin{tabular}{p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}}
        ~  & Normal & textsf       & textit       & textsf+textit         \\
        B  & B      & \textsf{B}   & \textit{B}   & \textit{\textsf{B}}   \\
        PB & \PB    & \textsf{\PB} & \textit{\PB} & \textit{\textsf{\PB}} \\
    \end{tabular}

\end{document}

pdflatex

All glyphs use the correct style, and all have the correct font except the serif-italic glyph. (This would be fine for me, except that I want to use xelatex.)

enter image description here

xelatex

The normal glyph uses the wrong font, the sf glyph uses the wrong font and serifs, but the italic versions are both correct:

enter image description here

1
  • Welcome to TeX.SX! The macros such as \PB use math mode for their job. This is surely going to give problems.
    – egreg
    Apr 25, 2015 at 23:49

1 Answer 1

2

OK, so egreg's comment pointed me in the right direction. I tried using mathspec to change the math fonts, with not luck. After taking a closer look at the macros in hepparticles, I fount that they use \mathup and similar macros for rendering the particle names. I couldn't find out how to change those with mathspec, so I switched to unicode-math and found a working configuration that gives a satisfactory result:

\documentclass{minimal}

\usepackage{hepparticles}
\usepackage{hepnames}

\usepackage{fontspec}
\setmainfont{Linux Libertine}
\setsansfont[BoldItalicFont=Linux Biolinum O Bold Oblique]{Linux Biolinum}

\usepackage[math-style=ISO]{unicode-math}

\setmathfont{Linux Libertine}

\setmathfont[range=\mathrm]{Linux Libertine}
\setmathfont[range=\mathup]{Linux Libertine}
\setmathfont[range=\mathit]{Linux Libertine Italic}
\setmathfont[range=\mathbf]{Linux Libertine Bold}
\setmathfont[range=\mathbfit]{Linux Libertine Bold Italic}

\setmathfont[range=\mathsf]{Linux Biolinum}
\setmathfont[range=\mathsfup]{Linux Biolinum}
\setmathfont[range=\mathsfit]{Linux Biolinum Italic}
\setmathfont[range=\mathbfsf]{Linux Biolinum Bold}
\setmathfont[range=\mathbfsfit]{Linux Biolinum O Bold Oblique}

\begin{document}
    \begin{tabular}{p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}}
        ~  & Normal & textsf       & textit       & textsf+textit         \\
        B  & B      & \textsf{B}   & \textit{B}   & \textit{\textsf{B}}   \\
        PB & \PB    & \textsf{\PB} & \textit{\PB} & \textit{\textsf{\PB}} \\
    \end{tabular}
\end{document}

enter image description here

Edit: I ran into a follow-up problem, which is discussed in another thread.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .