2

I'm writing a document using Tex Gyre Bonum as roman font and Tex Gyre Bonum Math as math font. But these fonts have different commas. So, commas in equation environments are not equal to commas in regular text. How can I make commas in math mode equal to commas in regular text?

\documentclass[12pt,a4paper,titlepage]{report}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{amsmath,amssymb,cancel,esint,mathtools,stackrel,stmaryrd,undertilde,amsfonts,siunitx}
\usepackage{fontspec}
\usepackage{unicode-math}
\setromanfont{TeX Gyre Bonum}
\setmathfont[math-style=ISO,bold-style=ISO]{TeX Gyre Bonum Math}

\begin{document}

Lorem, ipsum, dolor, sit, amet, consectetur, adipiscing, elit. Fusce, vel, pellentesque, tellus. 
$$E=mc^2,$$
Nunc, ut, pharetra, mauris, quis, maximus, risus. Fusce, eu, laoreet, justo. 
$$,,,$$

This is comma in regular text: ,

This is comma in math mode: $,$

\end{document}

PDF

  • 3
    looks quite equal to me. Show a complete document. – Ulrike Fischer Mar 22 at 17:04
  • I have added some LaTeX code that shows what I'm saying. I compiled it with LuaLaTeX – AgnusDei Mar 22 at 17:53
  • 2
    It's the fault of the italian option, it redefines the comma in math. – Ulrike Fischer Mar 22 at 18:10
5

Two possible workarounds:

  1. load the dcolumn package
  2. use polyglossia instead of babel

For various reasons, babel-italian started to mess with commas in order to emulate the behavior of icomma. There is apparently no way to disable this without loading dcolumn, that avoids the mess to even start.

Also issuing \AtBeginDocument{\NoIntelligentComma} doesn't solve the problem, because this restores the mathcode of the comma to the value it has in legacy LaTeX and is not good for unicode-math.

\documentclass{article}
\usepackage[italian]{babel}
\usepackage{amsmath,dcolumn}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{TeX Gyre Bonum}
\setmathfont[math-style=ISO,bold-style=ISO]{TeX Gyre Bonum Math}

\begin{document}

Lorem, ipsum, dolor, sit, amet, consectetur, 
adipiscing, elit. Fusce, vel, pellentesque, tellus. 
\[E=mc^2,\]
Nunc, ut, pharetra, mauris, quis, maximus, risus. Fusce, eu, laoreet, justo. 
\[,\text{,},\]

This is comma in regular text: ,

This is comma in math mode: $,$

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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