\psframe を LuaLatex で動作させるにはどうすればいいですか?

\psframe を LuaLatex で動作させるにはどうすればいいですか?

以下のコードを Overlef でコンパイルしようとすると、 を設定するとエラーが発生しますLuaLaTeXLaTeX Engine、 を設定するとエラーは発生しませんChoose Automatically

\documentclass[a4paper,10pt]{book}

\usepackage{pst-electricfield,multido} % campos elétricos

\begin{document}

\begin{pspicture*}(-6,-6)(6,6)
 \psframe*[linecolor=lightgray!50](-6,-6)(6,6)
 \psgrid[subgriddiv=0,gridcolor=gray,griddots=10]
 \psElectricfield[Q={[-1 -2 2][1 2 2][-1 2 -2][1 -2 -2]},linecolor=red]
 \psEquipotential[Q={[-1 -2 2][1 2 2][-1 2 -2][1 -2 -2]},linecolor=blue](-6.1,-6.1)(6.1,6.1)
 \psEquipotential[Q={[-1 -2 2][1 2 2][-1 2 -2][1 -2 -2]}, linecolor=green, linewidth=2\pslinewidth, Vmax=0, Vmin=0](-6.1,-6.1)(6.1,6.1)
\end{pspicture*}

\end{document}

次のようなエラーが発生します:

./main.tex:8: Undefined control sequence.
<recently read> \c@lor@to@ps          
l.8  \psframe*[linecolor=lightgray!50](-6,-6)(6,6)
Here is how much of LuaTeX's memory you used:  8148 strings out of 494688 ...

答え1

実行するにはlualatex --shell-escape <file>:

\documentclass[a4paper,10pt]{book}
\usepackage{auto-pst-pdf}
\ifpdf\else
  \usepackage{pst-electricfield}
\fi
\begin{document}

\begin{pspicture*}(-6,-6)(6,6)
    \psframe*[linecolor=lightgray!50](-6,-6)(6,6)
    \psgrid[subgriddiv=0,gridcolor=gray,griddots=10]
    \psElectricfield[Q={[-1 -2 2][1 2 2][-1 2 -2][1 -2 -2]},linecolor=red]
    \psEquipotential[Q={[-1 -2 2][1 2 2][-1 2 -2][1 -2 
    -2]},linecolor=blue](-6.1,-6.1)(6.1,6.1)
    \psEquipotential[Q={[-1 -2 2][1 2 2][-1 2 -2][1 -2 -2]}, linecolor=green, 
    linewidth=2\pslinewidth, Vmax=0, Vmin=0](-6.1,-6.1)(6.1,6.1)
\end{pspicture*}

\end{document}

ここに画像の説明を入力してください

関連情報