# PDFTricks with standalone class

This is a PDFTricks question much more than a PSTricks question.

I am trying to use PDFTricks to compile a PSTricks document with the standalone class. I believe I have followed the manual's instructions, but must have missed something: I am compiling with pdflatex. I have allowed shell-escape as you can see from the first line of code in the preamble, and the log reports \write18 enabled. I get the following error:

! LaTeX Error: Environment psinputs undefined.


But I do have PDFTricks installed. As you can see from the code below, I pass pdftricks as an option to class standalone, now perhaps that's not allowed? Well, I also tried with an explicit usepackage{pdftricks} instead, and I get the following error (edited for clarity):

! LaTeX Error: Something's wrong--perhaps a missing \item.
...
l.82 \end{pdfpic}


The code works when compiled with PSTricks in a LaTeX -> DVI -> PDF workflow. See my earlier question PSTricks with standalone class and newpage or pagebreak

The PSTricks code I use is from: http://tug.org/PSTricks/Examples/bracket.tex

% !TeX document-id = {b33ceedb-1e8e-41cf-91b1-c1c63954e674}
% !TeX TXS-program:compile = txs:///pdflatex/[--shell-escape]
% Author: Peter S. Simon, Camarillo, CA
\documentclass[margin=3pt,pdftricks]{standalone}
\begin{psinputs}
\usepackage{pstricks}
\usepackage{pst-node}
\end{psinputs}
% \nbox draws an ovalbox labeled by the argument which is also used
% as the node label.
\newcommand\nbox[2][white]{\rnode{#2}{\psframebox[fillcolor=#1,fillstyle=solid]{\makebox[3.5\unitlength][l]%
{\scriptsize #2:}\rule[-.3\unitlength]{0cm}{0.6\unitlength}}}}

% \race[#1]{#2}{#3}{#4}{#5}
% \race draws two \nbox's vertically centered and separated by #4 (no units).
% #1 is the top \nbox argument, #2 is the race label, #3 is the bottom \nbox
% argument.
\vspace{#5\unitlength}\par\nbox[#1]{#4}}%
\ncline{-}{#2}{#4}\rput*(!
\psGetNodeCenter{#2} \psGetNodeCenter{#4} #2.x #4.x add 2 div #2.y #4.y add 2 div     ){\small\sf Race #3}}

\begin{document}

\psset{linewidth=1.5pt,framearc=0.3}
\begin{pdfpic}
\begin{pspicture}(0,0)(25,20)
%\psset{unit=0.95cm}
\rput[t]{0}(12.5,20){\huge\bf
\begin{tabular}[t]{c}
\hphantom{The} Intratribal Winner's Bracket
\end{tabular}}
\rput[t]{0}(17,19){\large\bf
\begin{tabular}[t]{ll}
Tribe: &
\underbar{\hphantom{The Shoshone Tribe}}
\\[2\baselineskip]
Race Time: &
\underbar{\hphantom{The Shoshone Tribe}}
\end{tabular}}
\rput{0}(1,19){\race[yellow!40]{Car1}{1}{Car9}{.5}}
\rput{0}(1,16.5){\race[blue!40]{Car5}{2}{Car13}{.5}}
\rput{0}(1,14){\race[red!40]{Car3}{3}{Car11}{.5}}
\rput{0}(1,11.5){\race[green!40]{Car7}{4}{Car15}{.5}}
\rput{0}(1,9){\race[magenta!40]{Car16}{5}{Car8}{.5}}
\rput{0}(1,6.5){\race[cyan!40]{Car12}{6}{Car4}{.5}}
\rput{0}(1,4){\race[lime!40]{Car6}{7}{Car14}{.5}}
\rput{0}(1,1.5){\race[black!20]{Car10}{8}{Car2}{.5}}
%
\rput{0}(5.5,17.75){\race[yellow!40]{W1}{9}{W2}{1.7}}
\rput{0}(5.5,12.75){\race[red!40]{W3}{10}{W4}{1.7}}
\rput{0}(5.5,7.75){\race[green!40]{W5}{11}{W6}{1.7}}
\rput{0}(5.5,2.75){\race[blue!40]{W7}{12}{W8}{1.7}}
%
\psset{angleB=180,linearc=5pt}
\ncdiag{-}{Car1}{W1}    \ncdiag{-}{Car9}{W1}
\ncdiag{-}{Car5}{W2}    \ncdiag{-}{Car13}{W2}
\ncdiag{-}{Car3}{W3}    \ncdiag{-}{Car11}{W3}
\ncdiag{-}{Car7}{W4}    \ncdiag{-}{Car15}{W4}
\ncdiag{-}{Car16}{W5}    \ncdiag{-}{Car8}{W5}
\ncdiag{-}{Car12}{W6}    \ncdiag{-}{Car4}{W6}
\ncdiag{-}{Car6}{W7}    \ncdiag{-}{Car14}{W7}
\ncdiag{-}{Car10}{W8}    \ncdiag{-}{Car2}{W8}
%
\rput{0}(10,15.25){\race[yellow!40]{W9}{17}{W10}{4.25}}
\rput{0}(10,5.25){\race[red!40]{W11}{18}{W12}{4.25}}
%
\ncdiag{-}{W1}{W9}    \ncdiag{-}{W2}{W9}
\ncdiag{-}{W3}{W10}    \ncdiag{-}{W4}{W10}
\ncdiag{-}{W5}{W11}    \ncdiag{-}{W6}{W11}
\ncdiag{-}{W7}{W12}    \ncdiag{-}{W8}{W12}
%
\rput{0}(14.5,10.25){\race[yellow!40]{W17}{23}{W18}{9}}
%
\ncdiag{-}{W9}{W17}    \ncdiag{-}{W10}{W17}
\ncdiag{-}{W11}{W18}    \ncdiag{-}{W12}{W18}
%
\rput{0}(19,12){\race[yellow!40]{W23}{30}{W29}{2}}
%
\ncdiag{-}{W17}{W23}    \ncdiag{-}{W18}{W23}
%
\rput[l]{0}(22,12){\nbox[green!40]{W30}}
%
\ncdiag{-}{W23}{W30}    \ncdiag{-}{W29}{W30}
%
\rput{0}(19,5){\race[blue!40]{W23}{31 (if necessary)}{W29}{2}}
\rput[l]{0}(22,5){\nbox[lime!40]{Champ}}
%
\ncdiag{-}{W23}{Champ}    \ncdiag{-}{W29}{Champ}
\end{pspicture}
\end{pdfpic}

\end{document}


An alternative preamble that doesn't work either is:

\documentclass[margin=3pt]{standalone}
\usepackage{pdftricks}
\begin{psinputs}
\usepackage{pstricks}
\usepackage{pst-node}
\end{psinputs}


Something wrong with my preamble?

• Where is the sense to use standalone and pdftricks? Both are used to create single pdf images. – user2478 Feb 14 '14 at 18:56
• The original code (see the url to bracket.tex) had this in the preamble: \documentclass[landscape]{article} \usepackage[margin=5mm]{geometry} \thispagestyle{empty} and my purpose in using standalone was to remove these lines and obtain a nicely cropped image. My purpose in using PDFTricks was to obtain a PDF in one compilation instead of 3. I do not know much about PDFTricks and particularly as I have not been able to make it work, and may never have to. ;-) Thanks for your help Herbert. – PatrickT Feb 14 '14 at 19:03
• Yes, that's ok. But you are using the standalone class to create a single pdf file. That is the reason why using the pdflatex call makes no real sense. – user2478 Feb 14 '14 at 19:05
• @Herbert, how do you suggest I compile the document? I tried XeLaTeX earlier with shell-escape, pdftricks and pdfpic, but that crashed. If I compile with XeLaTeX with usepackage[pdf]{pstricks} it produces the correct output except that the margin is wider than the requested 3pt, and it also generates errors. I compile with pdflatex only because I don't know any better. Thanks. – PatrickT Feb 14 '14 at 19:12
• Also, standalone is a class and pdftricks is a package, is there a reason I should know why the two couldn't be used together? Thanks. – PatrickT Feb 14 '14 at 19:13

A preamble that works with pdflatex, provided you have a relatively recent version, is without loading pdftricks and loading pstricks with the pdf option:

\documentclass[margin=3pt]{standalone}%
\usepackage[pdf]{pstricks}
\usepackage{pst-node}

\newcommand\nbox[2]{…}
............


and removing the pdfpic environment. This gives:

• Wow, could it be any simpler? Thanks!!! – PatrickT Feb 14 '14 at 18:57