2

I am currently typesetting a relatively long document (around 170 pages); and to avoid slowing down compilation, I am generating the figures externally and I am including them in the main tex file as pdfs via includegraphics. So far, I have had no major troubles compiling the figures, but I do when I draw the trees. Namely, when drawing the trees, standalone does not respect at all the real size of the figure. Before explaining my issue further, let me show you a figure that illustrates my problem:

enter image description here

This is a MWE that reproduces my problem:

\documentclass[]{standalone}
\usepackage{tikz} % To plot almost everything.
\usepackage{pstricks,pst-node,egameps} % To get extensive form games. 

\begin{document}
\begin{egame}(0,350)
\putbranch(100,340)(2,1){200}
\iib{$1$}[o]{$D$}{$A$}[c][$1,1$][]
\putbranch(300,240)(2,1){200}
\iib{$2$}[o]{$D$}{$A$}[c][$0,3$][]
\putbranch(500,140)(2,1){200}
\iib{$1$}[o]{$D$}{$A$}[c][$2,2$][]
\putbranch(700,40)(2,1){200}
\iib{$2$}[o]{$D$}{$A$}[c][$1,4$][]
\putbranch(900,-60)(2,1){200}
\iib{$1$}[o]{$D$}{$A$}[c][$3,3$][$...$]
\putbranch(1100,-210)(2,1){200}
\iib{$1$}[o]{$D$}{$A$}[c][$99,99$][]
\putbranch(1300,-310)(2,1){200}
\iib{$2$}[o]{$D$}{$A$}[c][$98,101$][$100,100$]
\end{egame}
\end{document}

I am drawing the trees using the egameps package (full documentation here: https://www.economics.utoronto.ca/osborne/latex/egameps.pdf) because it has a simple syntax and it's the standard when typesetting Game Theory. Therefore, I DO want to stick to this package, which relies on pstricks (it can also work with pdftricks instead). The thing is that I can't get standalone to properly get the size of the tree; therefore getting incomplete trees or/and too large margins. The problem could supposedly be solved by correctly specifying the size of the tree in:

\begin{egame}(0,350)

Where (0,350) indicates a figure of 0mm width and 350mm height. However, I am absolutely unable to compute the correct size of the tree. Could anybody help me specify the correct size of the tree? I need a way to compute the correct size because I have several trees to draw and I have this problem with most of them. Therefore, manually gessing the size of this specific tree is not enough. Notice also that I have read the full package pdf twice; but no matter what I do, I never get the size right.

Alternatively, if specifying the correct size of every tree is too hard; maybe someone can provide an alternative way (via a specification in standalone?) to force standalone to get the document size right even if the tree size is wrongly specified. That would be enough for me.

Also, maybe someone knows an alternative documentclass that will not generate this issue but just the output I desire. Such a solution would also suffice for me.

Notice that compiling the figure as an article and then transforming it into eps is something I have tried and I do NOT like it because when transforming the pdf into an eps, some things (like Greek letters or other fancy stuff) change and look weird. Also, including eps into my main tex file slows down compilation a lot, and I precisely do not want that. Though I could generate the figure with article documentclass, then transforming into eps and then reverting the eps to pdf again with the correct sizes, I don't think this is a good working solution (it's to time expensive and the fancy stuff like the Greek letters would still be wrong).

If anyone can help me with this, I'd be VERY happy (I am aware that this is a very user-specific question and I am aware I might not get any answer; but I need to get this right!).

  • Trial-and-error, I am afraid, will be the only way to get the fitting bounding box for the egame environment, because the size of the underlying pspicture environment must be set manually in general (in contrast to tikzpicture of the TikZ package). – AlexG Jan 25 '17 at 11:53
  • I hope you are wrong; but I am afraid you are very likely right. However, if no one comes up with a way of getting this right without using a trial-error approach, I will try to contact the package author by mail, and see what he replies. – Héctor Jan 25 '17 at 13:02
2

The code of egame is totally buggy. The internal defined pspicture has completely wrong coordinates. However, you can use instead directly the pspicture environment:

\documentclass[pstricks]{standalone}
\usepackage{pstricks,pst-node,egameps} % To get extensive form games. 

\begin{document}
\psset{unit=0.1mm}\initialtrue
\begin{pspicture}(-200,-500)(1600,400)
    \putbranch(100,340)(2,1){200}
    \iib{$1$}[o]{$D$}{$A$}[c][$1,1$][]
    \putbranch(300,240)(2,1){200}
    \iib{$2$}[o]{$D$}{$A$}[c][$0,3$][]
    \putbranch(500,140)(2,1){200}
    \iib{$1$}[o]{$D$}{$A$}[c][$2,2$][]
    \putbranch(700,40)(2,1){200}
    \iib{$2$}[o]{$D$}{$A$}[c][$1,4$][]
    \putbranch(900,-60)(2,1){200}
    \iib{$1$}[o]{$D$}{$A$}[c][$3,3$][$...$]
    \putbranch(1100,-210)(2,1){200}
    \iib{$1$}[o]{$D$}{$A$}[c][$99,99$][]
    \putbranch(1300,-310)(2,1){200}
    \iib{$2$}[o]{$D$}{$A$}[c][$98,101$][$100,100$]
\end{pspicture}
\end{document}

enter image description here

The internal unit is set by egame to 0.1mm, if not modified by the user. The first node starts at 100,340 with arms of 200 to the left and right. The last node is set at 1300,-310 also with arms of 200. This is the reason why I choosed for the pspicture environment at lower left coordinates (-200,-500) and upper right (1600,400). Something like \begin{egame}(0,350) is without any sense: it creates a drawing area of 0 width and 350 height.

  • Thank you a freaking lot! I am willing to mark your answer as accepted, but I'd love you to explain to me (a little) what (-2cm,-150pt)(440pt,120pt) is and how you got these numbers. That is: (a) what do these numbers do? And, second, (b) how did you compute them? :) – Héctor Jan 25 '17 at 13:19
  • 1
    I looked into your code and thought that (0,350) maybe the center of your image. A closer look into the package would tell me if I am right, but I have not the time unitl evening. So I tried to find a use full coordinates for pstricks which are then used by standalone for the cropping. – user2478 Jan 25 '17 at 14:09
  • If I am not wrong, (0,350) are the width and the height, respectively. But even knowing that, I don't seem to be able to get those numbers right at all. If later on you feel like taking a look at the package, I'll be extremely grateful; otherwise, your solution works perfectly fine. However, I still don't get what (-2cm,-150pt)(440pt,120pt) are and do; but I assume you found those numbers manually through a trial-and-error approach, right? – Héctor Jan 25 '17 at 14:14
  • 1
    yes, you are right. But it should be no problem to make it better if looking into the gameps. Will see ... – user2478 Jan 25 '17 at 14:44
  • 1
    See my edited answer for the explanation and a modified solution. – user2478 Jan 25 '17 at 21:07
4

Here is another solution to use the istgame package, which is based on TikZ. The istgame environment is almost the same as the tikzpicture environment. With the istgame package (basically tikz tree), you don't need to worry about finding correct coordinates. Instead, you can use \xtdistance to determine the shape of a game tree.

enter image description here

\documentclass[border=1pt]{standalone}

\usepackage{istgame}

\begin{document}

\begin{istgame}[scale=1]
% tree
\tikzset{oval node/.style={ellipse node,draw=none}}
\xtdistance{15mm}{50mm}
% \xtdistance{15mm}{30mm}
\istrooto(0){1}
  \istb{D}[fill=white]{1,1}
  \istb{A}[fill=white]
  \endist
\istrooto(1)(0-2){2}
  \istb{D}[fill=white]{0,3}
  \istb{A}[fill=white]
  \endist
\istrooto(2)(1-2){1}
  \istb{D}[fill=white]{2,2}
  \istb{A}[fill=white]
  \endist
\istrooto(3)(2-2){2}
  \istb{D}[fill=white]{1,4}
  \istb{A}[fill=white]
  \endist
\istrooto(4)(3-2){1}
  \istb{D}[fill=white]{3,3}
  \istb{A}[fill=white]{\dots}
  \endist
\istrooto(5)([yshift=-5mm]4-2){1}
  \istb{D}[fill=white]{99,99}
  \istb{A}[fill=white]
  \endist
\istrooto(6)(5-2){2}
  \istb{D}[fill=white]{98,101}
  \istb{A}[fill=white]{100,100}
  \endist
\end{istgame}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.