Fig. 1: The structure of T EX Fig. 2: The structure of HiT EX Fig. 3: The structure of HINT HINT: Reflowing T EX output
T EX and the rest is a mixture of good and bad luck. HINT: Reflowing T EX output So let me start explaining the details. Martin Ruckert A first overview can be obtained by looking at Figure 1, 2, and 3. The first figure is a simplified de- piction of T EX’s structure: A complex input process- Introduction ing part translates T EX input files into lists of 16- Current implementations of T EX produce .pdf (por- bit integers, called tokens, which form the machine table document format) or .dvi (device indepen- language of T EX. The main loop of T EX is an inter- dent) files. These formats are designed for printing preter that executes these programs, which eventu- output on physical paper where the paper size and ally produce lots of boxes—most of them character perhaps even the output resolution is known in ad- boxes—and glue (and a few other items) that end vance. If these conditions are met, T EX, in spite of up on the so called contribution list. Every now and its age, still produces results of unsurpassed quality. then, the page builder will inspect the contribution Due to improvements in display size, resolu- list and moves items to the current page. As soon tion, and technology over the past decades, it has as it is satisfied with the current page, it will invoke become common practice to read T EX output on the user defined output routine, again a token list, screen not only before printing but also instead of which can inspect the proposed page, change it at printing. For viewing T EX output before printing, will, add insertions like footnotes, floating images, excellent programs[4][5] for “pre-viewing” are avail- page headers and footers, even store it for later use, able. The prefix “pre” indicates that these programs and eventually “ship out” the page to a .dvi file. intend to provide the user with a view that matches, HINT splits this whole machinery into two sep- as close as possible, the “final” appearance on pa- arate parts: frontend and backend. The backend is per. If, however, there is no intention of printing, the HINT viewer. The design goal is to reduce the for example if we read during a train ride on a mo- processing in the backend as much as possible be- bile device, then matching the appearance on paper cause we expect the viewer to run on small mobile is of no importance, and we would rather prefer if devices where reduced processing implies reduced the T EX output would instead adapt to the size and energy consumption and longer battery life. The resolution of our mobile device. Anyone who was frontend is the HiT EX version of T EX which is pre- forced to read a PDF file designed for output on vented from doing the full job of T EX because it letter paper on a 5” smartphone screen knows the does not know the values of hsize and vsize . As problem. a first approximation of this split, HiT EX can write For this reason, web browsers or ebooks use a the contribution list to a file and HINT can read reflowable text format. The HTML format, how- this file and feed it to the page builder as shown in ever, was never designed as a format for book print- Figure 2 and 3. ing, and epub , the ebook file format based on it, As an overall design goal, the HiT EX and HINT has inherited its deficiencies. Microsoft’s PDF reflow combination should produce exactly the same ren- solution—converting PDF files to word documents— dering as T EX for any given fixed hsize and vsize . is an indication of the need for reflowable file formats A closer look at Figure 3 reveals that the “Out- but a proprietary surrogate at best. put” arrow, representing the users output routine, Considering that the T EX engine is able to re- has disappeared; instead a new arrow, labeled “Tem- flow whole documents just by assigning new values plates”, has taken its place. Keeping the full power to hsize and vsize , it seems long overdue to put of T EX’s output routines would imply keeping the this engine to use for that purpose. full T EX interpreter, all the token lists generated The HINT project does just that. It defines a file from the T EX input file, and possibly even the files format and provides two utilities: HiT EX, a special that such an output routine might read or write in version of T EX to produce such files, and HINT , a the viewer. This seemed to be too high a price and stand alone viewer to display them. therefore output routines have been replaced by the template mechanism described below. This was the What is HINT ? single most important design decision guided by the desire to allow light-weight viewers to run efficiently Adopting the usual free software naming convention, with a minimum amount of resources. HINT is a recursive acronym for “ HINT is not T EX”. Several iterations were necessary to arrive at a But then, what is it? One answer could be: It‘s 90% suitable file format that was compact, easy to digest, and sufficiently expressive to provide the necessary Martin Ruckert
Recommend
More recommend