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

Setting tectonic (LaTeX compiler) doesn't work #113

Open
BrianChevalier opened this issue Apr 16, 2019 · 7 comments
Open

Setting tectonic (LaTeX compiler) doesn't work #113

BrianChevalier opened this issue Apr 16, 2019 · 7 comments

Comments

@BrianChevalier
Copy link

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?

@BrianChevalier
Copy link
Author

This is related to #70 since it requires having an arbitrary build process, but with user customizable flags.

@s-weigand
Copy link

I guess those are the lines in question:

full_latex_sequence = (
c.latex_command,
escape_flag,
"-interaction=nonstopmode",
"-halt-on-error",
"-file-line-error",
f"-synctex={synctex}",
f"{tex_base_name}",
)
full_bibtex_sequence = (
c.bib_command,
f"{tex_base_name}",
)
command_sequence = [full_latex_sequence]
if run_bibtex:
command_sequence += [
full_bibtex_sequence,
full_latex_sequence,
full_latex_sequence,
]
else:
command_sequence = command_sequence * c.run_times

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:

return any([re.match(r'.*\.bib', x) for x in set(glob.glob("*"))])

@ian-r-rose
Copy link
Member

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.

@RealYHD
Copy link

RealYHD commented Sep 14, 2022

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.

@RealYHD
Copy link

RealYHD commented Sep 14, 2022

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 with tectonic 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.

@RealYHD
Copy link

RealYHD commented Sep 15, 2022

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.

@ktaletsk
Copy link
Collaborator

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.

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

No branches or pull requests

5 participants