emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Replace EMAIL keyword by some LaTeX command
@ 2013-10-14  8:20 Xavier Garrido
  2013-10-15  0:11 ` Rasmus
  0 siblings, 1 reply; 4+ messages in thread
From: Xavier Garrido @ 2013-10-14  8:20 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

Dear Orgers,

I would like to use the EMAIL keyword from an orgmode file and translate 
it into a LaTeX command I have defined. To understand what I would like 
to achieve is to have an org mode file with

#+BEGIN_SRC org
#+TITLE:  LaTeX test
#+AUTHOR: toto
#+EMAIL:  toto@toto.org
#+END_SRC

and to get it translated to LaTeX

#+BEGIN_SRC latex
\title{LaTeX test}
\author{toto}
\email{toto@toto.org}
#+END_SRC

I have defined my own =email= LaTeX command so I know it will work. The 
only point is that I do not know how to translate =#+EMAIL= org keyword 
into =\email= LaTeX command. Can a export filter do it ?

Thanks,
Xavier

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

* Re: Replace EMAIL keyword by some LaTeX command
  2013-10-14  8:20 Replace EMAIL keyword by some LaTeX command Xavier Garrido
@ 2013-10-15  0:11 ` Rasmus
  2013-10-15  6:08   ` Xavier Garrido
  2013-10-15 19:19   ` Marcin Borkowski
  0 siblings, 2 replies; 4+ messages in thread
From: Rasmus @ 2013-10-15  0:11 UTC (permalink / raw)
  To: emacs-orgmode

Hi Xavier,

Xavier Garrido <xavier.garrido@gmail.com> writes:

But you have to be certain that this command is present.

You could use etoolbox to test it.  That brings in another dependency,
tho.

> The only point is that I do not know how to translate =#+EMAIL= org
> keyword into =\email= LaTeX command. Can a export filter do it ?

Of course.  Should it?  Up to you. . .

Here's an example that you can work on.  It's not well-tested and it
has limitations and evident from the example.  E.g. you disable it by
setting #+EMAIL: .

Hope it helps,
Rasmus

#+BEGIN_SRC Org
#+TITLE:  LaTeX test
#+AUTHOR: toto
#+EMAIL:  toto@toto.org
#+LATEX_HEADER: \usepackage{nopkg}
#+OPTIONS: with-email: t
Note that 
  1. email is inserted after other =latex_headers=
  2. with-email is ignored and only the presence of email matters.
     - You could add a check to =(plist-get options :with-email)= in
       the =(and ...)= statement below and remove the =\thanks{.}= in
       a final output filter.

#+begin_src emacs-lisp
  (defun rasmus/force-insert-email (options backend)
    "Insert EMAIL as \email{EMAIL} in the latex backend when EMAIL is present."
    (when (and (org-export-derived-backend-p backend 'latex)
               (plist-get options :email))
      (plist-put options :latex-header
                 (mapconcat 'identity 
                            (remove nil
                                    (list
                                     (plist-get options :latex-header)
                                     (format "\\email{%s}" 
                                             (plist-get options :email))))
                            "\n"))
      ;; don't insert email in \thanks{.}
      (plist-put options :with-email nil))
    options)
  
  (add-to-list 'org-export-filter-options-functions 'rasmus/force-insert-email)
#+end_src
#+END_SRC 


-- 
Enough with the bla bla!

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

* Re: Replace EMAIL keyword by some LaTeX command
  2013-10-15  0:11 ` Rasmus
@ 2013-10-15  6:08   ` Xavier Garrido
  2013-10-15 19:19   ` Marcin Borkowski
  1 sibling, 0 replies; 4+ messages in thread
From: Xavier Garrido @ 2013-10-15  6:08 UTC (permalink / raw)
  To: Rasmus, emacs-orgmode

Hi Rasmus,

It works like a charm ! Thanks a lot for the trick and for your help.

Xavier

Le 15/10/2013 02:11, Rasmus a écrit :
>
> #+BEGIN_SRC Org
> #+TITLE:  LaTeX test
> #+AUTHOR: toto
> #+EMAIL:  toto@toto.org
> #+LATEX_HEADER: \usepackage{nopkg}
> #+OPTIONS: with-email: t
> Note that
>    1. email is inserted after other =latex_headers=
>    2. with-email is ignored and only the presence of email matters.
>       - You could add a check to =(plist-get options :with-email)= in
>         the =(and ...)= statement below and remove the =\thanks{.}= in
>         a final output filter.
>
> #+begin_src emacs-lisp
>    (defun rasmus/force-insert-email (options backend)
>      "Insert EMAIL as \email{EMAIL} in the latex backend when EMAIL is present."
>      (when (and (org-export-derived-backend-p backend 'latex)
>                 (plist-get options :email))
>        (plist-put options :latex-header
>                   (mapconcat 'identity
>                              (remove nil
>                                      (list
>                                       (plist-get options :latex-header)
>                                       (format "\\email{%s}"
>                                               (plist-get options :email))))
>                              "\n"))
>        ;; don't insert email in \thanks{.}
>        (plist-put options :with-email nil))
>      options)
>
>    (add-to-list 'org-export-filter-options-functions 'rasmus/force-insert-email)
> #+end_src
> #+END_SRC
>
>

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

* Re: Replace EMAIL keyword by some LaTeX command
  2013-10-15  0:11 ` Rasmus
  2013-10-15  6:08   ` Xavier Garrido
@ 2013-10-15 19:19   ` Marcin Borkowski
  1 sibling, 0 replies; 4+ messages in thread
From: Marcin Borkowski @ 2013-10-15 19:19 UTC (permalink / raw)
  To: emacs-orgmode

Dnia 2013-10-15, o godz. 02:11:53
Rasmus <rasmus@gmx.us> napisał(a):

> Hi Xavier,
> 
> Xavier Garrido <xavier.garrido@gmail.com> writes:
> 
> But you have to be certain that this command is present.
> 
> You could use etoolbox to test it.  That brings in another dependency,
> tho.

Not really.

\providecommand{\email}[1]{whatever you like}

works like \newcommand, but if \email is defined, it doesn't change
it's definition.

Just my 2c.

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University

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

end of thread, other threads:[~2013-10-15 19:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-14  8:20 Replace EMAIL keyword by some LaTeX command Xavier Garrido
2013-10-15  0:11 ` Rasmus
2013-10-15  6:08   ` Xavier Garrido
2013-10-15 19:19   ` Marcin Borkowski

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