8 Generación y manipulación de gráficos

TEX probably has the best algorithms for formatting paragraphs and building pages from them. But in this era of ever-increasing information exchange, most publications do not limit themselves to text— the importance of graphical material has grown tremendously. TEX by itself does not address this area, as it deals only with positioning (glyph) boxes on pages. Knuth, however, provided a hook for implementing “features” that are not available in the basic language, via the

command. The latter command does not affect the output page being formatted,1 but TEX will put the material, specified as an argument to the

command, literally at the current point in the output, e.g., the .dvi file. The program that displays or prints that output then has to interpret the received information and load the graphic or execute the appropriate graphic operation. Engines that can directly produce Portable Document Format (PDF) offer other primitives to add raw data to the PDF output, but conceptually the process is the same: it is the backend that has to deal with the graphics.

The main problem with this approach was that different backends provide different methods and interfaces so that any TEX source file that used

directly became nonportable, working only with specific output devices or printers.

This problem was largely resolved with LaTEX 2ε, which provided a generalized driver-independent interface to include external graphic material and to scale and rotate LaTEX boxes.1 This interface is the subject of Section 8.1. It exists in the form of two implementations: the graphics package offers a simple interface, while the graphicx package provides a convenient key/value interface with additional features. Free-standing scaling and rotation and other manipulations are the subjects of Section 8.2.

A similar abstraction for line graphics was announced at the same time, but it took more than a decade until it was finally implemented. This and some applications thereof are discussed in Section 8.3. This section also talks about special graphic languages and as one useful application thereof generating QR codes with LaTEX.

Section 8.4 is then devoted to tcolorbox, a very comprehensive package for producing boxed material.

We conclude the chapter by taking a brief look at the powerful tikz package. There is no way we can do justice to this package, which builds a universe of its own — one could easily devote a whole book to it. Thus, all we try here is to give you an introduction to its basics and give a few teasers to show what it is capable of, but direct you to its documentation (more than a thousand pages) if you get hooked.