* Accessing #+EMAIL in LaTeX Export
@ 2014-02-04 4:30 R. Michael Weylandt
2014-02-04 5:54 ` Nick Dokos
0 siblings, 1 reply; 6+ messages in thread
From: R. Michael Weylandt @ 2014-02-04 4:30 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
HI,
I'm writing a latex export class which has an \email macro.
Is it possible to autofill this macro using the #+EMAIL: property?
Looking at ox-latex.el, it seems that email is hardcoded to be placed
in \thanks{} but there might be a hook I'm missing.
I thought that using a {{{ email }}} macro might work, but I keep
winding up with
\email{ {{{email}}} } in the produced LaTeX.
Thanks for any help,
Michael
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Accessing #+EMAIL in LaTeX Export
2014-02-04 4:30 Accessing #+EMAIL in LaTeX Export R. Michael Weylandt
@ 2014-02-04 5:54 ` Nick Dokos
2014-02-04 13:54 ` R. Michael Weylandt
0 siblings, 1 reply; 6+ messages in thread
From: Nick Dokos @ 2014-02-04 5:54 UTC (permalink / raw)
To: emacs-orgmode
"R. Michael Weylandt" <michael.weylandt@gmail.com> writes:
> HI,
>
> I'm writing a latex export class which has an \email macro.
>
> Is it possible to autofill this macro using the #+EMAIL: property?
> Looking at ox-latex.el, it seems that email is hardcoded to be placed
> in \thanks{} but there might be a hook I'm missing.
>
> I thought that using a {{{ email }}} macro might work, but I keep
> winding up with
> \email{ {{{email}}} } in the produced LaTeX.
>
Not sure what your \email macro is supposed to look like or what
it is supposed to do, but the {{{email}}} works for me, e.g. the
following produces my italicized email in the output:
--8<---------------cut here---------------start------------->8---
#+EMAIL: ndokos@gmail.com
* foo
This is my email: \emph{ {{{email}}} }.
--8<---------------cut here---------------end--------------->8---
--
Nick
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Accessing #+EMAIL in LaTeX Export
2014-02-04 5:54 ` Nick Dokos
@ 2014-02-04 13:54 ` R. Michael Weylandt
2014-02-04 14:22 ` Nick Dokos
0 siblings, 1 reply; 6+ messages in thread
From: R. Michael Weylandt @ 2014-02-04 13:54 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
On Tue, Feb 4, 2014 at 12:54 AM, Nick Dokos <ndokos@gmail.com> wrote:
> "R. Michael Weylandt" <michael.weylandt@gmail.com> writes:
>
>> HI,
>>
>> I'm writing a latex export class which has an \email macro.
>>
>> Is it possible to autofill this macro using the #+EMAIL: property?
>> Looking at ox-latex.el, it seems that email is hardcoded to be placed
>> in \thanks{} but there might be a hook I'm missing.
>>
>> I thought that using a {{{ email }}} macro might work, but I keep
>> winding up with
>> \email{ {{{email}}} } in the produced LaTeX.
>>
>
> Not sure what your \email macro is supposed to look like or what
> it is supposed to do, but the {{{email}}} works for me, e.g. the
> following produces my italicized email in the output:
>
> --8<---------------cut here---------------start------------->8---
> #+EMAIL: ndokos@gmail.com
>
> * foo
>
> This is my email: \emph{ {{{email}}} }.
> --8<---------------cut here---------------end--------------->8---
>
Hi Nick,
Thanks for taking a look at this. Let me say a bit more about what I'm
trying to do:
I want org-mode to export to the "amsart" class by default. In
addition to the regular \title, \author, \date macros, amsart also
allows for "email".
--8<---------------cut here-------------start--------------->8---
(add-to-list 'org-latex-classes
'("amsart"
"\\documentclass{amsart}
[DEFAULT-PACKAGES]
[PACKAGES]
[EXTRA]
\\email{ {{{email}}} }"
("\\section{%s}" . "\\section{%s}")
("\\subsection{%s}" . "\\subsection{%s}")
("\\subsubsection{%s}" . "\\subsubsection{%s}")))
--8<---------------cut here---------------end--------------->8---
Running this on a document like:
--8<---------------cut here-------------start--------------->8---
#+TITLE: Test 1
#+AUTHOR: Michael Weylandt
#+EMAIL: Michael.Weylandt@gmail.com
#+LATEX_CLASS: amsart
* Header 1
Hello World
--8<---------------cut here---------------end--------------->8---
leaves me with "\email{email}" in the resulting LaTeX instead of
"\email{Michael.Weylandt@mail.com}". Since this is used as part of
\maketitle, doing something in the body (like your example) is too
late.
The #+EMAIL: value is handled by ox-latex.el, but it's only placed
inside the \author{} macro instead of in a stand alone \email{}.
That's the behavior I'm hoping to tweak.
Is that clearer?
Thanks again,
Michael
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Accessing #+EMAIL in LaTeX Export
2014-02-04 13:54 ` R. Michael Weylandt
@ 2014-02-04 14:22 ` Nick Dokos
2014-02-04 17:31 ` Nick Dokos
0 siblings, 1 reply; 6+ messages in thread
From: Nick Dokos @ 2014-02-04 14:22 UTC (permalink / raw)
To: emacs-orgmode
"R. Michael Weylandt" <michael.weylandt@gmail.com> writes:
> On Tue, Feb 4, 2014 at 12:54 AM, Nick Dokos <ndokos@gmail.com> wrote:
>> "R. Michael Weylandt" <michael.weylandt@gmail.com> writes:
>>
>>> HI,
>>>
>>> I'm writing a latex export class which has an \email macro.
>>>
>>> Is it possible to autofill this macro using the #+EMAIL: property?
>>> Looking at ox-latex.el, it seems that email is hardcoded to be placed
>>> in \thanks{} but there might be a hook I'm missing.
>>>
>>> I thought that using a {{{ email }}} macro might work, but I keep
>>> winding up with
>>> \email{ {{{email}}} } in the produced LaTeX.
>>>
>>
>> Not sure what your \email macro is supposed to look like or what
>> it is supposed to do, but the {{{email}}} works for me, e.g. the
>> following produces my italicized email in the output:
>>
>> --8<---------------cut here---------------start------------->8---
>> #+EMAIL: ndokos@gmail.com
>>
>> * foo
>>
>> This is my email: \emph{ {{{email}}} }.
>> --8<---------------cut here---------------end--------------->8---
>>
>
> Hi Nick,
>
> Thanks for taking a look at this. Let me say a bit more about what I'm
> trying to do:
>
> I want org-mode to export to the "amsart" class by default. In
> addition to the regular \title, \author, \date macros, amsart also
> allows for "email".
>
> (add-to-list 'org-latex-classes
> '("amsart"
> "\\documentclass{amsart}
> [DEFAULT-PACKAGES]
> [PACKAGES]
> [EXTRA]
> \\email{ {{{email}}} }"
> ("\\section{%s}" . "\\section{%s}")
> ("\\subsection{%s}" . "\\subsection{%s}")
> ("\\subsubsection{%s}" . "\\subsubsection{%s}")))
>
> Running this on a document like:
>
> #+TITLE: Test 1
> #+AUTHOR: Michael Weylandt
> #+EMAIL: Michael.Weylandt@gmail.com
> #+LATEX_CLASS: amsart
> * Header 1
> Hello World
>
> leaves me with "\email{email}" in the resulting LaTeX instead of
> "\email{Michael.Weylandt@mail.com}". Since this is used as part of
> \maketitle, doing something in the body (like your example) is too
> late.
>
> The #+EMAIL: value is handled by ox-latex.el, but it's only placed
> inside the \author{} macro instead of in a stand alone \email{}.
> That's the behavior I'm hoping to tweak.
>
> Is that clearer?
>
Much - thanks. I haven't thought much about it but my knee-jerk reaction
is to use a marker (something like \email{@EMAIL@}) when defining the
class and use a filter to replace it at the end. But there are might be
more elegant solutions around.
--
Nick
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Accessing #+EMAIL in LaTeX Export
2014-02-04 14:22 ` Nick Dokos
@ 2014-02-04 17:31 ` Nick Dokos
2014-02-04 21:46 ` R. Michael Weylandt <michael.weylandt@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Nick Dokos @ 2014-02-04 17:31 UTC (permalink / raw)
To: emacs-orgmode
Nick Dokos <ndokos@gmail.com> writes:
> "R. Michael Weylandt" <michael.weylandt@gmail.com> writes:
>
>> I want org-mode to export to the "amsart" class by default. In
>> addition to the regular \title, \author, \date macros, amsart also
>> allows for "email".
>>
>> (add-to-list 'org-latex-classes
>> '("amsart"
>> "\\documentclass{amsart}
>> [DEFAULT-PACKAGES]
>> [PACKAGES]
>> [EXTRA]
>> \\email{ {{{email}}} }"
>> ("\\section{%s}" . "\\section{%s}")
>> ("\\subsection{%s}" . "\\subsection{%s}")
>> ("\\subsubsection{%s}" . "\\subsubsection{%s}")))
>>
>> Running this on a document like:
>>
>> #+TITLE: Test 1
>> #+AUTHOR: Michael Weylandt
>> #+EMAIL: Michael.Weylandt@gmail.com
>> #+LATEX_CLASS: amsart
>> * Header 1
>> Hello World
>>
>> leaves me with "\email{email}" in the resulting LaTeX instead of
>> "\email{Michael.Weylandt@mail.com}". Since this is used as part of
>> \maketitle, doing something in the body (like your example) is too
>> late.
>>
>> The #+EMAIL: value is handled by ox-latex.el, but it's only placed
>> inside the \author{} macro instead of in a stand alone \email{}.
>> That's the behavior I'm hoping to tweak.
>>
>> Is that clearer?
>>
>
> Much - thanks. I haven't thought much about it but my knee-jerk reaction
> is to use a marker (something like \email{@EMAIL@}) when defining the
> class and use a filter to replace it at the end. But there are might be
> more elegant solutions around.
So here's a brute-force solution along the above lines:
--8<---------------cut here---------------start------------->8---
#+EMAIL: ndokos@gmail.com
#+LATEX_CLASS: amsart
* foo
bar
* code :noexport:
This should probably go in some initialization file - for testing, I just executed
the code blocks by hand:
#+name: email-filter
#+BEGIN_SRC elisp :results none
(defun nd-email-filter (contents backend info)
(let ((email (plist-get info :email)))
(replace-regexp-in-string "@EMAIL@" email contents t)))
(add-to-list 'org-export-filter-final-output-functions (function nd-email-filter))
#+END_SRC
#+name: amsart
#+BEGIN_SRC elisp :results none
(setq amsart-class
'("amsart"
"\\documentclass{amsart}
[DEFAULT-PACKAGES]
[PACKAGES]
[EXTRA]
\\email{@EMAIL@ }"
("\\section{%s}" . "\\section{%s}")
("\\subsection{%s}" . "\\subsection{%s}")
("\\subsubsection{%s}" . "\\subsubsection{%s}")))
(add-to-list 'org-latex-classes amsart-class)
#+END_SRC
This deletes the amsart from the org-latex-classes list:
#+BEGIN_SRC elisp
(setq org-latex-classes (cdr org-latex-classes))
#+END_SRC
--8<---------------cut here---------------end--------------->8---
Nick
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Accessing #+EMAIL in LaTeX Export
2014-02-04 17:31 ` Nick Dokos
@ 2014-02-04 21:46 ` R. Michael Weylandt <michael.weylandt@gmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: R. Michael Weylandt <michael.weylandt@gmail.com> @ 2014-02-04 21:46 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 4590 bytes --]
On Feb 4, 2014, at 12:31, Nick Dokos <ndokos@gmail.com> wrote:
> Nick Dokos <ndokos@gmail.com> writes:
>
>> "R. Michael Weylandt" <michael.weylandt@gmail.com> writes:
>>
>>> I want org-mode to export to the "amsart" class by default. In
>>> addition to the regular \title, \author, \date macros, amsart also
>>> allows for "email".
>>>
>>> (add-to-list 'org-latex-classes
>>> '("amsart"
>>> "\\documentclass{amsart}
>>> [DEFAULT-PACKAGES]
>>> [PACKAGES]
>>> [EXTRA]
>>> \\email{ {{{email}}} }"
>>> ("\\section{%s}" . "\\section{%s}")
>>> ("\\subsection{%s}" . "\\subsection{%s}")
>>> ("\\subsubsection{%s}" . "\\subsubsection{%s}")))
>>>
>>> Running this on a document like:
>>>
>>> #+TITLE: Test 1
>>> #+AUTHOR: Michael Weylandt
>>> #+EMAIL: Michael.Weylandt@gmail.com
>>> #+LATEX_CLASS: amsart
>>> * Header 1
>>> Hello World
>>>
>>> leaves me with "\email{email}" in the resulting LaTeX instead of
>>> "\email{Michael.Weylandt@mail.com}". Since this is used as part of
>>> \maketitle, doing something in the body (like your example) is too
>>> late.
>>>
>>> The #+EMAIL: value is handled by ox-latex.el, but it's only placed
>>> inside the \author{} macro instead of in a stand alone \email{}.
>>> That's the behavior I'm hoping to tweak.
>>>
>>> Is that clearer?
>>
>> Much - thanks. I haven't thought much about it but my knee-jerk reaction
>> is to use a marker (something like \email{@EMAIL@}) when defining the
>> class and use a filter to replace it at the end. But there are might be
>> more elegant solutions around.
>
> So here's a brute-force solution along the above lines:
>
> --8<---------------cut here---------------start------------->8---
> #+EMAIL: ndokos@gmail.com
> #+LATEX_CLASS: amsart
>
> * foo
> bar
>
> * code :noexport:
> This should probably go in some initialization file - for testing, I just executed
> the code blocks by hand:
>
> #+name: email-filter
> #+BEGIN_SRC elisp :results none
> (defun nd-email-filter (contents backend info)
> (let ((email (plist-get info :email)))
> (replace-regexp-in-string "@EMAIL@" email contents t)))
>
> (add-to-list 'org-export-filter-final-output-functions (function nd-email-filter))
> #+END_SRC
>
> #+name: amsart
> #+BEGIN_SRC elisp :results none
> (setq amsart-class
> '("amsart"
> "\\documentclass{amsart}
> [DEFAULT-PACKAGES]
> [PACKAGES]
> [EXTRA]
> \\email{@EMAIL@ }"
> ("\\section{%s}" . "\\section{%s}")
> ("\\subsection{%s}" . "\\subsection{%s}")
> ("\\subsubsection{%s}" . "\\subsubsection{%s}")))
>
> (add-to-list 'org-latex-classes amsart-class)
> #+END_SRC
>
> This deletes the amsart from the org-latex-classes list:
>
> #+BEGIN_SRC elisp
> (setq org-latex-classes (cdr org-latex-classes))
> #+END_SRC
> --8<---------------cut here---------------end--------------->8---
>
> Nick
Hi Nick,
Thanks for the example; the filter seems to work well. Two possible issues:
1. I only want to use it for some latex classes
2. When using \email{} I want to get rid of the \thanks{} in \author{}.
I came up with the following:
<---------------------->
(require 'cl-lib)
(defun any (x) (cl-reduce (lambda (x y) (if x x y)) x))
;; For certain latex classes, the org-mode default of \author{NAME\thanks{EMAIL}}
;; isn't what the class wants
(defvar org-latex-classes-with-email '("amsart" "amsbook"))
;; After completing latex export, check if we are in one of the classes listed in 'org-latex-classes-with-email;
;; if we are, we need to
;; 1) Remove the \thanks{} macro inside \author{}
;; 2) Add an \email{} macro
;; This can be done with a single regex replace using captures.
(defun org-latex-classes-with-email-filter (contents backend info)
(if (any (mapcar (lambda (x) (string-match x contents)) org-latex-classes-with-email))
(replace-regexp-in-string "\\\\author{\\(.*\\)\\\\thanks{\\(.*\\)}}" "\\\\author{\\1}\n\\\\email{\\2}" contents)))
;; Thanks to Nick Dokos for the filter setup help --http://lists.gnu.org/archive/html/emacs-orgmode/2014-02/msg00130.html
(add-to-list 'org-export-filter-final-output-functions (function org-latex-classes-with-email-filter))
<------------------->
It's regex based so there may be some false positives, but it seems to work well enough for me.
Michael
[-- Attachment #2: Type: text/html, Size: 14926 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-02-04 21:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-04 4:30 Accessing #+EMAIL in LaTeX Export R. Michael Weylandt
2014-02-04 5:54 ` Nick Dokos
2014-02-04 13:54 ` R. Michael Weylandt
2014-02-04 14:22 ` Nick Dokos
2014-02-04 17:31 ` Nick Dokos
2014-02-04 21:46 ` R. Michael Weylandt <michael.weylandt@gmail.com>
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.