DVISVGM(1)
โจ NAME โจ
Okay bestie, welcome to dvisvgm(1) from the dvisvgm Manual ๐ โ dvisvgm converts DVI, EPS, and PDF files to the XML-based SVG format. Slay.
๐ SYNOPSIS ๐
dvisvgm [options] file[.dvi]
dvisvgm --eps [options] file1[.eps] file2[.eps] ...
dvisvgm --pdf [options] file[.pdf]
๐ DESCRIPTION ๐
So the command-line utility dvisvgm converts DVI files โ the kind TeX/LaTeX makes โ to the XML-based scalable vector graphics format SVG. It supports the classic DVI version 2 as well as version 3 (created by pTeX in vertical mode), and the XeTeX versions 5 to 7 which are also known as XDV. Besides the basic DVI commands, dvisvgm also evaluates many so-called specials which heavily extend the capabilities of the plain DVI format. For a more detailed overview, see section Supported Specials below. ๐
Since the current SVG standard 1.1 doesnโt specify multi-page graphics, dvisvgm creates separate SVG files for each DVI page. Because of compatibility reasons, only the first page is converted by default. In order to select a different page or arbitrary page sequences, use option -p which is described below.
SVG is a vector-based graphics format and therefore dvisvgm tries to convert the glyph outlines of all fonts referenced in a DVI page section to scalable path descriptions. The fastest way to achieve this is to extract the path information from vector-based font files available in PFB, TTF, or OTF format. If dvisvgm is able to find such a file, it extracts all necessary outline information about the glyphs from it. โจ
However, TeXโs former main source for font descriptions is Metafont, which produces bitmap output in terms of GF files. Thatโs why not all obtainable TeX fonts are available in a scalable format. In these cases, dvisvgm tries to vectorize Metafontโs output by tracing the glyph bitmaps. The results are not as perfect as most (manually optimized) PFB or OTF counterparts, but are nonetheless really nice in most cases. ๐ซถ
When running dvisvgm without option --no-fonts, it creates font elements (<font>...</font>) to embed the font data into the SVG files. Unfortunately, only few SVG renderers support these elements. Most web browsers and vector graphics applications donโt evaluate them properly so that the text components of the resulting graphics might look strange. In order to create more compatible SVG files, command-line option --no-fonts can be given to replace the font elements by plain graphics paths. Most web browsers (but only few external SVG renderers) also support WOFF and WOFF2 fonts that can be used instead of the default SVG fonts. Option --font-format offers the functionality to change the format applied to the fonts being embedded. This, however, only works when converting DVI files. Text present in PDF and PostScript files is always converted to path elements. ๐
๐ OPTIONS ๐
dvisvgm provides a POSIX-compliant command-line interface with short and long option names. They may be given before and/or after the name of the file to be converted. Also, the order of specifying the options is not significant, i.e. you can add them in any order without changing dvisvgmโs behavior. Certain options accept or require additional parameters which are directly appended to or separated by whitespace from a short option (e.g. -v0 or -v 0). Long options require an additional equals sign (=) between option name and argument but without any surrounding whitespace (e.g. --verbosity=0). Multiple short options that donโt expect further parameters can be combined after a single dash (e.g. -ejs rather than -e -j -s). ๐
Long option names may also be shortened by omitting trailing characters as long as the shortened name is still unambiguous. For example, option --exact-bbox can be shortened to --exact, --exa, or --ex. In case of ambiguous abbreviations, dvisvgm prints an error message together with all matching option names.
-b,--bbox=fmtโ sets the bounding box of the generated SVG graphic to the specified format. This option only affects the conversion of DVI files. SVG documents generated from PDF and PostScript always inherit the bounding boxes of the input files.
Okay so fmt takes either one of the format specifiers listed below, or a sequence of four comma- or whitespace-separated length values x1, y1, x2 and y2. The latter define the absolute coordinates of two diagonal corners of the bounding box. Each length value consists of a floating point number and an optional length unit (pt, bp, cm, mm, in, pc, dd, cc, or sp). If the unit is omitted, TeX points (pt) are assumed.
Itโs also possible to give only one length value l. In this case, the minimal bounding box is computed and enlarged by adding (-l,-l) to the upper left and (l,l) to the lower right corner.
Additionally, dvisvgm also supports the following format specifiers:
International DIN/ISO paper sizes โ An, Bn, Cn, Dn, where n is a non-negative integer, e.g. A4 or a4 for DIN/ISO A4 format (210mm ร 297mm).
North American paper sizes โ invoice, executive, legal, letter, ledger
Special bounding box sizes
dviโ page size stored in the DVI fileminโ computes the minimal/tightest bounding boxnoneโ no bounding box is assignedpapersizeโ box sizes specified bypapersizespecials present in the DVI filepreviewโ bounding box data computed by the preview package (if present in the DVI file)
Page orientation โ the default page orientation for DIN/ISO and American paper sizes is portrait, i.e. width < height. Appending -landscape or simply -l to the format string switches to landscape mode (width > height). For symmetry reasons you can also explicitly add -portrait or -p to indicate the default portrait format. Note that these suffixes are part of the size string and not separate options. Thus, they must directly follow the size specifier without additional blanks. Furthermore, the orientation suffixes canโt be used with dvi, min, and none.
Note: Option-b,--bboxonly affects the bounding box and does not transform the page content. Hence, if you choose a landscape format, the page wonโt be rotated. ๐
-B,--bitmap-format=fmtโ this option sets the image format used to embed bitmaps that are extracted from PostScript or PDF data. By default,dvisvgmembeds all bitmaps as JPEG images because itโs the most compact of the two formats supported by SVG. To select the alternative lossless PNG format,--bitmap-format=pngcan be used. There are some more format variantsdvisvgmcurrently supports even thoughjpegandpngshould be sufficient in most cases. The following list gives an overview of the known format names which correspond to names of Ghostscript output devices.noneโ disable processing of bitmap imagesjpegโ color JPEG formatjpeggrayโ grayscale JPEG formatpngโ grayscale or 24-bit color PNG format depending on current color spacepnggrayโ grayscale PNG formatpngmonoโ black-and-white PNG formatpngmonodโ dithered black-and-white PNG formatpng16โ 4-bit color PNG formatpng256โ 8-bit color PNG formatpng16mโ 24-bit color PNG format
Since the collection of supported output devices can vary among local Ghostscript installations, not all formats may be available in some environments. dvisvgm quits with a PostScript error message if the selected output format requires a locally unsupported output device.
The two JPEG format specifiers accept an optional parameter to set the IJG quality level which must directly follow the format specifier separated by a colon, e.g. --bitmap-format=jpeg:50. The quality value is an integer between 0 and 100. Higher values result in better image quality but lower compression rates and therefore larger files. The default quality level is 75 which is applied if no quality parameter is given or if itโs set to 0.
-C,--cache[=dir]โ to speed up the conversion process of bitmap fonts,dvisvgmsaves intermediate conversion information in cache files. By default, these files are stored in$XDG_CACHE_HOME/dvisvgm/or$HOME/.cache/dvisvgmifXDG_CACHE_HOMEis not set. If you prefer a different location, use option--cacheto overwrite the default. Furthermore, it is also possible to disable the font caching mechanism completely with option--cache=none. If argument dir is omitted,dvisvgmprints the path of the default cache directory together with further information about the stored fonts. Additionally, outdated and corrupted cache files are removed. ๐ง-j,--clipjoinโ this option tellsdvisvgmto compute all intersections of clipping paths itself rather than delegating this task to the SVG renderer. The resulting SVG files are more portable because some SVG viewers donโt support intersecting clipping paths which are defined byclipPathelements containing aclip-pathattribute.--colorโ enables colorization of messages printed during the conversion process. The colors can be customized via environment variableDVISVGM_COLORS. See the Environment section below for further information. ๐ธ--colornamesโ by default,dvisvgmexclusively uses RGB values of the form#RRGGBBor#RGBto represent colors in the SVG file. The latter is a short form for colors whose RGB components each consist of two identical hex digits, e.g.#123equals#112233. According to the SVG standard, itโs also possible to use color names (likeblackanddarkblue) for a limited number of predefined colors (https://www.w3.org/TR/SVG11/types.html#ColorKeywords). In order to apply these color names rather than their RGB values, calldvisvgmwith option--colornames. All colors without an SVG color name will still be represented by RGB values.--commentsโ adds comments with further information about selected data to the SVG file. Currently, only font elements and font CSS rules related to native fonts are annotated.--currentcolor[=color]โ this option tellsdvisvgmto replace the specified color with CSS variablecurrentColorwhich holds the current foreground color set by CSS propertycolor. This way an application or website can change the color via CSS without the need to modify the SVG code. ๐ฆ
The optional argument of --currentcolor is where you tell it which RGB color gets swapped out โ and bestie, it has to be a hex color value with either six or three digits ([https://www.w3.org/TR/css-color/#typedef-hex-color](https://www.w3.org/TR/css-color/#typedef-hex-color)) with a # character in front, like #0000ff or #00f for blue. If you justโฆ don't give the optional argument? Black is assumed. Default behavior slay ๐
--embed-bitmapsโ this one shoves the actual contents of your bitmap files into the generated SVG files instead of just dropping file references in there. Because of the base64-encoded data, the SVG files usually end up much bigger, but lowkey more portable at the same time, because they don't rely on external bitmap files. ๐ซถ
This option only affects bitmaps referenced in DVI/XDV files โ like by \includegraphics or the special command dvisvgm:img (see below). Bitmaps that are present in PostScript or PDF files are always embedded, no discussion. Also go peek at option bitmap-format.
-E,--epsโ give it this option anddvisvgmdoes not expect a DVI, it expects a single or multiple EPS input files and tries to convert them to SVG. To do that, a singlepsfilespecial command is created and forwarded to the PostScript special handler. Heads up though: this option is only available ifdvisvgmwas built with PostScript support enabled, and it needs Ghostscript to be available. See option--libgsfor more info. โจ-e,--exact-bboxโ ok so this one tellsdvisvgmto compute the precise bounding box of each character. By default, the values stored in a font's TFM file are used to determine a glyph's extent. But those values were made to implement optimal character placements, not to represent exact dimensions โ so they don't necessarily line up with the bounds of the visual glyphs ๐ญ. Which means width and/or height of some glyphs may be larger (or smaller) than the respective TFM values, and as a result you can get clipped characters at the bounds of the SVG graphics. With--exact-bboxgiven,dvisvgmanalyzes the actual shape of each character and derives a usually tight bounding box. Iconic.
This option only affects the processing of DVI files. When converting EPS or PDF files, the bounding box information stored in those files is used to derive the SVG bounding box. No cap.
-f,--font-format=formatโ picks the file format used to embed font data into the generated SVG output when converting DVI or PDF files. The latter (PDF) requires the newmutool-based PDF handler introduced withdvisvgm3.0 (also see option--pdf). Heads up:--font-formathas no effect when converting PDF or PostScript files using Ghostscript โ text fragments in those files are then always converted to path elements. Periodt.
Following formats are supported: SVG (that's the default), TTF (TrueType), WOFF, and WOFF2 (Web Open Font Format version 1 and 2). By default, dvisvgm creates unhinted fonts that might look bad on low-resolution devices ๐. To improve the display quality, the generated TrueType, WOFF, or WOFF2 fonts can be autohinted. The autohinter is enabled by appending ,autohint or ,ah to the font format, e.g. --font-format=woff,autohint or --fwoff,ah. This functionality requires the ttfautohint library ([https://freetype.org/ttfautohint](https://freetype.org/ttfautohint)). If it's not available or can't be found, dvisvgm issues a corresponding warning message.
Option --font-format is only available if dvisvgm was built with WOFF support enabled. ๐ฆ
-m,--fontmap=filenamesโ loads and evaluates a single font map file or a whole sequence of font map files. These files are required to resolve font file names and encodings.dvisvgmdoes not provide its own map files but tries to read available ones coming withdvipsordvipdfm. If option--fontmapis omitted,dvisvgmlooks for the default map filesdvisvgm.map,ps2pk.map,pdftex.map,dvipdfm.map, andpsfonts.map(in this order). Otherwise, the files given as option arguments are evaluated in the given order. Multiple filenames must be separated by commas without leading and/or trailing whitespace. ๐
By default, redefined mappings do not replace previous ones. But each filename can be preceded by an optional mode specifier (+, -, or =) to change this behavior:
+mapfileโ only those entries in the given map file that don't redefine a font mapping are applied, i.e. fonts already mapped keep untouched. That's also the default mode if no mode specifier is given.-mapfileโ ensures that none of the font mappings defined in the given map file are used, i.e. previously defined mappings for the specified fonts are removed.=mapfileโ all mappings defined in the map file are applied. Previously defined settings for the same fonts are replaced.
If the first filename in the filename sequence is preceded by a mode specifier, dvisvgm loads the default font map (see above) and applies the other map files afterwards. Otherwise, none of the default map files will be loaded automatically.
Examples: --fontmap=myfile1.map,+myfile2.map loads myfile1.map followed by myfile2.map where all redefinitions of myfile2.map are ignored. --fontmap==myfile1.map,-myfile2.map loads the default map file followed by myfile1.map and myfile2.map where all redefinitions of myfile1.map replace previous entries. Afterwards, all definitions for the fonts given in myfile2.map are removed from the font map tree.
For further information about the map file formats and the mode specifiers, see the manuals of dvips ([https://tug.org/texinfohtml/dvips.html](https://tug.org/texinfohtml/dvips.html)) and dvipdfm ([https://ctan.org/tex-archive/dviware/dvipdfm](https://ctan.org/tex-archive/dviware/dvipdfm)).
dvisvgm supports both the dvips and the dvipdfm map file formats. It extends both variants by two include statements that allow for loading other map files inside a map file. The syntax is as follows:
#include [<modechar>] <filename|filepath>
#includefirst [<modechar>] <filename|filepath>
They must be placed on a separate line and start at the first column of that line. Otherwise, they are ignored ๐ซ . While the first variant always tries to include the specified file, #includefirst is only executed once, i.e. once a file was successfully included by this statement, all subsequent #includefirst lines are skipped. This can be used to include one of several alternative files, whereby the first one found is loaded and all others are ignored. Chef's kiss.
The optional parameter <modechar> (which can be +, -, or =) determines how to integrate the data read from the included file into the already present mapping data. They work the same way as the mode specifiers described above. If the <modechar> parameter is omitted, it defaults to +.
The following filename or file path specifies the file to include. In case of plain filenames (without path indicators), the files are looked up using the TeX file search functionality, i.e. files in the TeX directory tree can easily be added. Relative paths are relative to the location of the file containing the #include statement. Path components must be separated by forward slashes (/), also on Windows systems. ๐
Examples: #include pdftex.map looks for pdftex.map in the current working directory and in the TeX directory tree. #include ./pdftex.map, on the other hand, looks for pdftex.map only in the directory where the including file is located.
--grad-overlapโ tellsdvisvgmto create overlapping grid segments when approximating color gradient fills (also see option--grad-segmentsbelow). By default, adjacent segments don't overlap but only touch each other like separate tiles. However, this alignment can lead to visible gaps between the segments because the background color usually influences the color at the boundary of the segments if the SVG renderer uses anti-aliasing to create smooth contours. One way to avoid this and to create seamlessly touching color regions is to enlarge the segments so that they extend into the area of their right and bottom neighbors. Since the latter are drawn on top of the overlapping parts, the visible size of all segments keeps unchanged โ just the former gaps disappear as the background is now completely covered by the correct colors. Currently,dvisvgmcomputes the overlapping segments separately for each patch of the mesh (a patch mesh may consist of multiple patches of the same type). Therefore, there still might be visible gaps at the seam of two adjacent patches. ๐ญ--grad-segments=numberโ determines the maximum number of segments per column and row used to approximate gradient color fills. Since SVG 1.1 only supports a small subset of the shading algorithms available in PostScript,dvisvgmapproximates some of them by subdividing the area to be filled into smaller, monochromatic segments. Each of these segments gets the average color of the region it covers. So increasing the number of segments leads to smaller monochromatic areas and therefore a better approximation of the actual color gradient. As a drawback though, more segments imply bigger SVG files because every segment is represented by a separate path element. โญ
Currently, dvisvgm supports free- and lattice-form triangular patch meshes as well as Coons and tensor-product patch meshes. They are approximated by subdividing the area of each patch into a nรn grid of smaller segments. The maximum number of segments per column and row can be changed with option --grad-segments.
--grad-simplify=deltaโ if the size of the segments created to approximate gradient color fills falls below the given delta value,dvisvgmreduces their level of detail. For example, Bรฉzier curves are replaced by straight lines, and triangular segments are combined to tetragons. For a small delta, these simplifications are usually not noticeable but reduce the size of the generated SVG files significantly. ๐ธ-h,--help[=mode]โ prints a short summary of every available command-line option, and honestly? iconic behavior. The optional mode parameter is an integer value between0and2, and it selects the display variant of the help text. Mode0lists all options divided into categories with section headers โ this is also the default ifdvisvgmis called without parameters. Mode1lists all options ordered by the short option names, while mode2sorts the lines by the long option names.
๐ก little legend moment: values in brackets after the description text indicate the default parameter of the option. They get applied if an option with a mandatory parameter isn't used, or if an optional parameter is omitted. For example, option --bbox requires a size parameter which defaults to min if --bbox isn't used. Option --zip, which isn't applied by default, accepts an optional compression level parameter โ and if that's omitted, the stated default value 9 is used. iykyk ๐
--keepโ turns off the removal of temporary files, the ones created by Metafont (usually.gf,.tfm, and.logfiles) or by the TrueType/WOFF module. no more vanishing acts โจ--libgs=pathโ okay so this one's got lore. This option is only available if the Ghostscript library is not directly linked todvisvgmand if PostScript support wasn't completely disabled during compilation. In that case,dvisvgmtries to load the shared GS library dynamically during runtime. By default it expects the library's name to belibgs.so.X(on Unix-like systems, whereXis the ABI version of the library) orgsdll32.dll/gsdll64.dll(Windows). Ifdvisvgmdoesn't find the library, option--libgscan be used to specify the correct path and filename, e.g.--libgs=/usr/local/lib/libgs.so.9or--libgs=\gs\gs9.25\bin\gsdll64.dll.
Alternatively, it's also possible to assign the path to environment variable LIBGS, e.g. export LIBGS=/usr/local/lib/libgs.so.9 or set LIBGS=\gs\gs9.25\bin\gsdll63.dll. LIBGS has less precedence than the command-line option, i.e. dvisvgm ignores variable LIBGS if --libgs is given. the flag always wins, periodt ๐
-L,--linkmark=styleโ picks the method for how to mark hyperlinked areas. The style argument can take one of the valuesnone,box, andline, whereboxis the default โ i.e. a rectangle is drawn around the linked region if option--linkmarkis omitted. Style argumentlinejust draws the lower edge of the bounding rectangle, andnonetellsdvisvgmnot to add any visible objects to hyperlinks. The lines and boxes get the current text color selected. In order to apply a different, constant color, a colon followed by a color specifier can be appended to the style string. A color specifier is either a hexadecimal RGB value of the form#RRGGBB, or a dvips color name (https://en.wikibooks.org/wiki/LaTeX/Colors#The_68_standard_colors_known_to_dvips). ๐
Moreover, argument style can take a single color specifier to highlight the linked region by a frameless box filled with that color. An optional second color specifier separated by a colon selects the frame color.
Examples: box:red or box:#ff0000 draws red boxes around the linked areas. yellow:blue creates yellow filled rectangles with blue frames. aesthetic ๐
-l,--list-specialsโ prints a list of registered special handlers and exits. Each handler processes a set of special statements belonging to the same category. In most cases these categories are identified by the prefix of the special statements, which is usually a leading string followed by a colon or a blank, e.g.colororps. The listed handler names, however, don't need to match these prefixes โ e.g. if there's no common prefix, or if functionality is split into separate handlers in order to allow them to be disabled separately using option--no-specials. All special statements not covered by one of the special handlers are silently ignored. ๐คซ-M,--mag=factorโ sets the magnification factor applied in conjunction with Metafont calls prior to tracing the glyphs. The larger this value, the better the tracing results. Nevertheless, large magnification values can cause Metafont arithmetic errors due to number overflows, so use this option with care. The default setting usually produces nice results. ๐
โ ๏ธ fr fr be careful with big factor values โ overflow errors are not the vibe.
--message=textโ prints a given message to the console after an SVG file has been written. Argument text may consist of static text as well as the macros listed below in the description of special commanddvisvgm:raw. For example,--message="page {?pageno} written to {?svgfile}"prints the message with the macros expanded after the conversion of each page of a DVI or PDF file or after processing an EPS file. ๐ฆ
The output of option --message is not affected by a specified verbosity level, i.e. dvisvgm prints the text even with --verbosity=0. it simply refuses to be silenced ๐
--no-mergeโ puts every single character in a separatetextelement with correspondingxandyattributes. By default, newtextortspanelements are only created if a string starts at a location that differs from the regular position defined by the characters' advance values.--no-mktexmfโ suppresses the generation of missing font files. Ifdvisvgmcan't find a font file through the kpathsea lookup mechanism, it calls the external toolsmktextfmormktexmf. This option disables these calls. no unsolicited phone calls, thank u ๐-n,--no-fonts[=variant]โ if this option is given,dvisvgmdoesn't create SVGfontelements but uses paths instead. The resulting SVG files tend to be larger but are concurrently more compatible with most applications that don't support SVG fonts. The optional argument variant selects the method for how to substitute fonts by paths. Variant0createspathanduseelements in order to avoid lengthy duplicates. Variant1createspathelements only. Option--no-fontsimplies--no-styles. compatibility slay ๐-c,--scale=sx[,sy]โ scales the page content horizontally by sx and vertically by sy. This option is equivalent to-TSsx,sy. cute and short โจ-S,--no-specials[=names]โ disables processing of special commands embedded in the DVI file. If no further parameter is given, all specials are ignored. To disable a selected set of specials, an optional comma-separated list of names can be appended to this option. A name is the unique identifier referencing the intended special handler as listed by option--list-specials.--no-stylesโ by default,dvisvgmcreates CSS styles andclassattributes to reference fonts. This variant is more compact than adding the complete font information to eachtextelement over and over again. However, if you prefer direct font references, the default behavior can be disabled with option--no-styles.-O,--optimize[=modules]โ applies several optimizations on the generated SVG tree to reduce the file size. The optimizations are performed by running separate optimizer modules specified by optional argument modules. It may consist of a single module name or a comma-separated list of several module names. The corresponding modules are executed one by one in the given order and thus transform the XML tree gradually. A leading hyphen (-) can be used to exclude a module from processing. For example,-Oall,-collapse-groupsperforms all optimizations exceptcollapse-groups. If the first module name in the list starts with a hyphen,dvisvgmautomatically insertsallat the beginning, i.e.-O-collapse-groupsis identical to-Oall,-collapse-groups. big brain energy ๐ง โจ
The following list describes the currently available optimizer modules.
listโ lists all available optimizer modules and exits.noneโ if this argument is given,dvisvgmdoesn't apply any optimization.nonecan't be combined with other module names.allโ performs all optimizations listed below. This is also the default if option--optimizeis used without any arguments. The modules are executed in a predefined order that usually leads to the best results.allmust be the only or the first entry in the list of module names.collapse-groupsโ combines nested group elements (<g>...</g>) that contain only a single attribute each. If possible, the group attributes are moved to the outermost element of the processed subtree. This module also unwraps group elements that have no attributes at all.group-attributesโ creates groups (<g>...</g>) for common attributes around adjacent elements. Each attribute is moved to a separate group so that multiple common attributes lead to nested groups. They can be combined by applying optimizer modulecollapse-groupsafterwards. The algorithm only takes inheritable properties, such asfillorstroke-width, into account and only removes them from an element if none of the other attributes, likeid, prevents this.reassign-clippathsโ collects allclipPathelements that differ only by their IDs. Afterwards, the duplicates are removed so that only one remains. Allclip-pathattributes referencing one of the duplicates are updated accordingly. dedupe queen ๐remove-clippathsโ removes all redundantclipPathelements. This optimization was already present in former versions ofdvisvgmand was always applied by default. This behavior is retained, i.e.dvisvgmexecutes this module even if option--optimizeis not given. You can use argumentnoneto prevent that.simplify-textโ if atextelement only contains whitespace nodes andtspanelements, all common inheritable attributes of the latter are moved to the enclosingtextelement. Alltspanelements without further attributes are unwrapped, i.e. thetspantags are removed.simplify-transformโ tries to shorten alltransformattributes. This module combines the transformation commands of each attribute and decomposes the resulting transformation matrix into a sequence of basic transformations, i.e. translation, scaling, rotation, and skewing. If this sequence is shorter than the equivalent matrix expression, it's assigned to the attribute. Otherwise, the matrix expression is used.
-o,--output=patternโ bestie, this is THE option that decides what your SVG files get named, and it can totally include a file path too ๐ Thepatternyou hand over can be any sequence of characters that makes up the filenames or file paths โ and those paths are relative to the current working directory, just so we're clear.
Here's the thing though: except for the variables and expressions listed below, every single character is treated as a static part of the filename/folder, so it's identical for every page processed during a single run of dvisvgm. The strings %f, %p, %P, %n, %N, %hd, %ho, and %hc are the variables you're allowed to sprinkle into pattern:
%fexpands to the base name of the DVI file โ i.e. the filename without its suffix โจ%pis the current page number%Pis the total number of pages in the DVI file%nand%Nexpand to the number of the current file being converted (starting at1) and the total number of files given, respectively
Ok now the cute numeric formatting part ๐
You can put an optional number (0-9) directly after the percent sign of a variable that holds a numeric value, and it sets the minimal number of digits to create. If a value has fewer digits, it gets padded with leading zeros. Example: %3p enforces 3 digits for the current page number (001, 002, etc.). And if you don't give an explicit width specifier, %p just inherits the same number of digits as %P. Iconic.
Need even more control over numbering? You can use arithmetic expressions as part of the pattern, no cap ๐งฎ The syntax is %(expr) where expr may contain additions, subtractions, multiplications, and integer divisions with common precedence. The variables p and P hold the current page number and the total number of pages, respectively. So for example, --output="%f-%(p-1)" creates filenames where the numbering starts with 0 rather than 1. Slay.
The variables %hX contain different hash values computed from the DVI page data and the options given on the command-line. Just so you know: %hd and %hc are only set if option --page-hashes is present. Otherwise they're empty โ literally nothing. For further info, see the description of option --page-hashes below ๐
The default pattern is %f-%p.svg if the DVI file has more than one page, and %f.svg otherwise. So a DVI file foo.dvi becomes foo.svg when foo.dvi is a single-page document. Otherwise you get multiple SVG files: foo-01.svg, foo-02.svg, etc. ๐
Windows heads-up! In Windows environments, the percent sign indicates dereferenced environment variables, so it must be protected by a second percent sign, e.g. --output=%%f-%%p. Don't forget or it's gonna be a whole thing ๐ญ
-p,--page=rangesโ picks which pages actually get processed. The parameterrangesis a comma-separated list of single page numbers and/or page ranges. A page range is a pair of numbers separated by a hyphen, e.g.5-12. So a page sequence might look like this:
2-4,6,9-12,15
And honestly? It doesn't matter if a page is given more than once or if page ranges overlap โ dvisvgm always extracts the page numbers in ascending order and converts them only once ๐
For compatibility with previous versions, the default page sequence is 1. Which means dvisvgm only converts the first page and not the whole document if you omit --page. Usually ranges are two numbers denoting the first and last page to convert. If the conversion should start at page 1, or if it should continue up to the last DVI page, you can just omit the first or second range number respectively:
--page=-10converts all pages up to page10--page=10-converts all pages starting with page10
Important vibe check: those page values do not refer to the page numbers printed on the page. It's the physical page count, where the first page always gets number 1. No arguing ๐
To select the last page, expression %P can be used instead of an explicit page number โ it gets replaced by the number of the last page. For example, --page=1,%P converts the first and the last page of the document ๐ฆ
Arithmetic expressions of the form %(expr) in place of numbers are valid too, and the resulting values are always rounded down to the nearest integer. See option --output for more about the syntax and supported arithmetic operators. Example: --page=%(P-2)- converts the last three pages ๐ธ
At the end of the range sequence you can append an optional filter specifier to remove certain page numbers from the sequence. Currently the two filters :even and :odd are supported, restricting the preceding values to even and odd numbers respectively. For example, --page=1-11,20:even is equivalent to --page=2,4,6,8,10,20.
-H,--page-hashes[=params]โ give this option anddvisvgmcomputes hash values of all pages to be processed ๐ฅ As long as the page contents don't change, that page's hash value stays the same. Which means you can use it to figure out whether a DVI page must be converted again or can be skipped in consecutive runs ofdvisvgm. This works by propagating the hash value to variable%hd, which you can access in the output pattern (see option--output).
By default, dvisvgm changes the output pattern to %f-%hd if option --page-hashes is given. So all SVG file names contain the hash value instead of the page number. When you call dvisvgm again with --page-hashes and the same output pattern, it checks whether the SVG file to be created exists and skips the conversion if it's already there ๐ This also applies to consecutive calls of dvisvgm with different command-line parameters. If you want to force another conversion of a DVI file that hasn't changed, you must remove the corresponding SVG files beforehand or add the parameter replace (see below). And ngl, if you manually set the output pattern so it doesn't contain a hash value, the conversion won't be skipped.
Alternatively, the output pattern may contain the variables %ho and %hc:
%hoexpands to a 32-bit hash representing the given command-line options that affect the generated SVG output, like--no-fontsand--precision. Different combinations of options and parameters lead to different hashes. So pattern%f-%hd-%hocreates filenames that change depending on the DVI data and the given command-line options.%hcprovides a combined hash computed from the DVI data and the command-line options. It has the same length as%hd.
Ok so since the page number isn't part of the file name by default, different DVI pages with identical contents get the same file name ๐ Therefore only the first one is converted while the others are skipped. To create separate files for each page, add the page number to the output pattern, e.g. --output="%f-%p-%hc".
By default, dvisvgm uses the fast XXH64 hash algorithm to compute the values provided through %hd and %hc. 64-bit hashes should be sufficient for most documents with an average size of pages. Alternatively, XXH32 and MD5 can be used as well. The desired algorithm is specified by argument params of option --page-hashes. It takes one of the strings MD5, XXH32, and XXH64, where the names can be given in lower case too, like --page-hashes=md5 โจ
Since version 0.7.1, xxHash provides an experimental 128-bit hash function whose algorithm has been stabilized as of version 0.8. When using a version prior to 0.8, the 128-bit hash values can vary depending on the used xxHash version. If the corresponding API is available, dvisvgm supports the new hash function, and option --page-hashes additionally accepts the algorithm specifier XXH128.
Finally, option --page-hashes can take a second argument that must be separated by a comma. Currently only the two parameters list and replace are evaluated, e.g. --page-hashes=md5,list or --page-hashes=replace.
listโdvisvgmdoesn't perform any conversion, it just lists the hash values%hdand%hcof the pages specified by option--page๐replaceโ forcesdvisvgmto convert a DVI page even if a file with the target name already exists ๐ฅ
-P,--pdfโ give this one anddvisvgmdoesn't expect a DVI but a PDF input file, and it tries to convert that to SVG. Similar to DVI conversion, only the first page is processed by default, and option--pagecan be used to select different pages, page ranges, and/or page sequences ๐ซถ
If a Ghostscript version < 10.01.0 is found, dvisvgm uses Ghostscript to process the PDF file. In this case the conversion is realized by creating a single pdffile special command which is forwarded to dvisvgm's PostScript special handler. So this option is only available if dvisvgm was built with PostScript support enabled, and it requires Ghostscript to be accessible. See option --libgs for further info.
RIP to the old way: as of Ghostscript10.01.0this will no longer work, due to the introduction of a new PDF interpreter ๐ญ Therefore an alternative conversion module based onmutool, a utility which is part of the MuPDF (https://mupdf.com) package, has been introduced. It's automatically invoked if Ghostscript can't be used and if a workingmutoolexecutable is present in a directory which is part of the system's search path.
Alternatively, the environment variable DVISVGM_PDF_PROC can be used to select the PDF processor. The currently supported values are gs and mutool ๐
-d,--precision=digitsโ sets the maximum number of decimal places applied to floating-point attribute values. All attribute values written to the generated SVG file(s) are rounded accordingly. The parameter digits accepts integer values from0to6, where0enables the automatic selection of significant decimal places โ and that's also the default value ifdvisvgmis called without--precision๐--progress[=delay]โ turns on a simple progress indicator, shown when time-consuming operations like PostScript specials are being processed. It doesn't appear before the given delay (in seconds) has elapsed, and the default delay value is0.5seconds โณ-r,--rotate=angleโ rotates the page content clockwise by angle degrees around the page center. This option is equivalent to-TRangle๐-R,--relativeโ bestie, SVG lets you define paths either with absolute coordinates or with coordinates relative to wherever the drawing position currently is, and each command expects one or the other. By defaultdvisvgmbuilds paths out of absolute commands. Give it--relativeand it makes relative ones instead. Lowkey it shrinks your SVG files a lil bit in most cases. โจ--stdinโ tellsdvisvgmto read the DVI or EPS input data fromstdininstead of from a file. Or, alternative vibe: just hand it a single dash (-). The generated SVG file is namedstdin.svgby default, and you can change that with--output. ๐ซถ-s,--stdoutโ don't write the SVG output to a file at all, just yeet it straight tostdout. ๐--tmpdir[=path]โ okay so sometimesdvisvgmgenuinely needs to make temporary files to work properly. Those go to the system's temporary folder by default, like/tmpon Linux systems.--tmpdirlets you pick a different location. Important though:dvisvgmwill not create that folder if it doesn't exist โ so you gotta make sure it's actually there before you rundvisvgm, no cap.
And to stop files from colliding when you run dvisvgm in parallel, the program doesn't dump the files directly in the directory you specified โ it creates a uniquely named subfolder in there and puts the temporary files inside that. Wanna skip that? Append // or \\ (on Windows) to the directory name. So like, --tmpdir=.// puts the temporary files directly in the current working directory, while --tmpdir=. puts them in a dedicated subfolder of the current working directory. ๐
If the optional parameter path is omitted, dvisvgm just prints the location of the system's temp folder and exits.
-a,--trace-all=[retrace]โ this one forcesdvisvgmto vectorize all the glyphs of all fonts referenced in the DVI file, not just the glyphs actually needed to render the SVG correctly (which is the default). Why would you do that? Becausedvisvgmstores tracing results in a font cache, so every following conversion of those fonts gets significantly faster. Obsessed. โก
The boolean option retrace decides how to handle glyphs that are already sitting in the cache. By default they get skipped. Set retrace to yes or true and dvisvgm will retrace the corresponding bitmaps again.
Note โ this option only takes effect if font caching is active. So--trace-allcannot be combined with--cache=none. Periodt.
-T,--transform=commandsโ applies a sequence of transformations to the SVG content. Each transformation is described by a command that starts with a capital letter, followed by a list of comma-separated parameters. Here's the supported lineup, bestie: ๐T tx[,ty]โ translates (moves/shifts) the page in the direction of vector (tx,ty). Iftyis omitted,ty=0is assumed. The expected unit length oftxandtyare TeX points (1pt = 1/72.27in). But there are several constants defined to simplify the unit conversion (see below ๐).S sx[,sy]โ scales the page horizontally bysxand vertically bysy. Ifsyis omitted,sy=sxis assumed.R angle[,x,y]โ rotates the page clockwise byangledegrees around point (x,y). If the optional argumentsxandyare omitted, the page rotates around its center depending on the chosen page format. When option-bnoneis given, the rotation center is origin (0,0).KX angleโ skews the page along the x-axis byangledegrees. Argumentanglecan take any value except90+180k, wherekis an integer.KY angleโ skews the page along the y-axis byangledegrees. Argumentanglecan take any value except90+180k, wherekis an integer.FH [y]โ mirrors (flips) the page at the horizontal line through point (0,y). Omitting the optional argument leads toy=h/2, wherehdenotes the page height (see pre-defined constants below).FV [x]โ mirrors (flips) the page at the vertical line through point (x,0). Omitting the optional argument leads tox=w/2, wherewdenotes the page width (see pre-defined constants below).M m1,...,m6โ applies a transformation described by the 3ร3 matrix((m1,m2,m3),(m4,m5,m6),(0,0,1)), where the inner triples denote the rows.
Note โ all transformation commands of option-T,--transformare applied in the order they appear. Multiple commands can optionally be separated by spaces, and in that case the whole transformation string has to be enclosed in double quotes to keep them together. All parameters are expressions of floating point type. You can give plain numbers or arithmetic terms combined with the operators+(addition),-(subtraction),*(multiplication),/(division) or%(modulo), with the usual associativity and precedence rules. Parentheses are allowed too. ๐งฎ On top of that, some pre-defined constants are provided: -uxโ horizontal position of upper left page corner in TeX point units -uyโ vertical position of upper left page corner in TeX point units -hโ page height in TeX point units (0in case of-bnone) -wโ page width in TeX point units (0in case of-bnone) Also, you can use the 9 length constantspt,bp,cm,mm,in,pc,dd,cc, andsp, like2cmor1.6in. So option-TT1in,0R45moves the page content 1 inch to the right and then rotates it by 45 degrees around the page center. Iconic. ๐ For single transformations there are also the short-hand options-c,-tand-r. But heads up โ in contrast to the--transformcommands, the order of these options is not significant, so you can't describe transformation sequences with them. ๐ฆ
-t,--translate=tx[,ty]โ translates (moves) the page content in the direction of vector (tx,ty). This option is equivalent to-TTtx,ty. ๐ซ-v,--verbosity=levelโ controls the type of messages printed during advisvgmrun:0โ no message output at all1โ error messages only2โ warning messages only4โ informational messages only8โ user messages only (e.g. created by specialdvisvgm:message)
Note โ by adding these values you can combine the categories. The default level is 15, i.e. all messages are printed. ๐
-V,--version[=extended]โ prints the version ofdvisvgmand exits. If the optional argument is set toyes, the version numbers of the linked libraries are printed as well. ๐-z,--zip[=level]โ creates a compressed SVG file with suffix.svgz. The optional argument specifies the compression level. Valid values are in the range of1to9(default value is9). Larger values cause better compression results but may take slightly more computation time. ๐-Z,--zoom=factorโ multiplies the values of thewidthandheightattributes of the SVG root element by argumentfactor, while the coordinate system of the graphic content is retained. Result? Most SVG viewers zoom the graphics accordingly, slay. If a negative zoom factor is given, thewidthandheightattributes are omitted. ๐
โจ SUPPORTED SPECIALS โจ
Okay so dvisvgm supports several special commands that level up the DVI command set with extra instructions for things like color, graphics, and hyperlinks. The term special command, or just special, comes from the TeX command \special{...} which honestly does almost nothing. TeX only forwards the argument of this command to the DVI file using the corresponding xxx opcode, which basically delegates execution to the DVI driver. The driver then gets to decide whether to process it or ignore it, depending on which statements it supports. The parameter of TeX's \special command goes in curly braces and can be any arbitrary character sequence representing the actual instruction โ for example color Red. ๐จ
Worth mentioning: specials are only evaluated when processing DVI files. PS/EPS and PDF don't know anything about the concept of specials and therefore don't provide any means to represent them. Ngl, RIP to them. ๐ญ
To evaluate the special commands, dvisvgm implements several dedicated handlers. Each handler is responsible for all special statements belonging to the same command set, i.e. commands that usually โ but not necessarily โ begin with a common prefix. For example, all PDF specials start with the prefix pdf:, while the TPIC special set consists of 13 different commands with no common identifier. The PDF specials are processed by dvisvgm's pdf handler, and the TPIC ones by the tpic handler. Wanna see a list of the actually provided special handlers? Use option --list-specials (see above). ๐
Here's the overview of the special sets currently supported. The names of the handlers can also be used to disable the processing of individual sets of specials โ for more info on that, see option --no-specials.
๐๏ธ bgcolor
Special statements for changing the background/page color. Right now dvisvgm only supports the background statement as specified in the dvips manual (https://tug.org/texinfohtml/dvips.html#Color-specifications). Since SVG 1.1 doesn't support background colors, dvisvgm inserts a rectangle of the chosen color into the generated SVG document. This rectangle always gets the same size as the selected or computed bounding box. This background color command is part of the color special set but is handled separately so the user can turn it off. ๐ซถ
๐ธ color
Statements of this command set provide instructions to change the text/paint color. For an overview of the exact syntax, see the documentation of dvips, for instance. Literally go look, iykyk. ๐
Okay so, dvisvgm extends the dvips syntax of the color specials with two optional modifiers, bestie, and theyโre literally the glow-up for telling fill and stroke colors apart. Like, fill = the color inside enclosed areas, stroke = the color used to draw lines, respectively. If one of the color specifiers โ say a color name, or a color model followed by a sequence of color components โ is preceded by fill or stroke, only the corresponding color changes. Without those modifiers, both colors are affected. Example: color push fill rgb 1 0 1 pushes a new color pair onto the color stack, where the fill color is set to magenta and the stroke color retains its current value. And color push rgb 1 0 1 pushes a color pair with both colors set to magenta. Slay. ๐
Also, the new special color set is introduced. Its syntax is the same as the one of color push, including the optional fill and stroke modifiers. Instead of pushing a new color pair, it modifies the topmost one on the stack. If the color stack is empty, the default (black) fill/stroke color is changed. Periodt. ๐
dvisvgm ๐
The following list gives a brief overview of dvisvgmโs own set of currently supported specials. Buckle up, bestie โ this is the main character energy section. โจ
dvisvgm:raw text ๐ฆ
Adds an arbitrary sequence of XML nodes to the page section of the SVG document. dvisvgm checks syntax and proper nesting of the inserted elements but does not perform any validation, so the user has to ensure that the resulting SVG is still valid. Opening and closing tags may be distributed among different raw specials. The tags themselves can also be split but must be continued with the immediately following raw special. Both syntactically incorrect and wrongly nested tags lead to error messages. No cap. ๐ญ
Parameter text may also contain the expressions {?x}, {?y}, {?color}, {?fillcolor}, {?strokecolor}, {?matrix}, {?pageno}, {?svgfile}, and {?svgpath} that respectively expand to the current x and y coordinate, an RGB hex string of the current active fill and stroke color, the current transformation matrix, the current page number, and the relative and absolute path of the SVG file being created. {?color} expands to the same string as {?fillcolor} and is still available for compatibility with older dvisvgm versions that didnโt distinguish between fill and stroke colors (see information about color specials below). ๐
As SVG doesnโt support CMYK colors, for example in fill and stroke attributes, dvisvgm provides macro {?cmyk(c,m,y,k)} to create an RGB hex string from a CMYK color. It can be used instead of a combination of color/PostScript specials and color macros to directly insert a CMYK color value. Obsessed. ๐
Character sequence {?nl} expands to a newline character. Finally, constructions of the form {?(expr)} enable the evaluation of mathematical expressions which may consist of basic arithmetic operations including modulo. As above, the variables x and y represent the current coordinates. Invalid operations, like divisions by zero, lead to an error message on the console. Example: {?(-10*(x+2y)-5)} is a valid expression and expands to the corresponding numeric string. Math but make it cute. ๐ง
dvisvgm:rawdef text ๐ซถ
This command is similar to dvisvgm:raw, but puts the XML nodes into the <defs> section of the SVG document currently being generated. Lowkey iconic. โญ
dvisvgm:rawset name ... dvisvgm:endrawset ๐
This pair of specials marks the begin and end of a definition of a named raw SVG fragment. All dvisvgm:raw and dvisvgm:rawdef specials enclosed by dvisvgm:rawset and dvisvgm:endrawset are not evaluated immediately but stored together under the given name for later use. Once defined, the named fragment can be referenced throughout the DVI file by dvisvgm:rawput (see below). The two commands dvisvgm:rawset and dvisvgm:endrawset must not be nested, i.e. each call of dvisvgm:rawset has to be followed by a corresponding call of dvisvgm:endrawset before another dvisvgm:rawset may occur. Also, the identifier name must be unique throughout the DVI file. Using dvisvgm:rawset multiple times together with the same name leads to warning messages. Keep it unique, bestie โ no duplicates in this group chat. ๐
dvisvgm:rawput name โจ
Inserts raw SVG fragments previously stored under the given name. dvisvgm distinguishes between fragments that were specified with dvisvgm:raw or dvisvgm:rawdef, and handles them differently: it inserts all dvisvgm:raw parts every time dvisvgm:rawput is called, whereas the dvisvgm:rawdef portions go to the <defs> section of the current SVG document only once. The way that works is genuinely so satisfying. ๐ธ
dvisvgm:img width height file ๐ฆ
Creates an image element using the current graphic position, transformation matrix, the specified extents, and the given filename. This special command also updates the bounding box of the resulting SVG to entirely enclose the transformed image. The image itself is positioned such that the lower left corner of the untransformed image lies at the current graphic position. The length width and height specify the extents of the untransformed image. For a list of supported length units see option --bbox. Plain numbers without an appended unit specifier imply TeX points (1in = 72.27pt). ๐
Parameter file can be a plain filename or a relative or absolute path of a file. By default, dvisvgm just creates links referencing the image file so that the SVG renderer will evaluate the filename or path relative to the location of the generated SVG file. If option --embed-bitmaps is given, JPEG and PNG images are embedded into the SVG document. As this requires base64-encoding of the image data, the resulting SVG files can become quite big. Big SVG energy, ngl. ๐ญ
dvisvgm:bbox lock ๐
Locks the bounding box of the current page and prevents it from further updating, i.e. graphics elements added after calling this special are not taken into account in determining the extent of the bounding box. Locked in, fr fr. ๐ฅ
dvisvgm:bbox unlock ๐
Unlocks the previously locked bounding box of the current page so that it gets updated again when adding graphics elements to the page. Weโre so back. ๐
dvisvgm:bbox n[ew] name ๐
Defines or resets a local bounding box called name. The name may consist of letters and digits. While processing a DVI page, dvisvgm continuously updates the (global) bounding box of the current page in order to determine the minimal rectangle containing all visible page components (characters, images, drawing elements etc.) Additionally to the global bounding box, the user can request an arbitrary number of named local bounding boxes. Once defined, these boxes are updated together with the global bounding box starting with the first character that follows the definition. Thus, the local boxes can be used to compute the extent of parts of the page. This is useful for scenarios where the generated SVG file is post-processed. Big brain moment. ๐ง โจ
In conjunction with special dvisvgm:raw, the macro {?bbox name} expands to the four values x, y, w, and h (separated by spaces) specifying the coordinates of the upper left corner, width, and height of the local box name. If box name wasnโt previously defined, all four values equal to zero. Zeroes, but make it aesthetic. ๐ซถ
dvisvgm:bbox width height [depth] [transform] ๐
Updates the bounding box of the current page by embedding a virtual rectangle (x, y, width, height) where the lower left corner is located at the current DVI drawing position (x,y). If the optional parameter depth is specified, dvisvgm embeds a second rectangle (x, y, width, -depth). The lengths width, height, and depth can be given together with a unit specifier (see option --bbox) or as plain floating point numbers. In the latter case, TeX point units are assumed (1in = 72.27pt). Depending on size and position of the virtual rectangle, this command either enlarges the overall bounding box or leaves it as is. So, itโs not possible to reduce its extent. Not me trying to shrink the box โ cannot be done. ๐
This special is supposed to be used together with dvisvgm:raw in order to update the viewport of the page properly. By default, the box extents are assigned unchanged and, in particular, are not altered by transformation commands. In order to apply the current transformation matrix, the optional modifier transform can be added at the end of the special statement. Vibe check: transform goes last. โ
dvisvgm:bbox a[bs] x1 y1 x2 y2 [transform] ๐ฆ
This variant of the bbox special updates the bounding box by embedding a virtual rectangle (x1,y1,x2,y2). The points (x1,y1) and (x2,y2) denote the absolute coordinates of two diagonal corners of the rectangle. As with the relative special variant described above, the optional modifier transform allows for applying the current transformation matrix to the bounding box. Absolute coords, absolute slay. โจ
dvisvgm:bbox f[ix] x1 y1 x2 y2 [transform] ๐
This variant of the bbox special assigns an absolute (final) bounding box to the resulting SVG. After executing this command, dvisvgm doesnโt further alter the bounding box coordinates, except this special is called again later. The points (x1,y1) and (x2,y2) denote the absolute coordinates of two diagonal corners of the rectangle. As with the relative special variant described above, the optional modifier transform allows for applying the current transformation matrix to the bounding box. Final boss bbox. Periodt. ๐
The following TeX fragment adds two raw SVG elements to the output and updates the bounding box accordingly:
\special{dvisvgm:raw <circle cx='{?x}' cy='{?y}' r='10' stroke='black' fill='red'/>}%
\special{dvisvgm:bbox 10bp 10bp 10bp transform}%
\special{dvisvgm:bbox -10bp 10bp 10bp transform}
\special{dvisvgm:raw <path d='M50 200 L10 250 H100 Z' stroke='black' fill='blue'/>}%
\special{dvisvgm:bbox abs 10bp 200bp 100bp 250bp transform}
dvisvgm:currentcolor [on|off]โ okay so this one is basically option--currentcolorโs chill cousin ๐ . It doesnโt need an explicit color argument; instead it grabs the currently active color and replaces it withcurrentColor. So the result depends on both where you put the special and what color changes came before it. Theonargument โ which activates the currentColor functionality โ can be omitted entirely. Call it withoffand the functionality gets deactivated again.dvisvgm:message msgโ prints the given textmsgto the console. Besides static text, it may also contain the{?...}macros mentioned in the description ofdvisvgm:raw. The messages created by this special can be suppressed with option--verbosity(see above). ๐ซถ
๐งต em
These specials were introduced with the emTeX distribution by Eberhard Mattes. They provide line drawing statements, instructions for embedding MSP, PCX, and BMP image files, plus two PCL commands. dvisvgm supports only the line drawing statements and silently ignores all other em specials. A description of the command syntax can be found in the DVI driver documentation coming with emTeX (https://ctan.org/pkg/emtex). โจ
๐ html
The hyperref specification defines several variants on how to mark hyperlinked areas in a DVI file. dvisvgm supports the plain HyperTeX special constructs as created with hyperref package option hypertex. By default, all linked areas of the document are marked by a rectangle. Option --linkmark lets you change this behavior โ see above for further details. Info on syntax and semantics of the HyperTeX specials lives in the hyperref manual (https://ctan.org/pkg/hyperref). ๐
๐ papersize
The papersize special is an extension introduced by dvips, and it can specify the widths and heights of the pages in the DVI file. It affects the page it appears on as well as all following pages until another papersize special is found. If thereโs more than one papersize special on a page, dvisvgm applies the last one. BUT โ to stay compatible with previous versions of dvisvgm that did not evaluate these specials, their processing must be explicitly enabled by adding option --bbox=papersize on the command-line. Otherwise dvisvgm ignores them and computes tight bounding boxes. ๐
๐ pdf
pdfTeX and dvipdfmx introduced several special commands related to the generation of PDF files. Currently, only pdf:mapfile, pdf:mapline, pdf:pagesize, and PDF hyperlink specials are supported by dvisvgm. Those hyperlink specials are the PDF pendants to the HTML HyperTeX specials โ the hyperref package generates them in PDF mode, for example. If a DVI page contains unsupported PDF specials, dvisvgm prints a warning message showing the number of ignored special commands. ๐
pdf:pagesize is similar to the papersize special (see above), which specifies the size of the current and all following pages. In order to actually apply the extents to the generated SVG files, option --bbox=papersize must be given.
pdf:mapfile and pdf:mapline allow for modifying the font map tree while processing the DVI file. Theyโre used by CTeX, for example. dvisvgm supports both the dvips and dvipdfm font map format. For further information on command syntax and semantics, see the documentation of \pdfmapfile in the pdfTeX user manual (https://ctan.org/pkg/pdftex). ๐
๐ป ps
The famous DVI driver dvips (https://www.tug.org/texinfohtml/dvips.html) introduced its own set of specials in order to embed PostScript code into DVI files, which greatly improves the capabilities of DVI documents. One aim of dvisvgm is to completely evaluate all PostScript fragments and convert as many of them as possible to SVG. In contrast to dvips, dvisvgm uses floating point arithmetic to compute the precise position of each graphic element โ i.e. it doesnโt round the coordinates. Therefore, the relative locations of the graphic elements may slightly differ from those computed by dvips. ๐ฆ
Since PostScript is a rather complex language, dvisvgm does not implement its own PostScript interpreter but relies on Ghostscript (https://ghostscript.com) instead. If the Ghostscript library was not linked to the dvisvgm binary, it gets looked up and loaded dynamically during runtime. In this case, dvisvgm looks for libgs.so.X on Unix-like systems (supported ABI versions: 7,8,9), for libgs.X.dylib on macOS, and for gsdll32.dll or gsdll64.dll on Windows. You can override the default file names with environment variable LIBGS or command-line option --libgs. The library must be reachable through the ld search path (*nix) or the PATH environment variable (Windows). Alternatively, the absolute file path can be specified. If the library cannot be found, dvisvgm disables the processing of PostScript specials and prints a warning message. Use option --list-specials to check whether PostScript support is available, i.e. whether entry ps is present. ๐
The PostScript handler also recognizes and evaluates bounding box data generated by the preview package (https://ctan.org/pkg/preview) with option tightpage. If such data is present in the DVI file and if dvisvgm is called with option --bbox=preview, dvisvgm sets the width and total height of the SVG file to the values derived from the preview data. Additionally, it prints a message showing the width, height, and depth of the box in TeX point units to the console. The depth value especially can be read by a post-processor to vertically align the SVG graphics with the baseline of surrounding text in HTML or XSL-FO documents, for example. Please note that SVG bounding boxes are defined by a width and (total) height. In contrast to TeX, SVG provides no means to differentiate between height and depth, i.e. the vertical extents above and below the baseline, respectively. Therefore, it is generally not possible to retrieve the depth value from the SVG file itself. ๐ญ
If you call dvisvgm with option --bbox=min (the default) and preview data is present in the DVI file, dvisvgm doesnโt apply the preview extents but computes a bounding box that tightly encloses the page contents. The height, depth and width values written to the console are adapted accordingly. ๐
๐ง tpic
The TPIC special set defines instructions for drawing simple geometric objects. Some LaTeX packages, like eepic and tplot, use these specials to describe graphics. ๐ธ
๐ EXAMPLES ๐
dvisvgm fileโ converts the first page offile.dvitofile.svg.dvisvgm -p1-5 fileโ converts the first five pages offile.dvitofile-1.svg,...,file-5.svg.dvisvgm -p1- fileโ converts all pages offile.dvito separate SVG files.dvisvgm -p1,3 -O fileโ converts the first and third page offile.dvito optimized SVG files.dvisvgm - < file.dviโ converts the first page offile.dvitostdin.svgwhere the contents offile.dviis read from stdin.dvisvgm -z fileโ converts the first page offile.dvitofile.svgzwith default compression level9.dvisvgm -p5 -z3 -ba4-l -o newfile fileโ converts the fifth page offile.dvitonewfile.svgzwith compression level3. The bounding box is set to DIN/ISO A4 in landscape format.dvisvgm --transform="R20,w/3,2h/5 T1cm,1cm S2,3" fileโ converts the first page offile.dvitofile.svgwhere three transformations are applied.
๐ ENVIRONMENT ๐
dvisvgm uses the kpathsea library for locating the files that it opens. Hence, the environment variables described in the libraryโs documentation influence the converter. โจ
If dvisvgm was linked without the Ghostscript library, and if PostScript support has not been disabled, the shared Ghostscript library is looked up during runtime via dlopen(). The environment variable LIBGS can be used to specify path and file name of the library. ๐ซถ
The pre-compiled Windows versions of dvisvgm require a working installation of MiKTeX 2.9 or above. dvisvgm does not work together with the portable edition of MiKTeX because it relies on MiKTeXโs COM interface that is only accessible in a local installation. To enable the evaluation of PostScript specials, the original Ghostscript DLL gsdll32.dll must be present and reachable through the search path. 64-bit Windows builds require the 64-bit Ghostscript DLL gsdll64.dll. Both DLLs come with the corresponding Ghostscript installers available from https://ghostscript.com. ๐
The environment variable DVISVGM_COLORS specifies the colors used to highlight various parts of dvisvgmโs message output. It is only evaluated if option --color is given. The value of DVISVGM_COLORS is a list of colon-separated entries of the form gg=BF, where gg denotes one of the color group indicators listed below, and BF are two hexadecimal digits specifying the background (first digit) and foreground/text color (second digit). The color values are defined as follows: 0=black, 1=red, 2=green, 3=yellow, 4=blue, 5=magenta, 6=cyan, 7=gray, 8=bright red, 9=bright green, A=bright yellow, B=bright blue, C=bright magenta, D=bright cyan, E=bright gray, F=white. Depending on the terminal, the colors may differ. Rather than changing both the text and background color, itโs also possible to change only one of them: an asterisk (*) in place of a hexadecimal digit indicates the default text or background color of the terminal. ๐บ
All malformed entries in the list are silently ignored. ๐
erโ error messageswnโ warning messagespnโ messages about page numberspsโ page size messagesfwโ information about the files writtensmโ state messagestrโ messages of the glyph tracerpiโ progress indicator
Example: er=01:pi=*5 sets the colors of error messages (er) to red (1) on black (0), and those of progress indicators (pi) to cyan (5) on default background (*). โญ
Variable DVISVGM_PDF_PROC allows you to select the desired PDF processor. dvisvgm requires either Ghostscript (version < 10.01.0) or mutool to process PDF files. If DVISVGM_PDF_PROC is not set, dvisvgm tries to detect the available processors. See option --pdf for further information. To select a specific PDF processor, you can set DVISVGM_PDF_PROC to gs or mutool, which forces the use of Ghostscript and mutool respectively. ๐
๐ธ FILES ๐ธ
okay so here's the thing about where dvisvgm finds its lil files โ it does not just make up paths, bestie. The location of every file below is determined by the kpathsea library. periodt.
and if you wanna check what your actual kpathsea configuration is doing (because honestly, same, i need to know), you can just use the kpsewhich utility. it'll tell you where each thing lives. iconic behavior, no notes. โจ
so here's the full squad of file types it cares about:
*.encโ font encoding files. the whole "which character is which number" situation.*.fgdโ font glyph data files. these are cache files created bydvisvgm, so yeah, it's making its own little snacks ๐*.mapโ font map files. the mapping of one name to another, very matchmaker of them.*.mfโ Metafont input files. source code for fonts, highkey unhinged in the best way.*.pfbโ PostScript Type 1 font files. vintage, but make it slay.*.proโ PostScript header/prologue files. the warm-up act ๐ค*.tfmโ TeX font metric files. all the measurements, all the vibes.*.ttfโ TrueType font files. the classic, the moment, the main character.*.vfโ Virtual font files. fake it till you make it, but in a mathematically rigorous way ๐
like, that's the whole list. nine file types. know them, love them, let kpathsea handle the searching. ๐ฆ
๐ซถ SEE ALSO ๐ซถ
go read these when you're done here, they're the friend group:
tex(1)mf(1)mktexmf(1)grodvi(1)potrace(1)- and the
kpathsealibrary info documentation ๐
๐ RESOURCES ๐
- Project home page โ
https://dvisvgm.deโ go say hi, it's giving homepage realness ๐ - Code repository โ
https://github.com/mgieseki/dvisvgmโ the source, the lore, the whole archive โจ
๐ BUGS ๐
found a bug? not me being dramatic but please actually tell someone ๐ญ โ report it using the bug tracker at GitHub:
https://github.com/mgieseki/dvisvgm/issues
that's the whole assignment. no cap, that's where the reports go. ๐
๐ AUTHOR ๐
Written by Martin Gieseking <martin.gieseking@uos.de>. shoutout to the author fr fr, this tool ate. ๐ซถ
โญ COPYING โญ
Copyright ยฉ 2005-2025 Martin Gieseking. Free use of this software is granted under the terms of the GNU General Public License (GPL) version 3 or, (at your option) any later version. ๐
and that's the whole manpage bestie, we made it to the end ๐ง๐ โ this was dvisvgm version 3.6, dated 2025-10-28, page DVISVGM(1). go convert some TeX, you absolute icon. ๐ฆโจ
๐ฆ where this page comes from
- alpine 3.24: texmf-dist-binextra-doc 2026.0-r0 ยท LPPL-1.0 AND LPPL-1.1 AND LPPL-1.2 AND LPPL-1.3a AND LPPL-1.3c AND GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms