PSTricks drawing not working with XeLaTeX

pdfpagespstricksxetex

Consider the following (non-minimal) example test.tex:

\documentclass{article}

\usepackage{xfp}
\usepackage{multido}
\usepackage{pst-slpe}

% Atommodel.
\psset{dimen = m}
\newcommand*\bane[1]{%
  \rput{#1}(3.15,3.55){%
    \psellipse[
      linestyle = dashed,
      linewidth = \pslinewidth
    ](0,0)(3.55,1.05)}}
\def\elektron(#1,#2){%
  \rput(#1,#2){\psBall{white}{0.7ex}}
  \rput(#1,#2){\psBall{green!70!black}{0.5ex}}
  \rput(#1,#2){\tiny$-$}}
\def\proton#1#2{%
  \rput(\fpeval{3.15+#1*cosd(#2)},\fpeval{3.55+#1*sind(#2)}){\psBall{red}{2ex}}
  \rput(\fpeval{3.15+#1*cosd(#2)},\fpeval{3.55+#1*sind(#2)}){$+$}}
\def\neutron#1#2{%
  \rput(\fpeval{3.15+#1*cosd(#2)},\fpeval{3.55+#1*sind(#2)}){\psBall{blue}{2ex}}}

\begin{document}

\begin{figure}[htbp]
  \begin{pspicture}(6.3,7.1)
   % Elektronbaner.
   \bane{30}
   \elektron(5.07,5.48)
   \bane{90}
   \elektron(3.94,1.24)
   \bane{150}
   \elektron(0.75,4)
   % Kerne.
   \multido{\iA = 30+120, \iB = 90+120}{3}{%
     \neutron{0.5}{\iA}
     \proton{0.5}{\iB}}
   \neutron{0}{0}
   % Betegnelser.
  {\psset{linecolor = orange}
   \pscircle[
     linewidth = 1.5\pslinewidth
   ](3.15,3.55){0.95}
   \rput(1.3,6.5){%
     \shortstack[c]{%
       Atomkerne/\strut\\[-0.75ex]
       nukleon\strut}}
   \psline{->}(1.3,6)(2.5,4.2)}
   \rput(0.9,0.6){Elektron}
   \psline[linecolor = green!70!black]{->}(1.8,0.6)(3.8,1.2)
   \rput(5.5,0.6){Proton}
   \psline[linecolor = red]{->}(5.5,0.85)(3.65,3.25)
   \rput(5.5,6.5){Neutron}
   \psline[linecolor = blue]{->}(5.5,6.25)(3.6,3.8)
  \end{pspicture}
\end{figure}

\end{document}

When I compile it using latex test.tex –> dvips test.tex –> p2pdf -dALLOWPSTRANSPARENCY test.ps everything is fine. However, when I compile it using xelatex test.tex the drawing is "destroyed".

I need to use xelatex or something similar which can be used with the pdfpages package. How do I get around this?

Update

With Ulrike's help, it's now working for me.

Best Answer

Update 2021-09-12

The bug has been resolved in 2021/09/10 v3.08 `PSTricks'.


PSTricks with XeLaTeX is currently broken, but the maintainer knows it already.

As an alternative you can try LuaLaTeX with the experimental luapstricks from https://github.com/zauguin/luapstricks. You example works fine for me with it.

Related Question