emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Sebastian Hofer <sebhofer@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] latex export - title placement
Date: Sat, 28 May 2011 14:42:07 +0200	[thread overview]
Message-ID: <87wrhbdmjk.wl%sebhofer@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1638 bytes --]

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


[-- Attachment #2: org-patch.diff --]
[-- Type: application/octet-stream, Size: 5733 bytes --]

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

             reply	other threads:[~2011-05-28 12:42 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-28 12:42 Sebastian Hofer [this message]
2011-05-28 12:59 ` [PATCH] latex export - title placement Sebastian Hofer
2011-05-28 17:27 ` Thomas S. Dye
2011-06-01 22:05   ` Nick Dokos
2011-06-01 23:19     ` Thomas S. Dye
2011-06-01 23:55     ` Nick Dokos
2011-06-02  8:36       ` Sebastian Hofer
2011-06-02  8:12     ` Sebastian Hofer
2011-06-02 15:57       ` Nick Dokos
2011-06-02 19:05         ` Sebastian Hofer
  -- strict thread matches above, loose matches on Subject: below --
2011-06-03  4:23 Nick Dokos
2011-06-03  8:11 ` Sebastian Hofer
2011-12-01 12:51 [bug] Symbol's function definition is void: org-pop-to-buffer-same-window Sebastien Vauban
2011-12-01 14:40 ` Kenny Meyer
2011-12-01 15:00   ` Nick Dokos
2011-12-01 15:05     ` Nick Dokos
2011-12-02 19:46       ` Kenny Meyer
2011-12-02 20:09         ` Nick Dokos
2011-12-02 20:41           ` Sebastien Vauban
2011-12-02 21:32             ` Nick Dokos
2011-12-06 20:24   ` Shelagh Manton
2011-12-06 21:19     ` Nick Dokos
2011-12-07  7:07       ` Shelagh Manton
2011-12-07  8:23         ` Nick Dokos
2011-12-07  8:34           ` Sebastien Vauban
2011-12-07 11:25             ` shelagh Manton
2011-12-07 20:45             ` Sebastien Vauban
2011-12-21 17:10               ` Gustav Wikström
2012-08-09 21:45 [OT] Current website not very attractive Marcelo de Moraes Serpa
2012-08-09 23:14 ` Jude DaShiell
2012-08-10  0:09   ` Sankalp
2012-08-10  4:02     ` Nick Dokos
2012-08-10  5:27       ` Jambunathan K
2012-08-10  6:30       ` Nick Dokos
2012-08-10 16:43         ` Marcelo de Moraes Serpa
2012-08-10 17:46           ` Nick Dokos
2012-08-11  9:29             ` Bastien
2012-08-10 19:56           ` brian powell
2012-08-11  9:30             ` Bastien
2012-09-13 20:19               ` Marcelo de Moraes Serpa
2012-09-13 20:21                 ` Marcelo de Moraes Serpa
2012-09-13 20:23                   ` Marcelo de Moraes Serpa
2012-09-14  5:41                     ` Bastien
2012-09-21 21:19                       ` Marcelo de Moraes Serpa
2012-09-21 22:50                         ` Nick Dokos
2012-09-21 22:59                           ` Eric Schulte
2012-09-21 23:14                             ` Nick Dokos
2012-09-22  4:06                               ` Nick Dokos
2012-09-22  6:51                               ` Bastien
2012-09-22  7:20                                 ` Nick Dokos
2012-09-22  7:44                                   ` Bastien
2012-09-22 14:13                                 ` Achim Gratz
2012-09-22 13:55                           ` John Hendy
2012-08-11 10:46             ` [ANN] Letter modes in the Groff exporter Luis Anaya
2012-08-11 11:03               ` Suvayu Ali
2012-08-11 15:50                 ` Luis Anaya
2012-08-11 17:00                   ` Bastien
2012-08-11  9:27           ` [OT] Current website not very attractive Bastien
2012-08-10  0:57 ` Ista Zahn
2012-08-10  7:05 ` [Contest] Redesign orgmode.org by the end of august (was: [OT] Current website not very attractive) Bastien
2012-08-10 12:40   ` John Hendy
2012-08-10 16:43     ` [Contest] Redesign orgmode.org by the end of august Thomas S. Dye
2012-08-10 18:04       ` Suvayu Ali
2012-08-11  9:33       ` Bastien
2012-08-11 21:45         ` Thomas S. Dye
2012-08-11 22:01           ` Bastien
2012-08-10 16:13   ` Rémi Letot
2012-08-11  9:25     ` Bastien
2012-08-25 20:18   ` Bastien
2012-08-25 21:11     ` Nick Dokos
2012-09-10 11:00   ` Bastien
2012-09-10 11:04     ` Bastien
2012-09-10 14:43       ` Nick Dokos
2012-09-10 12:01     ` Giovanni Ridolfi
2012-09-10 14:41     ` Nick Dokos
2012-09-10 14:45       ` Bastien
2012-09-11  0:23         ` Takaaki ISHIKAWA
2012-09-13  0:25           ` Bastien
2012-09-20 22:42     ` Brian van den Broek
2012-09-21  7:24       ` Bastien
2012-09-21 11:14         ` Brian van den Broek
2013-01-15 10:02 Logging of work no longer working with emcas24 Im Exil
2013-01-15 10:27 ` Nick Dokos
2013-01-15 10:47   ` Im Exil
2013-01-15 11:17   ` Nick Dokos
2013-01-15 13:55     ` Im Exil
2013-01-15 19:10       ` Achim Gratz
2013-01-16  8:20         ` Im Exil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wrhbdmjk.wl%sebhofer@gmail.com \
    --to=sebhofer@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).