* [PATCH] Add author and title to exported PDF properties
@ 2014-05-12 21:40 Marcel van der Boom
2014-05-14 7:05 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Marcel van der Boom @ 2014-05-12 21:40 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Marcel van der Boom
* lisp/ox-latex.el (org-latex-template): add pdfauthor and pdftitle
(org-latex-hyperref-template): add placeholders for author and title
(org-latex-template): adjust default template with author and title
This adds author and title to the pdf properties of the exported PDF
file when using the LaTeX backend.
---
lisp/ox-latex.el | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index cea21be..844f2cd 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -349,7 +349,7 @@ the toc:nil option, not to those generated with #+TOC keyword."
:type 'string)
(defcustom org-latex-hyperref-template
- "\\hypersetup{\n pdfkeywords={%k},\n pdfsubject={%d},\n pdfcreator={%c}}\n"
+ "\\hypersetup{\n pdfkeywords={%k},\n pdfsubject={%d},\n pdfcreator={%c},\n pdfauthor={%a},\n pdftitle={%t}}"
"Template for hyperref package options.
Value is a format string, which can contain the following placeholders:
@@ -357,6 +357,8 @@ Value is a format string, which can contain the following placeholders:
%k for KEYWORDS line
%d for DESCRIPTION line
%c for CREATOR line
+ %a for AUTHOR line
+ %t for TITLE line
Set it to the empty string to ignore the command completely."
:group 'org-export-latex
@@ -1216,6 +1218,8 @@ holding export options."
(format-spec (plist-get info :latex-hyperref)
(format-spec-make
?k (or (plist-get info :keywords) "")
+ ?a (or (first (plist-get info :author)) "")
+ ?t (or (first (plist-get info :title)) "")
?d (or (plist-get info :description)"")
?c (if (plist-get info :with-creator)
(plist-get info :creator)
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Add author and title to exported PDF properties
2014-05-12 21:40 [PATCH] Add author and title to exported PDF properties Marcel van der Boom
@ 2014-05-14 7:05 ` Nicolas Goaziou
2014-05-14 12:24 ` Marcel van der Boom
0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2014-05-14 7:05 UTC (permalink / raw)
To: Marcel van der Boom; +Cc: emacs-orgmode
Hello,
Marcel van der Boom <marcel@hsdev.com> writes:
Thanks for your patch. A few comments follow.
> * lisp/ox-latex.el (org-latex-template): add pdfauthor and pdftitle
> (org-latex-hyperref-template): add placeholders for author and title
> (org-latex-template): adjust default template with author and title
You need full stops at the end of sentences, and upper case letters
after the colons.
> (defcustom org-latex-hyperref-template
> - "\\hypersetup{\n pdfkeywords={%k},\n pdfsubject={%d},\n pdfcreator={%c}}\n"
> + "\\hypersetup{\n pdfkeywords={%k},\n pdfsubject={%d},\n pdfcreator={%c},\n pdfauthor={%a},\n pdftitle={%t}}"
Nitpick: the number of space characters after newline characters should
be consistent, even though it wasn't the case before your patch.
> + ?a (or (first (plist-get info :author)) "")
> + ?t (or (first (plist-get info :title)) "")
This part is buggy. Both (plist-get info :author) and (plist-get
info :title) will return a "secondary list", which is a list of strings
and syntax objects. You usually need to handle these with
`org-export-data', not `first'.
Alas, in this case, `org-export-data' may not be appropriate, as some
objects should be exported differently in these keywords. For example,
you may want to remove footnote references, radio-targets, targets,
links and possibly any LaTeX markup (e.g., are "\textbf{bold}" macros
allowed in these keywords?).
The usual way to achieve this is to create an anonymous export back-end,
derived from `latex', with `org-export-create-backend', and let it
handle specially problematic objects. You then use it within
`org-export-data-with-backend'. See `org-html--format-toc-headline' for
an example.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add author and title to exported PDF properties
2014-05-14 7:05 ` Nicolas Goaziou
@ 2014-05-14 12:24 ` Marcel van der Boom
2014-05-14 12:48 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Marcel van der Boom @ 2014-05-14 12:24 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 680 bytes --]
On wo 14-mei-2014 09:05
Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> [...]
>> + ?a (or (first (plist-get info :author)) "")
>> + ?t (or (first (plist-get info :title)) "")
>
> The usual way to achieve this is to create an anonymous export
> back-end, derived from `latex', with `org-export-create-backend', and
> let it handle specially problematic objects. You then use it within
> `org-export-data-with-backend'. See `org-html--format-toc-headline'
> for an example.
>
Are you saying 'author' and 'title' are problematic? How do they differ
from, say 'subject'? Was this the reason they are not included by
default in the PDF info?
marcel
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add author and title to exported PDF properties
2014-05-14 12:24 ` Marcel van der Boom
@ 2014-05-14 12:48 ` Nicolas Goaziou
2014-05-14 15:48 ` Marcel van der Boom
0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2014-05-14 12:48 UTC (permalink / raw)
To: Marcel van der Boom; +Cc: emacs-orgmode
Marcel van der Boom <marcel@hsdev.com> writes:
> Are you saying 'author' and 'title' are problematic?
I am saying that they need to be treated differently, and with more
care.
> How do they differ from, say 'subject'?
"subject", which refers to :description property, only contains a single
string, no Org syntax. OTOH, TITLE and AUTHOR keywords have their
contents parsed and, as such, can contain parsed objects. E.g.,
| keyword | value | property value |
|-------------+-------------+----------------------------|
| DESCRIPTION | some *text* | "some *text*" |
| TITLE | some *text* | ("some" (bold ... "text")) |
See also `org-element-document-properties'.
> Was this the reason they are not included by default in the PDF info?
They are not included by default in Org 8 because they were not included
in Org 7 either. I don't know the historical reason, though.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add author and title to exported PDF properties
2014-05-14 12:48 ` Nicolas Goaziou
@ 2014-05-14 15:48 ` Marcel van der Boom
2014-05-15 12:14 ` Sebastien Vauban
0 siblings, 1 reply; 6+ messages in thread
From: Marcel van der Boom @ 2014-05-14 15:48 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1033 bytes --]
On wo 14-mei-2014 14:48
Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> [...]
>> How do they differ from, say 'subject'?
>
> "subject", which refers to :description property, only contains a
> single string, no Org syntax. OTOH, TITLE and AUTHOR keywords have
> their contents parsed and, as such, can contain parsed objects. E.g.,
>
> | keyword | value | property value |
> |-------------+-------------+----------------------------|
> | DESCRIPTION | some *text* | "some *text*" |
> | TITLE | some *text* | ("some" (bold ... "text")) |
>
> See also `org-element-document-properties'.
>
Thanks, this section made the click for me.
I think I sort of assumed that 'LateX codes' in author and title were
just going to be dropped by the hyperref package itself to produce the
properties.
I'm not sure I can find the time to produce a better patch, this is
uncharted territory for me, so it will take some learning effort.
Thanks again,
marcel
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add author and title to exported PDF properties
2014-05-14 15:48 ` Marcel van der Boom
@ 2014-05-15 12:14 ` Sebastien Vauban
0 siblings, 0 replies; 6+ messages in thread
From: Sebastien Vauban @ 2014-05-15 12:14 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Marcel van der Boom wrote:
> On wo 14-mei-2014 14:48
> Nicolas Goaziou <n.goaziou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>> [...]
>>> How do they differ from, say 'subject'?
>>
>> "subject", which refers to :description property, only contains a
>> single string, no Org syntax. OTOH, TITLE and AUTHOR keywords have
>> their contents parsed and, as such, can contain parsed objects. E.g.,
>>
>> | keyword | value | property value |
>> |-------------+-------------+----------------------------|
>> | DESCRIPTION | some *text* | "some *text*" |
>> | TITLE | some *text* | ("some" (bold ... "text")) |
>>
>> See also `org-element-document-properties'.
>>
>
> Thanks, this section made the click for me.
>
> I think I sort of assumed that 'LateX codes' in author and title were
> just going to be dropped by the hyperref package itself to produce the
> properties.
For example, a complex author property which I sometimes have:
#+AUTHOR: \href{mailto:me-IsZ/h5lOg2PQT0dZR+AlfA@public.gmane.org}{My name} -- \href{mailto:colleague-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org}{My colleague}
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-05-15 12:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-12 21:40 [PATCH] Add author and title to exported PDF properties Marcel van der Boom
2014-05-14 7:05 ` Nicolas Goaziou
2014-05-14 12:24 ` Marcel van der Boom
2014-05-14 12:48 ` Nicolas Goaziou
2014-05-14 15:48 ` Marcel van der Boom
2014-05-15 12:14 ` Sebastien Vauban
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.