我正在尝试使用节点中的数学模式在 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 替换它,它就起作用了!