nbconvert icon indicating copy to clipboard operation
nbconvert copied to clipboard

Support for tectonic for LaTeX

Open jakirkham opened this issue 7 years ago • 8 comments

Would be great if tectonic were supported by nbconvert as a PDF conversion tool.

cc @pkgw

jakirkham avatar May 06 '18 22:05 jakirkham

Have you tried setting the LaTeX command in the nbconvert config file?

c.PDFExporter.latex_command = ['xelatex', '{filename}']

Try replacing XeLaTeX with tectonic. I've never heard of tectonic before. I don't know if that would work, but if tectonic wraps XeLaTeX it might.

t-makaro avatar May 16 '18 16:05 t-makaro

Part of the issue is tectonic is not xelatex. It is certainly based off of xelatex. However it's made some different design decisions (am not aware of all of the details here so hopefully others can fill these in). So depending on how much nbconvert is relying on tectonic being xelatex either in terms of options provided or behavior this may or may not work. If I have said anything inaccurate here, would be happy to have someone more knowledgeable correct me.

xref: https://github.com/tectonic-typesetting/tectonic/issues/158

jakirkham avatar May 19 '18 04:05 jakirkham

Tectonic has made various changes, yes, but for standard usages it should look like a drop-in replacement for other TeX engines. In particular I'd expect the suggested command to work, though I haven't tried it myself.

pkgw avatar May 19 '18 06:05 pkgw

Have you tried setting the LaTeX command in the nbconvert config file?

c.PDFExporter.latex_command = ['xelatex', '{filename}']

Try replacing XeLaTeX with tectonic. I've never heard of tectonic before. I don't know if that would work, but if tectonic wraps XeLaTeX it might.

@t-makaro I tried your suggestion, and it works for me. However, I also had to install bibtex.

W1M0R avatar Mar 09 '23 17:03 W1M0R

That's a bit odd, since Tectonic bundles its own bibtex tool. (It doesn't and can't bundle biber, used by biblatex, which is a perennial source of issues, though.)

FWIW, in the time since this issue was first opened, Tectonic has started evolving to a git-like CLI, so a more future-compatible command should be:

c.PDFExporter.latex_command = ['tectonic', '-X', 'compile', '{filename}']

For the time being this is exactly compatible with a simple tectonic {filename} but the hope is to gradually deprecate the no-subcommand form of invocation.

pkgw avatar Mar 10 '23 15:03 pkgw

@pkgw Thanks for the info! The missing bibtex is then very likely a symptom of my dev environment.

EDIT: It looks like the bibtex program is called separately by nbconvert, explaining why I had to install it: https://github.com/jupyter/nbconvert/blob/acf41acf6d83cb725f3a2c48686c828eff7b24d8/nbconvert/exporters/pdf.py#L66

W1M0R avatar Mar 11 '23 20:03 W1M0R

@pkgw Thanks for the info! The missing bibtex is then very likely a symptom of my dev environment.

EDIT: It looks like the bibtex program is called separately by nbconvert, explaining why I had to install it:

https://github.com/jupyter/nbconvert/blob/acf41acf6d83cb725f3a2c48686c828eff7b24d8/nbconvert/exporters/pdf.py#L66

@pkgw can you tell how to call bundled bibtex from tectonic here?

Ingvar-Y avatar Aug 15 '23 10:08 Ingvar-Y

@Ingvar-Y Hmmm. Tectonic doesn't currently have a way to "call" its bundled bibtex in this way. Since Tectonic automatically runs bibtex as needed, would it potentially work to just set the program to /bin/true or something along those lines? Part of the Tectonic idea is that you just run it and get the PDF you want, without every higher-level tool needing to implement its own logic for the tex/bibtex/tex/tex dance.

That being said it's conceivable to add a feature to expose the bundled bibtex — it might even be effectively possible now, if one were to develop a clever wrapper script involving a throwaway .tex file or something.

pkgw avatar Aug 24 '23 14:08 pkgw