ProdriveTechnologies / bazel-latex

Bazel build system rules for LaTeX

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to make use of the metropolis beamer theme?

Vertexwahn opened this issue · comments

I try to make use of the metropolis Beamer theme. My docu.tex looks like this:

\documentclass{beamer}
\usetheme{metropolis}           % Use metropolis theme
\title{Some title}
\date{\today}
\author{Me}
\begin{document}
  \maketitle
  \section{First Section}
  \begin{frame}{First Frame}
    Hello, world!
  \end{frame}
\end{document}

My BUILD.bazel file:

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

latex_document(
    name = "prentation",
    srcs = [
        "@bazel_latex//packages:siunitx",
        "@bazel_latex//packages:tikz",
        "@bazel_latex//packages:beamer",
        "@bazel_latex//packages:beamertheme-metropolis",
    ],
    main = "docu.tex",
)

My WORKSPACE.bazel file:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "bazel_latex",
    sha256 = "52eff66049f05716889e06ac71fffdc95c3f0270bd354c8e6c502244577f0748",
    strip_prefix = "bazel-latex-1.2.0",
    url = "https://github.com/ProdriveTechnologies/bazel-latex/archive/refs/tags/v1.2.0.tar.gz",
)

load("@bazel_latex//:repositories.bzl", "latex_repositories")

latex_repositories()

When I do a bazel build //... it tells me that the the target "@bazel_latex//packages:beamertheme-metropolis" is not known. I this theme supported at all? You can I use it?

This seems to solve the issue:

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

latex_document(
    name = "present",
    srcs = [
        "@bazel_latex//packages:siunitx",
        "@bazel_latex//packages:tikz",
        "@bazel_latex//packages:beamer",
        "@bazel_latex//packages:pgfopts",
        "@bazel_latex//packages:fontspec",
        "@texlive_texmf__texmf-dist__tex__latex__beamertheme-metropolis",
        "@texlive_texmf__texmf-dist__tex__latex__grfext",
    ],
    main = "docu.tex",
)

Hi!

The way this repository works is that only a few packages are directly accessible, you can see the list here. But it doesn't mean you can't use Metropolis (#50 used to be kind of blocking for that one, but it should be fixed now). If you have a look at #101 for example, adding a package can be fairly easy, if its dependencies are already declared. If a package uses a lot of dependencies that aren't declared yet, it's a bit trickier (e.g. #76). There's also this script (which I only noticed very recently and have never used myself yet) which should probably be able to help.

Once you figured that out, there are two options, as outlined briefly here:

  • Keep that patch locally, add apply it to your own repo. This allows you to be a bit less regardant on how your packages are defined (e.g. it might be fine for you to not have a test for every package you define locally)
  • Submit a PR. I try to be as quick as possible when it comes to reviewing and merging PRs, and a new package definition should be pretty straightforward. You can then use a specific commit in your WORKSPACE and use the new package as soon as it's merged, or wait for a release (I'm considering introducing a ~monthly patch release with newly added packages).

With that said with Metropolis specifically in mind, I'm having a look right now. Expect an update here fairly soon.

Ha, this would also work indeed I guess - you figured out what Metropolis' dependencies were :-) I'll still go ahead with adding the theme directly as a supported package, so you should be able to use @bazel_latex//packages:beamertheme-metropolis directly soon.