emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Different set of packages for LaTeX export
@ 2015-10-01 18:44 Manfred Lotz
  2015-10-01 19:21 ` Rasmus
  2015-10-06 10:17 ` Julien Cubizolles
  0 siblings, 2 replies; 6+ messages in thread
From: Manfred Lotz @ 2015-10-01 18:44 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,
I have configured LaTeX export for using xelatex. For this I have
defined a list of packages in org-latex-default-packages-alist. One of
those packages is hyperref with certain options.

When creating a normal document, e.g. using class article that works
fine.

When creating slides, i.e using beamer I get an option clash
during compiling the tex file because beamer did already load hyperref.

How can I solve it? 

Could I have a different package list if the class is beamer?


-- 
Manfred

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

* Re: Different set of packages for LaTeX export
  2015-10-01 18:44 Different set of packages for LaTeX export Manfred Lotz
@ 2015-10-01 19:21 ` Rasmus
  2015-10-02  3:30   ` Manfred Lotz
  2015-10-06 10:17 ` Julien Cubizolles
  1 sibling, 1 reply; 6+ messages in thread
From: Rasmus @ 2015-10-01 19:21 UTC (permalink / raw)
  To: emacs-orgmode

Hi Manfred,

Manfred Lotz <manfred.lotz@arcor.de> writes:

> When creating slides, i.e using beamer I get an option clash
> during compiling the tex file because beamer did already load hyperref.
>
> How can I solve it? 
>
> Could I have a different package list if the class is beamer?

No you can only discriminate based on the compiler version (and actually
only in ox-latex, not ox-beamer).

You can use a filter to remove hyperref.  AFAIK, there's only issues if
you use funny options for hyperref, e.g. I use

    ("unicode, psdextra,hidelinks" "hyperref" nil).

Last I checked there was an open bug report for this, so it might have
been fixed in upstream beamer.

I use this filter to remove hyperref in beamer exports:

       (defun rasmus/org-beamer-filter-remove-hyperref (text backend info)
         "Remove hyperref from beamer tex files.

     My default values are incompatible with beamer."
         ;; TODO: make better solution; check if still necessary
         (when (org-export-derived-backend-p backend 'beamer)
           (replace-regexp-in-string
            "\\\\usepackage\\[\\(.*?\\)\\]{hyperref}\n"
            ""
            text)))

       (add-to-list 'org-export-filter-final-output-functions
                    'rasmus/org-beamer-filter-remove-hyperref)


Hope it helps,
Rasmus

-- 
Slowly unravels in a ball of yarn and the devil collects it

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

* Re: Different set of packages for LaTeX export
  2015-10-01 19:21 ` Rasmus
@ 2015-10-02  3:30   ` Manfred Lotz
  2015-10-02  4:50     ` Fabrice Popineau
  0 siblings, 1 reply; 6+ messages in thread
From: Manfred Lotz @ 2015-10-02  3:30 UTC (permalink / raw)
  To: emacs-orgmode

On Thu, 01 Oct 2015 21:21:42 +0200
Rasmus <rasmus@gmx.us> wrote:

> Hi Manfred,
> 
> Manfred Lotz <manfred.lotz@arcor.de> writes:
> 
> > When creating slides, i.e using beamer I get an option clash
> > during compiling the tex file because beamer did already load
> > hyperref.
> >
> > How can I solve it? 
> >
> > Could I have a different package list if the class is beamer?
> 
> No you can only discriminate based on the compiler version (and
> actually only in ox-latex, not ox-beamer).
> 

Hm, I think it would be great if a package list could be mapped to a
certain LaTeX class.

> You can use a filter to remove hyperref.  AFAIK, there's only issues
> if you use funny options for hyperref, e.g. I use
> 
>     ("unicode, psdextra,hidelinks" "hyperref" nil).
> 

I have this 
      ("colorlinks=true, urlcolor=FireBrick, plainpages=false,
pdfpagelabels, bookmarksnumbered" "hyperref" nil)

which IMHO doesn't look to exotic.


> Last I checked there was an open bug report for this, so it might have
> been fixed in upstream beamer.
> 
> I use this filter to remove hyperref in beamer exports:
> 
>        (defun rasmus/org-beamer-filter-remove-hyperref (text backend
> info) "Remove hyperref from beamer tex files.
> 
>      My default values are incompatible with beamer."
>          ;; TODO: make better solution; check if still necessary
>          (when (org-export-derived-backend-p backend 'beamer)
>            (replace-regexp-in-string
>             "\\\\usepackage\\[\\(.*?\\)\\]{hyperref}\n"
>             ""
>             text)))
> 
>        (add-to-list 'org-export-filter-final-output-functions
>                     'rasmus/org-beamer-filter-remove-hyperref)
> 
> 

Yep, this works fine.


Thanks a lot for your help.

-- 
Best, Manfred

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

* Re: Different set of packages for LaTeX export
  2015-10-02  3:30   ` Manfred Lotz
@ 2015-10-02  4:50     ` Fabrice Popineau
  2015-10-02  8:41       ` Manfred Lotz
  0 siblings, 1 reply; 6+ messages in thread
From: Fabrice Popineau @ 2015-10-02  4:50 UTC (permalink / raw)
  To: Manfred Lotz; +Cc: emacs-orgmode@gnu.org

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

2015-10-02 5:30 GMT+02:00 Manfred Lotz <manfred.lotz@arcor.de>:

> On Thu, 01 Oct 2015 21:21:42 +0200
> Rasmus <rasmus@gmx.us> wrote:
>
> > Hi Manfred,
> >
> > Manfred Lotz <manfred.lotz@arcor.de> writes:
> >
> > > When creating slides, i.e using beamer I get an option clash
> > > during compiling the tex file because beamer did already load
> > > hyperref.
> > >
> > > How can I solve it?
> > >
> > > Could I have a different package list if the class is beamer?
> >
> > No you can only discriminate based on the compiler version (and
> > actually only in ox-latex, not ox-beamer).
> >
>
> Hm, I think it would be great if a package list could be mapped to a
> certain LaTeX class.
>
>
To solve this, I set up my own LaTeX class. I find it at least as good as
to rely
on Org configuration. Actually, I removed the list of packages that Org is
exporting.
My LaTeX class can produce slides, course notes, exams and so on. Based on
options, I can chose which kind of document and a few things like the style
(font, etc.).

Fabrice

[-- Attachment #2: Type: text/html, Size: 1690 bytes --]

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

* Re: Different set of packages for LaTeX export
  2015-10-02  4:50     ` Fabrice Popineau
@ 2015-10-02  8:41       ` Manfred Lotz
  0 siblings, 0 replies; 6+ messages in thread
From: Manfred Lotz @ 2015-10-02  8:41 UTC (permalink / raw)
  To: emacs-orgmode

Hi Fabrice,
Hope you are well. Last time I saw you was in Pont-à-Mousson in
2005. 


On Fri, 2 Oct 2015 06:50:03 +0200
Fabrice Popineau <fabrice.popineau@supelec.fr> wrote:

> 2015-10-02 5:30 GMT+02:00 Manfred Lotz <manfred.lotz@arcor.de>:
> 
> > On Thu, 01 Oct 2015 21:21:42 +0200
> > Rasmus <rasmus@gmx.us> wrote:
> >
> > > Hi Manfred,
> > >
> > > Manfred Lotz <manfred.lotz@arcor.de> writes:
> > >
> > > > When creating slides, i.e using beamer I get an option clash
> > > > during compiling the tex file because beamer did already load
> > > > hyperref.
> > > >
> > > > How can I solve it?
> > > >
> > > > Could I have a different package list if the class is beamer?
> > >
> > > No you can only discriminate based on the compiler version (and
> > > actually only in ox-latex, not ox-beamer).
> > >
> >
> > Hm, I think it would be great if a package list could be mapped to a
> > certain LaTeX class.
> >
> >
> To solve this, I set up my own LaTeX class. I find it at least as
> good as to rely
> on Org configuration. Actually, I removed the list of packages that
> Org is exporting.
> My LaTeX class can produce slides, course notes, exams and so on.
> Based on options, I can chose which kind of document and a few things
> like the style (font, etc.).
> 

You are right, of course. Using my own class I have the full control to
do what I like.


Thanks for the idea.


-- 
Manfred

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

* Re: Different set of packages for LaTeX export
  2015-10-01 18:44 Different set of packages for LaTeX export Manfred Lotz
  2015-10-01 19:21 ` Rasmus
@ 2015-10-06 10:17 ` Julien Cubizolles
  1 sibling, 0 replies; 6+ messages in thread
From: Julien Cubizolles @ 2015-10-06 10:17 UTC (permalink / raw)
  To: emacs-orgmode

Manfred Lotz <manfred.lotz@arcor.de> writes:

> Hi all,
> I have configured LaTeX export for using xelatex. For this I have
> defined a list of packages in org-latex-default-packages-alist. One of
> those packages is hyperref with certain options.
>
> When creating a normal document, e.g. using class article that works
> fine.
>
> When creating slides, i.e using beamer I get an option clash
> during compiling the tex file because beamer did already load hyperref.
>
> How can I solve it? 

The way I do it: I have different classes for different types of export
(beamer, or "normal") and I'm using different projects to choose from at
export time. The following code is at the beginning of the org file and
has to be run (C-c C-c) when you open the org file. The publishing
functions are just here to rename the pdf file.


--8<---------------cut here---------------start------------->8---
#+begin_src emacs-lisp :tangle yes :exports none
  (setq org-publish-project-alist
        `(("TeX"
           :base-directory "./"
           :publishing-directory "./"
           :publishing-function org-beamer-publish-to-latex
           :exclude ".*"
           :latex-class "mpsi_beamer"
           :include ,(list (file-name-nondirectory buffer-file-name))
           )
          ("beamer"
           :base-directory "./"
           :publishing-directory "./"
           :publishing-function org-beamer-publish-to-pdf
           :exclude ".*"
           :latex-class "mpsi_beamer"
           :include ,(list (file-name-nondirectory buffer-file-name))
           :completion-function jc-org-publish-rename-beamer-pdf
           )
          ("notes"
           :base-directory "./"
           :publishing-directory "./"
           :preparation-function jc-org-latex-notes-preparation
           :publishing-function org-beamer-publish-to-latex
           :exclude ".*"
           :latex-class "mpsi-beamerarticle"
           :include ,(list (file-name-nondirectory buffer-file-name))
           :completion-function jc-org-publish-rename-notes-pdf
           )
          ("eleves"
           :base-directory "./"
           :publishing-directory "./"
           :preparation-function jc-org-latex-notes-preparation
           :publishing-function org-beamer-publish-to-pdf
           :exclude ".*"
           :latex-class "mpsi-beamerarticle-eleves"
           :include ,(list (file-name-nondirectory buffer-file-name))
           :select-tags ("eleves")
           :completion-function jc-org-publish-rename-eleves-pdf
           )          
          ("cours" :components ("beamer" "notes" "eleves"))))
#+end_src
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
(defun jc-org-publish-rename-beamer-pdf ()
  "Rename file.pdf to file-beamer.pdf and file.tex to file-beamer.tex when buffer is visiting file.org"
  (jc-org-publish-rename '"pdf" '"beamer")
  (jc-org-publish-rename '"tex" '"beamer"))
--8<---------------cut here---------------end--------------->8---

--8<---------------cut here---------------start------------->8---
(defun jc-org-publish-rename (suffix version)
    "Rename file.suffix to file-version.suffix when buffer is visiting file.org"
    (let*   ((file-base-name (remove-org-suffix (buffer-file-name)))
	     (file-suffix-name (concat file-base-name "." suffix))
	     (file-version-suffix-name (concat file-base-name "-" version  "." suffix)))
    (if (file-exists-p file-suffix-name)
	(rename-file file-suffix-name file-version-suffix-name t))
    )
    )
--8<---------------cut here---------------end--------------->8---

Julien.

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

end of thread, other threads:[~2015-10-06 10:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-01 18:44 Different set of packages for LaTeX export Manfred Lotz
2015-10-01 19:21 ` Rasmus
2015-10-02  3:30   ` Manfred Lotz
2015-10-02  4:50     ` Fabrice Popineau
2015-10-02  8:41       ` Manfred Lotz
2015-10-06 10:17 ` Julien Cubizolles

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