1

This question already has an answer here:

When I try to compile the code below in Overlef, I get an error if I set LuaLaTeX as LaTeX Engine, but no error if I set 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}

This is the error I get:

./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 ...

marked as duplicate by Alan Munn, Mensch, user13907, Werner, Community Feb 4 '16 at 18:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • The simple answer is that you can't use PSTricks with LuaTeX. There are some ways around this; see the linked duplicate for details. – Alan Munn Feb 4 '16 at 17:11
  • The solutions work well with my MWE, but a lot of other errors appear when I apply them to a long document. I decided to compile PS pictures in a different project and to include them with includegraphics. – Leonardo Castro Feb 6 '16 at 22:37
1

Run with 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}

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.