From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthew Leifer Subject: Re: Re: [PATCH] Compiling multiple times the LaTeX output Date: Tue, 5 Oct 2010 15:30:41 +0100 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> <87sk0kyfgw.fsf@mundaneum.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0181086432==" Return-path: Received: from [140.186.70.92] (port=42271 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P38Y7-0001PE-FK for emacs-orgmode@gnu.org; Tue, 05 Oct 2010 10:31:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P38Xu-0002Vu-Rd for emacs-orgmode@gnu.org; Tue, 05 Oct 2010 10:31:23 -0400 Received: from mail-iw0-f169.google.com ([209.85.214.169]:62533) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P38Xu-0002VU-K1 for emacs-orgmode@gnu.org; Tue, 05 Oct 2010 10:31:10 -0400 Received: by iwn41 with SMTP id 41so822675iwn.0 for ; Tue, 05 Oct 2010 07:31:09 -0700 (PDT) In-Reply-To: <87sk0kyfgw.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: emacs-orgmode --===============0181086432== Content-Type: multipart/alternative; boundary=0022152d622d97cb5c0491df82ea --0022152d622d97cb5c0491df82ea Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi, I don't know if you are aware, but there is a utility called texi2dvi that figures out how many times LaTeX, bibtex, etc. need to be run and automatically runs them the correct number of times for you. It also has a= n option -p that uses pdflatex and generates pdf instead of dvi. In my opinion, it would be better to make use of this rather than writing new cod= e to do this, as they have thought about all the edge cases in far more detai= l than is possible here. It is possible that some LaTeX installations do not come with texi2dvi, but it does come with the full TeXLive installation so plenty of people are likely to have it installed. If you want to avoid thi= s breaking on systems that do not have texi2dvi installed then you could just check for it, use it if it is available and, if not, give the user a warnin= g message that they may get better results if they install texi2dvi whilst using the existing code. Best, Matt Leifer 2010/10/5 S=E9bastien Vauban > Hi Carsten, > > Carsten Dominik wrote: > > Thanks for the patch! I would certainly have a better way to process > these > > files. > > Could you make your latest sentence more explicit? > > > > 1. Can we run bibtex only if we have an indication that it might be > needed? > > Maybe by looking at the output of the first LaTeX run? Hmm, maybe th= is > > would not work if only the bibtex database file was changed. > > I guess things in that direction are entirely possible. I don't use bibte= x > yet, but will have a look at a better integration. > > > > 2. The contrill structures you are using, are they standard shell or is > bash > > needed for this? > > Good question! Yes, I implicitly wrote in bash. That won't work for sure > in > Windows... > > But, then, how do we do for writing such shells in Emacs? Go to Emacs's > builtin shell? I have no experience with it, but I can have a look, > except: > how would we be sure that the preferred shell of the user is that one? > > > > 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? > > For sure, such behaviors would be a great, in case of failures. > > Best regards, > Seb > > >> 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) > >> > >> +(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 > >> -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 nam= e, > %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 > >> stable > >> -result, and it also does not do any error checking. > >> +pdflatex, mixed with a call to bibtex. Org does now have a clever > >> mechanism > >> +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 compilation= s > >> after > >> +bibtex is limited to 3 by default (see `org-latex-pdf-max-runs' for > more). > >> +Though, it does not do any error checking. > >> > >> Alternatively, this may be a Lisp function that does the processing, s= o > you > >> could use this to apply the machinery of AUCTeX or the Emacs LaTeX mod= e. > >> 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 > >> org-latex > >> (before defining org-latex-to-pdf-process). Not a problem, IMHO. Mayb= e > >> 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) > > -- > 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 > --0022152d622d97cb5c0491df82ea Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi,

I don't know if you are aware, but there is a ut= ility called texi2dvi that figures out how many times LaTeX, bibtex, etc. n= eed to be run and automatically runs them the correct number of times for y= ou. =A0It also has an option -p that uses pdflatex and generates pdf instea= d of dvi. =A0In my opinion, it would be better to make use of this rather t= han writing new code to do this, as they have thought about all the edge ca= ses in far more detail than is possible here. =A0It is possible that some L= aTeX installations do not come with texi2dvi, but it does come with the ful= l TeXLive installation so plenty of people are likely to have it installed.= =A0If you want to avoid this breaking on systems that do not have texi2dvi= installed then you could just check for it, use it if it is available and,= if not, give the user a warning message that they may get better results i= f they install texi2dvi whilst using the existing code.

Best,

Matt Leifer

2010/10/5 S=E9bastien Vauban <= wxhgmqzgwmuf@spammotel.com>
Hi Carsten,

Carsten Dominik wrote:
> Thanks for the patch! I would certainly have a better way to process t= hese
> files.

Could you make your latest sentence more explicit?


> 1. Can we run bibtex only if we have an indication that it might be ne= eded?
> =A0 =A0Maybe by looking at the output of the first LaTeX run? Hmm, may= be this
> =A0 =A0would not work if only the bibtex database file was changed.
I guess things in that direction are entirely possible. I don't u= se bibtex
yet, but will have a look at a better integration.


> 2. The contrill structures you are using, are they standard shell or i= s bash
> =A0 =A0needed for this?

Good question! =A0Yes, I implicitly wrote in bash. That won't wor= k for sure in
Windows...

But, then, how do we do for writing such shells in Emacs? =A0Go to Emacs= 9;s
builtin shell? =A0I have no experience with it, but I can have a look, exce= pt:
how would we be sure that the preferred shell of the user is that one?


> 3. Maybe we can extract a useful error message if the last PDFLaTeX ru= n
> =A0 =A0still contains problems? Maybe even load the log file in this c= ase?

For sure, such behaviors would be a great, in case of failures.

Best regards,
=A0Seb

>> 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. =A0The default we use here encompas= ses both."
>> =A0 :group 'org-export-latex
>> =A0 :group 'org-export)
>>
>> +(defcustom org-latex-pdf-max-runs 3
>> + =A0"Maximum number of times PDFLaTeX is run after BibTeX.&q= uot;
>> + =A0:group 'org-export-pdf
>> + =A0:type 'int)
>> +
>> (defcustom org-latex-to-pdf-process
>> - =A0'("pdflatex -interaction nonstopmode -output-directo= ry %o %f"
>> - =A0 =A0"pdflatex -interaction nonstopmode -output-directory= %o %f")
>> + =A0`("pdflatex -interaction nonstopmode -output-directory %= o %f"
>> + =A0 =A0"bibtex %b"
>> + =A0 =A0,(concat "let COUNTER=3D0; while (grep -e \"Rer= un .* cross-
>> references\" %b.log > /dev/null); do if [ $COUNTER -eq &qu= ot;
>> + =A0 =A0 =A0 =A0 =A0 =A0 (int-to-string org-latex-pdf-max-runs) >> + =A0 =A0 =A0 =A0 =A0 =A0 " ]; then break; fi; pdflatex -inte= raction nonstopmode
>> -output-directory %o %f; let COUNTER=3DCOUNTER+1; done"))
>> =A0 "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. =A0%f in the command will be replaced by the full fi= le 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 run= s of
>> -pdflatex, maybe mixed with a call to bibtex. =A0Org does not have= a clever
>> -mechanism to detect which of these commands have to be run to get= to a
>> stable
>> -result, and it also does not do any error checking.
>> +pdflatex, mixed with a call to bibtex. =A0Org does now have a cle= ver
>> mechanism
>> +to detect how many times the document has to be compiled to get t= o a stable
>> +result for the cross-references. =A0Moreover, the number of compi= lations
>> after
>> +bibtex is limited to 3 by default (see `org-latex-pdf-max-runs= 9; for more).
>> +Though, it does not do any error checking.
>>
>> Alternatively, this may be a Lisp function that does the processin= g, 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.&= quot;
>> =A0 :group 'org-export-pdf
>> =A0 :type '(choice (repeat :tag "Shell command sequence&q= uot;
>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0(string :tag "Shell command"= ;))
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (string :tag "Shell= command"))
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 (function)))
>>
>> (defcustom org-export-pdf-logfiles
>> --8<---------------cut here---------------end--------------->= ;8---
>>
>> Enhancements:
>>
>> - variable to limit the number of PDFLaTeX runs (3, by default) >>
>> =A0Though, the way it is evaluated, you need to set it before call= ing
>> org-latex
>> =A0(before defining org-latex-to-pdf-process). Not a problem, IMHO= . Maybe
>> there
>> =A0are better ways, though?
>>
>> - real standard sequence to compile the doc:
>>
>> =A0+ one call to PDFLaTeX
>> =A0+ one call to BibTeX
>> =A0+ as many calls as needed to PDFLaTeX (max 3)


--0022152d622d97cb5c0491df82ea-- --===============0181086432== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --===============0181086432==--