### compiling egameps.sty in TeXnic Center

8 April 2010

Running Adobe Reader X? Use these instructions.

If you've spent any time typing extensive-form games in LaTeX, you've run into egameps.sty, by the formidable Martin Osborne (of A Course in Game Theory fame). It's an excellent package which will do just about anything you need — although I do wish I could make indifference sets with an arc, rather than horizontal or vertical lines (actually, it turns out this is possible, if convoluted) — and will allow you to extend it to produce everything else.

All is good and well, then, except for the fact that it (natively) compiles only to PostScript; for those of us stuck on Windows boxes, this is a painful reality. Not to knock Ghostview, but PostScript rendering on Windows is tedious at best, and frustrating and time-prohibitive at worst. Compared to the sleek, fast interface of Acrobat Reader (who can compete with a company with the funding of Adobe?), there's really no argument in my book; perhaps if I were working on a bigger project, PostScript would have its advantages, but as someone typing up a couple dozen pages of problem set per week, there's no cause.

How can we make the whole process easier, if perhaps violating the principle which drives PostScript compilation in the first place? For the purposes of this how-to, I'll be using TeXnicCenter, my favorite go-to editor in Windows. The way I use it, it's not much more than a GUI wrapper for VI, but it's comfortable and has some useful macros. If you're interested in doing this more generally (say, a system binding to run as :!latexpdf in VI or whatnot), the general principles should extend to any batch/Perl/Python script you can cook up.

The general principle at work here is that TeXnicCenter allows you to define Output Profiles, which correspond to different compilation mechanisms for your . Included with the program are default output profiles for compilation to DVI, PS, or PDF. We're going to chain these mechanisms together to get what we're looking for.

For the purposes of this set of instructions, we'll assume my MiKTeX install directory is C:\Program Files\MiKTeX 2.7.

• Step 1: from within TeXnicCenter, go to Build > Define Output Profiles; or simply press Alt + F7. This will bring up the Profiles dialog.
• Step 2: click on the Add button at the bottom left, to create and define a new output profile. Name the profile whatever you like; I chose LaTeX => DVI => PS => PDF, to make it as descriptive as possible.
• Step 3: open the Postprocessor tab. Here, we will define the three compilation steps.
• Step 4: click the New (Insert) button above the postprocessor list (which should be empty) — it's the button with a dashed rectangle and a starburst coming out the top-left corner. Type a name for this compilation step: LaTeX => DVI. In the Executable box, enter the path to the DVI compiler: C:\Program Files\MiKTeX 2.7\miktex\bin\latex.exe (again, that's because my install path is in program files; your MiKTeX directory may be located elsewhere). In the Arguments box, enter --src -interaction=nonstopmode "%Wm" (this, I stole from the DVI output profile predefined in TeXnicCenter).
• Step 5: add another postprocessor, this one for the step converting DVI to PS. Enter C:\Program Files\Miktex 2.7\miktex\bin\dvips.exe in the Executable box, and place "%bm.dvi" in the Arguments box; notice that the double-quotes in the arguments may be necessary! If your MiKTeX install path has spaces in it, you should have the double-quotes; if it doesn't, they won't hurt, so just leave them in. The arguments here say to read in the working filename sans extension, appended with .dvi, and use this as the DVI source to convert to PS.
• Step 6: add another postprocessor, this one for the step converting PS to PDF. Enter "C:\Program Files\Miktex 2.7\miktex\bin\ps2pdf.exe" in the Executable box, and place "%bm.ps" "%bm.pdf" in the Arguments box. These arguments say to read in the current file's PS compilation, and to spit out the same filename, sans extension, as a PDF.

At this point, the document should successfully compile: just select LaTeX => DVI => PS => PDF (or whatever you chose) from the dropdown in the top bar, and compile (Ctrl + F7). Compilation will take a hair longer than normal, as the background postprocessors run. You can watch the compilation icons in the top bar to see the status, as there's some nonverbose lag in the conversion from DVI to PS and then to PDF.

However, there is still a little more we can do. One of the nicest features of TeXnicCenter is the ability to view your document at any time, simply by pressing F5. I am going to assume you are using Adobe Reader, and that it is installed as C:\PROGRAM FILES\ADOBE\READER 8.0\READER\ACRORD32.EXE. To enable this, reopen the Output Profiles dialog (if you closed it), and select your new output profile.

• Step 1: open the Viewer tab.
• Step 2: in the Path to Executable box, enter C:\PROGRAM FILES\ADOBE\READER 8.0\READER\ACRORD32.EXE.
• Step 3: in all three subsections of the form, select the DDE command radio box; enter acroview in the Server box, and control in the Topic box.
• Step 4: enter [DocOpen("%bm.pdf")][FileOpen("%bm.pdf")] in the Command box in the View project's output and Forward search subsections.
• Step 5: in the Close document before running (La)TeX subsection, enter [DocClose("%bm.pdf")] into the Command' box.
TeXnicCenter should now be prepared to close the PDF upon compilation (to avoid read-only issues), and to properly open the file when asked.

Putting these together is not particularly difficult: with a little time to browse the existing output profiles which ship with TeXnicCenter, and some knowledge of the conversion and compilation utilities that come with MiKTeX, you can piece it together for yourself. Still, these are the kinds of things I'm always looking for when it's late at night an my game tree just won't compile the way I need it to.

\documentclass[12pt]{article}
\usepackage{pstricks}
\usepackage{egameps}

\begin{document}
\begin{center}
\begin{figure}[htb]
\hspace*{\fill}

%
% Notice the careful use of {}, (), and [] below
%
\begin{egame}(1000,1000)
\putbranch(500,900)(2,1){300}
\iib{N}{Hungry}{Thirsty}

\putbranch(200,750)(1,2){150}
\iib{K}{Eat}{Drink}[$10$][$9$]

\putbranch(800,750)(1,2){150}
\iib{K}{Eat}{Drink}[$9$][$10$]

\infoset(200,750){600}{}
\end{egame}
\end{figure}
\end{center}
\end{document}


This model is not realistic, as Nature cannot choose both

Happy LaTeXing!

PS You can do something similar with dvipng.exe in the MiKTeX distribution, but why bother when you've got LaTeX to png at 618034.com?

Update (2011-01-31): thanks to Rob in the comments for pointing out that the DDE instructions above no longer work in Adobe Reader X. There is a helpful set of instructions over at Agmon's blog, although the server seems to have issues from time to time (Google's cache of the page is ugly but contains all of the important stuff). Once I've upgraded to X, I'll update the instructions here, but as I see it it's useful to have instructions for multiple versions of Reader.

All included graphics are generated at LaTeX to png .

### contemporary entries

That works very well, thank you so much for posting!
R. (3 June 2010, 8:14am)
I am fairly new to TeX and have been using MikTeX. As far as I can tell I am following the above directions correctly. The document does correctly (I think) compile between Step 6 and Step 1 (generating files: .aux, .txt, .dvi, .pdf, .ps) and the PDF looks as it should.

However, when I go to view the document (F5) TeXnicCenter gives me the error "Cannot execute command". After following the second steps 1-5 the document compiles as before. Now when I try to view the document (F5), Adobe Reader opens (but does not open the PDF) and TeXnicCenter gives me the error "[DocOpen("%bm.pdf")][FileOpen("%bm.pdf")]" and then "Cannot execute command" on a separate line.

Note: I installed TeXnicCenter for the purpose of this article and I suspect this may be part of the problem. Any assistance greatly appreciated.
Rob White (20 January 2011, 7:43pm)
I found the solution to the problem. Adobe broke your instructions with the newest version of acrobat. A simple fix is found here.