下面的 MWE 得出
Runaway argument?
3\pgfflt@EOI \ifpgfmathfloatparsenumberpendingperiod \pgfmathfloat@a@Mtok \ETC.
./TeX-SE.tex:29: Paragraph ended before \pgfflt@readlowlevelfloat was complete.
<to be read again>
\par
当我尝试使用手册int()
中所述的功能时pgf
:
笔记:
- 添加图表
floor
只是为了显示语法正确。因此,交换第二个\addplot
会产生输出。
代码:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle
]
%% This works
\addplot [
jump mark mid,
domain=-3:3,
samples=100,
very thick, red
] {floor(x)};
%%% This now no work.
\addplot [
jump mark mid,
domain=-3:3,
samples=100,
very thick, red
] {int(x)};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
如果其他人遇到此错误,我会发布我的解决方法,直到错误得到修复。我定义了
MyInt(\x)=x-mod(\x,1)
得出的结果是:
笔记
MyInt()
产生与当前相同的结果破碎的floor()
Floor()
函数。修正版本在 MWE 中 定义为如何在 LaTeX 中绘制 Floor/Ceiling 函数图(PGFPlots)。
代码:
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\tikzset{
declare function={Floor(\x)=round(\x-0.5);},% floor() is broken.
declare function={MyInt(\x)=x-mod(\x,1);},
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=-3.2, xmax=3.2,
ymin=-2.2, ymax=2.2,
axis lines=middle
]
\addplot [
jump mark mid,
domain=-3:3,
samples=100,
very thick, red
] {MyInt(x)};
\end{axis}
\end{tikzpicture}
\end{document}