emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: tsd@tsdye.com (Thomas S. Dye)
To: Alexander Vorobiev <alexander.vorobiev@gmail.com>
Cc: Bastien <bzg@altern.org>,
	Orgmode Mailing List <emacs-orgmode@gnu.org>,
	Gary Oberbrunner <garyo@oberbrunner.com>
Subject: Re: LaTeX export problem
Date: Fri, 21 Sep 2012 11:21:19 -1000	[thread overview]
Message-ID: <m1vcf7rs4a.fsf@tsdye.com> (raw)
In-Reply-To: <CAGOCFPUp8GodquFjG3tV7yU-WKQb8fzhX8T1tBfhY9NU_06j0Q@mail.gmail.com> (Alexander Vorobiev's message of "Fri, 21 Sep 2012 14:47:21 -0500")

Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:

> I tried the new exporter (using today's snapshot of the sources) and
> it produced invalid LaTeX (it calls hypersetup without loading
> hyperref package). It also ignored the #+LaTeX_CLASS: and all the
> #+LaTeX_HEADER:lines in my file. Are there any examples of org files
> which show how to customize the new LaTeX exporter?
>
> Thanks
> Alex

Aloha Alex,

I've been exploring the new exporter with a recent project. I have the
following probably too complex setup that lets me use biblatex in
conjunction with ebib.  I'm also using a customized setup for the Lucida
fonts (packages tsdlucida and lucidabr), which you'll most likely want
to change.

* Org-mode setup                                                   :noexport:
This is a setup for Nicolas Goaziou's new exporter

#+name: setup
#+begin_src emacs-lisp :noweb yes :results silent
    (require 'org-export)
    (require 'org-e-latex)
    (require 'org-e-html)
    (setq org-export-latex-packages-alist nil)
    (add-to-list 'org-export-latex-packages-alist '("colorlinks=true,urlcolor=SteelBlue4,linkcolor=Firebrick4,citecolor=Green4" "hyperref"))
    (add-to-list 'org-export-latex-packages-alist '("style=authoryear-comp,backend=bibtex8" "biblatex"))
    (add-to-list 'org-export-latex-packages-alist '("x11names" "xcolor"))
    (add-to-list 'org-export-latex-packages-alist '("" "microtype"))
    (add-to-list 'org-export-latex-packages-alist '("" "graphicx"))
    (add-to-list 'org-export-latex-packages-alist '("" "ragged2e"))
    (add-to-list 'org-export-latex-packages-alist '("" "booktabs"))
    (add-to-list 'org-export-latex-packages-alist '("" "tabularx"))
    (add-to-list 'org-export-latex-packages-alist '("" "tsdlucida"))
    (add-to-list 'org-export-latex-packages-alist '("" "wasysym"))
    (add-to-list 'org-export-latex-packages-alist '("" "paralist"))
    (add-to-list 'org-export-latex-packages-alist '("altbullet,lucidasmallscale,expert,vargreek" "lucidabr"))
    (add-to-list 'org-export-latex-packages-alist '("T1" "fontenc"))
    (add-to-list 'org-export-latex-packages-alist '("AUTO" "inputenc"))
    (setq org-entities-user nil) 
    (add-to-list 'org-entities-user '("space" "\\ " nil " " " " " " " "))
    (add-to-list 'org-entities-user '("amacron" "\\={a}" nil "&#0257" "a" "a" "ā"))
    (add-to-list 'org-entities-user '("emacron" "\\={e}" nil "&#0275" "e" "e" "ē"))
    (add-to-list 'org-entities-user '("imacron" "\\={i}" nil "&#0299" "i" "i" "ī"))
    (add-to-list 'org-entities-user '("omacron" "\\={o}" nil "&#0333" "o" "o" "ō"))
    (add-to-list 'org-entities-user '("umacron" "\\={u}" nil "&#0363" "u" "u" "ū"))
    (add-to-list 'org-entities-user '("Amacron" "\\={A}" nil "&#0256" "A" "A" "Ā"))
    (add-to-list 'org-entities-user '("Emacron" "\\={E}" nil "&#0274" "E" "E" "Ē"))
    (add-to-list 'org-entities-user '("Imacron" "\\={I}" nil "&#0298" "I" "I" "Ī"))
    (add-to-list 'org-entities-user '("Omacron" "\\={O}" nil "&#0332" "O" "O" "Ō"))
    (add-to-list 'org-entities-user '("Umacron" "\\={U}" nil "&#0362" "U" "U" "Ū"))
    (setq org-e-latex-pdf-process '("texi2dvi --pdf --clean --verbose --batch %f"))
    (require 'org-special-blocks)
    (define-key org-mode-map (kbd "C-c e") 'org-export-dispatch)
    (setq org-e-latex-tables-booktabs t)
    (setq org-export-latex-hyperref-format "\\ref{%s}")
    (setq org-e-latex-remove-logfiles nil)
    (setq org-e-latex-toc-command "\\tableofcontents\n\n")
    (add-to-list 'org-e-latex-classes
                 '("koma-article"
                   "\\documentclass{scrartcl}
      [NO-DEFAULT-PACKAGES]
      [PACKAGES]
      [EXTRA]
      \\let\\itemize\\compactitem
      \\let\\description\\compactdesc
      \\let\\enumerate\\compactenum
      \\bibliography{local}
      \\newcolumntype{Y}{>{\\RaggedRight\\arraybackslash}X}"
                   ("\\section{%s}" . "\\section*{%s}")
                   ("\\subsection{%s}" . "\\subsection*{%s}")
                   ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                   ("\\paragraph{%s}" . "\\paragraph*{%s}")
                   ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
    <<ngz-nbsp>>
    <<define-standard-biblatex-commands>>
    <<define-style-specific-biblatex-commands>>
#+end_src

** Standard Biblatex citation commands

#+name: define-standard-biblatex-commands
#+begin_src emacs-lisp :noweb yes :results silent :exports none
  <<define-biblatex-cite-link>>
  <<define-biblatex-cap-cite-link>>
  <<define-biblatex-parencite-link>>
  <<define-biblatex-cap-parencite-link>>
  <<define-biblatex-footcite-link>>
  <<define-biblatex-footcitetext-link>>

#+end_src

#+name: define-biblatex-cite-link
#+begin_src emacs-lisp :results silent :exports none
  (org-add-link-type 
   "cite" 'ebib
   (lambda (path desc format)
     (cond
      ((eq format 'html)
       (format "(<cite>%s</cite>)" path))
      ((eq format 'latex)
       (if (or (not desc) (equal 0 (search "cite:" desc)))
           (format "\\cite{%s}" path)
         (format "\\cite[%s][%s]{%s}"
                 (cadr (split-string desc ";"))
                 (car (split-string desc ";"))  path))))))
#+end_src

#+name: define-biblatex-cap-cite-link
#+begin_src emacs-lisp :results silent :exports none
  (org-add-link-type 
   "Cite" 'ebib
   (lambda (path desc format)
     (cond
      ((eq format 'html)
       (format "(<cite>%s</cite>)" path))
      ((eq format 'latex)
       (if (or (not desc) (equal 0 (search "Cite:" desc)))
           (format "\\Cite{%s}" path)
         (format "\\Cite[%s][%s]{%s}"
                 (cadr (split-string desc ";"))
                 (car (split-string desc ";"))  path))))))
#+end_src

#+name: define-biblatex-parencite-link
#+begin_src emacs-lisp :results silent :exports none
  (org-add-link-type 
   "parencite" 'ebib
   (lambda (path desc format)
     (cond
      ((eq format 'html)
       (format "(<cite>%s</cite>)" path))
      ((eq format 'latex)
       (if (or (not desc) (equal 0 (search "parencite:" desc)))
           (format "\\parencite{%s}" path)
         (format "\\parencite[%s][%s]{%s}"
                 (cadr (split-string desc ";"))
                 (car (split-string desc ";"))  path))))))
#+end_src

#+name: define-biblatex-cap-parencite-link
#+begin_src emacs-lisp :results silent :exports none
  (org-add-link-type 
   "Parencite" 'ebib
   (lambda (path desc format)
     (cond
      ((eq format 'html)
       (format "(<cite>%s</cite>)" path))
      ((eq format 'latex)
       (if (or (not desc) (equal 0 (search "Parencite:" desc)))
           (format "\\Parencite{%s}" path)
         (format "\\Parencite[%s][%s]{%s}"
                 (cadr (split-string desc ";"))
                 (car (split-string desc ";"))  path))))))
#+end_src

#+name: define-biblatex-footcite-link
#+begin_src emacs-lisp :results silent :exports none
  (org-add-link-type 
   "footcite" 'ebib
   (lambda (path desc format)
     (cond
      ((eq format 'html)
       (format "(<cite>%s</cite>)" path))
      ((eq format 'latex)
       (if (or (not desc) (equal 0 (search "footcite:" desc)))
           (format "\\footcite{%s}" path)
         (format "\\footcite[%s][%s]{%s}"
                 (cadr (split-string desc ";"))
                 (car (split-string desc ";"))  path))))))
#+end_src

#+name: define-biblatex-footcitetext-link
#+begin_src emacs-lisp :results silent :exports none
  (org-add-link-type 
   "footcitetext" 'ebib
   (lambda (path desc format)
     (cond
      ((eq format 'html)
       (format "(<cite>%s</cite>)" path))
      ((eq format 'latex)
       (if (or (not desc) (equal 0 (search "footcitetext:" desc)))
           (format "\\footcitetext{%s}" path)
         (format "\\footcitetext[%s][%s]{%s}"
                 (cadr (split-string desc ";"))
                 (car (split-string desc ";"))  path))))))
#+end_src

** Style-specific biblatex commands

#+name: define-style-specific-biblatex-commands
#+begin_src emacs-lisp :noweb yes :results silent :exports none
  <<define-biblatex-textcite-link>>
  <<define-biblatex-cap-textcite-link>>
  <<define-biblatex-smartcite-link>>
  <<define-biblatex-cap-smartcite-link>>
  <<define-biblatex-citestar-link>>
  <<define-biblatex-parencitestar-link>>
  <<define-biblatex-supercite-link>>
  <<define-biblatex-multicite-link>>
#+end_src

#+name: define-biblatex-multicite-link
#+begin_src emacs-lisp :results silent :exports none
  (org-add-link-type 
   "multicite" 'ebib
   (lambda (path desc format)
     (cond
      ((eq format 'html)
       (format "(<cite>%s</cite>)" path))
      ((eq format 'latex)
       (if (or (not desc) (equal 0 (search "multicite:" desc)))
           (format "{%s}" path)
         (format "[%s][%s]{%s}"
                 (cadr (split-string desc ";"))
                 (car (split-string desc ";"))  path))))))
  
#+end_src

#+name: define-biblatex-textcite-link
#+begin_src emacs-lisp :results silent :exports none
  (org-add-link-type 
   "textcite" 'ebib
   (lambda (path desc format)
     (cond
      ((eq format 'html)
       (format "(<cite>%s</cite>)" path))
      ((eq format 'latex)
       (if (or (not desc) (equal 0 (search "textcite:" desc)))
           (format "\\textcite{%s}" path)
         (format "\\textcite[%s][%s]{%s}"
                 (cadr (split-string desc ";"))
                 (car (split-string desc ";"))  path))))))
#+end_src

#+name: define-biblatex-cap-textcite-link
#+begin_src emacs-lisp :results silent :exports none
  (org-add-link-type 
   "Textcite" 'ebib
   (lambda (path desc format)
     (cond
      ((eq format 'html)
       (format "(<cite>%s</cite>)" path))
      ((eq format 'latex)
       (if (or (not desc) (equal 0 (search "Textcite:" desc)))
           (format "\\Textcite{%s}" path)
         (format "\\Textcite[%s][%s]{%s}"
                 (cadr (split-string desc ";"))
                 (car (split-string desc ";"))  path))))))
#+end_src

#+name: define-biblatex-smartcite-link
#+begin_src emacs-lisp :results silent :exports none
  (org-add-link-type 
   "smartcite" 'ebib
   (lambda (path desc format)
     (cond
      ((eq format 'html)
       (format "(<cite>%s</cite>)" path))
      ((eq format 'latex)
       (if (or (not desc) (equal 0 (search "smartcite:" desc)))
           (format "\\smartcite{%s}" path)
         (format "\\smartcite[%s][%s]{%s}"
                 (cadr (split-string desc ";"))
                 (car (split-string desc ";"))  path))))))
#+end_src

#+name: define-biblatex-cap-smartcite-link
#+begin_src emacs-lisp :results silent :exports none
  (org-add-link-type 
   "Smartcite" 'ebib
   (lambda (path desc format)
     (cond
      ((eq format 'html)
       (format "(<cite>%s</cite>)" path))
      ((eq format 'latex)
       (if (or (not desc) (equal 0 (search "Smartcite:" desc)))
           (format "\\Smartcite{%s}" path)
         (format "\\Smartcite[%s][%s]{%s}"
                 (cadr (split-string desc ";"))
                 (car (split-string desc ";"))  path))))))
#+end_src

#+name: define-biblatex-citestar-link
#+begin_src emacs-lisp :results silent :exports none
  (org-add-link-type 
   "cite*" 'ebib
   (lambda (path desc format)
     (cond
      ((eq format 'html)
       (format "(<cite>%s</cite>)" path))
      ((eq format 'latex)
       (if (or (not desc) (equal 0 (search "cite*:" desc)))
           (format "\\cite*{%s}" path)
         (format "\\cite*[%s][%s]{%s}"
                 (cadr (split-string desc ";"))
                 (car (split-string desc ";"))  path))))))
#+end_src

#+name: define-biblatex-parencitestar-link
#+begin_src emacs-lisp :results silent :exports none
  (org-add-link-type 
   "parencite*" 'ebib
   (lambda (path desc format)
     (cond
      ((eq format 'html)
       (format "(<cite>%s</cite>)" path))
      ((eq format 'latex)
       (if (or (not desc) (equal 0 (search "parencite*:" desc)))
           (format "\\parencite*{%s}" path)
         (format "\\parencite*[%s][%s]{%s}"
                 (cadr (split-string desc ";"))
                 (car (split-string desc ";"))  path))))))
#+end_src

#+name: define-biblatex-supercite-link
#+begin_src emacs-lisp :results silent :exports none
  (org-add-link-type 
   "supercite" 'ebib
   (lambda (path desc format)
     (cond
      ((eq format 'html)
       (format "(<cite>%s</cite>)" path))
      ((eq format 'latex)
       (format "\\cite*{%s}" path)))))
#+end_src

** Nicolas Goaziou's filter for non-breaking spaces
#+name: ngz-nbsp
#+begin_src emacs-lisp
(defun ngz-latex-filter-nobreaks (text backend info)
  "Ensure \"_\" are properly handled in Beamer/LaTeX export."
  (when (memq backend '(e-beamer e-latex))
    (replace-regexp-in-string " " "~" text)))
(add-to-list 'org-export-filter-plain-text-functions
             'ngz-latex-filter-nobreaks)
#+end_src
 

The header of my org file looks like this:

#+TITLE:     A Regional Chronology of Leeward North Kohala District, Hawai`i Island
#+AUTHOR:    Thomas Dye
#+DATE:   
#+LANGUAGE:  en
#+OPTIONS:   H:3 num:t toc:1 \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
#+LaTeX_CLASS: koma-article 
#+LaTeX_HEADER: \subtitle{Draft: Not for citation}
#+startup: fnadjust
#+TOC: figures
#+TOC: tables

Currently, I'm exporting with org-export-dispatch, but eventually I'll
tangle the setup into an init.el file and have a makefile that launches
emacs -q so I can be certain nothing in my .emacs has an influence.

Right now, though, I'm quite happy with the new exporter.

hth,
Tom

> On Fri, Sep 21, 2012 at 3:48 AM, Bastien <bzg@altern.org> wrote:
>> Hi Alexander,
>>
>> Alexander Vorobiev <alexander.vorobiev@gmail.com> writes:
>>
>>> Could you point us to any documentation on how to switch to the new
>>> exporter?
>>
>> Add contrib/lisp to your load-path.
>>
>> (require 'org-e-latex)
>>
>> then M-x org-export-dispatch RET to get a menu and be able to
>> export to LaTeX from here.
>>
>>> Is the tutorial
>>> http://orgmode.org/worg/org-tutorials/org-latex-export.html still
>>> relevant?
>>
>> No, this tutorial is valid for the current exporter, not for
>> Nicolas exporter.
>>
>> HTH,
>>
>> --
>>  Bastien
>
>

-- 
Thomas S. Dye
http://www.tsdye.com

  reply	other threads:[~2012-09-21 21:21 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-12 16:47 LaTeX export problem Gary Oberbrunner
2012-09-19  7:57 ` Bastien
2012-09-20 14:59   ` Alexander Vorobiev
2012-09-21  8:48     ` Bastien
2012-09-21 19:47       ` Alexander Vorobiev
2012-09-21 21:21         ` Thomas S. Dye [this message]
2012-09-22  8:01           ` Nicolas Goaziou
2012-09-22  8:07         ` Nicolas Goaziou
2012-09-24 16:40           ` Alexander Vorobiev
2012-09-24 21:15             ` Nicolas Goaziou
2012-09-24 21:32               ` Alexander Vorobiev
2012-09-26 18:48                 ` Nicolas Goaziou
  -- strict thread matches above, loose matches on Subject: below --
2014-07-13 21:25 Thomas S. Dye
2014-07-16 14:36 ` Nicolas Goaziou
2014-07-16 16:35   ` Thomas S. Dye
2012-01-09 15:45 Piotr Kaźmierczak
2012-01-10  0:13 ` Nick Dokos
2012-01-17 13:35   ` Piotr Kaźmierczak
2012-01-17 17:00     ` Nick Dokos
2012-01-17 19:00       ` Piotr Kaźmierczak
2012-01-17 20:45     ` Eric S Fraga
2010-09-30 14:55 latex " Jörg Hagmann
     [not found] ` <4CA4C29B.1060404@christianmoe.com>
2010-10-01  7:30   ` Jörg Hagmann
2010-10-01  7:32 ` Noorul Islam K M
2010-10-01  7:40   ` Jörg Hagmann
2010-10-01  9:03     ` Noorul Islam K M
2010-10-01  9:17       ` Noorul Islam
2010-10-01 11:38         ` Jörg Hagmann
2010-10-01 12:05           ` Jörg Hagmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1vcf7rs4a.fsf@tsdye.com \
    --to=tsd@tsdye.com \
    --cc=alexander.vorobiev@gmail.com \
    --cc=bzg@altern.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=garyo@oberbrunner.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).