The xypdf package

PDF output for diagrams in TEX and LaTEX with the XY-pic package

Most mathe­mati­cians and many scien­tists from other fields use the type­set­ting system TEX with the macro pack­age LaTEX for their publi­ca­tions. These pro­grams can pro­duce highest qual­ity type­set­ting, ready for publi­ca­tion and print­ing, and they have been used for count­less books, jour­nals and lecture notes over the years.

One exten­sion for TEX and LaTEX for draw­ing graphs and dia­grams is the pack­age XY-pic. This pack­age is a clas­sic in the TEX world and is widely used in mathe­mat­ical publi­ca­tions for dia­grams of all sorts. To draw graph­ical ele­ments, the XY-pic pack­age assem­bles glyphs in spe­cial fonts by default; e.g. diag­onal lines are com­posed of short dashes, and curves are drawn with many tiny, over­lap­ping dots. Alter­na­tively, XY-pic con­tains Post­script dri­vers which output at least some graph­ical ele­ments with generic Post­script com­mands and thus pro­duce much better qual­ity.

Today's pre­ferred format for circu­lat­ing docu­ments has become PDF, not Post­script, how­ever. Since the XY-pic pack­age was writ­ten in times when PDF was not wide­spread, it lacked PDF sup­port. My pack­age xypdf fills that gap. It gives XY-pic the abil­ity to draw graph­ical ele­ments (lines, curves and cir­cles in vari­ous styles) by generic PDF commands, thus pro­duc­ing high-​qual­ity output and re­duc­ing file size. Com­pare the output in the follow­ing fig­ure (10 times magni­fied, resolu­tion 960dpi).

without xypdf
graphics without xypdf
with xypdf
graphics with xypdf

For a more detailed de­scrip­tion, which de­scribes all fea­tures and the tech­ni­cal high­lights, read the docu­men­ta­tion. There are a few hid­den gems in the source code. E.g., the pack­age fea­tures a Bé­zier curve off­set al­go­rithm com­plete­ly writ­ten in TEX with its 31-bit fixed point arithmetic, only the four basic arith­metic opera­tions sup­por­ted and no chances to re­cover from an over­flow.

Bézier offset curves example

When I wrote the xypdf pack­age in 2010, the most recent XY-pic ver­sion 3.7, which was stable for many years, dated from 1999. Having trig­gered a new re­lease of XY-pic after 11 years, xypdf is now inte­grated in and dis­trib­uted together with XY-pic. This makes it easy to obtain and to use: install the XY-pic pack­age or update it to ver­sion 3.8 or newer, by the spe­cific method of your TEX dis­tri­bu­tion. Then write \xyoption{pdf} in your docu­ments, and enjoy!