![使用森林环境的图表中的“错误额外 } 或忘记 $”](https://linux22.com/image/435416/%E4%BD%BF%E7%94%A8%E6%A3%AE%E6%9E%97%E7%8E%AF%E5%A2%83%E7%9A%84%E5%9B%BE%E8%A1%A8%E4%B8%AD%E7%9A%84%E2%80%9C%E9%94%99%E8%AF%AF%E9%A2%9D%E5%A4%96%20%7D%20%E6%88%96%E5%BF%98%E8%AE%B0%20%24%E2%80%9D.png)
我正在尝试使用节点中的数学模式在 beamer 中制作树形图,但收到消息错误:
! Extra }, or forgotten $.
<template> \unskip \hfil }
\endtemplate
l.130 \end{frame}
我的代码是:
\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}
我真的无法想象到底缺了什么或出了什么问题!请帮忙!
答案1
该=
符号在 Forest 中有特殊用途,用于将键与值分开。要告诉 Forest 你=
不属于任何键值对,请将{...}
文本括起来:
\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}
答案2
使用 return 命令,我注意到问题在于使用等号“=”。我真的不明白为什么,但我用 \equiv 替换它,它就起作用了!