Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there any tool that compares two dvi files. I would like to check if they are identical after I make some changes with source tex file.

share|improve this question
    
Any special reason you want to work on the dvi file directly and not convert them to ps and then to pdf so that you can employ tools like diffpdf or pdftotext, depending on whether you're interested in the text content or the layout? –  Christian Feb 15 '13 at 11:05

3 Answers 3

TeX adds a comment into the DVI file, e.g.:

 TeX output 2013.02.15:1010

It contains the date and time that complicates the comparison of the DVI files:

  • The time stamp can be set explicitly by setting \year, \month, and \time. If the two files for comparison have the same values, then the time stamp in the DVI files are the same and you can compare the files using the usual programs (diff, comp, …).

  • The comment has a fixed location in the DVI file format in the preamble. The fifteenth byte contains the length of the comment that follows. With the usual standard case, just ignore the first 42 bytes of the file. The missing values for numerator, denominator and magnification are repeated in the postamble anyway. In Linux the stripping could be done with tail by setting option -c to the file length minus 42.

  • Another possibility is dvitype that outputs the DVI contents in a more human readable manner, here the eigths line with the DVI comment and timestamp can be ignored in the comparison.

share|improve this answer

You can use dvitype, that converts a DVI file to "human readable" form. The start of the obtained file is

This is DVItype, Version 3.6 (TeX Live 2012)
Options selected:
  Starting page = * 
  Maximum number of pages = 1000000
  Output level = 4 (the works)
  Resolution = 300.00000000 pixels per inch
numerator/denominator=25400000/473628672
magnification=1000;       0.00006334 pixels per DVI unit
' TeX output 2013.02.15:1014'

and so you should ignore the lines up to and including the last shown line with the time stamp that will surely be different.

The rest of the file will contain something like

Postamble starts at byte 353.
maxv=41484288, maxh=26673152, maxstackdepth=13, totalpages=1
Font 14: cmtt10---loaded at size 655360 DVI units 
Font 7: cmr10---loaded at size 655360 DVI units 

42: beginning of page 1 
87: down4 41484288 v:=0+41484288=41484288, vv:=2628 
92: push 
level 0:(h=0,v=41484288,w=0,x=0,y=0,z=0,hh=0,vv=2628) 
93: down4 -39649280 v:=41484288-39649280=1835008, vv:=116 
98: down4 37683200 v:=1835008+37683200=39518208, vv:=2503 
103: push 
...

that are low level instructions for associating fonts to a unique number and for setting type on the pages.

share|improve this answer

The dvii utility can calculate message digest for each page, e.g.

dvii -p -M1 filex > before.md
cat before.md
[message digest: simple sum (ignore font)]
p:[1/1]::9C8E26458F1B019011D2F28DA18B18CC
p:[2/2]::9C8E26468F1B029011D2F28DA18B18CC
p:[3/3]::9C8E26478F1B039011D2F28DA18B18CC
p:[4/4]::9C8E26488F1B049011D2F28DA18B18CC

You can then compare .md files, instead of .dvi.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.