[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [patch, ox-latex] better hyperref and title options
From: |
Rasmus |
Subject: |
[O] [patch, ox-latex] better hyperref and title options |
Date: |
Thu, 12 Feb 2015 01:39:21 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Hi,
This patch does two things.
1. Add better format-spec to ox-latex hyperref and title-command.
2. Use this to extend basic hyperref formatting to include title,
author, language etc.
Wrt the title-command, this is useful if you need one-off "custom"
formatting of a header in LaTeX, e.g. in ox-publish projects.
—Rasmus
--
There are known knowns; there are things we know that we know
>From d011059ef326827bd944b7949c4a14e7bdf215dd Mon Sep 17 00:00:00 2001
From: Rasmus <address@hidden>
Date: Wed, 11 Feb 2015 02:18:09 +0100
Subject: [PATCH] ox-latex: Format-spec for hyperref and title
* ox-latex.el (org-latex-format-spec): New function with format-specs.
(org-latex-template): Use org-latex-format-spec.
(org-latex-hyperref-template): New defaults and use
org-latex-format-spec.
(org-latex-title-command): Use org-latex-format-spec.
* ORG-NEWS: Mention change.
---
etc/ORG-NEWS | 3 +++
lisp/ox-latex.el | 51 ++++++++++++++++++++++++++++++++++-----------------
2 files changed, 37 insertions(+), 17 deletions(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 103828b..cc2c49a 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -227,6 +227,9 @@ Exact heading search for links now ignore spaces and
cookies. This is
the case for links of the form ~file:projects.org::*task title~, as
well as links of the form ~file:projects.org::some words~
when ~org-link-search-must-match-exact-headline~ is not nil.
+*** ~org-latex-hyperref-template~, ~org-latex-title-command~ formatting
+New formatting keys are supported. See ~org-latex-format-spec~.
+Further, ~org-latex-hyperref-template~ has new default value.
* Version 8.2
** Incompatible changes
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index d7514aa..5210447 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -383,9 +383,9 @@ are written as utf8 files."
(defcustom org-latex-title-command "\\maketitle"
"The command used to insert the title just after \\begin{document}.
-If this string contains the formatting specification \"%s\" then
-it will be used as a formatting string, passing the title as an
-argument."
+
+A number of formatting keys can be used to construct the command.
+See `org-latex-format-spec'."
:group 'org-export-latex
:type 'string)
@@ -397,14 +397,11 @@ 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 pdfauthor={%a},\n pdftitle={%t},\n pdfkeywords={%k},
+ pdfsubject={%d},\n pdfcreator={%c}, \n pdflang={%l}}\n"
"Template for hyperref package options.
-Value is a format string, which can contain the following placeholders:
-
- %k for KEYWORDS line
- %d for DESCRIPTION line
- %c for CREATOR line
+See `org-latex-format-spec' for placeholder keys.
Set it to the empty string to ignore the command completely."
:group 'org-export-latex
@@ -1193,6 +1190,26 @@ just outside of it."
INFO is a plist used as a communication channel."
(org-export-translate s :latex info))
+(defun org-latex-format-spec (info)
+ "Create a format-spec for e.g. `org-latex-hyperref-template'.
+
+Value is a format string, which can contain the following placeholders:
+
+ %a for AUTHOR keyword
+ %t for TITLE keyword
+ %k for KEYWORDS line
+ %d for DESCRIPTION line
+ %c for CREATOR line
+ %l for Language keyword
+ %D for DATE keyword"
+
+ `((?a . ,(or (org-export-data (plist-get info :author) info) ""))
+ (?t . ,(or (org-export-data (plist-get info :title) info) ""))
+ (?k . ,(or (plist-get info :keywords) ""))
+ (?d . ,(or (plist-get info :description) ""))
+ (?c . ,(if (plist-get info :with-creator) (plist-get info :creator) ""))
+ (?l . ,(or (plist-get info :language) ""))
+ (?D . ,(org-export-data (org-export-get-date info) info))))
;;; Template
@@ -1248,17 +1265,17 @@ holding export options."
;; Title
(format "\\title{%s}\n" title)
;; Hyperref options.
- (format-spec (plist-get info :latex-hyperref-template)
- (format-spec-make
- ?k (or (plist-get info :keywords) "")
- ?d (or (plist-get info :description)"")
- ?c (if (plist-get info :with-creator)
- (plist-get info :creator)
- "")))
+ (let ((template (plist-get info :latex-hyperref-template)))
+ (and (stringp template)
+ (format-spec template
+ (org-latex-format-spec info))))
;; Document start.
"\\begin{document}\n\n"
;; Title command.
- (let ((command (plist-get info :latex-title-command)))
+ (let* ((title-command (plist-get info :latex-title-command))
+ (command (and (stringp title-command)
+ (format-spec title-command
+ (org-latex-format-spec info)))))
(org-element-normalize-string
(cond ((string= "" title) nil)
((not (stringp command)) nil)
--
2.3.0
- [O] [patch, ox-latex] better hyperref and title options,
Rasmus <=
- Re: [O] [patch, ox-latex] better hyperref and title options, Nicolas Goaziou, 2015/02/12
- Re: [O] [patch, ox-latex] better hyperref and title options, Rasmus, 2015/02/14
- Re: [O] [patch, ox-latex] better hyperref and title options, Nicolas Goaziou, 2015/02/15
- Re: [O] [patch, ox-latex] better hyperref and title options, Rasmus, 2015/02/15
- Re: [O] [patch, ox-latex] better hyperref and title options, Nicolas Goaziou, 2015/02/15
- Re: [O] [patch, ox-latex] better hyperref and title options, Rasmus, 2015/02/15
- Re: [O] [patch, ox-latex] better hyperref and title options, Nicolas Goaziou, 2015/02/15
- Re: [O] [patch, ox-latex] better hyperref and title options, Rasmus, 2015/02/15
- Re: [O] [patch, ox-latex] better hyperref and title options, Rasmus, 2015/02/18
- Re: [O] [patch, ox-latex] better hyperref and title options, Nicolas Goaziou, 2015/02/19