[Xy-pic] Fwd: pdflatex and xypic

Ross Moore ross at ics.mq.edu.au
Wed May 3 01:18:32 CEST 2006

Hi Scott,

On 03/05/2006, at 7:39 AM, Scott Morrison wrote:

> Hi Ross,
> thanks for the help! I've made it a little further, but I'm still
> having problems.
> I had to remove the second \documentclass line you had inside the
> psinputs environment; I think this was a mistake. Now everything is

Strange. It doesn't cause any problems for me.
My version of  pdftricks  is

.sty))) (/Users/rossmoor/texmf/tex/latex/pdftricks/pdftricks.sty

Package pdftricks Warning: ****************************************
(pdftricks)                Package pdftricks v,1.16 loaded
(pdftricks)                [psTricks support in PDF (CVR, ACL)]
(pdftricks)                ****************************************.

Unfortunately, the .log file of the spawned job is removed,
so I cannot easily check whether there are messages indicating
a possible problem.

> working (although I had to hack a unix-specific check that \write18
> was working inside pdftricks.sty...), except that the 'imported
> figure' the pdftricks is generating is being cropped too small, so the
> nice smooth arrow gets cut.

Hmm. That cropping doesn't happen to me.

> I've included below your (modified) code,
> and attached my output, the cropped pdf.

> I also don't understand your use of \setbox0; I understand what it
> does, but not why it's necessary. If I place the pdfpic environment
> directly at the place it's needed, I get 'runaway argument' tex
> errors.


This is because  {pdfpic}  is a verbatim-like environment.
It needs to read the environment contents verbatim, line-by-line,
to write this stuff into the  *-fig1.tex  file, for processing
via the spawned TeX run.

But Beamer's  {frame}  environment reads its contents as the
argument to a macro.  viz. (from a \tracingall):

\beamer at process@envbody ->\frame

\frame #1\end #2->\def \test {#1}\edef \beamer at begin@stack  
{\beamer at push@begins
#1\begin \end \expandafter \@gobble \beamer at begin@stack }\ifx \@empty  
begin at stack \global \beamer at envbody \expandafter {\the  
\beamer at envbody #1}\def
\reserved at a {#2} \ifx \reserved at a \beamer at frametext \endgroup \let  
\@next =\bea
mer at process@envbody \@checkend {#2}\else \let \@next = 
\beamer at process@expander
\fi \else \global \beamer at envbody \expandafter {\the \beamer at envbody  
#1\end {#2
}}\let \@next =\beamer at process@envbody \fi \@next
#1<-\box 0

This reading sets the catcodes and destroys line-endings.
Thus the end of the {pdfpic} environment is never found,
leading to the  'runaway argument'  errors.

By using \setbox, this kind of problem is bypassed.
But it is a bit of a hack, and it loses any settings that
the {frame} may have been providing.

>  Is there are way to place the pdfpic environments more
> naturally?

Yes, sort-of.
Use the  ps4pdf  package instead.

This requires first doing a run with  LaTeX+dvips+Ghostscript.
Then you rename the resulting .pdf file.
Then do the final run(s) with  pdfLaTeX.

The procedure isn't as straight-forward as with  pdftricks ,
but it may be more appropriate for this kind of LaTeX source.

Sometimes  pdftricks  is better,  other times  ps4pdf is better.
I have some documents in which *both* packages are used, to
include PostScript-generated graphics into a PDF created with

> Thanks, Scott Morrison
> \documentclass{beamer}
> %\usepackage[pdftex,all]{xy}
> \usepackage{pdftricks}
> \begin{psinputs}%
>  \usepackage[dvips,ps,all]{xy}
> \end{psinputs}
> \begin{document}
> \setbox0=\hbox{\vbox{%
> \begin{pdfpic}
> $\xymatrix{
>  X \ar@/^/[r] & Y
> }$
> \end{pdfpic}
> }}%  end of  \setbox 0
> \begin{frame}
> \box0 %
> \end{frame}
> \end{document}



Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia  2109                            fax: +61 +2 9850 8114

More information about the xy-pic mailing list