From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastian Hofer Subject: [PATCH] latex export - title placement Date: Sat, 28 May 2011 14:42:07 +0200 Message-ID: <87wrhbdmjk.wl%sebhofer@gmail.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/mixed; boundary="Multipart_Sat_May_28_14:42:07_2011-1" Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([140.186.70.92]:55206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QQIqY-0005n7-Bz for emacs-orgmode@gnu.org; Sat, 28 May 2011 08:42:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QQIqX-0002nA-4k for emacs-orgmode@gnu.org; Sat, 28 May 2011 08:42:26 -0400 Received: from lo.gmane.org ([80.91.229.12]:34144) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QQIqW-0002n4-MP for emacs-orgmode@gnu.org; Sat, 28 May 2011 08:42:25 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QQIqV-0003o9-HV for emacs-orgmode@gnu.org; Sat, 28 May 2011 14:42:23 +0200 Received: from ahgate1.aei.uni-hannover.de ([130.75.117.49]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 28 May 2011 14:42:23 +0200 Received: from sebhofer by ahgate1.aei.uni-hannover.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 28 May 2011 14:42:23 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --Multipart_Sat_May_28_14:42:07_2011-1 Content-Type: text/plain; charset=US-ASCII Hi all, This patch addresses the problem of ambiguous conventions for the placement of the title related macros (\author, \date,...) with respect to the main document body in different latex classes. It introduces the following changes: * org-exp.el: - added the following options: - title-position (tpos) - with-title (wtitle) - with-author (wauth) - with-date (wdate) - with-maketitle (wmtitle) * org-latex.el: - implemented handling of new options (see above): - title-position controls placement of \title, \author, \date; possible values are "b" = before \begin{document}, any other values default to after \begin{document} - with-* controls if the corresponding macro is exported at all this can be convenient for more complex titles (e.g. several authors including affiliations,...) The patch seems to work for me so far. What do you all think? IMO it would be useful to integrate this, as it gives slightly more control over the export process. Of course one might want to think about better option names. The diff is done against commit bc161ded3693f752616dcd247fc9d638789025ee. Let me briefly describe my current use case: I disable all commands except \title, use babel to created a title.tex file (including several authors and affiliations) by tangling latex code and then include the file (into the main body of the document, not the preamble). That's the only decent way I've found to do this, if anyone knows an easier way (I have the feeling that I might be overlooking an obvious solution) please let me know! Cheers Sebastian --Multipart_Sat_May_28_14:42:07_2011-1 Content-Type: application/octet-stream; type=patch Content-Disposition: attachment; filename="org-patch.diff" Content-Transfer-Encoding: 8bit diff --git a/lisp/org-exp.el b/lisp/org-exp.el index d6ed193..e8086a6 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -618,6 +618,8 @@ table.el tables." (defvar org-min-level nil) ; dynamically scoped variable (defvar org-levels-open nil) ; dynamically scoped parameter +;; patched +;; Time-stamp: <2011-05-27 19:12:11 c705264> (defconst org-export-plist-vars '((:link-up nil org-export-html-link-up) (:link-home nil org-export-html-link-home) @@ -672,7 +674,13 @@ table.el tables." (:select-tags nil org-export-select-tags) (:exclude-tags nil org-export-exclude-tags) - (:latex-image-options nil org-export-latex-image-default-option)) + (:latex-image-options nil org-export-latex-image-default-option) + (:latex-title-position "tpos" org-export-latex-title-position) + (:latex-with-author "wauth" org-export-latex-with-author) + (:latex-with-date "wdate" org-export-latex-with-date) + (:latex-with-title "wtitle" org-export-latex-with-title) + (:latex-with-maketitle "wmtitle" org-export-latex-with-maketitle) + ) "List of properties that represent export/publishing variables. Each element is a list of 3 items: 1. The property that is used internally, and also for org-publish-project-alist diff --git a/lisp/org-latex.el b/lisp/org-latex.el index 764a48d..c2dc8df 100644 --- a/lisp/org-latex.el +++ b/lisp/org-latex.el @@ -78,6 +78,26 @@ ;;; User variables: +;; begin patched +;; Time-stamp: <2011-05-27 18:31:51 c705264> + +(defvar org-export-latex-title-position "b" + "Determines if \\title, \\author, \\email and \\date commands are inserted before (default) or + after (\"a\") \\begin{document}.") + +(defvar org-export-latex-with-maketitle t + "Determines if \\maketitle is inserted") + +(defvar org-export-latex-with-author t + "Determines if \\author is inserted") + +(defvar org-export-latex-with-date t + "Determines if \\date is inserted") + +(defvar org-export-latex-with-title t + "Determines if \\title is inserted") +;; end patched + (defgroup org-export-latex nil "Options for exporting Org-mode files to LaTeX." :tag "Org Export LaTeX" @@ -1334,6 +1354,8 @@ LEVEL indicates the default depth for export." "The function formatting returning the string to create the table of contents. The function mus take one parameter, the depth of the table of contents.") +;; patched +;; Time-stamp: <2011-05-27 19:06:33 c705264> (defun org-export-latex-make-header (title opt-plist) "Make the LaTeX header and return it as a string. TITLE is the current title from the buffer or region. @@ -1344,7 +1366,12 @@ OPT-PLIST is the options plist for current buffer." (email (replace-regexp-in-string "_" "\\\\_" (org-export-apply-macros-in-string - (plist-get opt-plist :email))))) + (plist-get opt-plist :email)))) + (title-position (plist-get opt-plist :latex-title-position)) + (with-author (plist-get opt-plist :latex-with-author)) + (with-date (plist-get opt-plist :latex-with-date)) + (with-title (plist-get opt-plist :latex-with-title)) + (with-maketitle (plist-get opt-plist :latex-with-maketitle))) (concat (if (plist-get opt-plist :time-stamp-file) (format-time-string "%% Created %Y-%m-%d %a %H:%M\n")) @@ -1359,33 +1386,43 @@ OPT-PLIST is the options plist for current buffer." (org-export-apply-macros-in-string org-export-latex-append-header) ;; define alert if not yet defined "\n\\providecommand{\\alert}[1]{\\textbf{#1}}" + "\n\n" + ;; beginning of the document (title after \begin{document}) + (when (not (string= "b" title-position)) + "\n\\begin{document}\n\n") ;; insert the title - (format - "\n\n\\title{%s}\n" - (org-export-latex-fontify-headline title)) + (when with-title + (format + "\\title{%s}\n" + (org-export-latex-fontify-headline title))) ;; insert author info - (if (plist-get opt-plist :author-info) - (format "\\author{%s%s}\n" - (org-export-latex-fontify-headline (or author user-full-name)) - (if (and (plist-get opt-plist :email-info) email - (string-match "\\S-" email)) - (format "\\thanks{%s}" email) - "")) - (format "%%\\author{%s}\n" - (org-export-latex-fontify-headline (or author user-full-name)))) + (when with-author + (if (plist-get opt-plist :author-info) + (format "\\author{%s%s}\n" + (org-export-latex-fontify-headline (or author user-full-name)) + (if (and (plist-get opt-plist :email-info) email + (string-match "\\S-" email)) + (format "\\thanks{%s}" email) + "")) + (format "%%\\author{%s}\n" + (org-export-latex-fontify-headline (or author user-full-name))))) ;; insert the date - (format "\\date{%s}\n" - (format-time-string - (or (plist-get opt-plist :date) - org-export-latex-date-format))) - ;; beginning of the document - "\n\\begin{document}\n\n" + (when with-date + (format "\\date{%s}\n" + (format-time-string + (or (plist-get opt-plist :date) + org-export-latex-date-format)))) + ;; insert the title command - (when (string-match "\\S-" title) + (when (and (string-match "\\S-" title) with-maketitle) + "\n\n" (if (string-match "%s" org-export-latex-title-command) (format org-export-latex-title-command title) org-export-latex-title-command)) "\n\n" + ;; beginning of the document (maketitle before \begin{document}) + (when (string= "b" title-position) + "\n\\begin{document}\n\n") ;; table of contents (when (and org-export-with-toc (plist-get opt-plist :section-numbers)) --Multipart_Sat_May_28_14:42:07_2011-1--