我似乎无法在方程式中间找到一个换行符;在这个例子中,它无法放入一个框中(并且不会改变框的大小)。我通常的方法 \\
不起作用。
\documentclass[12pt]{report}
\usepackage{tikz}
\usepackage[version=3]{mhchem}
\usepackage{amsmath}
\begin{document}
\centering
\begin{figure}
\tikzstyle{1L} = [rectangle, draw, text width=8cm, text centered, fill=blue!20]
\tikzstyle{2L} = [rectangle, draw, text width=5cm, text centered, fill=blue!20]
\tikzstyle{arrow} = [thick,->,>=stealth,-to,shorten >=5pt, shorten <=2pt]
\begin{tikzpicture}[node distance=4cm]
\node (1L) [1L] {\underline{Oxidation}
\begin{equation} \ce{ $\underset{\text{Pyrite}}{\cf{FeS2}}$ + 3.5O2 + H2O -> Fe^2+ + 2SO4+2- + 2H+}
\end{equation}
};
\node (2L) [2L,below of=1L, minimum height=3em] {Fe$^{2+}$};
\draw [arrow] (1L)--(2L);
\end{tikzpicture}
\caption{Flowchart}
\end{figure}
\end{document}
答案1
你不能在方程中使用\\
。这与 TikZ 或mhchem
最简单的方法是使用split
这里或者在框内用几行写完整个内容:
% arara: pdflatex
\documentclass[12pt]{report}
\usepackage{tikz}
\usepackage[version=3]{mhchem}
\begin{document}
\begin{figure}
\centering
\tikzstyle{1L} = [rectangle, draw, text width=8cm, text centered, fill=blue!20]
\tikzstyle{2L} = [rectangle, draw, text width=5cm, text centered, fill=blue!20]
\tikzstyle{arrow} = [thick,->,>=stealth,-to,shorten >=5pt, shorten <=2pt]
\begin{tikzpicture}[node distance=4cm]
\node (1L) [1L] {\underline{Oxidation}
\begin{equation}\begin{split}
&\ce{ $\underset{\text{Pyrite}}{\cf{FeS2}}$ + 3.5O2 + H2O -> }\\
&\ce{Fe^2+ + 2SO4+2- + 2H+}
\end{split}\end{equation}
};
%
\node (2L) [2L,below of=1L, minimum height=3em] {Fe$^{2+}$};
%
\draw [arrow] (1L)--(2L);
\end{tikzpicture}
\caption{Flowchart}
\end{figure}
\end{document}