I use texi2dvi for most LaTeX compilations. However, lately I have
been struggling with the varioref package, which expand references
into longer text ("see fig. (2) on the following page") if the
reference is not on the same page, something which may of course
overflow to the next page rendering the extra text invalid and
ultimately causing an infinite loop!

Therefore, I have created a small patch which enables the user to set
a boundary on the number of times the files are processed. I chose an
option similar to what's already in MiKTeX:
<http://docs.miktex.org/manual/texify.html#id826609> (no reason to be
incompatible). Default is to keep going as in earlier versions. I
choose the error to be non-fatal; in most cases looping would be
caused by something changing back and forth, and before typesetting
the final version the log would be inspected anyway.

I reckon this is a feature (albeit small) in which more users could be
interested, thus sending it upstream. Patch is against version 4.13a.
Consider copyleft to be assigned to the FSF.

Yours sincerely,

   Roland Kaufmann
--- texi2dvi.orig	2009-10-26 13:55:49.658841311 +0100
+++ texi2dvi	2009-10-26 14:14:50.478841780 +0100
@@ -50,6 +50,7 @@ escape="\\"
 expand=         # t for expansion via makeinfo
 includes=
 line_error=true # Pass --file-line-error to TeX.
+max_iters=-1    # just keep going
 no_line_error=false  # absolutely do not pass --file-line-error to TeX
 oname=          # --output
 out_lang=dvi
@@ -331,6 +332,7 @@ Build modes:
 			 defaults to TEXI2DVI_BUILD_DIRECTORY [$build_dir]
   --mostly-clean       remove the auxiliary files and directories
 			 but not the output
+  --max-iterations=N   don't process files more than N times
 
 The MODE specifies where the TeX compilation takes place, and, as a
 consequence, how auxiliary files are treated.  The build mode
@@ -1093,6 +1095,13 @@ run_tex_suite ()
   local cycle=0
 
   while :; do
+    # check for probably LaTeX loop (e.g. varioref)
+    if test $cycle -eq $max_iters; then
+      error 0 "Maximum of $max_iters cycles exceeded"
+      break
+    fi
+
+    # report progress
     cycle=`expr $cycle + 1`
     verbose "Cycle $cycle for $command_line_filename"
 
@@ -1524,6 +1533,7 @@ while test x"$1" != x"$arg_sep"; do
     -l | --lang | --language) shift; set_language=$1;;
     --mostly-clean) action=mostly-clean;;
     --no-line-error) no_line_error=true;;
+    --max-iterations) shift; max_iters=$1;;
     -o | --out  | --output)
       shift
       # Make it absolute, just in case we also have --clean, or whatever.

Reply via email to