Skip to main content
subdued option as needed in new versions of mathastext
Source Link
Andrew Swann
  • 98.2k
  • 13
  • 210
  • 473

As mentioned in the comments TeX Gyre Heros is not a math fonts and this is what is causing the strange errors. However, you can use the mathastext package overcome this. The following demonstrates its use with lualatex. The order in the preamble is crucial.

Sample outputUpdate. I have added the subdued option to mathastext to prevent errors in processing in newer versions.

Sample output

\documentclass{article} \usepackage{pgfplots}\usepackage[no-math]{fontspec} \usepackage{lmodern} \usepackage[LGRgreek]\usepackage[LGRgreek,subdued]{mathastext} \setmainfont{TeX Gyre Heros}\Mathastext[Heros] \setmainfont{Latin Modern Roman} \pgfplotsset{compat=1.11} \begin{document} \begin{figure} \centering \MTversion{Heros} \begin{tikzpicture} \begin{axis}[font=\sffamily] \addplot [blue] coordinates { (0,0) (1,2) }; \end{axis} \node at (4, 1) { $\Delta T_{\mathrm S}$}; \node at (2, 5) {normal sans serif text}; \end{tikzpicture} \MTversion{normal} \caption{Some caption text.} \end{figure} Normal text in Latin Modern Roman here but math fails unless the next line is used. \begin{equation} a^2 + b^2 = c^2 \end{equation} \end{document} 

As mentioned in the comments TeX Gyre Heros is not a math fonts and this is what is causing the strange errors. However, you can use the mathastext package overcome this. The following demonstrates its use with lualatex. The order in the preamble is crucial.

Sample output

\documentclass{article} \usepackage{pgfplots}\usepackage[no-math]{fontspec} \usepackage{lmodern} \usepackage[LGRgreek]{mathastext} \setmainfont{TeX Gyre Heros}\Mathastext[Heros] \setmainfont{Latin Modern Roman} \pgfplotsset{compat=1.11} \begin{document} \begin{figure} \centering \MTversion{Heros} \begin{tikzpicture} \begin{axis}[font=\sffamily] \addplot [blue] coordinates { (0,0) (1,2) }; \end{axis} \node at (4, 1) { $\Delta T_{\mathrm S}$}; \node at (2, 5) {normal sans serif text}; \end{tikzpicture} \MTversion{normal} \caption{Some caption text.} \end{figure} Normal text in Latin Modern Roman here but math fails unless the next line is used. \begin{equation} a^2 + b^2 = c^2 \end{equation} \end{document} 

As mentioned in the comments TeX Gyre Heros is not a math fonts and this is what is causing the strange errors. However, you can use the mathastext package overcome this. The following demonstrates its use with lualatex. The order in the preamble is crucial.

Update. I have added the subdued option to mathastext to prevent errors in processing in newer versions.

Sample output

\documentclass{article} \usepackage{pgfplots}\usepackage[no-math]{fontspec} \usepackage{lmodern} \usepackage[LGRgreek,subdued]{mathastext} \setmainfont{TeX Gyre Heros}\Mathastext[Heros] \setmainfont{Latin Modern Roman} \pgfplotsset{compat=1.11} \begin{document} \begin{figure} \centering \MTversion{Heros} \begin{tikzpicture} \begin{axis}[font=\sffamily] \addplot [blue] coordinates { (0,0) (1,2) }; \end{axis} \node at (4, 1) { $\Delta T_{\mathrm S}$}; \node at (2, 5) {normal sans serif text}; \end{tikzpicture} \MTversion{normal} \caption{Some caption text.} \end{figure} Normal text in Latin Modern Roman here but math fails unless the next line is used. \begin{equation} a^2 + b^2 = c^2 \end{equation} \end{document} 
Source Link
Andrew Swann
  • 98.2k
  • 13
  • 210
  • 473

As mentioned in the comments TeX Gyre Heros is not a math fonts and this is what is causing the strange errors. However, you can use the mathastext package overcome this. The following demonstrates its use with lualatex. The order in the preamble is crucial.

Sample output

\documentclass{article} \usepackage{pgfplots}\usepackage[no-math]{fontspec} \usepackage{lmodern} \usepackage[LGRgreek]{mathastext} \setmainfont{TeX Gyre Heros}\Mathastext[Heros] \setmainfont{Latin Modern Roman} \pgfplotsset{compat=1.11} \begin{document} \begin{figure} \centering \MTversion{Heros} \begin{tikzpicture} \begin{axis}[font=\sffamily] \addplot [blue] coordinates { (0,0) (1,2) }; \end{axis} \node at (4, 1) { $\Delta T_{\mathrm S}$}; \node at (2, 5) {normal sans serif text}; \end{tikzpicture} \MTversion{normal} \caption{Some caption text.} \end{figure} Normal text in Latin Modern Roman here but math fails unless the next line is used. \begin{equation} a^2 + b^2 = c^2 \end{equation} \end{document}