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

Latex and texlive cannot be installed easily on macOS/ARM #1735

Open
certik opened this issue Jan 9, 2025 · 7 comments
Open

Latex and texlive cannot be installed easily on macOS/ARM #1735

certik opened this issue Jan 9, 2025 · 7 comments
Labels
bug Something isn't working

Comments

@certik
Copy link

certik commented Jan 9, 2025

I followed the documentation at https://mystmd.org/guide/installing and it seems neither latexmk nor texlive-core can be easily installed. I previously installed the mystmd package:

(myst) repos/math_notes$ mamba install texlive-core latexmk

Looking for: ['texlive-core', 'latexmk']

conda-forge/osx-arm64                                       Using cache
conda-forge/noarch                                          Using cache

Pinned packages:
  - python 3.13.*


warning  libmamba Added empty dependency for problem type SOLVER_RULE_UPDATE
Could not solve for environment specs
The following packages are incompatible
├─ latexmk does not exist (perhaps a typo or a missing channel);
└─ texlive-core is installable and it requires
   └─ python >=3.10,<3.11.0a0 *_cpython, which can be installed.
(myst) repos/math_notes$ mamba install texlive-core        

Looking for: ['texlive-core']

conda-forge/osx-arm64                                       Using cache
conda-forge/noarch                                          Using cache

Pinned packages:
  - python 3.13.*


warning  libmamba Added empty dependency for problem type SOLVER_RULE_UPDATE
Could not solve for environment specs
The following package could not be installed
└─ texlive-core is installable and it requires
   └─ python >=3.10,<3.11.0a0 *_cpython, which can be installed.

On macOS I usually use the tectonic package which packages TeX and it just works.

@certik certik added the bug Something isn't working label Jan 9, 2025
@agoose77
Copy link
Contributor

agoose77 commented Jan 9, 2025

Thanks for the report @certik! Yes, it looks like there aren't any binaries for ARM in OSX: https://prefix.dev/channels/conda-forge/packages/latexmk

That's odd because I saw a PR there to add ARM support. Something must not be quite right with the recipe. I will note that latexmk is a simple perl script, so in this case it shouldn't need much to fix. Meanwhile, you can directly download the perl script and put it somewhere in PATH.

Regarding tectonic, that is something that we're looking to move to. There's an open PR #1093, but it needs a bit more work to get it over the line.

Right now, you have a few different options:

  1. Manually install the texlive and latexmk packages. You can get texlive by downgrading Python (my first thought is why does texlive need Python?!), and then add latexmk by hand. Or, use brew if you're familiar with it.
  2. Run in a Docker container (ARM or Intel)
  3. Use the Typst export instead of LaTeX

We generally encourage people to use the Typst exporter because it's a lot easier to target (for us) than LaTeX. However, I don't know if there are additional constraints that dissuade you from doing that.

I'll give this some more thought, and pop back here if anything else comes to mind.

@choldgraf choldgraf changed the title The documentation doesn't work on macOS/arm Latex and texlive cannot be installed easily on macOS/ARM Jan 9, 2025
@certik
Copy link
Author

certik commented Jan 9, 2025

Here is how I got the pdf working using tectonic:

$ myst build --tex && (cd _build/exports/paper_tex && tectonic paper.tex)
📬 Performing exports:
   01-paper.md -> _build/exports/paper_tex/paper.tex
📖 Built 01-paper.md in 4.79 ms.
📖 Built README.md in 4.32 ms.
📚 Built 2 pages for export (including 1 dependency) from /Users/ondrej/repos/math_notes in 7.83 ms.
📑 Exported TeX in 7.5 ms, copying to _build/exports/paper_tex/paper.tex
Running TeX ...
warning: fmtcount.sty:10:
Invalid UTF-8 byte or sequence at line 10 replaced by U+FFFD.
warning: fmtcount.sty:22: Invalid UTF-8 byte or sequence at line 22 replaced by U+FFFD.
warning: fcprefix.sty:10:
Invalid UTF-8 byte or sequence at line 10 replaced by U+FFFD.
warning: fcprefix.sty:22: Invalid UTF-8 byte or sequence at line 22 replaced by U+FFFD.
warning: fcnumparser.sty:10:
Invalid UTF-8 byte or sequence at line 10 replaced by U+FFFD.
warning: fcnumparser.sty:22: Invalid UTF-8 byte or sequence at line 22 replaced by U+FFFD.
warning: fc-english.def:10:
Invalid UTF-8 byte or sequence at line 10 replaced by U+FFFD.
warning: fc-english.def:22: Invalid UTF-8 byte or sequence at line 22 replaced by U+FFFD.
Rerunning TeX because "paper.aux" changed ...
warning: fmtcount.sty:10:
Invalid UTF-8 byte or sequence at line 10 replaced by U+FFFD.
warning: fmtcount.sty:22: Invalid UTF-8 byte or sequence at line 22 replaced by U+FFFD.
warning: fcprefix.sty:10:
Invalid UTF-8 byte or sequence at line 10 replaced by U+FFFD.
warning: fcprefix.sty:22: Invalid UTF-8 byte or sequence at line 22 replaced by U+FFFD.
warning: fcnumparser.sty:10:
Invalid UTF-8 byte or sequence at line 10 replaced by U+FFFD.
warning: fcnumparser.sty:22: Invalid UTF-8 byte or sequence at line 22 replaced by U+FFFD.
warning: fc-english.def:10:
Invalid UTF-8 byte or sequence at line 10 replaced by U+FFFD.
warning: fc-english.def:22: Invalid UTF-8 byte or sequence at line 22 replaced by U+FFFD.
warning: warnings were issued by the TeX engine; use --print and/or --keep-logs for details.
Running xdvipdfmx ...
Writing `paper.pdf` (23.92 KiB)
Skipped writing 2 intermediate files (use --keep-intermediates to keep them)
$ open _build/exports/paper_tex/paper.pdf

And that works beautifully.

@agoose77
Copy link
Contributor

agoose77 commented Jan 9, 2025

@certik that was a good idea. It didn't occur to me to suggest handling the build yourself! I'm glad that you had success.

@certik
Copy link
Author

certik commented Jan 9, 2025

I just tried typst as well. I discovered a lot of issues with the math:

  • Doesn't understand \wedge and \over, so I removed them for now
  • It renders the math incorrectly, doesn't render matrices, renders \cdot at the wrong place, etc.

Maybe there is a way to workaround all these, I need to see. Latex via tectonic has been rock solid in my experience, so I've been using that. Although I discovered a bug in mystmd for latex (#1737). Is the plan to fully support latex, but perhaps use typst as the recommended backend?

Update: I see, it's because typst doesn't use latex notation, so mystmd is translating the latex to typst notation. And the bugs are in the translation layer in mystmd. That raises several questions:

  • which notation to use in the myst document -- latex or typst?
  • can the mystmd latex parser be fully fixed to work for most latex equations?

These bugs happen even in the official documentation, say here: https://mystmd.org/guide/math#dollar-math, click on the LaTeX tab, it generates correct latex, then click on the Typst tab and it skips the more complicated equations, only shows the simple one.

I think it makes sense to be able to parse latex equations, and generate for example proper Word equations out of it. But that will all take time, so it seems using the latex exporter is the only robust solution for now.

Also I got a lot of warnings for typst:

$ myst build --typst
📬 Performing exports:
   01-paper.md -> _build/exports/paper_typst/paper.pdf
📖 Built 01-paper.md in 72 ms.
📖 Built README.md in 72 ms.
📚 Built 2 pages for export (including 1 dependency) from /Users/ondrej/repos/math_notes in 79 ms.
📑 Exported typst in 32 ms, copying to _build/temp/mystNYj4Ud/paper.typ
⛔️ 01-paper.md 'parts' missing required key: abstract (at 01-paper.md)
warning: `locate` with callback function is deprecated
   ┌─ _build/temp/mystNYj4Ud/lapreprint.typ:83:12


83 │       header: locate(loc => {
   │ ╭─────────────^
84 │ │       if(loc.page() == 1) {
85 │ │         let headers = (
86 │ │           if (open-access) {smallcaps[Open Access]},
   · │
94 │ │       }
95 │ │     }),
   │ ╰──────^

   = hint: use a `context` expression instead

warning: `counter.display` without context is deprecated
    ┌─ _build/temp/mystNYj4Ud/lapreprint.typ:112:15

112 │               #counter(page).display() of #locate((loc) => {counter(page).final(loc).first()})
    │                ^^^^^^^^^^^^^^^^^^^^^^^

    = hint: use it in a `context` expression instead

warning: `locate` with callback function is deprecated
    ┌─ _build/temp/mystNYj4Ud/lapreprint.typ:112:43

112 │               #counter(page).display() of #locate((loc) => {counter(page).final(loc).first()})
    │                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    = hint: use a `context` expression instead


warning: unknown font family: noto sans
    ┌─ _build/temp/mystNYj4Ud/lapreprint.typ:121:17

121 │   set text(font: font-face, size: 10pt)
    │                  ^^^^^^^^^

warning: `show par: set block(spacing: ..)` has no effect anymore
    ┌─ _build/temp/mystNYj4Ud/lapreprint.typ:294:2

294 │   show par: set block(spacing: 1.5em)
    │   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    = hint: write `set par(spacing: ..)` instead
    = hint: this is specific to paragraphs as they are not considered blocks anymore

warning: `locate` with callback function is deprecated

    ┌─ _build/temp/mystNYj4Ud/lapreprint.typ:132:22

132 │     show heading: it => locate(loc => {
    │ ╭───────────────────────^
133 │ │     // Find out the final number of the heading counter.
134 │ │     let levels = counter(heading).at(loc)
135 │ │     set text(10pt, weight: 400)
    · │
170 │ │     ]
171 │ │   })
    │ ╰────^

    = hint: use a `context` expression instead

warning: calling `counter.final` with a location is deprecated
    ┌─
 _build/temp/mystNYj4Ud/lapreprint.typ:112:60

112 │               #counter(page).display() of #locate((loc) => {counter(page).final(loc).first()})
    │                                                             ^^^^^^^^^^^^^^^^^^^^^^^^

    = hint: try removing the location argument


🖨  Rendering typst pdf to _build/exports/paper_typst/paper.pdf

@rowanc1
Copy link
Member

rowanc1 commented Jan 9, 2025

Thanks @certik for the feedback on typst. This is something that we are actively working on at the moment. Many of the warnings are from the recent typst upgrade which deprecated quite a few things, and our templates haven't all been updated yet.

The Typst math errors are difficult, as you note, their syntax is different (sometimes very different), and the automated translation solutions are still evolving and patchy.

MyST expects all math in latex (not typst). I was planning to get a feature over the line for an escape hatch this week (i.e. write in latex, and have an explicit typst line as well for ones that are not translated automatically). I think also surfacing this as errors is also a good idea. I will make a few issues.

To handle your equations specifically, it would be good to get the examples. We will release another version likely tomorrow and I can get those ones done at least to unblock you.

@certik
Copy link
Author

certik commented Jan 9, 2025

@rowanc1 awesome, thanks! I uploaded the paper I've been writing here: https://gist.github.com/certik/62deb4eacf23ab71c6c4fa1fb8f230f2, it's standalone, I removed the bibtex references. It compiles with myst build --tex && (cd _build/exports/paper_tex && tectonic paper.tex), but fails with myst build --typst.

@rowanc1
Copy link
Member

rowanc1 commented Jan 9, 2025

Thanks I will take a look today. :)

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

3 participants