简体   繁体   中英

RStudio + Knitr + mind mapping

I am trying to integrate mind mapping using tikz library into rstudio code. But am getting an error:

improper \\prevdepth

missing \\endgroup inserted.

Here is the piece of code.

  % mind mapping packages.

   \usepackage{tikz}

   \usetikzlibrary{mindmap}

   \usetikzlibrary{shadows}

\begin{tikzpicture}[grow cyclic, text width = 3cm, align=flush center, ]

\node{Data }

      child{node{Renaming Data Variable}}

      child{node{Converting data types}}

      child{node{Working with date format}}

      child{node{Adding New Records}}

      child{node{Filtering Data}}

      child{node{Dropping Data}}

      child{node{Merging and sorting data}}

      child{node{Reshaping Data}}

      child{node{Detecting Messy Data}}

      child{node{{Imputing Missing Data}}
;
\end{tikzpicture}

As your post does not contain valid TikZ/mindmap code, here is a reproducible example based on code examples found on TeXample.net .

RMarkdown code

Here the critical part is to include additional LaTeX packages and header directives under header-includes in the YAML header of the RMarkdown document.

---
title: "Untitled"
header-includes:
   - \usepackage{tikz}
   - \usetikzlibrary{mindmap,shadows}
output: pdf_document
---

\begin{tikzpicture}
  \path[mindmap,concept color=black,text=white]
    node[concept] {Computer Science}
    [clockwise from=0]
    child[concept color=green!50!black] {
      node[concept] {practical}
      [clockwise from=90]
      child { node[concept] {algorithms} }
      child { node[concept] {data structures} }
      child { node[concept] {pro\-gramming languages} }
      child { node[concept] {software engineer\-ing} }
    }
    child[concept color=blue] {
      node[concept] {applied}
      [clockwise from=-30]
      child { node[concept] {databases} }
      child { node[concept] {WWW} }
    }
    child[concept color=red] { node[concept] {technical} }
    child[concept color=orange] { node[concept] {theoretical} };
\end{tikzpicture}

Screenshot of output

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM