2

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!

5
  • 1
    give a complete example and not only fragments
    – user2478
    Sep 27, 2011 at 14:25
  • the example is quite long. I will try to isolate the error on a simple file, and get back to you.
    – knulp
    Sep 27, 2011 at 14:31
  • ok, now is somehow simpler (but still many lines of code). Should I edit the question?
    – knulp
    Sep 27, 2011 at 14:38
  • 1
    An alternative approach would be to create the chart as a single page postscript file (with no page number). Then use ps2eps to add a bounding box, and finally use epstopdf 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. Sep 27, 2011 at 15:08
  • @IanThompson I will consider your suggestion. However, I would first like to see if there is a direct solution. (I can also convert all those jpg and png into eps...)
    – knulp
    Sep 27, 2011 at 15:12

1 Answer 1

2

That example cannot work because a lot of variables are not defined. The reason why I cannot test it.

However, try this:

\pspicture(\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{\endpspicture}
2
  • It does not work. Try this link for the whole file: retis.sssup.it/~lipari/rtsched.sty
    – knulp
    Sep 27, 2011 at 16:05
  • To conclude: the problem was the use of \begin{pspicture}. I substituted it with \pspicture, and the corresponding closing with \endpspicture, and it works. Do you know why this happens?
    – knulp
    Sep 27, 2011 at 16:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .