ProdriveTechnologies / bazel-latex

Bazel build system rules for LaTeX

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for biber/biblatex

kylecarbon opened this issue · comments

Hello! Enjoying the bazel support thus far :)

I'm trying to use biblatex but having some trouble so far. I'm not very familiar with bazel, so I'm not sure how to run a biber command in between. For example, I have the following added to packages/BUILD.bazel:

latex_package(
    name = "biblatex",
    srcs = [
        "@texlive_texmf__texmf-dist__tex__latex__biblatex",
        "@texlive_texmf__texmf-dist__tex__latex__logreq",
        "@texlive_texmf__texmf-dist__tex__latex__oberdiek",
        ":etoolbox",
        ":keyval",
        ":url",
        "biblatex.bib",
    ],
    tests = ["biblatex_test.tex"],
)

Then biblatex_test.tex simply has:

\documentclass{report}
\usepackage{biblatex}
\addbibresource{biblatex.bib}
\begin{document}
Check out my citation \cite{my_ref}
\printbibliography
\end{document}

If I run this locally, I'm able to build the PDF just fine but if I run bazel run //packages:biblatex_biblatex_test.tex_view, I get the following error code:

ERROR: /home/kyle/code/bazel-latex/packages/BUILD.bazel:96:1: LuaLatex packages/biblatex_biblatex_test.tex.pdf failed (Exit 1) python failed: error executing command python external/bazel_latex/run_lualatex.py external/texlive_bin__x86_64-linux/kpsewhich external/texlive_bin__x86_64-linux/luatex external/bazel_latex_latexrun/latexrun biblatex_biblatex_test.tex ... (remaining 2 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
packages/biblatex_test.tex:5: warning: Citation 'my_ref' on page 1 undefined
packages/biblatex_test.tex:6: warning: Empty bibliography
packages/biblatex_test.tex: warning: [biblatex] Please (re)run Biber on the file: biblatex_biblatex_test.tex and rerun LaTeX afterwards
biblatex_biblatex_test.tex.aux: error: no \citation commands
biblatex_biblatex_test.tex.aux: error: no \bibdata command
biblatex_biblatex_test.tex.aux: error: no \bibstyle command
Target //packages:biblatex_biblatex_test.tex_view failed to build
Use --verbose_failures to see the command lines of failed build steps.

Any thoughts/advice on how to integrate Biber with bazel-latex?

I'm interested in this too, I started looking at adding the :bibtex target to packages/BUILD.bazel but haven't been successful yet.

Update: I got things to work on my end, but using biber and not biblatex

BUILD

load("@bazel_latex//:latex.bzl", "latex_document")

latex_document(
  name = "demo",
  srcs = glob([
    "intro.tex",
    "demo.bib",
    "sections/*.tex",
    "images/*",
  ]) + [
    "@bazel_latex//packages:graphicx",
    "@texlive_texmf__texmf-dist__bibtex__bst__base",
  ],
  main = "demo.tex",
)

demo.tex

\documentclass{article}

\title{Bazel-Latex Demo}
\author{J Doe}
\date{September 23, 2019}

\usepackage{graphicx}

\begin{document}

\begin{titlepage}
\maketitle
\end{titlepage}

\input{intro.tex}

\include{sections/section1}

\include{sections/section2}

\bibliographystyle{plain}
\bibliography{demo}{}

\end{document}

Update:

I got things to work with biblatex. You'll need to modify

"--latex-cmd=lualatex",
and add:

        "--bibtex-cmd=biber",

By default latexrun uses bibtex. Finally, here's the BUILD file:

load("@bazel_latex//:latex.bzl", "latex_document")

latex_document(
  name = "demo",
  srcs = glob([
    "intro.tex",
    "demo.bib",
    "sections/*.tex",
    "images/*",
  ]) + [
    "@bazel_latex//packages:graphicx",
    "@texlive_texmf__texmf-dist__bibtex__bst__biblatex",
    "@texlive_texmf__texmf-dist__bibtex__bib__biblatex__biblatex",
    "@texlive_texmf__texmf-dist__tex__latex__biblatex",
    "@texlive_texmf__texmf-dist__tex__latex__etoolbox",
    "@texlive_texmf__texmf-dist__tex__latex__logreq",
    "@texlive_texmf__texmf-dist__tex__latex__url",
  ],
  main = "demo.tex",
)

I'll be working on a PR to add this as an optional argument to the latex_document rule.

Sorry for the delayed response to this issue.

I think @yperess resolved your issue with a pretty neat solution. If you believe this should be included in master, you can create a PR and we can review the change there. If you are still running into any issues with biblatex, feel free to re-open this issue.

I send a new PR for this issue: #35
Please check it out.