Sometimes ago I wrote a style file for drawing GANNT charts with pstricks. I typically compile my code with latex+dvips+ps2pdf, and everything works fine. However, I am now preparing a presentation where I also need to include a lot of jpg and png files, and I do not want to convert all of them into eps. So, I have to use pdflatex.
However, my style does not work with pdflatex. I tried to include packages:
\usepackage[pdf]{pstricks}
and also
\usepackage{auto-pst-pdf}
But I always get this error:
! LaTeX Error: \begin{pspicture} on input line 469 ended by \end{RTGrid}.
The problem is that I define an environment \begin{RTGrid} \end{RTGRid}
, which uses pspicture inside. It looks like auto-pst-pdf cannot correctly expand my environment.
Does anybody has any clue on how to solve this?
Here is my style file rtsched.sty (I apologize if my coding style is not very good!):
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{rtsched}[2005/01/01]
\typeout{'rtsched' style for Latex and PSTricks}
\typeout{Easily draw real-time schedules in TeX/Latex.}
\typeout{(c) 2005, Giuseppe Lipari, Pisa, Italy ([email protected])}
\typeout{Version 1.0}
\RequirePackage{multido}
\RequirePackage{pstricks}
\RequirePackage{keyval}
% something removed here
\def\RTGrid{\@ifnextchar[\@mygrid@begin{\@mygrid@begin[]}}
\def\RTGridBegin{\@ifnextchar[\@mygrid@begin{\@mygrid@begin[]}}
\def\@mygrid@begin[#1]#2#3{\setkeys{RT}{#1}%
\begin{pspicture}(0,0)(\RTWindowLength,\hy) %
%% draw grid (if not invisible)
\if\RTGridInvisible\RTDefGridInvisible
\multips(0,\sy)(0,\sy){\nsy}{\psline[linecolor=lightgray]{-}(0,\sy)(\RTWindowLength,\sy)}%
\multips(\sx,0)(\sx,0){\nsx}{\psline[linecolor=lightgray]{-}(0,\sy)(0,\hy)}%
\psframe(0,\sy)(\RTWindowLength,\hy)%
\else\relax
\fi
}
\def\endRTGrid{
\end{pspicture}%
}
\newcommand{\@compute@xx}[1]{
\xx = #1\sx
\divide \xx by \RTXScale
\advance \xx by \sx
}
\newcommand{\@compute@xxx}[1]{
\xxx = #1\sx
\divide \xxx by \RTXScale
\advance \xxx by \sx
}
\newcommand{\@compute@yy}[1]{
\yy = -3\sy \multiply \yy by #1
\advance \yy by \hy
}
\newcommand{\TaskArrDead}[4][nocommand=1]{
\setkeys{RT}{#1}%
\@compute@yy{#2}
\@compute@xx{#3}
\yyy = \yy \advance \yyy by 2\sy
\psline[linecolor=\RTLineColor]{->}(\xx,\yy)(\xx,\yyy)
\advance \xx by #4\sx
\psline[linecolor=\RTLineColor]{->}(\xx,\yyy)(\xx,\yy)
}
\newcommand{\TaskExecution}[4][nocommand=1]{
\setkeys{RT}{#1}%
\@compute@yy{#2}
\@compute@xx{#3}
\yyy = \yy \advance \yyy by \sy
\@compute@xxx{#4}
\psframe[fillstyle=\RTTaskFill,fillcolor=\RTTaskColor,linecolor=\RTLineColor](\xx,\yy)(\xxx,\yyy)
\advance \xx by \xxx \xx = .5\xx
\uput{2pt}[u](\xx,\yy){%
\usefont{T1}{phv}{m}{n}%
\fontsize{\RTNumberLabelSize}{\RTNumberLabelSize}%
\selectfont{\RTExecLabel}%
}
}
\endinput
And here is the example:
\documentclass{article}
\usepackage{rtsched}
\usepackage{auto-pst-pdf}
\begin{document}
\begin{RTGrid}{2}{10}
\TaskArrDead{1}{0}{5}
\TaskArrDead{1}{5}{5}
\TaskExecution{1}{0}{4}
\end{RTGrid}
\end{document}
PS: since I removed many lines of code from rtsched.sty, it may be possible that after solving the error described in this post, other errors will pop up. However, it is important for me to go past this error!
ps2eps
to add a bounding box, and finally useepstopdf
to create a pdf for inclusion in your presentation. This is likely to be a lot simpler than getting auto-pst-pdf to work with your code.