[pstricks] Difficulties with pst-pdf

David Arnold dwarnold45 at suddenlink.net
Fri May 15 05:12:01 CEST 2009


Herbert,

Ouch! Did not know this, as our textbook now have 8 chapters to date  
and lots of pstricks that is not in a pspicture or psmatrix envrionment.

So, what to do?

As I may have mentioned in the past, we have this Optimath system  
we've built (perl, shell scripts, pdflatex, mysql, html):

http://msenux.redwoods.edu/cgi-bin/online/s09/OTlogin.cgi

It serves up quizzes, homework, etc., and builds the files on the  
fly, fully randomized. It is filled with metapost graphics that are  
built on the fly. We'd like to include pstricks graphics as well. One  
of the scripts of our system uses a perl script to take this file:

# File: section1exercises.qdf
# Version: 1.0 Spring 2009 Optimath
# Part of the College of the Redwoods Online Testing in Mathematics  
Project.
# Copyright (c) 2005, David Arnold and Bruce Wagner. All rights  
reserved.


### testbank: 01
########################################
### TOPIC 1

\topic = 1.1: place value
|@|


# author: RC & BHW

### MODEL 1.1, QUESTION 1
\versions=1
|@|
\code = my ($a,$b,$c,$d,$e,$f,$g,$h);
do {
	($a,$b,$c,$d,$e,$f,$g,$h)=randint(-6,6,8,());
} until unique($a,$b,$c,$d,$e,$f,$g,$h);
my ($ans1,$ans2,$ans3,$ans4);
$ans1=($a<$b ? "\$$a>$b\$" : "\$$a<$b\$");
$ans2=($c<$d ? "\$$c<$d\$" : "\$$c>$d\$");
$ans3=($e<$f ? "\$$e<$f\$" : "\$$e>$f\$");
$ans4=($g<$h ? "\$$g<$h\$" : "\$$g>$h\$");
my $lies;
$lies=($a<$b ? "lies to the left of" : "lies to the right of");
my $compare=($a<$b ? "<" : ">");
|@|
\qutext=Which one of the following statements is false?
|@|
\bookqu=In each of the following exercises, enter the inequality  
symbol $<$ or the symbol $>$ in the shaded box in order that the  
resulting inequality is a true statement.
|@|
\shortqu=$#a\quad\fcolorbox{black}{yellow}{\phantom{M}}\quad #b$
|@|
\mode = multiplechoice
|@|
\columns=2
|@|
\rowsep=5
|@|
\answer=#ans1;#ans2;#ans3;#ans4
|@|
\answertex=$#a#compare#b$
|@|
\soltext = If you locate the numbers $#a$ and $#b$ on a number line,  
you can see that $#a$ #lies $#b$.
\begin{center}
	\psset{unit=0.25in}
	\begin{pspicture}(-8,-1)(8,1)
	\psaxes[arrowscale=1.5,arrows=<->,yAxis=false,labels=none](0,0)(-8,0) 
(8,0)
	\psxTick[linecolor=red](-7){-7}
	\psxTick[linecolor=red](0){0}
	\psxTick[linecolor=red](7){7}
	\psdots*[linecolor=red,dotsize=2pt 2](#a,0)(#b,0)
	\uput[90](#a,0){$#a$}
	\uput[90](#b,0){$#b$}
	\end{pspicture}
\end{center}
Hence, $#a#compare#b$.
|@|
\endquestion
|@|


\endtopic|@|



And convert it to this file:


\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{polynom}
\usepackage{graphicx}
\usepackage{OTqdbpreview,OTglobal}

\usepackage{pst-pdf}
\usepackage{pst-bar}
\usepackage{pst-plot}
\usepackage{pst-tree}
\usepackage{pstricks-add}

\usepackage[makeroom]{cancel}
\usepackage{filecontents}

\usepackage{xcolor}
\definecolor{shadecolor}{gray}{0.9}
\definecolor{darkgreen}{rgb}{0,0.625,0}
\definecolor{darkred}{rgb}{0.625,0,0}

\usepackage{dcolumn}
\newcolumntype{.}{D{.}{.}{-1}}

\usepackage{emp,ifpdf}
\ifpdf
\DeclareGraphicsRule{*}{mps}{*}{}
\fi
\setlength{\unitlength}{1cm}

% statsmac and online macros for qdf files
\empprelude{input statsmac}
\empaddtoprelude{input onlinemacros}
\empaddtoprelude{input mp-tool}
\empTeX{}

\newdimen\temptextwidth \temptextwidth=\textwidth

\def\subprob#1{\par\smallskip(#1)\,\,}

\newcommand\qand{\quad\text{and}\quad}
\newcommand\qqand{\qquad\text{and}\qquad}
\newcommand\qor{\quad\text{or}\quad}
\newcommand\qqor{\qquad\text{or}\qquad}

\newpsstyle{bgCyan}{fillstyle=solid,fillcolor=cyan! 
10,linestyle=none,framesep=6pt}
\def\pBox#1{\psframebox[style=bgCyan]{{%
   \tabular{@{}c@{}}#1\endtabular}}}

\newpsbarstyle{cyan}{fillcolor=cyan!10,fillstyle=solid}

\begin{document}

\begin{topic}{1.1: place value}

\model

\begin{question}{multiplechoice}
\qutext{Which one of the following statements is false?
}
\choice*{$2<0$}
\choice{$-6<-3$}
\choice{$-4<5$}
\choice{$6>-2$}
\columns{2}
\rowsep{5}
\soltext{If you locate the numbers $2$ and $0$ on a number line, you  
can see that $2$ lies to the right of $0$.
\begin{center}
	\psset{unit=0.25in}
	\begin{pspicture}(-8,-1)(8,1)
	\psaxes[arrowscale=1.5,arrows=<->,yAxis=false,labels=none](0,0)(-8,0) 
(8,0)
	\psxTick[linecolor=red](-7){-7}
	\psxTick[linecolor=red](0){0}
	\psxTick[linecolor=red](7){7}
	\psdots*[linecolor=red,dotsize=2pt 2](2,0)(0,0)
	\uput[90](2,0){$2$}
	\uput[90](0,0){$0$}
	\end{pspicture}
\end{center}
Hence, $2>0$.
}
\bookqu{In each of the following exercises, enter the inequality  
symbol $<$ or the symbol $>$ in the shaded box in order that the  
resulting inequality is a true statement.
}
\shortqu{$2\quad\fcolorbox{black}{yellow}{\phantom{M}}\quad 0$
}
\answerTeX{$2>0$
}
\end{question}

\end{topic}

\end{document}


This is all served off a linux server. What we need to know is how to  
compile the latter file so that all the pstricks output will shop up  
in the resulting pdf file. We're not wedded to pst-pdf, but are just  
looking for a robust way to compile the latter file. We need some  
solid advice.

Thanks.

D.


On May 14, 2009, at 1:44 PM, Herbert Voss wrote:

David Arnold schrieb:

> \documentclass[12pt]{article}
>
> %\usepackage{pst-pdf}
> \usepackage{pst-bar}
> \usepackage{pst-plot}
> \usepackage{pst-tree}
> \usepackage{pstricks-add}
>
> \begin{document}
> In the shaded box that follows, enter the inequality symbol $<$ or $>$
> so that the resulting inequality is a true statement.
>
> $-3\quad\psframe 
> [linewidth=2pt,fillstyle=solid,fillcolor=lightgray,framearc=0.2] 
> (0,0)(0.5,0.5)\quad
> -2$
>
> \end{document}

pst-pdf scans only the pspicture and psmatrix environment.

\documentclass[12pt]{article}

\usepackage{pst-pdf}
\usepackage{pstricks}
\def\psFrame[#1](#2)(#3){\begin{pspicture}(#2)(#3)\psframe[#1](#2)(#3) 
\end{pspicture}}

\begin{document}
In the shaded box that follows, enter the inequality symbol $<$ or $>$
so that the resulting inequality is a true statement.

$-3\quad\psFrame 
[linewidth=2pt,fillstyle=solid,fillcolor=lightgray,framearc=0.2](0,0) 
(0.5,0.5)\quad
-2$

\end{document}

Herbert

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



More information about the PSTricks mailing list