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

Hensh, Richard hensh at math.msu.edu
Fri Mar 23 23:32:19 CET 2012

The minimal(?) example below should do the trick PROVIDED that you modify the file auto-pst-pdf.sty file to replace the latex'' commands with lualatex (at least under MiKTeX 2.9 on a Windows box). I've emailed the package author about this but I have not heard back. And I don't know enough about extending packages to write something myself.

%%%%%%%%
%% autoPdf.tex
%%%%%%%%
\documentclass{article}
\usepackage[latex={--output-format=dvi}]{auto-pst-pdf}
\usepackage{pst-all}%
%\usepackage{pst-func}
\usepackage{xparse}
\usepackage{luacode}
%\usepackage{fontspec}
\newgray{LightGray}{0.65}%
\newpsobject{myaxes}{psaxes}{%
linewidth=1pt%
,linecolor=gray%
%    ,arrowinset=0.6%
%    ,arrowsize=1.5pt 3%
,arrowscale=1.5%
,labels=none%
,ticks=none%
,axesstyle=axes}

\begin{document}

\def\xmin{-3}\def\xmax{3}
\def\ymin{-1}\def\ymax{10}
\psset{unit=6mm,yunit=4mm}
\begin{pspicture}(\xmin,\ymin)(\xmax,\ymax)
%\showgrid
\myaxes{<->}(0,0)(\xmin,\ymin)(\xmax,\ymax)
\SpecialCoor
\psclip{\psframe[linestyle=none](\xmin,\ymin)(\xmax,\ymax)}
\psplot{\xmin}{\xmax}{x dup mul}
\endpsclip
\psdots(2,4)
\NormalCoor
\end{pspicture}
A random number:
\begin{luacode}
tex.print(math.random())
\end{luacode}
\bigskip
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}

\end{document}
%%%%%%%%%%%%
%% end AutoPdf.tex
%%%%%%%%%%%%

regards
rick

________________________________________
From: pstricks-bounces at tug.org [pstricks-bounces at tug.org] on behalf of Hubert Lam [hubert at lamfamily.info]
Sent: Thursday, March 08, 2012 5:28 PM
To: Graphics with PSTricks
Subject: Re: [pstricks] Using pstricks with Lua - is it possible?

I've been wanting to investigate + ask this, so thanks Luis.

At the moment if I need to do things "programmatically" I will resort to Excel and using formulae + the "=concatenate()" (the "&" function) to get the varying parameters into pstricks/LaTeX code.

However for more complicated stuff, yes it would be nice for LuaTeX to be easily integrated with PSTricks....
________________________________________
From: pstricks-bounces at tug.org [pstricks-bounces at tug.org] on behalf of Luis Sequeira [lfsequeira at gmail.com]
Sent: Thursday, 8 March 2012 3:23 AM
To: pstricks at tug.org
Subject: [pstricks] Using pstricks with Lua - is it possible?

I have used pstricks for years. One aspect that really interests me is the generation of complex pstricks figures programatically.
(for an example, consider generating a calendar for, a given year, say, 2013; it involves drawing 365 boxes, with numbers, different colors, markings for holidays, etc. and a lot of calculations that are better done in more general programming language, rather than LaTeX)

I have generated complex pstricks code like that, containing hundreds of commands, automatically (via C++ programming) - that involves writing a C++ program that writes down a tex file, and then running this through LaTeX

I was hoping to use Lua scripting to be able to automatically generate pstricks code, right from inside LaTeX, thus making this process self-contained.

But this looks like it may not be possible:

- running lualatex with pstricks code in the LaTeX file only appears to be possible through the auto-pst-pdf package;
- and that in turn spawns separate latex runs for all the pstricks stuff, where the lua scripting is *not* interpreted.

Is there some way to do this? Any suggestions? I am able to "script" regular LaTeX commands in lualatex, but I'm stumped because of the postscript nature of pstricks via the "pdflatex" nature of lualatex.

TIA

Luis Sequeira

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

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