# LuaLaTeX and PSTricks

Is there the possibility to produce PSTricks graphics in LuaLaTeX?

I tried it, but i get

    ! Undefined control sequence.

l.9 \psline(
-5,2)(5,4)


With auto-pst-pdf I get a warning to use pdflatex.

So how can i use pstricks in LuaLaTeX?

Edit:@Marco Daniel

I asked where to pack packages for specified for lualatex, "normal packages", and pstricks packages: Maybe something like this:

    \RequirePackage{ifluatex}
\documentclass{scrartcl}
\usepackage{amsmath}

\ifluatex
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\usepackage{lua-visual-debug}
\else
\usepackage{pstricks}
\usepackage{pst-plot}
\fi
\usepackage{auto-pst-pdf}
\begin{document}
Here text...
\end{document}


Niklas

-
–  Marco Daniel Feb 24 '13 at 14:53
Thanks! That works now. All Packages for lualatex must be put into after ifluatex right? –  Niklas Feb 24 '13 at 15:19
What do you mean with "after ifluatex"? To specify your question you should provide a minimal working example (MWE). –  Marco Daniel Feb 24 '13 at 15:57
Packages like pstricks or auto-pst-pdf are independent from the test ifluatex. Normally the test is used for fontspec or polyglossia. –  Marco Daniel Feb 24 '13 at 17:36
Did you get it to work? If so, how? You can answer your own question, then... –  nutty about natty Jul 3 '13 at 16:14

You can't use PSTricks directly with LuaTeX as even in DVI mode you can't get the 'correct' output. As detailed on the PSTricks website, the way around this is to do a conditional compilation using auto-pst-pdt to generate the required graphical elements using pdfTeX in DVI mode:

\RequirePackage{ifluatex}
\documentclass{article}

\ifluatex
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}
\else
\usepackage{tgpagella}
\usepackage{pstricks}
\fi
\usepackage{auto-pst-pdf}

\begin{document}

\paragraph{Hier ein pstricks-Bild}
\begin{pspicture}(5,3)
\pspolygon[fillstyle=vlines](0,0)(5,3)(3,0)
\end{pspicture}

\end{document}


To see how this works, note that when auto-pst-pdf runs the auxiliary compiles, it always uses pdfTeX (in DVI mode). Thus the \ifluatex conditional will be false and any LuaTeX-specific stuff will be skipped. To get as close as possible appearance-wise, there is therefore a need to use a 'similar' font in the standard run route. Also note that anything to do with PSTricks goes in the 'else' branch: that includes additional PSTricks packages and anything else that needs DVI mode.

-