From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?S=C3=A9bastien_Vauban?= Subject: Re: [PATCH] Compiling multiple times the LaTeX output Date: Fri, 01 Oct 2010 23:17:35 +0200 Message-ID: <87lj6h1ukw.fsf@mundaneum.com> References: <87zkv0pqyi.fsf@mundaneum.com> <87r5gcshnf.fsf@noorul.maa.corp.collab.net> <874od7uzsa.fsf_-_@mundaneum.com> <30671.1285861145@gamaville.dokosmarshall.org> <87vd5njhm8.fsf@mundaneum.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org Hi Nick and Thomas, "Thomas S. Dye" wrote: > On Sep 30, 2010, at 6:55 AM, S=C3=A9bastien Vauban wrote: >> Nick Dokos wrote: >>> S=C3=A9bastien Vauban wrote: >>>> Noorul Islam K M wrote: >>>>> S=C3=A9bastien Vauban writes: >>>>>> I've been taught of a weird observation: the page number indicated in >>>>>> the TOC of a PDFLaTeX output is wrong by one page... >>>>> >>>>> Quoting from source code >>>>> >>>>> (defcustom org-latex-to-pdf-process >>>>> '("pdflatex -interaction nonstopmode -output-directory %o %f" >>>>> "pdflatex -interaction nonstopmode -output-directory %o %f") >>>>> "Commands to process a LaTeX file to a PDF file. >>>>> This is a list of strings, each of them will be given to the shell >>>>> as a command. >>>> >>>> Attached my proposed patch for fixing this, regarding the TOC error >>>> (needed a third compilation). Here, as many compilations as necessary = are >>>> run, up to when LaTeX confirms the result is stable (no message "please >>>> re- run..."). >>> >>> I don't know if that's still the case, but there were (rare) situations >>> where that would *never* happen: LaTeX would oscillate between two >>> different states of output, so you always needed to do one more >>> compilation. The only fix was to rearrange the *input* sligthly to try = to >>> get LaTeX out of its rut. >> >> In years of LaTeX use, that's something that I never have had to play wi= th. >> I think such experiences are close to 0 in one full LaTeX live. Though, >> yes, it can happen. >> >>> It may be wise to limit the number of compilations to 3 (but perhaps ma= ke >>> it configurable, so that it can be increased if necessary). >> >> Nice idea. I'll try to see if I can come up with something like that. > > This will be a nice addition to Org-mode. Here is my (much) better proposition: --8<---------------cut here---------------start------------->8--- diff --git a/lisp/org-latex.el b/lisp/org-latex.el index 9a62457..0a2c5fe 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -455,25 +455,35 @@ allowed. The default we use here encompasses both." :group 'org-export-latex :group 'org-export) =20 +(defcustom org-latex-pdf-max-runs 3 + "Maximum number of times PDFLaTeX is run after BibTeX." + :group 'org-export-pdf + :type 'int) + (defcustom org-latex-to-pdf-process - '("pdflatex -interaction nonstopmode -output-directory %o %f" - "pdflatex -interaction nonstopmode -output-directory %o %f") + `("pdflatex -interaction nonstopmode -output-directory %o %f" + "bibtex %b" + ,(concat "let COUNTER=3D0; while (grep -e \"Rerun .* cross-references\= " %b.log > /dev/null); do if [ $COUNTER -eq " + (int-to-string org-latex-pdf-max-runs) + " ]; then break; fi; pdflatex -interaction nonstopmode -outpu= t-directory %o %f; let COUNTER=3DCOUNTER+1; done")) "Commands to process a LaTeX file to a PDF file. This is a list of strings, each of them will be given to the shell as a command. %f in the command will be replaced by the full file name, %b by the file base name (i.e. without extension) and %o by the base directory of the file. The reason why this is a list is that it usually takes several runs of -pdflatex, maybe mixed with a call to bibtex. Org does not have a clever -mechanism to detect which of these commands have to be run to get to a sta= ble -result, and it also does not do any error checking. +pdflatex, mixed with a call to bibtex. Org does now have a clever mechani= sm +to detect how many times the document has to be compiled to get to a stable +result for the cross-references. Moreover, the number of compilations aft= er +bibtex is limited to 3 by default (see `org-latex-pdf-max-runs' for more). +Though, it does not do any error checking. =20 Alternatively, this may be a Lisp function that does the processing, so you could use this to apply the machinery of AUCTeX or the Emacs LaTeX mode. This function should accept the file name as its single argument." :group 'org-export-pdf :type '(choice (repeat :tag "Shell command sequence" - (string :tag "Shell command")) + (string :tag "Shell command")) (function))) =20 (defcustom org-export-pdf-logfiles --8<---------------cut here---------------end--------------->8--- Enhancements: - variable to limit the number of PDFLaTeX runs (3, by default) Though, the way it is evaluated, you need to set it before calling org-la= tex (before defining org-latex-to-pdf-process). Not a problem, IMHO. Maybe th= ere are better ways, though? - real standard sequence to compile the doc: + one call to PDFLaTeX + one call to BibTeX + as many calls as needed to PDFLaTeX (max 3) Best regards, Seb --=20 S=C3=A9bastien Vauban _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode-mXXj517/zsQ@public.gmane.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode