LuaLatex 和交叉段:仅在 Lua 中出现错误

LuaLatex 和交叉段:仅在 Lua 中出现错误

我需要在文档中使用 LuaLatex,但在编译图时不知何故遇到了错误。我将文档缩减为以下 MWE:

\documentclass{scrartcl}
\usepackage{shellesc}
\usepackage{pgfplots}

\pgfplotsset{compat = newest}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{patterns}

\begin{document}

\begin{tikzpicture}[
        declare function = {
                f(\x) = \x;
            },
    ]
    % Set the circle dimensions
    \pgfmathsetmacro\xc{1}
    \pgfmathsetmacro\yc{0}
    \pgfmathsetmacro\ri{1}
    \pgfmathsetmacro\ro{3}

    \begin{axis}[
            ymin = 0, ymax = 5,
            xmin=-3, xmax=5,
            axis lines = center,
            xlabel = {\textbf{Re}\((z)\)},
            ylabel = {\textbf{Im}\((z)\)},
            major grid style = {lightgray},
            width = .9\textwidth,
            scale mode=scale uniformly,
        ]
        % Draw the circles and the line
        \draw [name path=outerCircle] (\xc,\yc) circle (\ro);
        \draw [name path=innerCircle] (\xc,\yc) circle (\ri);
        \addplot[domain=0:5, name path=f] {f(x)};

        % Add the labels
        \node [anchor=north west] at (4,{f(4)}) {\(\phi = \frac{\pi}{4}\)};
        \node [anchor=north west] at (0,\pgfkeysvalueof{/pgfplots/ymax} - 1) {\(\phi = \frac{\pi}{2}\)};

        % Add a path along the y axis of the plot
        \path[name path=yAxis] (0, \pgfkeysvalueof{/pgfplots/ymin}) --
        (0,\pgfkeysvalueof{/pgfplots/ymax});

        % Add the intersection between inner circle and line
        \draw [
            name path=lower,
            draw=none,
            intersection segments={
                    of=innerCircle and f,
                    sequence={L2[reverse] -- R3},
                },
        ];

        % Add the intersection between inner circle + line and the outer circle
        \draw [
            name path=rightSide,
            draw=none,
            intersection segments={
                    of=outerCircle and lower,
                    sequence={R1 -- L2},
                },
        ];

        % Add the intersection between inner circle + line + outer circle and the y axis
        \draw [
            name path=full,
            draw=none,
            thick,
            intersection segments={
                    of=rightSide and yAxis,
                    sequence={R2 -- L2},
                },
        ];

        % Fill in the horizontal gray lines to mark the area
        \addplot[pattern=horizontal lines, semitransparent] fill between[of=yAxis and full];

    \end{axis}
\end{tikzpicture}

\end{document}

它看起来应该是这样的:

PGF 图的输出

当我用以下方法编译它时:

latexmk -shell-escape -synctex=1 -interaction=nonstopmode -file-line-error -pdf -outdir=build <file.tex>

我没有收到任何错误,并且生成了所示的图表(Latex Workshop VSCode 扩展的配方)。

但如果我编译它

latexmk -shell-escape -synctex=1 -interaction=nonstopmode -file-line-error -lualatex -outdir=build <file.tex>

Package pgf Error: There is no intersection segment '2' in path '2'它在 行处给了我以下错误\end{axis}。仅使用 lualatex、outdir 和 shell-escape 选项运行命令会产生相同的错误。

有人知道这里的问题是什么吗?提前致谢

答案1

如果代码是用 LuaLaTeX 编译的,则找不到原点处的交点。这可能是由于舍入错误造成的。如果将行中的域\addplot[domain=0:5, name path=f] {f(x)};更改为,domain=-0.0001:5则代码可以使用 LuaLaTeX 进行编译。但使用 则不行domain=-0.00001:5

相关内容