device independent file format
{{Short description|Typesetting file format}}
{{More citations needed|date=August 2014}}
{{Infobox file format
| name = Device-independent (DVI)
| icon =
| logo =
| screenshot = 225px
| caption = Evince previewing a DVI file. Note that referenced images are not displayed, because they are not part of the DVI file. Images will be added in by a print driver, such as dvips.
| extension = .dvi
| mime = application/x-dvi
(unofficial)
|_nomimecode = yes
| owner = David R. Fuchs
| typecode =
| genre = document
| containerfor =
| containedby =
| extendedfrom =
| extendedto =
}}{{For|the video display interface|Digital Visual Interface}}
The device independent file format (DVI) is the output file format of the TeX typesetting program, designed by David R. Fuchs in 1979.{{cite web | author = Donald E. Knuth | author-link = Donald E. Knuth | title = DVItype | version = Version 3.6 | date = December 1995 | url = http://www.ctan.org/pkg/dvitype | format = WEB source code; extract full documentation using WEAVE | access-date = 2008-05-07 | quote=The first DVItype program was designed by David Fuchs in 1979}} Unlike the TeX markup files used to generate them, DVI files are not intended to be human-readable; they consist of binary data describing the visual layout of a document in a manner not reliant on any specific image format, display hardware or printer. DVI files are typically used as input to a second program (called a DVI driver) which translates DVI files to graphical data. For example, most TeX software packages include a program for previewing DVI files on a user's computer display; this program is a driver. Drivers are also used to convert from DVI to popular page description languages (e.g. PostScript, PDF) and for printing.
TeX markup may be at least partially reverse-engineered from DVI files, although this process is unlikely to produce high-level constructs identical to those present in the original markup, especially if the original markup used high-level TeX extensions (e.g. LaTeX).
DVI differs from PostScript and PDF in that it does not support any form of font embedding, instead merely referencing external font names. (Both PostScript and PDF formats can embed their fonts inside the documents.) For a DVI file to be printed or even properly previewed, the fonts it references must be already installed. Like PDF, DVI uses a limited sort of machine language with termination guarantees that is not a full, Turing-complete programming language like PostScript.
As of 2004 there is a compilation of the specifications a DVI driver must implement by the "TUG DVI Driver Standards Committee".{{Cite web|url=http://mirrors.ctan.org/dviware/driv-standard/level-0/dvistd0.pdf|title=The DVI Driver Standard, Level 0|last=TUG DVI Driver Standards Committee|website=ctan.org}} It seems to be based on a TUGboat article of the same name from 1992, but which is much shorter.{{Cite journal|last=TUG DVI Driver Standards Committee|date=1992|title=The DVI Driver Standard, Level 0|url=https://www.tug.org/TUGboat/tb13-1/tb34dvistd.pdf|journal=TUGboat|volume=13|pages=54}} These documents do not specify the endianness, which is however big endian, as can be seen looking into a DVI file itself.
History
The DVI format was designed in 1979 by David R. Fuchs under the supervision of Donald E. Knuth, during the early development of the TeX typesetting system. Fuchs collaborated with Knuth for over eight years, contributing to both TeX and Metafont development.{{cite web | url=https://www.overleaf.com/blog/interview-with-david-fuchs-creator-of-the-original-dvi-file-format | title=Interview with David Fuchs, creator of the original DVI file format | website=Overleaf Blog | date=July 10, 2017 | access-date=2024-06-18}}
Standardization
In 1992, the TUG DVI Driver Standards Committee released the "DVI Driver Standard, Level 0," which outlined a minimum set of requirements for DVI drivers. The specification was intended to ensure interoperability between drivers and DVI-producing software.{{cite journal|last=TUG DVI Driver Standards Committee|date=1992|title=The DVI Driver Standard, Level 0|url=https://www.tug.org/TUGboat/tb13-1/tb34dvistd.pdf|journal=TUGboat|volume=13|pages=54}} This was later compiled into a more comprehensive PDF specification, hosted on CTAN.{{cite web|url=http://mirrors.ctan.org/dviware/driv-standard/level-0/dvistd0.pdf|title=The DVI Driver Standard, Level 0|last=TUG DVI Driver Standards Committee|website=ctan.org}}
Specification
The DVI format was designed to be compact and easily machine-readable. Toward this end, a DVI file is a sequence of commands which form "a machine-like language", in Knuth's words. Each command begins with an eight-bit opcode, followed by zero or more bytes of parameters. For example, an opcode from the group 0x00
through 0x7F
(decimal 127), set_char_i
, typesets a single character and moves the implicit cursor right by that character's width. In contrast, opcode 0xF7
(decimal 247), pre
(the preamble, which must be the first opcode in the DVI file), takes at least fourteen bytes of parameters, plus an optional comment of up to 255 bytes.
The DVI format specifies that the byte order is big-endian, though this is not explicitly defined in the standard documentation. This has been verified by inspecting raw DVI file content and interpreting its multi-byte values.{{cite book|last=Kopka|first=Helmut|author2=Patrick W. Daly|title=Guide to LaTeX|publisher=Pearson Education|edition=4th|year=2004|isbn=978-0-321-17385-0|page=362}}
In a broader sense, a DVI file consists of a preamble, one or more pages, and a postamble. Six state variables are maintained as a tuple of signed, 32-bit integers: . h and v are the current horizontal and vertical offsets from the upper-left corner (increasing v moves down the page), w and x hold horizontal space values, y and z, vertical.
These variables can be pushed to or popped from the stack. In addition, the current font f is held as an integer value, but is not pushed and popped with the rest of the state variables when the opcodes push
or pop
are encountered. Font spacing information is loaded from TFM files. The fonts themselves are not embedded in the DVI file, only referenced by an integer value defined in the relevant fnt_defi
op. (This is done exactly twice for each loaded font: once before it is referenced, and once in the postamble.) f contains an integer value of up to four bytes in length, though in practice, TeX only ever outputs font numbers in the range 0 through 255.
Similarly, the DVI format supports character codes up to four bytes in length, even though only the 0–255 range is commonly seen, as the TFM format is limited to that range. Character codes in DVI files refer to the character encoding of the current font rather than that of the system processing it. This means, for instance, that an EBCDIC-based system can process a DVI file that was generated by an ASCII-based system, so long as it has the same fonts installed.
Graphics as specials
The DVI format does not have support for graphics except for the most basic black-and-white boxes. Instead DVI has a general escape/extension mechanism, known as specials (expressed by the \special
command in TeX), which defers graphics (and color) to post-processing filters. There are numerous DVI specials, the most notable of which are PostScript specials, but other programs like tpic have their own.{{cite book|title=The LaTeX Graphics Companion|year=2008|publisher=Addison-Wesley|isbn=978-0-321-50892-8|author=Michel Goossens, Frank Mittelbach, Sebastian Rahtz, Denis Roegel, Herbert Voß|edition=2nd}}{{rp|6,17}}
Common uses of \special include PostScript instructions via dvips, tpic specials for basic diagrams, and color settings. The behavior and support for these specials vary between DVI drivers, making portability dependent on the driver used.{{cite book|title=The LaTeX Graphics Companion|year=2008|publisher=Addison-Wesley|isbn=978-0-321-50892-8|author=Goossens, Mittelbach, Rahtz, Roegel, Voß|edition=2nd|pages=6, 17}}
DVI versions
Although the DVI format has remained largely stable since its inception, there have been several minor extensions and de facto versioning conventions based on driver expectations rather than formal version numbers.
The original DVI specification, as designed by David R. Fuchs and described by Donald Knuth, was intended to be simple and forward-compatible. As such, DVI files include a fixed value in the preamble indicating the format version; this has historically remained at value 2, which is understood by all DVI drivers.{{cite journal |last=Fuchs |first=David |date=October 1982 |title=The format of TeX's DVI files |journal=TUGboat |volume=3 |issue=2 |pages=13–19 |url=http://www.tug.org/TUGboat/Articles/tb03-2/tb06software.pdf |access-date=2024-06-18}}
There is no official \"DVI version 1\", as TeX began emitting version 2 files from its early public release. According to the TUG DVI Driver Standards Committee, all conforming drivers are expected to support this version.{{cite web|url=http://mirrors.ctan.org/dviware/driv-standard/level-0/dvistd0.pdf|title=The DVI Driver Standard, Level 0|website=ctan.org}}
Some DVI extensions have been introduced via the use of `\special` commands rather than modifying the core format itself. This has enabled support for modern features such as color, hyperlinks, scalable graphics (e.g., PDF or SVG), and multi-byte character encodings without altering the base DVI structure.{{cite book|title=The LaTeX Graphics Companion|year=2008|publisher=Addison-Wesley|isbn=978-0-321-50892-8|author=Goossens, Mittelbach, Rahtz, Roegel, Voß|edition=2nd|pages=803}}
More advanced workflows—such as those relying on dvipdfmx or dvisvgm—may assume the presence of certain `\special` conventions (e.g., for Unicode or image embedding). However, these are not formal DVI version upgrades but rather usage conventions built atop the stable binary structure.
As of today, all standard TeX distributions (e.g., TeX Live, MiKTeX) still emit DVI files conforming to this long-standing version 2, ensuring compatibility with older and newer drivers alike.
= DVI-to-PDF converters =
dvipdf is a tool to translate DVI files (generated by TeX) to PDF files. In current Linux distributions like Ubuntu, it is a thin wrapper around dvips and Ghostscript, and copyrighted by Artifex Software (the makers of Ghostscript).{{cite web |url=http://manpages.ubuntu.com/manpages/intrepid/man1/dvipdf.1.html |title=Ubuntu Manpage: Dvipdf - Convert TeX DVI file to PDF using ghostscript and dvips |access-date=2014-08-03 |url-status=dead |archive-url=https://web.archive.org/web/20150909224433/http://manpages.ubuntu.com/manpages/intrepid/man1/dvipdf.1.html |archive-date=2015-09-09 }} A possibly different program with the same name—described as a modified version of dvips—was announced in the late 1990s by Sergey Lesenko,https://www.tug.org/TUGboat/tb17-3/tb52lese.pdf {{Bare URL PDF|date=March 2022}}https://www.tug.org/TUGboat/tb18-3/tb56lese.pdf {{Bare URL PDF|date=March 2022}}{{cite web | url=http://tex.loria.fr/general/eurotex98/eurotex98-lesenko.ps.gz | title=(La)TeX Navigator }} however it was apparently never released.{{cite book|author1=Helmut Kopka|author2=Patrick W. Daly|title=Guide to LaTeX|url=https://books.google.com/books?id=BTPgB6dzhG4C&pg=PT364|date=February 2008|orig-year=2004|publisher=Pearson Education|isbn=978-0-321-17385-0|at=§ 13.2.2 the dvipdfm driver|edition=4th; 9th printing}}{{Cite web|url=http://compgroups.net/comp.text.tex/where-art-dvipdf/1912300|archive-url=https://web.archive.org/web/20140811072544/http://compgroups.net/comp.text.tex/where-art-dvipdf/1912300|url-status=usurped|archive-date=August 11, 2014|title=Where art dvipdf? - comp.text.tex|website=compgroups.net}}
dvipdfm is a DVI-to-PDF translator developed by Mark A. Wicks. The early documentation of dvipdfm specifically mentions the limited availability of Lesenko's dvipdf as a reason for creating dvipdfm.Mark A. Wicks, [http://gaspra.kettering.edu/dvipdfm/dvipdfm-0.12.4.pdf Dvipdfm User’s Manual] {{webarchive|url=https://web.archive.org/web/20150706063108/http://gaspra.kettering.edu/dvipdfm/dvipdfm-0.12.4.pdf |date=2015-07-06 }}, Version 0.12.4 September 19, 1999, page 2 dvipdfm supports most of the newer special functions of the PDF format, including bookmarks, annotations, thumbnails, and dvips specials—a feature making possible the inclusion of Encapsulated PostScript (.eps) files like METAPOST output—as well inclusion of JPEG and PNG images; other features of dvipdfm include partial font embedding (reducing file size) and balancing the internal PDF document trees to speed up rendering of large documents.{{rp|798}} Many of these features (except for the direct support for .eps files{{Cite web|url=https://www.texfaq.org/cgi-bin/texfaq2html?label=dvipdfmgraphics|title=texfaq2html redirect emulating cgi-bin lookup on the original site|website=www.texfaq.org}}) are also present in pdfTeX, which typesets TeX directly to PDF. The 2004, 4th edition of the Guide to LaTeX compares them in the following way:{{cite book|author1=Helmut Kopka|author2=Patrick W. Daly|title=Guide to LaTeX|url=https://books.google.com/books?id=BTPgB6dzhG4C&pg=PT366|date=February 2008|orig-year=2004|publisher=Pearson Education|isbn=978-0-321-17385-0|at=§ 13.2.3 The pdfTEX program|edition=4th; 9th printing}}
{{blockquote|The dvipdfm program is in the original spirit of TEX, that uses DVI as a universal intermediate format for all outputs. Purists might tend to respect this ideal. After all, no one ever considered rewriting TEX to produce PostScript output directly. That said, one must consider that TEX was invented in the days when no one printer specification dominated the field. Today, PDF is much more than a printer format; it is the means of representing documents electronically. That alone would not justify preferring pdfTEX over a DVI-to-PDF converter, nor would the fact that it saves a processing step; the deciding argument is that pdfTEX has established itself as reliable, robust, and flexible. In the end, it is likely a question of which program one is more comfortable with, and which one has given the better results for the particular user.}}
dvipdfmx is an extended version of the dvipdfm DVI-to-PDF translator, included in current TeX distributions like TeX Live 2014{{Cite web|url=https://packages.debian.org/sid/texlive-base|title=Debian -- Details of package texlive-base in sid|website=packages.debian.org}} and MiKTeX 2.9.{{Cite web|url=https://miktex.org/pkg/az|title=MiKTeX Packages A-Z|website=miktex.org}} The primary goal of the dvipdfmx project is to support multi-byte character encodings and CJK character sets for East Asian languages.{{Cite web|url=http://project.ktug.org/dvipdfmx/|title=The DVIPDFMx Project|website=project.ktug.org}} dvipdfmx is also included (in a somewhat modified form) in XeTeX.{{rp|798}}
The 2nd, 2008 edition of the LaTeX Graphics Companion makes the following workflow suggestion:{{rp|803}}
{{blockquote|text=The route that you should follow depends mostly on the graphics material that you want to include. If most of it is in EPS format, the easiest way is to use latex, followed by dvips and finally ps2pdf. If all of your graphics files are already in PDF format, with some JPEG and PNG images, the more direct route is to run pdflatex. You can also combine both approaches by running latex and the dvipdfmx program. If you make a lot of use of PSTricks, you should look at [...] the pst-pdf package.}}
References and notes
{{Reflist}}
- {{cite journal |last=Fuchs |first=David |date=October 1982 |title=The format of TeX's DVI files |journal=TUGboat |volume=3 |issue=2 |pages=13–19 |url=http://www.tug.org/TUGboat/Articles/tb03-2/tb06software.pdf |access-date=2009-08-19 }}
External links
- [https://web.archive.org/web/20070403030353/http://www.math.umd.edu/~asnowden/comp-cont/dvi.html (Unofficial) description of the DVI file format]
- [http://www.macrotex.net/dvii/ TeX DVI file Information utility]
- [http://www.ctan.org/tex-archive/dviware/ CTAN: /tex-archive/dviware]
- [http://tex.stackexchange.com/questions/38145/why-does-pdflatex-produce-bigger-output-files-than-latexdvipdfm pdftex - Why does pdflatex produce bigger output files than latex+dvipdfm?]
- [https://github.com/TeX-Live/texlive-source/tree/master/texk/dviasm dviasm source code on GitHub]
{{TeX navbox}}
Category:Page description languages