未定义控制序列。\end{axis}

未定义控制序列。\end{axis}

我正在使用 TiZ 绘制图表LaTeX

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
%\usepackage{pgfplotstable}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title={Temperature dependence of CuSO$_4\cdot$5H$_2$O solubility},
xlabel={Temperature [\textcelsius]},
ylabel={Solubility [g per 100 g water]},
xmin=0, xmax=100,
ymin=0, ymax=120,
xtick={0,20,40,60,80,100},
ytick={0,20,40,60,80,100,120},
legend pos=north west,
ymajorgrids=true,
grid style=dashed,
]
\addplot[color=blue,mark=square,]
coordinates {(0,23.1)(10,27.5)(20,32)(30,37.8)(40,44.6)(60,61.8)(80,83.8)(100,114)};
\legend{CuSO$_4\cdot$5H$_2$O}
\end{axis}
\end{tikzpicture}
\end{document}

**Undefined control sequence. \end{axis}**我在使用编译时遇到错误PDF 乳胶TeX工作室

答案1

代码抱怨\textcelsius未知。使用\usepackage{textcomp}获取此命令。

或者使用\usepackage{siunitx}xlabel={Temperature [\si{\celsius}]}

对于化学公式,使用化学包可能比使用数学模式更合适。

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{textcomp}
\usepackage{siunitx}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
title={Temperature dependence of CuSO$_4\cdot$5H$_2$O solubility},
xlabel={Temperature [\textcelsius]},
xlabel={Temperature [\si{\celsius}]},
ylabel={Solubility [\si{g} per \SI{100}{g} water]},
xmin=0, xmax=100,
ymin=0, ymax=120,
xtick={0,20,40,60,80,100},
ytick={0,20,40,60,80,100,120},
legend pos=north west,
ymajorgrids=true,
grid style=dashed,
]
\addplot[color=blue,mark=square,]
coordinates {(0,23.1)(10,27.5)(20,32)(30,37.8)(40,44.6)(60,61.8)(80,83.8)(100,114)};
\legend{CuSO$_4\cdot$5H$_2$O}
\end{axis}
\end{tikzpicture}


\begin{tikzpicture}
\begin{axis}[
title={Temperature dependence of CuSO$_4\cdot$5H$_2$O solubility},
xlabel={Temperature [\textcelsius]},
ylabel={Solubility [g per 100 g water]},
xmin=0, xmax=100,
ymin=0, ymax=120,
xtick={0,20,40,60,80,100},
ytick={0,20,40,60,80,100,120},
legend pos=north west,
ymajorgrids=true,
grid style=dashed,
]
\addplot[color=blue,mark=square,]
coordinates {(0,23.1)(10,27.5)(20,32)(30,37.8)(40,44.6)(60,61.8)(80,83.8)(100,114)};
\legend{CuSO$_4\cdot$5H$_2$O}
\end{axis}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容