emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Compiling multiple times the LaTeX output
@ 2010-09-29 14:25 Sébastien Vauban
  2010-09-29 15:17 ` Noorul Islam K M
  0 siblings, 1 reply; 25+ messages in thread
From: Sébastien Vauban @ 2010-09-29 14:25 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hello,

I've been taught of a weird observation: the page number indicated in the TOC
of a PDFLaTeX output is wrong by one page...

I've re-exported my Org document. Same observation. So, it was not a problem
during export or so.

Taking the `.tex' file, and running `pdflatex' on it shows me twice this
message:

--8<---------------cut here---------------start------------->8---
LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
--8<---------------cut here---------------end--------------->8---

After the 3rd compilation, everything is right in the PDF.

Is it possible, somehow, that Org does not run `pdflatex' enough times??

Best regards,
  Seb

-- 
Sébastien 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

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Compiling multiple times the LaTeX output
  2010-09-29 14:25 Compiling multiple times the LaTeX output Sébastien Vauban
@ 2010-09-29 15:17 ` Noorul Islam K M
  2010-09-30 13:27   ` [PATCH] " Sébastien Vauban
  0 siblings, 1 reply; 25+ messages in thread
From: Noorul Islam K M @ 2010-09-29 15:17 UTC (permalink / raw)
  To: Sébastien Vauban; +Cc: emacs-orgmode

Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> writes:

> Hello,
>
> I've been taught of a weird observation: the page number indicated in the TOC
> of a PDFLaTeX output is wrong by one page...
>
> I've re-exported my Org document. Same observation. So, it was not a problem
> during export or so.
>
> Taking the `.tex' file, and running `pdflatex' on it shows me twice this
> message:
>
> LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.
>
> After the 3rd compilation, everything is right in the PDF.
>
> Is it possible, somehow, that Org does not run `pdflatex' enough times??
>

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.  %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
stable
result, and it also does not do any error checking.

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."

Thanks and Regards
Noorul

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH] Compiling multiple times the LaTeX output
  2010-09-29 15:17 ` Noorul Islam K M
@ 2010-09-30 13:27   ` Sébastien Vauban
  2010-09-30 15:39     ` Nick Dokos
  0 siblings, 1 reply; 25+ messages in thread
From: Sébastien Vauban @ 2010-09-30 13:27 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

[-- Attachment #1: Type: text/plain, Size: 893 bytes --]

Hi Noorul and all,

Noorul Islam K M wrote:
> Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> 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...").

Best regards,
  Seb

-- 
Sébastien Vauban

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-latex-patch --]
[-- Type: text/x-patch, Size: 1669 bytes --]

Changes in HEAD
	Modified lisp/org-latex.el
diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index 9a62457..4b3e7f2 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -456,17 +456,17 @@ allowed.  The default we use here encompasses both."
   :group 'org-export)
 
 (defcustom org-latex-to-pdf-process
-  '("pdflatex -interaction nonstopmode -output-directory %o %f"
-    "pdflatex -interaction nonstopmode -output-directory %o %f")
+  '("rm -f %b.log; pdflatex -interaction nonstopmode -output-directory %o %f; while (grep -e \"Rerun .* cross-references\" %b.log > /dev/null); do rm -f %b.log; pdflatex -interaction nonstopmode -output-directory %o %f; 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 stable
-result, and it also does not do any error checking.
+pdflatex, maybe 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.  Though, bibtex calls
+are still missing and it also does not do any error checking.
 
 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.


[-- Attachment #3: Type: text/plain, Size: 222 bytes --]

_______________________________________________
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

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH] Compiling multiple times the LaTeX output
  2010-09-30 13:27   ` [PATCH] " Sébastien Vauban
@ 2010-09-30 15:39     ` Nick Dokos
  2010-09-30 16:55       ` Sébastien Vauban
  0 siblings, 1 reply; 25+ messages in thread
From: Nick Dokos @ 2010-09-30 15:39 UTC (permalink / raw)
  To: =?utf-8?Q?S=C3=A9bastien_Vauban?=; +Cc: nicholas.dokos, emacs-orgmode

Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> wrote:

> Hi Noorul and all,
> 
> Noorul Islam K M wrote:
> > Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> 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.

It may be wise to limit the number of compilations to 3 (but perhaps make
it configurable, so that it can be increased if necessary).

Nick

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] Compiling multiple times the LaTeX output
  2010-09-30 15:39     ` Nick Dokos
@ 2010-09-30 16:55       ` Sébastien Vauban
  2010-10-01 15:32         ` Thomas S. Dye
  2010-10-01 16:12         ` Nick Dokos
  0 siblings, 2 replies; 25+ messages in thread
From: Sébastien Vauban @ 2010-09-30 16:55 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Nick,

Nick Dokos wrote:
> Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> wrote:
>> Noorul Islam K M wrote:
>> > Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> 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 with. 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 make 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.

Best regards,
  Seb

-- 
Sébastien 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

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Re: [PATCH] Compiling multiple times the LaTeX output
  2010-09-30 16:55       ` Sébastien Vauban
@ 2010-10-01 15:32         ` Thomas S. Dye
  2010-10-01 21:17           ` Sébastien Vauban
  2010-10-01 16:12         ` Nick Dokos
  1 sibling, 1 reply; 25+ messages in thread
From: Thomas S. Dye @ 2010-10-01 15:32 UTC (permalink / raw)
  To: Sébastien Vauban; +Cc: emacs-orgmode

On Sep 30, 2010, at 6:55 AM, Sébastien Vauban wrote:

> Hi Nick,
>
> Nick Dokos wrote:
>> Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> wrote:
>>> Noorul Islam K M wrote:
>>>> Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> 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 with. 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 make 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.
>
> Best regards,
>  Seb
>
> -- 
> Sébastien Vauban
>
>
Aloha Seb,

This will be a nice addition to Org-mode.

All the best,
Tom

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Re: [PATCH] Compiling multiple times the LaTeX output
  2010-09-30 16:55       ` Sébastien Vauban
  2010-10-01 15:32         ` Thomas S. Dye
@ 2010-10-01 16:12         ` Nick Dokos
  2010-10-06  9:36           ` Bruno Tavernier
  1 sibling, 1 reply; 25+ messages in thread
From: Nick Dokos @ 2010-10-01 16:12 UTC (permalink / raw)
  To: =?utf-8?Q?S=C3=A9bastien_Vauban?=; +Cc: nicholas.dokos, emacs-orgmode

Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> wrote:

> Hi Nick,
> 
> Nick Dokos wrote:
> > Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> wrote:
> >> Noorul Islam K M wrote:
> >> > Sébastien Vauban <wxhgmqzgwmuf@spammotel.com> 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 with. I
> think such experiences are close to 0 in one full LaTeX live. Though, yes, it
> can happen.
> 

Me neither - it is really rare. See

   http://www.tex.ac.uk/cgi-bin/texfaq2html?label=rerun

for one possibility.

OTOH, I have never had a document that requires more than 3 compilations to get
references right either, although I'm sure that they exist. That's what the "3"
suggestion was based on.

> 
> > It may be wise to limit the number of compilations to 3 (but perhaps make 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.
> 

Cheers,
Nick

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-01 15:32         ` Thomas S. Dye
@ 2010-10-01 21:17           ` Sébastien Vauban
  2010-10-04  7:41             ` Carsten Dominik
  0 siblings, 1 reply; 25+ messages in thread
From: Sébastien Vauban @ 2010-10-01 21:17 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Nick and Thomas,

"Thomas S. Dye" wrote:
> On Sep 30, 2010, at 6:55 AM, Sébastien Vauban wrote:
>> Nick Dokos wrote:
>>> Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> wrote:
>>>> Noorul Islam K M wrote:
>>>>> Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> 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 with.
>> 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 make
>>> 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)
 
+(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=0; 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=COUNTER+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 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 compilations 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, 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)))
 
 (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. 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

-- 
Sébastien 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

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-01 21:17           ` Sébastien Vauban
@ 2010-10-04  7:41             ` Carsten Dominik
  2010-10-04 10:36               ` Scot Becker
  2010-10-05 12:46               ` Sébastien Vauban
  0 siblings, 2 replies; 25+ messages in thread
From: Carsten Dominik @ 2010-10-04  7:41 UTC (permalink / raw)
  To: Sébastien Vauban; +Cc: emacs-orgmode

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  
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ébastien 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  
> 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=0; 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=COUNTER+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 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  
> compilations 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,  
> 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)))
>
> (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.  
> 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
>
> -- 
> Sébastien 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

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-04  7:41             ` Carsten Dominik
@ 2010-10-04 10:36               ` Scot Becker
  2010-10-05 12:46               ` Sébastien Vauban
  1 sibling, 0 replies; 25+ messages in thread
From: Scot Becker @ 2010-10-04 10:36 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: Sébastien Vauban, emacs-orgmode

As soon as I can, I'll give the patch a test using XeLaTeX as well.
It'd be great to have this feature also be able to run xelatex instead
of pdflatex to support that toolchain as well (for its better UTF-8
support and OpenType font integration).  I expect this to be easy,
because as far as I can tell the output/error/warning messages are the
same.

Scot


2010/10/4 Carsten Dominik <carsten.dominik@gmail.com>:
> 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 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ébastien 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 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=0; 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=COUNTER+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
>> 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 compilations
>> 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, 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)))
>>
>> (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. 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
>>
>> --
>> Sébastien 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
>
>
>
>
> _______________________________________________
> 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
>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-04  7:41             ` Carsten Dominik
  2010-10-04 10:36               ` Scot Becker
@ 2010-10-05 12:46               ` Sébastien Vauban
  2010-10-05 14:17                 ` Carsten Dominik
  2010-10-05 14:30                 ` Matthew Leifer
  1 sibling, 2 replies; 25+ messages in thread
From: Sébastien Vauban @ 2010-10-05 12:46 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

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 this
>    would not work if only the bibtex database file was changed.

I guess things in that direction are entirely possible. I don't use bibtex
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=0; 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=COUNTER+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
>> 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 compilations
>> 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, 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)))
>>
>> (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. 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)

-- 
Sébastien 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

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-05 12:46               ` Sébastien Vauban
@ 2010-10-05 14:17                 ` Carsten Dominik
  2010-10-05 14:30                 ` Matthew Leifer
  1 sibling, 0 replies; 25+ messages in thread
From: Carsten Dominik @ 2010-10-05 14:17 UTC (permalink / raw)
  To: Sébastien Vauban; +Cc: emacs-orgmode


On Oct 5, 2010, at 2:46 PM, Sébastien Vauban wrote:

> Hi Carsten,
>
> Carsten Dominik wrote:
>> Thanks for the patch! I would certainly have a better way to  
>> process these
>> files.

I would certainly *like very much to have your* better way to process  
it.

Sorry about that confusing sentence...

>
> 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  
>> this
>>   would not work if only the bibtex database file was changed.
>
> I guess things in that direction are entirely possible. I don't use  
> bibtex
> 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?

I think the safe way would be to capture output of the run to an Emacs  
buffer and study it there.  this is what AUCTeX is doing, I think.

Anyway, I think your new way is already better than the old one.

Cheers.

- Carsten

>
>
>> 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=0; 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=COUNTER+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
>>> 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  
>>> compilations
>>> 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, 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)))
>>>
>>> (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.  
>>> 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)
>
> -- 
> Sébastien 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

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-05 12:46               ` Sébastien Vauban
  2010-10-05 14:17                 ` Carsten Dominik
@ 2010-10-05 14:30                 ` Matthew Leifer
  2010-10-05 15:02                   ` Indraneel Majumdar
                                     ` (2 more replies)
  1 sibling, 3 replies; 25+ messages in thread
From: Matthew Leifer @ 2010-10-05 14:30 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 5885 bytes --]

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 an
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 code
to do this, as they have thought about all the edge cases in far more detail
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 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 if they install texi2dvi whilst
using the existing code.

Best,

Matt Leifer

2010/10/5 Sébastien Vauban <wxhgmqzgwmuf@spammotel.com>

> 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 this
> >    would not work if only the bibtex database file was changed.
>
> I guess things in that direction are entirely possible. I don't use bibtex
> 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=0; 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=COUNTER+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
> >> 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 compilations
> >> 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, 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)))
> >>
> >> (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. 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)
>
> --
> Sébastien 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
>

[-- Attachment #1.2: Type: text/html, Size: 7340 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-05 14:30                 ` Matthew Leifer
@ 2010-10-05 15:02                   ` Indraneel Majumdar
  2010-10-05 16:26                   ` Carsten Dominik
  2010-10-05 18:24                   ` Achim Gratz
  2 siblings, 0 replies; 25+ messages in thread
From: Indraneel Majumdar @ 2010-10-05 15:02 UTC (permalink / raw)
  To: Matthew Leifer; +Cc: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 6782 bytes --]

  texi2dvi is also on my minimal MikTex system, I'd certainly love a 
patch that uses it instead of a shell script (although I also have 
cygwin too)..

On 2010-10-05 20:00, Matthew Leifer wrote:
> 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 an 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 code to do this, as they have thought about all the edge 
> cases in far more detail 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 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 if they install texi2dvi whilst using 
> the existing code.
>
> Best,
>
> Matt Leifer
>
> 2010/10/5 Sébastien Vauban <wxhgmqzgwmuf@spammotel.com 
> <mailto:wxhgmqzgwmuf@spammotel.com>>
>
>     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 this
>     >    would not work if only the bibtex database file was changed.
>
>     I guess things in that direction are entirely possible. I don't
>     use bibtex
>     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=0; 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=COUNTER+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
>     >> 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
>     compilations
>     >> 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, 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)))
>     >>
>     >> (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. 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)
>
>     --
>     Sébastien Vauban
>
>
>     _______________________________________________
>     Emacs-orgmode mailing list
>     Please use `Reply All' to send replies to the list.
>     Emacs-orgmode@gnu.org <mailto:Emacs-orgmode@gnu.org>
>     http://lists.gnu.org/mailman/listinfo/emacs-orgmode
>
>
>
> _______________________________________________
> 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

[-- Attachment #1.2: Type: text/html, Size: 11477 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-05 14:30                 ` Matthew Leifer
  2010-10-05 15:02                   ` Indraneel Majumdar
@ 2010-10-05 16:26                   ` Carsten Dominik
  2010-10-05 18:55                     ` Achim Gratz
  2010-10-06  8:21                     ` Sébastien Vauban
  2010-10-05 18:24                   ` Achim Gratz
  2 siblings, 2 replies; 25+ messages in thread
From: Carsten Dominik @ 2010-10-05 16:26 UTC (permalink / raw)
  To: Matthew Leifer; +Cc: emacs-orgmode

Hi Matthew,

you are completely right, we are re-inventing wheels here.

I have just pushed a fix which will use texi2dvi when available.
The echo area will now also give an indication of the kinds
of errors that happened during the final pdflatex run.

This is a big improvement, thanks to Sebastian for kicking
off this discussion, and to all who contributed.

Please test the new processing and let me know if there
are problems.

- Carsten

On Oct 5, 2010, at 4:30 PM, Matthew Leifer wrote:

> 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 an 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 code to do this, as they have thought  
> about all the edge cases in far more detail 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 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 if they install texi2dvi whilst using the existing code.
>
> Best,
>
> Matt Leifer
>
> 2010/10/5 Sébastien Vauban <wxhgmqzgwmuf@spammotel.com>
> 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 this
> >    would not work if only the bibtex database file was changed.
>
> I guess things in that direction are entirely possible. I don't use  
> bibtex
> 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=0; 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=COUNTER+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
> >> 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  
> compilations
> >> 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, 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)))
> >>
> >> (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.  
> 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)
>
> --
> Sébastien 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
>
> _______________________________________________
> 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

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-05 14:30                 ` Matthew Leifer
  2010-10-05 15:02                   ` Indraneel Majumdar
  2010-10-05 16:26                   ` Carsten Dominik
@ 2010-10-05 18:24                   ` Achim Gratz
  2 siblings, 0 replies; 25+ messages in thread
From: Achim Gratz @ 2010-10-05 18:24 UTC (permalink / raw)
  To: emacs-orgmode

Matthew Leifer <msleifer@gmail.com> writes:
> 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.
[...]

You know, I've been using LaTeX for so long, but it never occured to me
that texi2dvi could actually be used for something other than, well,
texinfo files (and the manual doesn't really make much fuzz about that
either).  But it just works... this is _great_ news, thank you!  Now
I'll have to make AucTeX use this.


Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptations for Waldorf Q V3.00R3 and Q+ V3.54R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-05 16:26                   ` Carsten Dominik
@ 2010-10-05 18:55                     ` Achim Gratz
  2010-10-05 21:12                       ` Carsten Dominik
  2010-10-06  8:21                     ` Sébastien Vauban
  1 sibling, 1 reply; 25+ messages in thread
From: Achim Gratz @ 2010-10-05 18:55 UTC (permalink / raw)
  To: emacs-orgmode


Commit 59ba4125 lisp/org-latex.el raises warning during byte-compile:

In org-export-as-pdf:
org-latex.el:882:28:Warning: assignment to free variable `errors'
org-latex.el:882:47:Warning: reference to free variable `errors'


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptation for Waldorf rackAttack V1.04R1:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-05 18:55                     ` Achim Gratz
@ 2010-10-05 21:12                       ` Carsten Dominik
  0 siblings, 0 replies; 25+ messages in thread
From: Carsten Dominik @ 2010-10-05 21:12 UTC (permalink / raw)
  To: Achim Gratz; +Cc: emacs-orgmode


On Oct 5, 2010, at 8:55 PM, Achim Gratz wrote:

>
> Commit 59ba4125 lisp/org-latex.el raises warning during byte-compile:
>
> In org-export-as-pdf:
> org-latex.el:882:28:Warning: assignment to free variable `errors'
> org-latex.el:882:47:Warning: reference to free variable `errors'

Fixed, thanks.

- Carsten

>
>
> Regards,
> Achim.
> -- 
> +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
>
> SD adaptation for Waldorf rackAttack V1.04R1:
> http://Synth.Stromeko.net/Downloads.html#WaldorfSDada
>
>
> _______________________________________________
> 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

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-05 16:26                   ` Carsten Dominik
  2010-10-05 18:55                     ` Achim Gratz
@ 2010-10-06  8:21                     ` Sébastien Vauban
  1 sibling, 0 replies; 25+ messages in thread
From: Sébastien Vauban @ 2010-10-06  8:21 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Carsten,

Carsten Dominik wrote:
> I have just pushed a fix which will use texi2dvi when available. The echo
> area will now also give an indication of the kinds of errors that happened
> during the final pdflatex run.

Thanks to Matthew for the info about texi2dvi!


> This is a big improvement, thanks to Sebastian for kicking off this
> discussion, and to all who contributed.

You're welcome. It was needed for me as well...


> Please test the new processing and let me know if there are problems.

Tested on the document for which I experienced the troubles in the first place
(because my TOC was more than one page long). Works perfect!

Only one comment, after reading your code in org-latex.el: if there is no
texi2dvi executable, please run pdflatex 3 times, as this is the right number
to get the TOC in sync' with the document, when it's more than one page long
(at least, in my above case, with a couple of org-babel sql source blocks).

--8<---------------cut here---------------start------------->8---
Changes in HEAD
	Modified lisp/org-latex.el
diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index c87071c..74d27b5 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -459,6 +459,7 @@ allowed.  The default we use here encompasses both."
   (if (executable-find "texi2dvi")
       '("texi2dvi -p -b -c -V %f")
     '("pdflatex -interaction nonstopmode -output-directory %o %f"
+      "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

--8<---------------cut here---------------end--------------->8---

Thanks.

Best regards,
  Seb

-- 
Sébastien 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

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-01 16:12         ` Nick Dokos
@ 2010-10-06  9:36           ` Bruno Tavernier
  2010-10-06 20:39             ` Matthew Leifer
  2010-10-06 21:54             ` Scot Becker
  0 siblings, 2 replies; 25+ messages in thread
From: Bruno Tavernier @ 2010-10-06  9:36 UTC (permalink / raw)
  To: emacs-orgmode

Just tried the texi2dvi command that is nice, one problem though, it
only makes use of pdflatex.

In certain situations, I like to use latex+ps2pdf (some journals ask for
.eps image file) or xelatex when mixing several fonts and writing in
UTF-8 is mandatory, for example French + Japanese, Chinese, Hindi, etc.

Currently I used the function below that I hook to the org-export-latex
process.

AFAIK, providing one use few packages, a .tex file to be used with
pdflatex can be similar to one to be used with xelatex. The content of
the document (UTF-8 characters) will make the difference.

To circumvent this problem, considering pdflatex as the default option,
I add to the org file a:
"#+LATEX_CMD: xelatex" or "#+LATEX_CMD: latex"

Note: bibtex and glossaries compilation are detected by their call,
e.g. \bibliography

How about introducing a "#+LATEX_CMD:" option in org-mode? (and default
to pdflatex)

,----
| ; Perform a 2 or 3 xe/pdf/latex compilation
| ; tex: tex + (glossaries) + (bibtex + tex) + tex
| 
| (defun my-auto-tex-cmd ()
|   "Automatically select the tex command to apply."
|   (let ((texcmd) (bibtexcmd) (glossariescmd) (dvi2pdfcmd))
|     ; default command
|     (setq texcmd "pdflatex -interaction nonstopmode %f;")
|     ; latex -> .dvi (for .eps images)
|     (if (string-match "LATEX_CMD: latex" (buffer-string))
| 	(progn
| 	  (setq texcmd "latex -interaction nonstopmode %f;")
| 	  (setq dvi2pdfcmd "dvips %b.dvi; ps2pdf %b.ps"))
|       ; xelatex -> .pdf
|       (if (string-match "LATEX_CMD: xelatex" (buffer-string))
| 	  (setq texcmd "xelatex -interaction nonstopmode %f;")))
|     ; first tex compilation command
|     (setq org-latex-to-pdf-process (list texcmd))
|     ; look for glossaries call
|     (if (string-match "\\\\makeglossaries" (buffer-string))
| 	(progn
| 	  (setq glossariescmd "makeindex -s %b.ist -t %b.glg -o %b.gls %b.glo;")
| 	  (setq org-latex-to-pdf-process
| 		(nconc org-latex-to-pdf-process (list glossariescmd)))))
|     ; look for bibtex call
|     (if (string-match "\\\\bibliography" (buffer-string))
| 	(progn
| 	  (setq bibtexcmd (concat "bibtex %b; " texcmd))
| 	  (setq org-latex-to-pdf-process
| 		(nconc org-latex-to-pdf-process (list bibtexcmd)))))
|     ; last tex compilation command
|     (setq org-latex-to-pdf-process
| 	  (nconc org-latex-to-pdf-process (list texcmd)))
|     ; dvi -> pdf
|     (if dvi2pdfcmd
| 	(setq org-latex-to-pdf-process
| 	      (nconc org-latex-to-pdf-process (list dvi2pdfcmd))))))
| 
| (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
`----


That also allow for customisation of the export of packages, for instance:

,----
| ; Default packages
| (setq org-export-latex-packages-alist
|       '(("" "graphicx" t)
| 	("" "longtable" nil)
| 	("" "amssymb" t)
| 	("" "color" t)
| 	("pdfborder=0" "hyperref" nil)
| 	("" "float" nil)))
| 
| ; Custom packages
| (defun my-auto-tex-parameters ()
|   "Automatically select the tex packages."
|   ; Default pdflatex
|   (setq org-export-latex-default-packages-alist
| 	'(("AUTO" "inputenc" t)))
|   ; Look for xelatex call
|   (if (string-match "LATEX_CMD: xelatex" (buffer-string))
|       (setq org-export-latex-default-packages-alist
| 	    '(("" "fontspec" t))))
| 
| (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-parameters)
`----


-- 
Bruno

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-06  9:36           ` Bruno Tavernier
@ 2010-10-06 20:39             ` Matthew Leifer
  2010-10-07  2:09               ` Bruno Tavernier
  2010-10-13  7:49               ` Olivier Schwander
  2010-10-06 21:54             ` Scot Becker
  1 sibling, 2 replies; 25+ messages in thread
From: Matthew Leifer @ 2010-10-06 20:39 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Bruno Tavernier


[-- Attachment #1.1: Type: text/plain, Size: 4674 bytes --]

That is odd.  texi2dvi should default to using regular latex.  You usually
have to pass a -p option or use the alias texi2pdf in order to use pdflatex.
 It might be that you have a LATEX environment variable set.  In any case,
you can alter this behaviour by setting the LATEX environment variable, e.g.
setting the variable LATEX=xelatex will make texi2dvi use xelatex instead of
regular latex.

Finally, regarding .eps files, note that the latest version of pdflatex can
handle .eps graphics without having to go through the latex->dvips->ps2pdf
route so it might be worth your while upgrading.  Failing that, you can put
\usepackage{epstopdf} in your preamble and then older versions of pdflatex
will work just fine.

Best,

Matt Leifer

On 6 October 2010 10:36, Bruno Tavernier <tavernier.bruno@gmail.com> wrote:

> Just tried the texi2dvi command that is nice, one problem though, it
> only makes use of pdflatex.
>
> In certain situations, I like to use latex+ps2pdf (some journals ask for
> .eps image file) or xelatex when mixing several fonts and writing in
> UTF-8 is mandatory, for example French + Japanese, Chinese, Hindi, etc.
>
> Currently I used the function below that I hook to the org-export-latex
> process.
>
> AFAIK, providing one use few packages, a .tex file to be used with
> pdflatex can be similar to one to be used with xelatex. The content of
> the document (UTF-8 characters) will make the difference.
>
> To circumvent this problem, considering pdflatex as the default option,
> I add to the org file a:
> "#+LATEX_CMD: xelatex" or "#+LATEX_CMD: latex"
>
> Note: bibtex and glossaries compilation are detected by their call,
> e.g. \bibliography
>
> How about introducing a "#+LATEX_CMD:" option in org-mode? (and default
> to pdflatex)
>
> ,----
> | ; Perform a 2 or 3 xe/pdf/latex compilation
> | ; tex: tex + (glossaries) + (bibtex + tex) + tex
> |
> | (defun my-auto-tex-cmd ()
> |   "Automatically select the tex command to apply."
> |   (let ((texcmd) (bibtexcmd) (glossariescmd) (dvi2pdfcmd))
> |     ; default command
> |     (setq texcmd "pdflatex -interaction nonstopmode %f;")
> |     ; latex -> .dvi (for .eps images)
> |     (if (string-match "LATEX_CMD: latex" (buffer-string))
> |       (progn
> |         (setq texcmd "latex -interaction nonstopmode %f;")
> |         (setq dvi2pdfcmd "dvips %b.dvi; ps2pdf %b.ps"))
> |       ; xelatex -> .pdf
> |       (if (string-match "LATEX_CMD: xelatex" (buffer-string))
> |         (setq texcmd "xelatex -interaction nonstopmode %f;")))
> |     ; first tex compilation command
> |     (setq org-latex-to-pdf-process (list texcmd))
> |     ; look for glossaries call
> |     (if (string-match "\\\\makeglossaries" (buffer-string))
> |       (progn
> |         (setq glossariescmd "makeindex -s %b.ist -t %b.glg -o %b.gls
> %b.glo;")
> |         (setq org-latex-to-pdf-process
> |               (nconc org-latex-to-pdf-process (list glossariescmd)))))
> |     ; look for bibtex call
> |     (if (string-match "\\\\bibliography" (buffer-string))
> |       (progn
> |         (setq bibtexcmd (concat "bibtex %b; " texcmd))
> |         (setq org-latex-to-pdf-process
> |               (nconc org-latex-to-pdf-process (list bibtexcmd)))))
> |     ; last tex compilation command
> |     (setq org-latex-to-pdf-process
> |         (nconc org-latex-to-pdf-process (list texcmd)))
> |     ; dvi -> pdf
> |     (if dvi2pdfcmd
> |       (setq org-latex-to-pdf-process
> |             (nconc org-latex-to-pdf-process (list dvi2pdfcmd))))))
> |
> | (add-hook 'org-export-latex-after-initial-vars-hook 'my-auto-tex-cmd)
> `----
>
>
> That also allow for customisation of the export of packages, for instance:
>
> ,----
> | ; Default packages
> | (setq org-export-latex-packages-alist
> |       '(("" "graphicx" t)
> |       ("" "longtable" nil)
> |       ("" "amssymb" t)
> |       ("" "color" t)
> |       ("pdfborder=0" "hyperref" nil)
> |       ("" "float" nil)))
> |
> | ; Custom packages
> | (defun my-auto-tex-parameters ()
> |   "Automatically select the tex packages."
> |   ; Default pdflatex
> |   (setq org-export-latex-default-packages-alist
> |       '(("AUTO" "inputenc" t)))
> |   ; Look for xelatex call
> |   (if (string-match "LATEX_CMD: xelatex" (buffer-string))
> |       (setq org-export-latex-default-packages-alist
> |           '(("" "fontspec" t))))
> |
> | (add-hook 'org-export-latex-after-initial-vars-hook
> 'my-auto-tex-parameters)
> `----
>
>
> --
> Bruno
>
> _______________________________________________
> 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
>

[-- Attachment #1.2: Type: text/html, Size: 5917 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-06  9:36           ` Bruno Tavernier
  2010-10-06 20:39             ` Matthew Leifer
@ 2010-10-06 21:54             ` Scot Becker
  1 sibling, 0 replies; 25+ messages in thread
From: Scot Becker @ 2010-10-06 21:54 UTC (permalink / raw)
  To: Bruno Tavernier; +Cc: emacs-orgmode

> How about introducing a "#+LATEX_CMD:" option in org-mode? (and default
> to pdflatex)

Yes, please!  I use xelatex almost exclusively since it has  unicode
support for non-latin scripts.  And increasingly, some will presumably
want to use LuaTeX, which I'm told is slated to replace pdflatex in
the longer term as the standard latex processing engine.

Scot

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-06 20:39             ` Matthew Leifer
@ 2010-10-07  2:09               ` Bruno Tavernier
  2010-10-13  7:49               ` Olivier Schwander
  1 sibling, 0 replies; 25+ messages in thread
From: Bruno Tavernier @ 2010-10-07  2:09 UTC (permalink / raw)
  To: Matthew Leifer; +Cc: org

Hey Matthew,

Thanks for the pointers.
I toyed with it a bit but that wasn't very successful.

> That is odd. texi2dvi should default to using regular latex. You usually
> have to pass a -p option or use the alias texi2pdf in order to use
> pdflatex.

It does default to latex, what I meant was that it default to pdflatex
with org-mode current setup.

> It might be that you have a LATEX environment variable set. In any case, you
> can alter this behaviour by setting the LATEX environment variable, e.g.
> setting the variable LATEX=xelatex will make texi2dvi use xelatex instead of
> regular latex. 

Setting the variable LATEX=xelatex indeed makes the compilation goes via
xelatex. However, texi2dvi seems to expect a .dvi to be generated (which
xelatex does not do) and thus fail to compile.

> Finally, regarding .eps files, note that the latest version of pdflatex can
> handle .eps graphics without having to go through the latex->dvips->ps2pdf
> route so it might be worth your while upgrading. Failing that, you can put \
> usepackage{epstopdf} in your preamble and then older versions of pdflatex will
> work just fine.

pdflatex -v
,----
| pdfTeX 3.1415926-1.40.10-2.2 (TeX Live 2009/Arch Linux)
`----

and still none of the above work. .eps file still require latex.

Nevermind though, the "#+LATEX_CMD" approach that is mentionned in my
previous post in this thread does the job. :-)

Emacs ought to be customized by the user!

-- 
Bruno

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-06 20:39             ` Matthew Leifer
  2010-10-07  2:09               ` Bruno Tavernier
@ 2010-10-13  7:49               ` Olivier Schwander
  2010-10-13 12:34                 ` Carsten Dominik
  1 sibling, 1 reply; 25+ messages in thread
From: Olivier Schwander @ 2010-10-13  7:49 UTC (permalink / raw)
  To: emacs-orgmode

Le 06 Oct 2010 21:39, Matthew Leifer a écrit:
> That is odd.  texi2dvi should default to using regular latex.  You usually
> have to pass a -p option or use the alias texi2pdf in order to use pdflatex.
>  It might be that you have a LATEX environment variable set.  In any case,
> you can alter this behaviour by setting the LATEX environment variable, e.g.
> setting the variable LATEX=xelatex will make texi2dvi use xelatex instead of
> regular latex.

Instead of texi2pdf, I'm used to work with rubber, which is a powerful
tool to automate the compilation of latex files (taking care of bibtex,
xfig figures, and a lot more). It works seamlessly with org-mode by
customizing the variable org-latex-to-pdf-process to "rubber -d --into
%o %f".

Cheers,

Olivier

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Re: [PATCH] Compiling multiple times the LaTeX output
  2010-10-13  7:49               ` Olivier Schwander
@ 2010-10-13 12:34                 ` Carsten Dominik
  0 siblings, 0 replies; 25+ messages in thread
From: Carsten Dominik @ 2010-10-13 12:34 UTC (permalink / raw)
  To: Olivier Schwander; +Cc: emacs-orgmode

Hi Oliver,

On Oct 13, 2010, at 9:49 AM, Olivier Schwander wrote:

> Le 06 Oct 2010 21:39, Matthew Leifer a écrit:
>> That is odd.  texi2dvi should default to using regular latex.  You  
>> usually
>> have to pass a -p option or use the alias texi2pdf in order to use  
>> pdflatex.
>> It might be that you have a LATEX environment variable set.  In any  
>> case,
>> you can alter this behaviour by setting the LATEX environment  
>> variable, e.g.
>> setting the variable LATEX=xelatex will make texi2dvi use xelatex  
>> instead of
>> regular latex.
>
> Instead of texi2pdf, I'm used to work with rubber, which is a powerful
> tool to automate the compilation of latex files (taking care of  
> bibtex,
> xfig figures, and a lot more). It works seamlessly with org-mode by
> customizing the variable org-latex-to-pdf-process to "rubber -d --into
> %o %f".

thank you for this information.  I have made this value one of the
built-in options in the customize interface.

Cheers

- Carsten

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2010-10-13 12:34 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-29 14:25 Compiling multiple times the LaTeX output Sébastien Vauban
2010-09-29 15:17 ` Noorul Islam K M
2010-09-30 13:27   ` [PATCH] " Sébastien Vauban
2010-09-30 15:39     ` Nick Dokos
2010-09-30 16:55       ` Sébastien Vauban
2010-10-01 15:32         ` Thomas S. Dye
2010-10-01 21:17           ` Sébastien Vauban
2010-10-04  7:41             ` Carsten Dominik
2010-10-04 10:36               ` Scot Becker
2010-10-05 12:46               ` Sébastien Vauban
2010-10-05 14:17                 ` Carsten Dominik
2010-10-05 14:30                 ` Matthew Leifer
2010-10-05 15:02                   ` Indraneel Majumdar
2010-10-05 16:26                   ` Carsten Dominik
2010-10-05 18:55                     ` Achim Gratz
2010-10-05 21:12                       ` Carsten Dominik
2010-10-06  8:21                     ` Sébastien Vauban
2010-10-05 18:24                   ` Achim Gratz
2010-10-01 16:12         ` Nick Dokos
2010-10-06  9:36           ` Bruno Tavernier
2010-10-06 20:39             ` Matthew Leifer
2010-10-07  2:09               ` Bruno Tavernier
2010-10-13  7:49               ` Olivier Schwander
2010-10-13 12:34                 ` Carsten Dominik
2010-10-06 21:54             ` Scot Becker

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).