当我尝试在 Ti 中添加换行符时出现错误钾Z 节点。有什么想法吗?
代码:
\documentclass[12pt,dvipsnames]{article}
\usepackage[a4paper, bindingoffset=0.1in, left=1in, right=1in,
top=.51in, bottom=1in, footskip=.25in]{geometry}
\usepackage{listings,xcolor,amssymb,tikz,amsmath,enumitem}
\usetikzlibrary{shadows.blur, shapes.arrows, shapes.geometric, shapes.misc}
\begin{document}
\tikzset{decision/.style= {diamond, draw, aspect=2,text badly centered, node
distance=2.5em, inner sep=0pt}}
\begin{center}
\begin{tikzpicture}
\node[decision] (dic) at (0,0) {\scriptsize{is $dE<0$}};
\node[decision](metro) at (-3,-2) {\scriptsize{is\\ $rand< e^{-\Delta E/k_BT}$}};
\end{tikzpicture}
\end{center}
\end{document}
错误
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.12 ...sion](metro) at (-3,-2) {\scriptsize{is\\
$rand< e^{-\Delta E/k_BT}$}};
答案1
您需要添加对齐方式(例如center
)以允许\\
节点内容。
\documentclass[12pt,dvipsnames]{article}
\usepackage[a4paper, bindingoffset=0.1in, left=1in, right=1in,
top=.51in, bottom=1in, footskip=.25in]{geometry}
\usepackage{listings,xcolor,amssymb,tikz,amsmath,enumitem}
\usetikzlibrary{shadows.blur, shapes.arrows, shapes.geometric, shapes.misc}
\begin{document}
\tikzset{decision/.style= {diamond, draw, aspect=2,text badly centered, node
distance=2.5em, inner sep=0pt,font=\scriptsize,align=center}}
\begin{center}
\begin{tikzpicture}
\node[decision] (dic) at (0,0) {is $\mathrm{d}E<0$};
\node[decision](metro) at (-3,-2) {is\\ $\text{rand}< e^{-\Delta E/k_\mathrm{B}T}$};
\end{tikzpicture}
\end{center}
\end{document}