I have a large latex file that contains a multitude of images of graphs generated by using tikz and pstricks libraries.
For example, imagine to have a document like the one here below with a very large number of graphs drawn by using tikz and psmatrix:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs}
\usetikzlibrary{graphs.standard}
\begin{document}
\begin{tikzpicture}[every node/.style={draw,circle,very thick}]
\graph[clockwise, radius=2cm] {subgraph C_n [n=5,name=A]};
\graph[clockwise, radius=1cm] {subgraph I_n [n=5,name=B]};
\foreach \i in {1,2,3,4,5}{\draw (A \i) -- (B \i);}
\newcounter{j}
\foreach \i in {1,2,3,4,5}{%
\pgfmathsetcounter{j}{ifthenelse(mod(\i+2,5),mod(\i+2,5),5)}
\draw (B \i) -- (B \thej);
}
\end{tikzpicture}
\end{document}
I would need to convert this file in R markdown. How to do it?
You can use the same code in rmarkdown:
---
output:
pdf_document
header-includes:
- \usepackage{tikz}
- \usetikzlibrary{graphs}
- \usetikzlibrary{graphs.standard}
---
\begin{tikzpicture}[every node/.style={draw,circle,very thick}]
\graph[clockwise, radius=2cm] {subgraph C_n [n=5,name=A]};
\graph[clockwise, radius=1cm] {subgraph I_n [n=5,name=B]};
\foreach \i in {1,2,3,4,5}{\draw (A \i) -- (B \i);}
\newcounter{j}
\foreach \i in {1,2,3,4,5}{%
\pgfmathsetcounter{j}{ifthenelse(mod(\i+2,5),mod(\i+2,5),5)}
\draw (B \i) -- (B \thej);
}
\end{tikzpicture}