From adbd4d4d14659fd8930ed9947ffb97696c4289da Mon Sep 17 00:00:00 2001 From: "Pedro A. Aranda" Date: Tue, 28 Jan 2025 10:16:20 +0100 Subject: [PATCH 1/2] obet with-title and with-author --- lisp/ox-latex.el: Obey :with-author and :with-title when exporting * lisp/ox-latex.el (org-latex-template) Do not generate `\title{}' and related when :with-title is nil. Do not generate `\author{}' and related when :with-author is nil. Fix `\hypersetup{}' accordingly. lisp/ox-latex.el | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) Reported-by: "Antero Mejr" Link: https://lists.gnu.org/archive/html/emacs-orgmode/2025-01/msg00313.html diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 16f8f5af2..409fa98cb 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2041,21 +2041,27 @@ holding export options." (let ((date (and (plist-get info :with-date) (org-export-get-date info)))) (format "\\date{%s}\n" (org-export-data date info))) ;; Title and subtitle. - (let* ((subtitle (plist-get info :subtitle)) - (formatted-subtitle - (when subtitle - (format (plist-get info :latex-subtitle-format) - (org-export-data subtitle info)))) - (separate (plist-get info :latex-subtitle-separate))) - (concat - (format "\\title{%s%s}\n" title - (if separate "" (or formatted-subtitle ""))) - (when (and separate subtitle) - (concat formatted-subtitle "\n")))) + (when (plist-get info :with-title) + (let* ((subtitle (plist-get info :subtitle)) + (formatted-subtitle + (when subtitle + (format (plist-get info :latex-subtitle-format) + (org-export-data subtitle info)))) + (separate (plist-get info :latex-subtitle-separate))) + (concat + (format "\\title{%s%s}\n" title + (if separate "" (or formatted-subtitle ""))) + (when (and separate subtitle) + (concat formatted-subtitle "\n"))))) ;; Hyperref options. (let ((template (plist-get info :latex-hyperref-template))) - (and (stringp template) - (format-spec template spec))) + (when (stringp template) + (unless (plist-get info :with-author) + (setq template (replace-regexp-in-string "%a" "" template))) + (unless (plist-get info :with-title) + ;; Replace title *and* subtitle + (setq template (replace-regexp-in-string "%[ts]" "" template))) + (format-spec template spec))) ;; engrave-faces-latex preamble (when (and (eq (plist-get info :latex-src-block-backend) 'engraved) (org-element-map (plist-get info :parse-tree) -- 2.34.1