Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor differences in generated DVI files #3

Closed
shreevatsa opened this issue Feb 18, 2018 · 7 comments
Closed

Minor differences in generated DVI files #3

shreevatsa opened this issue Feb 18, 2018 · 7 comments

Comments

@shreevatsa
Copy link
Contributor

There are some very minor differences between the DVI files generated by rsTeX, and those generated by the tex that comes with TeX Live. They do not seem to affect the generated output itself in any visual way (at least, as tried with a book-length .tex file), but the DVI files differ.

I plan to look at this later, but just documenting this here for now; hope you don't mind. The “error” may well be in the tex output (I know the implementation in TeX Live makes some changes and is not 100% true to the Pascal code in tex.web.) A difference shows up in this minimal example, say test.tex:

\input plain

Now the good news: straightforward text

\end

The difference seems to be (using dvitype and diffing the output) is that the rsTeX-generated DVI file contains a right3 instruction (opcode) where the tex one contains a w0 (and this shifts some future bytes).

These are the commands I'm using to compare them (./a.out is rsTeX):

tex -ini test.tex
mv test.dvi test-TeX.dvi
mv test.log test-TeX.log
dvitype test-TeX.dvi > test-TeX.dvi.txt

./a.out test.tex
mv test.log test-rsTeX.log
mv test.dvi test-rsTeX.dvi
dvitype test-rsTeX.dvi > test-rsTeX.dvi.txt
@nadder
Copy link
Owner

nadder commented Feb 19, 2018

Didn't see your comment until now. It's certainly worth investigating the difference. My knowledge of dvi format is very limited right now so it will take some time to determine if it does something wrong. Also interesting is that both MiKTeX (which I belive is the same as TeX Live in this respect but I haven't confirmed this) and rsTeX produce the same dvi files on trip test but differ on gentle.dvi. Seems the trip test does not test all that much when it comes to dvi output.

@shreevatsa
Copy link
Contributor Author

shreevatsa commented Feb 20, 2018

After the recent commits (specifically c780e16), the diff of DVI files generated from the above example went away! This is hope that maybe the outputs can be reconciled…

Here's a different input with which there's a difference:

\input plain

This manual would not have come into being without the aid of others.
In particular the proofreading and

\bye

The difference is quite minor:

% diff test-TeX.dvi.txt test-rsTeX.dvi.txt
86,90c86,90
< 194: right3 223728 h:=16739338+223728=16963066, hh:=1074 
< 198: setchar116 h:=16963066+254863=17217929, hh:=1090 
< 199: setchar104 h:=17217929+364090=17582019, hh:=1113 
< 200: setchar101 h:=17582019+291271=17873290, hh:=1131 
< 201: w0 223727 h:=17873290+223727=18097017, hh:=1146 
---
> 194: w0 223727 h:=16739338+223727=16963065, hh:=1074 
> 195: setchar116 h:=16963065+254863=17217928, hh:=1090 
> 196: setchar104 h:=17217928+364090=17582018, hh:=1113 
> 197: setchar101 h:=17582018+291271=17873289, hh:=1131 
> 198: right3 223728 h:=17873289+223728=18097017, hh:=1146 

or side-by-side:

% diff -y --suppress-common-lines test-TeX.dvi.txt test-rsTeX.dvi.txt
194: right3 223728 h:=16739338+223728=16963066, hh:=1074      |	194: w0 223727 h:=16739338+223727=16963065, hh:=1074 
198: setchar116 h:=16963066+254863=17217929, hh:=1090 	      |	195: setchar116 h:=16963065+254863=17217928, hh:=1090 
199: setchar104 h:=17217929+364090=17582019, hh:=1113 	      |	196: setchar104 h:=17217928+364090=17582018, hh:=1113 
200: setchar101 h:=17582019+291271=17873290, hh:=1131 	      |	197: setchar101 h:=17582018+291271=17873289, hh:=1131 
201: w0 223727 h:=17873290+223727=18097017, hh:=1146 	      |	198: right3 223728 h:=17873289+223728=18097017, hh:=1146 

As I understand it, this is 1 scaled point (I think) in the word aid, that resolves itself at the end of the word… probably a difference in the details of how rounding is done in the two programs. This difference would matter only at absurdly high (nonexistent in reality) resolutions, so it doesn't affect the visual appearance in any material way. (And again, the whole point of a lot of decisions in TeX is so that such rounding differences should not affect things…) Still, might be something interesting to look into.

@nadder
Copy link
Owner

nadder commented Feb 20, 2018

Yes, I agree, looks like different rounding. I still have a few places where I use double, I'm gonna change those to floats and see if it makes a difference.

@shreevatsa
Copy link
Contributor Author

Based on some output I somewhat suspect it's the other way around (TeX Live tex uses double in some place where rsTeX uses float), but I haven't looked into the details. (This just based on seeing more digits printed in some places in the output from tex.)

@nadder
Copy link
Owner

nadder commented Feb 20, 2018

Please take a look at the latest upload, also try increasing dvi_buf_size to some larger value. On my machine miktex and rstex agree almost completely on gentle now.

@shreevatsa
Copy link
Contributor Author

shreevatsa commented Feb 20, 2018

Wow great, I installed MikTeX on macOS, and with

const int dvi_buf_size = 800;

changed to

const int dvi_buf_size = 4000;

(or greater) the two DVI files for gentle.tex agree 100%, with no diffs!

There are actually differences when TeX Live tex is used, but I think it would be a separate project to look into why TeX Live and MikTeX differ :-)

@shreevatsa
Copy link
Contributor Author

Closing this “issue”, as the output is identical between rsTeX and MiKTeX!

Also, I just learned that the DVI files are not strictly required to be identical: https://tex.stackexchange.com/questions/416376/should-different-tex-implementations-e-g-miktexs-and-tex-lives-produce-iden

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants