Figures are great for presentation slides. I would like to add a figure to my slides, but wouldn't be nice to import an already designed image. I would like to instead draw from within latex, this way I can easily make changes and/or add text without having to re-insert every time I modify the image.
Asked
Active
Viewed 125 times
-1
2 Answers
1
The following might serve as a starting point:
\documentclass{beamer}
\usepackage[edges]{forest}
\begin{document}
\begin{frame}
\frametitle{example diagram}
\begin{forest}
for tree={
draw,
rounded corners,
node options={align=left,fill=gray!20},
text width=2.7cm,
},
[Approach,
[\textbf{location-based} \\ Some text,
]
[\textbf{inertial based} \\ some text,
]
[\textbf{Hybrid} \\some text,
]
]
\end{forest}
\end{frame}
\end{document}
leandriis
- 62,593
0
\documentclass{article}
\usepackage[edges]{forest}
\begin{document}
\begin{forest}
forked edges,
for tree={rounded corners,draw,fill=gray!20,font=\sffamily,
align=left,text width=8em,s sep+=1em}
[\textbf{Approach}
[{\textbf{location-based}\\[1.2em] blub}]
[{\textbf{inertia-based}\\[1.2em] blah}]
[{\textbf{hybrid}\\[1.2em] pft}]
]
\end{forest}
\end{document}
ADDENDUM: Of course the same code works in beamer presentations (up to making some distances a tiny bit smaller).
\documentclass{beamer}
\usepackage[edges]{forest}
\begin{document}
\begin{frame}[t]
\frametitle{A tree}
\centering
\begin{forest}
forked edges,
for tree={rounded corners,draw,fill=gray!20,font=\sffamily,
align=left,text width=7em,s sep+=0.5em}
[\textbf{Approach}
[{\textbf{location-based}\\[1.2em] blub}]
[{\textbf{inertia-based}\\[1.2em] blah}]
[{\textbf{hybrid}\\[1.2em] pft}]
]
\end{forest}
\end{frame}
\end{document}




forestpackage. – leandriis Jan 17 '20 at 17:20