jupyterlab-latex
jupyterlab-latex copied to clipboard
Setting tectonic (LaTeX compiler) doesn't work
Setting tectonic
to the LaTeX build compiler doesn't work. The extension automatically adds flags to the command it does not recognize and fails.
I also can't find the part of the extension responsible for setting these flags. Any ideas?
This is related to #70 since it requires having an arbitrary build process, but with user customizable flags.
I guess those are the lines in question:
https://github.com/jupyterlab/jupyterlab-latex/blob/424957b9ef83ef726c7a84a6f9df5001c5488ff9/jupyterlab_latex/build.py#L96-L120
I also would love to use tectonic
, especially on binder since it would speed up the build considerable compared to installing all texlive dependencies (which are massive).
Since tectonic
also handles the bibtex
invocation, there should also be a configureble setting to deactivate it even if a *.bib
file is present (i.e. config.skip_bibtex
).
Atm it is solely done by looking for a *.bib
file:
https://github.com/jupyterlab/jupyterlab-latex/blob/424957b9ef83ef726c7a84a6f9df5001c5488ff9/jupyterlab_latex/build.py#L133
I think it would be reasonable to add an escape hatch for a completely user-customizable command sequence. A config for disabling bibtex also sounds like a good idea.
I'm wondering if this is the same issue I'm having? Currently, setting tectonic
as the value of c.LatexConfig.latex_command
results in no output in the LaTeX Error window despite popping up. Manually running the tectonic command works fine.
Okay, I have a working prototype on my private git server. Mind you, I call it a working prototype since I've only lightly tested it with tectonic, but it's a simple enough implementation that it should work with most other compilers.
To make this work, I've added two additional configuration options (essentially exactly the two configuration options @ian-r-rose mentioned):
- The option to manually override the built-in arguments with a configuration option
c.LatexConfig.manual_cmd_args
. It takes a list of arguments with placeholders for the latex file name ({filename}
), and whether or not synctex should be used ({synctex}
). Using it withtectonic
goes something like this:c.LatexConfig.manual_cmd_args = ['{filename}.tex', '-Z', 'shell-escape']
. Of course,c.LatexConfig.latex_command = 'tectonic'
is still needed. - The second configuration option I added was taken from @s-weigand's note about bibtex. I'm going to be honest, I've never used bibtex at all before, but all I did was add a simple boolean toggle that disables the bibtex command sequence alterations. I plan on using bibtex in the very near future so although it's currently untested, I'll report back on this situation.
I did these changes as a rush job, and I have no experience developing extensions for JupyterLab whatsoever (I have more experience in python, but I feel most comfortable in slightly lower-level languages). That being said, I'd love to contribute these changes if given the opportunity and approval after some more rigorous testing.
Just to keep everyone posted, I ended up setting setting up and testing synctex
with the tectonic
compiler and it works nicely! Kudos to the team behind this extension and their implementation.
c.LatexConfig.manual_cmd_args = ['{filename}.tex', '-Z', 'shell-escape', '--synctex={synctex}']
is what it would look like with the current set-up.
I did have to install a package that included the synctex
binary, but that's to be expected (I used the conda texlive-core
package, but any synctex binary should work).
I'll probably get around testing bibtex today as I will be needing it.
EDIT: didn't feel it was worthy of a new post, but I wanted to mention that my previous issue of not seeing any output was also fixed, turns out the current code doesn't return the stderr
stream of the command run to the client, I've made a change so that now it returns stdout
and stderr
so long as they have data on error.
Hi @RealYHD, your changes sound like a great idea! I ran into the same issues on a new machine where I can't install arbitrary packages, but can and would like to use conda.
In your implementation, how did you go about interpolating the user input here:
['{filename}.tex', '-Z', 'shell-escape', '--synctex={synctex}']
The default command line arguments are using f-strings, but here we are dealing with the user-supplied configs.
That being said, would you like to contribute your changes and open a PR? I would be happy to review and test your changes.