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

🗺 Add tectonic support #1093

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

markusritschel
Copy link

This PR includes Tectonic as a LaTeX build engine instead of latexmk.
However, I let latexmk in the code as a fallback option.
The warning in packages/myst-cli/src/build/pdf/create.ts is extended with an availability check for tectonic.

See also the discussion here.

Currently, I cannot import isLatexmkAvailable and isTectonicAvailable from '../../../myst-cli/src/build/pdf/utils.ts'. I am therefore duplicating the two functions in jtex/src/tex/exports.
See also:
https://github.com/orgs/executablebooks/discussions/1154#discussioncomment-9084375.
Hopefully this can be modified later.
Copy link

welcome bot commented Apr 11, 2024

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out EBP's Code of Conduct and our Contributing Guide, as this will greatly help the review process.

Welcome to the EBP community! 🎉

Copy link
Collaborator

@rowanc1 rowanc1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes.

I think this is close, it would be wonderful if you could add a section in the docs.

I can aim to take a pass later today or tomorrow to clean anything up and get it in!


export function isTectonicAvailable() {
return which.sync('tectonic', { nothrow: true });
}

export function pdfTexExportCommand(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think let's remove the duplication here by moving this command to myst-cli/src/build/pdf.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great.
The only thing regarding the duplicated functions is that I cannot import them from myst-cli/src/build/pdf/utils.ts to jtex/src/tex/export.ts.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking to move the whole file over, but I see that is a bit complex, and we probably want to do it for typst at the same time.

I am happy to come in after and do a quick refactor, I also want to talk to @fwkoch to get a sense check on moving those around.

Have you tested the functionality locally?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it works on my local machine. Cloned the forked repo and followed your contribution guidelines for developers.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic - I will give it a go today or tomorrow and we can get this released early next week. Thanks again for your help in the PR, excited to try out tectonic and stop recommending 5gb downloads ... !

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄
My pleasure. Yes, it's still relatively unknown, but it's such a step forward for local LaTeX compiling.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the duplication - it would be nice to eliminate... that would mean "creating the command" (currently in jtex) and "invoking the command" (currently in myst-cli) in one single place. Definitely a smaller refactor to move "creation" to myst-cli, but it could also be interesting if part of the scope of jtex was to know how to create and invoke all the various rendering engines. MyST could then just say "jtex, build me a pdf using this template" hmm...

Anyway - the duplication here is relatively minor; I don't think we need to block this PR with a big refactor.

@markusritschel
Copy link
Author

Just added a paragraph for the documentation.

@agoose77 agoose77 changed the title Feat/add tectonic support 🗺️ Add tectonic support Apr 11, 2024
markusritschel and others added 2 commits April 11, 2024 17:04
Co-authored-by: Rowan Cockett
Copy link
Collaborator

@fwkoch fwkoch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I wanted to check on - if you have glossaries, the latexmk build runs twice with a makeglossaries command in between: https://github.com/executablebooks/mystmd/blob/main/packages/myst-cli/src/build/pdf/create.ts#L218-L250

I think the tectonic build will do the same thing. Is this correct (i.e. is the makeglossaries workflow fundamental to latex, regardless of engine), or do we need to make changes deeper in the build invocation flow?

@markusritschel
Copy link
Author

Hi @fwkoch,
Tectonic should take care of it automatically. It usually figures out by itself how often it needs to run the build process. (One of its conveniences 😉).

@rowanc1 rowanc1 changed the title 🗺️ Add tectonic support 🗺 Add tectonic support Apr 12, 2024
@rowanc1
Copy link
Collaborator

rowanc1 commented Apr 15, 2024

Update: I have taken a first look at this locally and am working through some of the error states and logging, which need to change a bit if tectonic does not succeed. I will continue to chip away at this during the week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants