1

Is it possible to \usetikzlibrary{bayesnet} in R Markdown documents? The command works fine in Tex. But R Markdown throws an error, saying it cannot find the file: tikzlibrarybayesnet.code.tex

Here is the header of my R markdown file:

---
title: "Sample R Markdown Report"
author: "My name"
date: "Today's date"
output:
  pdf_document: default
header-includes: 
  - \usepackage{tikz}
  - \usetikzlibrary{bayesnet}
---

## LDA as a Graphical Model:
  \begin{figure}
      \centering
      \tikz{ %
        \node[latent] (alpha) {$\alpha$} ; %
        \node[latent, right=of alpha] (theta) {$\theta$} ; %
        \node[latent, right=of theta] (z) {z} ; %
        \node[obs, right=of z] (w) {w} ; %
        \node[latent, right=of w] (phi) {$\phi$} ; %
        \node[latent, right=of phi] (beta) {$\beta$} ; %
        \plate[inner sep=0.25cm, xshift=-0.12cm, yshift=0.12cm] {plate1} {(z) (w)} {N}; %
        \plate[inner sep=0.25cm, xshift=-0.12cm, yshift=0.12cm] {plate2} {(theta) (plate1)} {M}; %
        \plate[inner sep=0.25cm, xshift=-0.12cm, yshift=0.12cm] {plate2} {(phi)} {K}; %
        \edge {alpha} {theta} ; %
        \edge {theta} {z} ; %
        \edge {z,phi} {w} ; %
        \edge {beta} {phi} ; %
      }
    \end{figure}

Here is the error I get:

! Package tikz Error: I did not find the tikz library 'bayesnet'. I looked for files named tikzlibrarybayesnet.code.tex and pgflibrarybayesnet.code.tex, but n either could be found in the current texmf trees..

If I know where the file lives at the location below, is it possible to specify it's path directly? /usr/local/texlive/2014/texmf-dist/tex/generic/pgf/frontendlayer/tikz/libraries/tikzlibrarybayesnet.code.tex

This tikz example runs fine. It is extending it to usetikzlibrary{} that's messing me up.

Community
  • 1
  • 1
Chris
  • 3,401
  • 5
  • 33
  • 42

1 Answers1

0

Was a problem with the bayesnet library. If you update the library all runs fine. Problem well described here.

Community
  • 1
  • 1
Chris
  • 3,401
  • 5
  • 33
  • 42