[pstricks] Using pstricks with Lua - is it possible?

Hensh, Richard hensh at math.msu.edu
Wed Mar 28 19:53:42 CEST 2012


The problem has now been resolved. It turns out that MiKTeX ignores the configuration file `dvipdfmx.cfg'. 

1. Locate the file dvipdfmx.cfg in the texmf tree (e.g., C:\Program Files\MiKTeX 2.9\dvipdfm\config\dvipdfmx.cfg).

2. Open up a command prompt and execute the following:
 
    initexmf --edit-config-file dvipdfmx
  
  This will open a *local copy* of the file dvipdfmx.cfg in your default text editor (usually Notepad). If the local 
  copy is blank (and only if), then copy the contents from the file obtained in step 1 into the local copy and save. 

3. Install the modified versions of auto-pst-pdf.sty and pst-pdf.sty (see the fixes provided by Herbert Voss below).

Now you should be all set.

You can first try (see AutoPdf.tex below)

  xelatex autoPdf.tex
  
If that is successful try

  lualatex -enable-write18 AutoPdf.tex


%%%%%%%%%%%%%
%% Begin AutoPdf.tex
%%%%%%%%%%%%%
\documentclass[10pt]{article}
\usepackage[dvips={},pspdf={}]{auto-pst-pdf}
\usepackage{amsmath,amsthm}
\usepackage{unicode-math} %% loads fontspec
\usepackage{pstricks-add}
\ifluatex
  \usepackage{luacode}
\fi
%\listfiles
\setmainfont[Ligatures=TeX]{XITS}
\setsansfont[Ligatures=TeX]{TeX Gyre Heros}
\setmonofont{Latin Modern Mono}
\setmathfont{XITS Math}
\iftrue
\newpsobject{myaxes}{psaxes}{%
    linewidth=1pt%
    ,linecolor=gray%
    ,arrowscale=1.5%
    ,labels=none%
    ,ticks=none%
    ,axesstyle=axes}
\newpsobject{myplot}{psplot}{%
    linecolor=blue%
    ,linewidth=1.5pt%
    ,plotstyle=curve%
    ,plotpoints=200}
\fi
\begin{document}
\emph{Hello} \textbf{World}
\def\xmin{-3}\def\xmax{6}
\def\ymin{-1}\def\ymax{10}
\begin{center}
\begin{pspicture}(\xmin,\ymin)(\xmax,\ymax)
   \myaxes{<->}(0,0)(\xmin,\ymin)(\xmax,\ymax)
   \psclip{\psframe[linestyle=none](\xmin,\ymin)(\xmax,\ymax)}
     \myplot{\xmin}{\xmax}{x dup mul}
   \endpsclip
   \psdots(2,4)
   \SpecialCoor
   \uput{6pt}[0](2,4){{\Huge $y = x^2$}}
   \NormalCoor
\end{pspicture}
\end{center}
  {\Large
  \begin{equation*}
    f(x) = \sin x
  \end{equation*}
  }
  
\ifluatex
A random number:
\begin{luacode}
tex.print(math.random())
\end{luacode}
\bigskip
\luadirect{
  for i=0, 15 do
    tex.print("Math: $x_{" .. i .. "}$")
  end
  }
\bigskip
\begin{luacode}
  tex.print('\\begin{tabular}{|c|c|}\\hline')
  for i=0, 2 do
    tex.print(i .. '&' .. i+10 .. '\\\\')
    tex.print('\\hline')
  end
  tex.print('\\end{tabular}')
\end{luacode}
\fi
\end{document}
%%%%%%%%%%%
%% End AutoPdf.tex
%%%%%%%%%%%

Thanks to Herbert for all of his work on this.

regards
rick


________________________________________
From: pstricks-bounces at tug.org [pstricks-bounces at tug.org] on behalf of Herbert Voss [Herbert.Voss at FU-Berlin.DE]
Sent: Sunday, March 25, 2012 6:37 AM
To: Graphics with PSTricks
Subject: Re: [pstricks] Using pstricks with Lua - is it possible?

Am 25.03.2012 00:17, schrieb Hensh, Richard:
> Thanks Herbert. The new style file works as advertised.
>
> The minimal example below illustrates a follow-up problem. Specifically, autoPdf.pdf is missing the label $y=x^2$. It seems unlikely that this is a PSTricks problem but it would appear that, at least for the time being, we are unable to use the new fontspec features inside of a pspicture
> environment.

Richard,
that is a real problem. I fixed both, pst-pdf and auto-pst-pdf
to work with files like:

\documentclass[10pt]{article}
\usepackage[dvips={},pspdf={}]{auto-pst-pdf}
\usepackage{pstricks-add}
\ifluatex
   \usepackage{unicode-math} %% loads fontspec
\else
   \usepackage{mathspec} %% loads fontspec
\fi
\setmathfont{XITS Math}
\begin{document}
Hello World

\def\xmin{-3}\def\xmax{3}
\def\ymin{-1}\def\ymax{10}
\begin{pspicture}(\xmin,\ymin)(\xmax,\ymax)
   \psaxes{<->}(0,0)(\xmin,\ymin)(\xmax,\ymax)
   \psclip{\psframe[linestyle=none](\xmin,\ymin)(\xmax,\ymax)}
     \psplot{\xmin}{\xmax}{x dup mul}
   \endpsclip
   \psdots(2,4)
   \uput{6pt}[0](2,4){$y = x^2$}
   \NormalCoor
\end{pspicture}

foo bar baz
\end{document}

The images are now created with xelatex and not latex.
the two files are here:

http://texnik.dante.de/tex/latex/auto-pst-pdf/auto-pst-pdf.sty
http://texnik.dante.de/tex/latex/pst-pdf/pst-pdf.sty

Herbert
_______________________________________________
PSTricks mailing list
PSTricks at tug.org
http://tug.org/mailman/listinfo/pstricks
archive: http://www.tug.org/pipermail/pstricks/


More information about the PSTricks mailing list