emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output


From: Bruno Tavernier
Subject: [Orgmode] Re: [PATCH] Compiling multiple times the LaTeX output
Date: Wed, 06 Oct 2010 18:36:42 +0900
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]