4

I am learning how to load fonts manually using TeXLive 2023 on Linux.

After much struggle I finally got this MWE working. This loads some random fonts I found under /usr/local/texlive/2023/texmf-dist/fonts just to learn how to load them. I am using the commands \setmainfont and \setmathfont.

\documentclass[12pt]{book}    
\usepackage{amsmath}     
\usepackage{fontspec,unicode-math}

\setmainfont[ Path = /usr/local/texlive/2023/texmf-dist/fonts/opentype/public/qualitype/, Extension = .otf, Ligatures = TeX ]{QTSchoolCentury}

\setmathfont[ Path = /usr/local/texlive/2023/texmf-dist/fonts/opentype/public/asana-math/, Extension = .otf, Ligatures = TeX ]{Asana-Math}

%\usepackage{breqn}

\begin{document} test

[ \sin x = \int_{0}^{\infty} \cos x ] \end{document}

I compile the above using lualatex and it gives no error.

>lualatex A.tex
This is LuaHBTeX, Version 1.16.0 (TeX Live 2023) 
 restricted system commands enabled.
(./A.tex
   .....

It compiles and gives

enter image description here

Now I uncommented \usepackage{breqn} and now same lualatex command gives

/usr/local/texlive/2023/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/local/texlive/2023/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
(/usr/local/texlive/2023/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
! Undefined control sequence.
<recently read> \

l.25 [

?

What am I doing wrong? Again, the above is just me learning how to load fonts to see how it is done. Why adding breqn gives an error? I have not even used the package yet.

Is there a workaround?

I am using this answer How to properly install and use a new font with LuaLaTeX? as reference.

TL 2023 on Linux

Nasser
  • 20,220
  • 1
    note you shouldn't do Path =/usr/local/texlive/2023/texmf-dist/fonts/opentype/public/qualitype as it's the default path on texlive 2023so not needed in that system and it;s wrong everywhere else. – David Carlisle Dec 20 '23 at 00:35
  • 2
    \setmathfont should only be used with an OpenType Math font, bit you have used it with a text font. Do not ignore Package unicode-math Warning: The first font loaded by unicode-math must be an (unicode-math) OpenType Math font (with script=math). nothing can work correctly with such a setting, with or without breqn. – David Carlisle Dec 20 '23 at 00:37
  • 1
    well if you didn't know before you should have known after unicode-math screamed that the font was wrong. mostly they have Math in their name, Cambria Math, Stix Two Math, TeX Gyre Termes Math, Fira Math, .... – David Carlisle Dec 20 '23 at 00:44
  • No you posted them here – David Carlisle Dec 20 '23 at 00:56
  • no in theory you can not rely on the filename for math features but it's a good start. – David Carlisle Dec 20 '23 at 00:57
  • 1
    that path only works for texlive 2023 from tug on *ix like operating systems, it is wrong on windows on macs on linux using the system texlive, on texlive 2022, ... It is only not wrong on upstream texlive 2023 where it does absolutely nothing useful. – David Carlisle Dec 20 '23 at 01:00
  • using an explicit path makes the document non portable: it may be necessary in some weird special cases but it should be avoided in almost all cases and certainly avoided here where there is no case where removing the setting stops the document working. The question is completely unrelated to the font setting so for this question you can remove the entire font setup not just the path key. – David Carlisle Dec 20 '23 at 01:09

1 Answers1

5

You can simplify the example to

\documentclass[12pt]{book}

\usepackage{unicode-math}

\usepackage{breqn}

\errorcontextlines=2000 \begin{document} test \end{document}

where you can see it failing setting the math strut, a simple fix would be to keep the original setting function, but something else may break, breqn was not written with Unicode in mind.

\documentclass[12pt]{book}
\makeatletter
\usepackage{unicode-math}
\let\foo\resetMathstrut@
\usepackage{breqn}
\let\resetMathstrut@\foo
\makeatother

\errorcontextlines=2000 \begin{document} test \end{document}

David Carlisle
  • 757,742