1

How to include following Latex code to Rmarkdown?

\usetikzlibrary{shapes.geometric,arrows}

\tikzstyle{decision} = [ diamond, draw, fill=blue!20, text width=4.5em, text badly centered, node distance=3cm, inner sep-0pt]  
\tikzstyle{block} = [ rectangle, draw, fill=blue!20, text width=5em, text badly centered, rounded corners, minimum height=4em]  
\tikzstyle{line} = [ draw, -latex']  
\tikzstyle{terminator} = [ draw, ellipse, fill=red!20, node distance=3cm, minimum height=2em]  

    \begin{tikzpicture}[node distance=2cm, auto]  
      \node [terminator]           (puc)  {Power-Up Reset};  
      \node [block, below of=puc]  (wdt)  {Stop Watchdog};  
      \node [block, below of=wdt]  (port) {Setup Port Pins};  
      \node [block, below of=port] (loop) {Loop Forever};  
      \path [line] (puc)  -- (wdt);  
      \path [line] (wdt)  -- (port);  
      \path [line] (port) -- (loop);  
      \path [line] (loop) -- (loop);  
    \end{tikzpicture}
1

Please, always include a minimal reproducible example: see here and there

In a file tikz.Rmd

---
title: "Title"
author: "Me"
header-includes:
   - \usepackage{tikz}
   - \usetikzlibrary{shapes.geometric,arrows}
output:
  pdf_document 
---


\begin{tikzpicture}[node distance=2cm, auto]  
\tikzstyle{decision}=[diamond, draw, fill=blue!20, text width=4.5em, text badly centered, node distance=3cm, inner sep-0pt]  
\tikzstyle{block}=[rectangle, draw, fill=blue!20, text width=5em, text badly centered, rounded corners, minimum height=4em]  
\tikzstyle{line}=[draw, -latex']  
\tikzstyle{terminator} = [ draw, ellipse, fill=red!20, node distance=3cm, minimum height=2em]    
\node [terminator] (puc) {Power-Up Reset};  
\node [block, below of=puc] (wdt)  {Stop Watchdog};  
\node [block, below of=wdt] (port) {Setup Port Pins};  
\node [block, below of=port] (loop) {Loop Forever};  
\path [line] (puc)  -- (wdt);  
\path [line] (wdt)  -- (port);  
\path [line] (port) -- (loop);  
\path [line] (loop) -- (loop);  
\end{tikzpicture}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.