Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Math not rendering correctly in pdf #5

Open
theorashid opened this issue Jan 20, 2023 · 6 comments
Open

Math not rendering correctly in pdf #5

theorashid opened this issue Jan 20, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@theorashid
Copy link
Contributor

Description

Hi @eeholmes, I inserted a basic equation into the template Chapter 1. It renders fine on quarto equation preview in VSCode, but it does not render in the pdf. If I change the output to html, the equation renders as expected.

Steps to Reproduce

$$
\int_{A_i}{\lambda (\mathbf{x})}
$$

Does quarto not natively support math such as \int?

From html output:
Screenshot 2023-01-20 at 17 06 47

From pdf:
Screenshot 2023-01-20 at 17 04 51

@theorashid theorashid added the bug Something isn't working label Jan 20, 2023
@eeholmes
Copy link
Member

I'll check this out. It should definitely render fine in the pdf.

@eeholmes
Copy link
Member

Ok, this is very strange. Something in the cls file, which I didn't write, is causing a problem with the xelatex engine and causing it not to recognize that amsmath package is loaded.

In _quarto.yml, I can change the engine to pdflatex and it works. See last line here:

format:
  quarto-thesis-pdf: 
    urlcolor: red
    toclinkcolor: black
    toc-depth: 2
    pdf-engine: pdflatex

However I am not sure you have pdflatex. I am not sure that it comes by default with tinytex. I will try to figure out what in the (huge) cls file is causing xelatex to do this.

@eeholmes
Copy link
Member

Found the problem! I should have found it sooner since I have actually fixed a similar problem before for another Quarto extension.

The fontenc package causes xelatex not to render math correctly. So this line in _extension/partials/in-header.tex caused the problem:

\usepackage[T1]{fontenc}

I have commented that out and pushed the fix to GitHub. You can update the extension or just go into that file and delete or comment out that line. It is used for international letters, but Quarto should take care of that with its tex headers.

@theorashid
Copy link
Contributor Author

theorashid commented Jan 20, 2023

Thanks for giving this a look. This bug is really strange. I found

$$
\int_{A_i}{\lambda (\pmb{\mu})}
$$ {#eq-ctl}

$$
\int_{A_i}{\lambda (\mathbf{\mu})}
$$ {#eq-ctl}

$$
\int_{A_i}{\lambda (\mathbf{x})}
$$ {#eq-ctl}

incorrectly gives for pdf
Screenshot 2023-01-20 at 22 44 07

I don't know if it's worth reopening the issue because the use of \pmb is probably fine in most cases, I'm just used to using \mathbf from using LaTeX in the past. Interestingly, the html renders all 3 as expected

Screenshot 2023-01-20 at 22 44 33

@eeholmes eeholmes reopened this Jan 20, 2023
@eeholmes
Copy link
Member

Those should render fine in pdf so I am reopening.

I tried running in just a default Quarto doc, so no cls file. The \mathbf{\mu} issue seems to be a xelatex problem. But the \mathbf{x} issue, is specific to quarto-thesis, so something in the header file is changing the behavior of \mathbf

With xelatex
image

With pdflatex
image

So for quarto-thesis, the issue is the \mathbf{x} not rendering. The problem was this line in the header

\usepackage{mathpazo}

xelatex is more picky than pdflatex about font conflicts and it didn't like this. Using Palatino in math is weird anyhow, to I deleted that. Now \mathbf{x} appears as intended. Note \mathbf{\mu} does not appear with xelatex but that's a xelatex problem.

@theorashid
Copy link
Contributor Author

\pmb has more consistent and expected behaviour than \mathbf it seems. It's a strange error. I'll let you know if I find any more issues while I'm writing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants