TransWikia.com

"Error Extra }, or forgotten $" in a diagram using forest environment

TeX - LaTeX Asked by chrm on June 19, 2021

I am trying to make a tree diagram in beamer using math mode in nodes but I receive the message error:

! Extra }, or forgotten $.
<template> unskip hfil }
                      endtemplate 
l.130 end{frame}

my code is:

documentclass[12pt]{beamer}

usetheme[block=fill,numbering=fraction,progressbar=frametitle]{metropolis}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[english]{babel}
usepackage{amssymb}
usepackage[edges]{forest}
usepackage{appendixnumberbeamer}

usepackage{graphicx} 
graphicspath{ {images/} }

usepackage{booktabs}
usepackage[scale=2]{ccicons}

usepackage{xspace}
newcommand{themename}{textbf{textsc{metropolis}}xspace}

begin{document}

begin{frame}{Stability}

begin{forest}
forked edges, 
for tree={draw,align=center,edge={-latex}}
[$|f'(x^{ast})|=1$
[$f'(x^{ast})=1$
[$f''(x^{ast})neq 0$ [$x^{ast}$ is unstable] ]
[$f''(x^{ast})=0$ 
[$f'''(x^{ast})<0$ [$x^{ast}$ is asymptotically stable] ]
[$f'''(x^{ast})>0$ [$x^{ast}$ is unstable ] ] ] ]
[$f'(x^{ast})=-1$
[$Sf(x^{ast})<0$ [$x^{ast}$ is asymptotically stable] ]
[$Sf(x^{ast})>0$ [$x^{ast}$ is unstable] ] ] ]
end{forest}
end{frame}

end{document}

I really cannot imagine what is missing or going wrong!!! Please help!

2 Answers

Using return command, I noticed that the problem is the use of the symbol of equality "=". I really can't understand why, but I replaced it with equiv and it worked!

Answered by chrm on June 19, 2021

The = sign has special usage in forest to separate keys from their values. To tell forest that your = is not part of any key value pairs, wrap {...} around your text:

documentclass[12pt]{beamer}

usetheme[block=fill,numbering=fraction,progressbar=frametitle]{metropolis}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[english]{babel}
usepackage{amssymb}
usepackage[edges]{forest}
usepackage{appendixnumberbeamer}

usepackage{graphicx} 
graphicspath{ {images/} }

usepackage{booktabs}
usepackage[scale=2]{ccicons}

usepackage{xspace}
newcommand{themename}{textbf{textsc{metropolis}}xspace}

begin{document}

begin{frame}{Stability}

scriptsize

begin{forest}
forked edges, 
for tree={draw,align=center,edge={-latex}}
[{$|f'(x^{ast})|= 1$}
[{$f'(x^{ast})= 1$}
[$f''(x^{ast})neq 0$ [$x^{ast}$ is unstable] ]
[{$f''(x^{ast})= 0$} 
[$f'''(x^{ast})<0$ [$x^{ast}$ is asym. stable] ]
[$f'''(x^{ast})>0$ [$x^{ast}$ is unstable ] ] ] ]
[{$f'(x^{ast})= -1$}
[$Sf(x^{ast})<0$ [$x^{ast}$ is asym. stable] ]
[$Sf(x^{ast})>0$ [$x^{ast}$ is unstable] ] ] ]
end{forest}

end{frame}

end{document}

forest diagram

Answered by user244594 on June 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP