ProdriveTechnologies / bazel-latex

Bazel build system rules for LaTeX

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

\include{} doesn't work

regisd opened this issue · comments

Thanks for making this rule.

I've encountered a problem on a basic document though: \include{} doesn't do anything.

Exemple
manual.tex

\documentclass{article}
\begin{document}
Generated by Bazel
\include{hello}
\include{wtf}
\end{document}

hello.tex

Hello world

BUILD

latex_document(
    name = "manual",
    srcs = [
        "hello.tex",
        ],
    main = "manual.tex",
)

The PDF is generated with no error but

  • hello.tex isn't included
  • wtf.tex which doesn't exist doesn't raise an error in the \include{} statement

Hello Régis,

Thanks for your pull requests! I added some temporary diagnostics to bazel-latex to figure out what's happening:

--- a/run_pdflatex.py
+++ b/run_pdflatex.py
@@ -65,6 +65,8 @@ for i in range(10):
     # Emit PDF when two successive runs yield the same PDF.
     if i != 0:
         if filecmp.cmp(intermediate_file, comparison_file):
+            with open(log_file, "r") as f:
+                shutil.copyfileobj(f, sys.stdout)
             os.rename(intermediate_file, output_file)
             sys.exit(0)
     os.rename(intermediate_file, comparison_file)

And it turns out that pdflatex for some odd reason ignores \include{} errors. It merely prints 'No file ${filename_here}' at some point during the build.

At Prodrive, we haven't run into this, because (almost?) all of our documents seem to use \input{}, which does appear to behave correctly. Let me try to do some more experiments.

Hmmm... I think there is little we can do here. I just invoked stock pdflatex on a Debian box:

$ cat manual.tex 
\documentclass{article}
\begin{document}
Generated by Bazel
\include{hello}
\include{wtf}
\end{document}
$ pdflatex manual.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016/Debian) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./manual.tex
LaTeX2e <2017/01/01> patch level 3
Babel <3.9r> and hyphenation patterns for 83 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo)) (./manual.aux
(./hello.aux) (./wtf.aux)) [1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map
}]
No file hello.tex.
No file wtf.tex.
(./manual.aux (./hello.aux) (./wtf.aux)) )</usr/share/texlive/texmf-dist/fonts/
type1/public/amsfonts/cm/cmr10.pfb>
Output written on manual.pdf (1 page, 12714 bytes).
Transcript written on manual.log.
$ echo $?
0

Bad \include{} directives simply don't seem to generate fatal errors. Would it be acceptable to use \input{} in your case?

My \LaTeX knowledge has fanished ; I'll give a try to \input{}. Thanks!

Hi there,

Just polished up bazel-latex to use latexrun. This at least improves your specific situation by changing the output of bazel build to this:

$ bazel build //...
INFO: Analysed 2 targets (0 packages loaded).
INFO: Found 2 targets...
INFO: From PdfLatex whatever.pdf:
manual.tex: warning: No file wtf.tex
INFO: Elapsed time: 0.714s, Critical Path: 0.53s
INFO: 1 process: 1 linux-sandbox.
INFO: Build completed successfully, 2 total actions