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

invalid filename for PDFExporter.latex_command #974

Closed
GorgiAstro opened this issue Mar 27, 2019 · 6 comments · Fixed by #1345
Closed

invalid filename for PDFExporter.latex_command #974

GorgiAstro opened this issue Mar 27, 2019 · 6 comments · Fixed by #1345
Labels
format:PDF pertains to exporting to the PDF format good first issue great for new contributors help wanted status:needs-info

Comments

@GorgiAstro
Copy link

Dear all,

I am not able to generate a PDF via pdflatex in Windows. The same code with the same configuration works on Ubuntu 18.04 x64 but fails on Windows 10 x64, with nbconvert 5.4.1 installed from conda-forge.

My jupyter_nbconvert_config.py has the following definition for latex_command:

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

In Windows, it looks like the notebook.tex filename gets an extra backslash:

[NbConvertApp] Running pdflatex 3 times: ['pdflatex', '.\\notebook.tex']

[NbConvertApp] CRITICAL | p failed: pdflatex .\notebook.tex

This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018/W32TeX) (preloaded format=pdflatex)

restricted \write18 enabled.

entering extended mode

! Undefined control sequence.

<*> .\notebook

              .tex

?

! Emergency stop.

<*> .\notebook

              .tex

!  ==> Fatal error occurred, no output PDF file produced!

Whereas it works on Linux:
[NbConvertApp] Running pdflatex 3 times: ['pdflatex', './notebook.tex']

Thank you,
Cheers
GorgiAstro

@MSeal
Copy link
Contributor

MSeal commented Mar 29, 2019

There's been a few filename issues in the pdf exporter, I've asked for some for some of the other contributors to try and take a look at that code.

@MSeal MSeal added help wanted good first issue great for new contributors labels Mar 29, 2019
@t-makaro
Copy link
Contributor

I cannot replicate this on windows. I see the double backslash too, so I don't think that's the issue. At first, I thought it was pdflatex, but I switched my config to use pdflatex instead of the default XeLaTeX and it still worked fine. The ! Undefined control sequence. makes it look like .\notebook.tex is being placed inside the .tex file itself, and not any error with finding the file.

@GorgiAstro If you send me a .tex file (and other output files) from the output of Jupyter nbconvert --to latex notebook.ipynb. I'd be happy to attempt to search the file .tex file for the cause.

Additional question: Does your notebook have a space in the filename? If so, try removing the space from the filename.

@DevinCharles
Copy link

I think this is the same issue, accidentally started in the Jupyter Core repo.

https://github.com/jupyter/jupyter_core/issues/144

@t-makaro t-makaro added the format:PDF pertains to exporting to the PDF format label Aug 2, 2019
@t-makaro
Copy link
Contributor

t-makaro commented Aug 7, 2019

I believe the problem was diagnosed on discourse, but I am still unable to replicate the issue.

@t-makaro t-makaro changed the title invalid filename for PDFExporter.latex_command in Windows invalid filename for PDFExporter.latex_command Sep 28, 2019
@asteppke
Copy link

asteppke commented Mar 9, 2020

Same issue here on Windows 10 with current Jupyter installation (nbconvert 5.6.1):

(base) F:\VTI\>jupyter nbconvert --to pdf "Quick analysis.ipynb"                      
[NbConvertApp] Converting notebook Quick analysis.ipynb to pdf                                                   
[NbConvertApp] Support files will be in Quick analysis_files\                                                    
[NbConvertApp] Making directory .\Quick analysis_files                                                           
[NbConvertApp] Making directory .\Quick analysis_files                                                           
[NbConvertApp] Making directory .\Quick analysis_files                                                           
[NbConvertApp] Writing 48019 bytes to .\notebook.tex                                                                    
[NbConvertApp] Building PDF                                                                                             
[NbConvertApp] Running xelatex 3 times: ['xelatex', '.\\notebook.tex', '-quiet']                                        
[NbConvertApp] CRITICAL | x failed: xelatex .\notebook.tex -quiet                                                       
This is XeTeX, Version 3.14159265-2.6-0.999992 (TeX Live 2020/W32TeX) (preloaded format=xelatex)                        
 restricted \write18 enabled.                                                                                           
entering extended mode                                                                                                  
! Undefined control sequence.                                                                                           
<*> .\notebook                                                                                                          
              .tex -quiet                                                                                               
?                                                                                                                       
! Emergency stop.                                                                                                       
<*> .\notebook                                                                                                          
              .tex -quiet                                                                                               
No pages of output.                                                                                                     
Transcript written on ?.                                                                                                

When changing the directory in pdf.py from nbconvert at line 66 from

    writer = Instance("nbconvert.writers.FilesWriter", args=(), kw={'build_directory': '.'})

to

    writer = Instance("nbconvert.writers.FilesWriter", args=(), kw={'build_directory': ''})

then the xelatex run at least gets much further. Unfortunately it still ends with an error message:

[...]
* (1in=72.27pt=25.4mm, 1cm=28.453pt)

(c:/texlive/2020/texmf-dist/tex/latex/ucs/ucsencs.def)
(c:/texlive/2020/texmf-dist/tex/latex/hyperref/nameref.sty
(c:/texlive/2020/texmf-dist/tex/latex/refcount/refcount.sty)
(c:/texlive/2020/texmf-dist/tex/generic/gettitlestring/gettitlestring.sty))

Package hyperref Warning: Rerun to get /PageLabels entry.

(c:/texlive/2020/texmf-dist/tex/latex/amsfonts/umsa.fd)
(c:/texlive/2020/texmf-dist/tex/latex/amsfonts/umsb.fd)
(c:/texlive/2020/texmf-dist/tex/latex/jknapltx/ursfs.fd)

LaTeX Warning: No \author given.

(c:/texlive/2020/texmf-dist/tex/generic/stringenc/se-ascii-print.def) [1]
(./notebook.aux)

Package rerunfilecheck Warning: File `notebook.out' has changed.
(rerunfilecheck)                Rerun to get outlines right
(rerunfilecheck)                or use package `bookmark'.

 )
Error -1073741819 (driver return code) generating output;
file notebook.pdf may not be valid.
Transcript written on notebook.log.

@jayqi
Copy link

jayqi commented Jul 15, 2020

@t-makaro

I recently ran into this issue when running GitHub Actions CI for a project that uses nbconvert. Ubuntu and MacOS builds ran with no problem, but I saw the same error in this issue show up for the Windows build.

I've managed to create a minimal reproducible example using GitHub Actions CI. You can see the details in this repository: jayqi/nbconvert-windows-pdf-repro

I have links to the particular failing build and some notes in the README. To respond to some of the comments you made in this thread:

  • I am seeing the double-back-slash show up in the logs for the xelatex command: [NbConvertApp] Running xelatex 3 times: ['xelatex', '.\\notebook.tex', '-quiet']
  • When using --to latex, after converting line endings from CRLF to LF for the .tex file produced by Windows, it seems like it is identical to the .tex files produced by Ubuntu and MacOS
  • My notebook name does not have a space in it.

Please let me know if you have any questions. I hope we can get to the bottom of this!

joelostblom added a commit to joelostblom/nbconvert that referenced this issue Aug 11, 2020
To prevent xelatex from failing on windows,
see jupyter#974 for details.
t-makaro pushed a commit that referenced this issue Aug 12, 2020
To prevent xelatex from failing on windows,
see #974 for details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
format:PDF pertains to exporting to the PDF format good first issue great for new contributors help wanted status:needs-info
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants