From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Re: [PATCH] Compiling multiple times the LaTeX output Date: Mon, 4 Oct 2010 09:41:49 +0200 Message-ID: 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> <87lj6h1ukw.fsf@mundaneum.com> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=44589 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P2fgJ-00050Q-Kt for emacs-orgmode@gnu.org; Mon, 04 Oct 2010 03:41:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P2fgI-0007Hl-0p for emacs-orgmode@gnu.org; Mon, 04 Oct 2010 03:41:55 -0400 Received: from mail-ew0-f41.google.com ([209.85.215.41]:52944) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P2fgH-0007HU-NE for emacs-orgmode@gnu.org; Mon, 04 Oct 2010 03:41:53 -0400 Received: by ewy19 with SMTP id 19so2165173ewy.0 for ; Mon, 04 Oct 2010 00:41:52 -0700 (PDT) In-Reply-To: <87lj6h1ukw.fsf@mundaneum.com> 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@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: =?ISO-8859-1?Q?S=E9bastien_Vauban?= Cc: emacs-orgmode@gnu.org Hi Sebastian, Thanks for the patch! I would certainly have a better way to process these files. My questions: 1. Can we run bibtex only if we have an indication that it might be =20 needed? Maybe by looking at the output of the first LaTeX run? Hmm, maybe this would not work if only the bibtex database file was changed. 2. The contrill structures you are using, are they standard shell or is bash needed for this? 3. Maybe we can extract a useful error message if the last PDFLaTeX run still contains problems? Maybe even load the log file in this case? Thanks! - Carsten On Oct 1, 2010, at 11:17 PM, S=E9bastien Vauban wrote: > > 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 =20= > both." > :group 'org-export-latex > :group 'org-export) > > +(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-=20 > references\" %b.log > /dev/null); do if [ $COUNTER -eq " > + (int-to-string org-latex-pdf-max-runs) > + " ]; then break; fi; pdflatex -interaction nonstopmode =20= > -output-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 =20 > name, %b > by the file base name (i.e. without extension) and %o by the base =20 > 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 =20 > clever > -mechanism to detect which of these commands have to be run to get =20 > to a stable > -result, and it also does not do any error checking. > +pdflatex, mixed with a call to bibtex. Org does now have a clever =20= > mechanism > +to detect how many times the document has to be compiled to get to =20= > a stable > +result for the cross-references. Moreover, the number of =20 > compilations after > +bibtex is limited to 3 by default (see `org-latex-pdf-max-runs' for =20= > more). > +Though, it does not do any error checking. > > Alternatively, this may be a Lisp function that does the processing, =20= > so you > could use this to apply the machinery of AUCTeX or the Emacs LaTeX =20 > 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))) > > (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 =20= > org-latex > (before defining org-latex-to-pdf-process). Not a problem, IMHO. =20 > Maybe there > 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=E9bastien Vauban > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode - Carsten