Re: [Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
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 ___ 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
[Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
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@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
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
Re: [Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
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.br...@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 ___ 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
Re: [Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
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 ___ 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
[Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
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 ___ 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
[Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
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
Re: [Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
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 wxhgmqzgw...@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.
Re: [Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
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 ___ 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
Re: [Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
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 wxhgmqzgw...@spammotel.com mailto:wxhgmqzgw...@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
[Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
Matthew Leifer mslei...@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 ___ 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
[Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
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 ___ 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
Re: [Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
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 ___ 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
Re: [Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
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
Re: [Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
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.domi...@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 ___ 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
Re: [Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
On Sep 30, 2010, at 6:55 AM, Sébastien Vauban wrote: Hi Nick, Nick Dokos wrote: Sébastien Vauban wxhgmqzgw...@spammotel.com wrote: Noorul Islam K M wrote: Sébastien Vauban wxhgmqzgw...@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 ___ 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
Re: [Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
Sébastien Vauban wxhgmqzgw...@spammotel.com wrote: Hi Nick, Nick Dokos wrote: Sébastien Vauban wxhgmqzgw...@spammotel.com wrote: Noorul Islam K M wrote: Sébastien Vauban wxhgmqzgw...@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 ___ 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
[Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
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 wxhgmqzgw...@spammotel.com wrote: Noorul Islam K M wrote: Sébastien Vauban wxhgmqzgw...@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. 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@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
Hi Nick, Nick Dokos wrote: Sébastien Vauban wxhgmqzgw...@spammotel.com wrote: Noorul Islam K M wrote: Sébastien Vauban wxhgmqzgw...@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 ___ 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