Hi, attached is a fix for the reported BUG, including a couple of test cases
Best, /PA On Tue, 28 Jan 2025 at 09:02, Pedro Andres Aranda Gutierrez < paag...@gmail.com> wrote: > BTW, > > Antero writes: > > The \title{} section is also populated when `org-export-with-title` is > > nil. > > In this case, we should also eliminate the \maketitle right? > > Best, /PA > > On Tue, 28 Jan 2025 at 08:31, Pedro Andres Aranda Gutierrez < > paag...@gmail.com> wrote: > >> Antero writes: >> > When exporting a latex document using `org-latex-export-to-latex`, a >> > \hypersetup section is added that contains the author name and title, >> > even though the variables `org-export-with-title` and >> > `org-export-with-author` are nil. >> > >> > The \title{} section is also populated when `org-export-with-title` is >> > nil. >> > >> > I think the latex exporter should work like the HTML exporter, and >> > respect the `org-export-with-*` settings to suppress the export of those >> > commands. >> > >> > Emacs : GNU Emacs 29.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version >> 3.24.41, >> > cairo version 1.18.0) >> > of 2024-04-01, modified by Debian >> > Package: Org mode version 9.6.15 (release_9.6.15 @ >> > /usr/share/emacs/29.3/lisp/org/) >> >> This is a good one... Working on it >> >> Best, /PA >> -- >> Fragen sind nicht da, um beantwortet zu werden, >> Fragen sind da um gestellt zu werden >> Georg Kreisler >> >> Headaches with a Juju log: >> unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should >> run a leader-deposed hook here, but we can't yet >> >> > > -- > Fragen sind nicht da, um beantwortet zu werden, > Fragen sind da um gestellt zu werden > Georg Kreisler > > Headaches with a Juju log: > unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run > a leader-deposed hook here, but we can't yet > > -- Fragen sind nicht da, um beantwortet zu werden, Fragen sind da um gestellt zu werden Georg Kreisler Headaches with a Juju log: unit-basic-16: 09:17:36 WARNING juju.worker.uniter.operation we should run a leader-deposed hook here, but we can't yet
From 46eedaf8c71446c2d12f5484ecced491ae7ae760 Mon Sep 17 00:00:00 2001 From: "Pedro A. Aranda" <paag...@gmail.com> Date: Tue, 28 Jan 2025 10:59:12 +0100 Subject: [PATCH 2/2] Test last patch and announce it in ORG-NEWS --- etc/ORG-NEWS: Announce fix for :with-title and :with-author testing/lisp/test-ox-latex.el: Add to tests for fixed behaviour * etc/ORG-NEWS: Announce fix for :with-title and :with-author * testing/lisp/test-ox-latex.el: (test-ox-latex/with-title-nil) Make sure the title is not included in the generated LaTeX if :with-title is nil (test-ox-latex/with-author-nil) Make sure the author is not included in the generated LaTeX if :with-author is nil etc/ORG-NEWS | 7 ++++++ testing/lisp/test-ox-latex.el | 44 +++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) Reported-by: "Antero Mejr" Link: https://lists.gnu.org/archive/html/emacs-orgmode/2025-01/msg00313.html diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index cb2c16da8..7fa30223f 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -527,6 +527,13 @@ were tangled into a file named =NAME.bibtex=. Now, they are tangled into a file named =FILE.bib=, using the standard extension =.bib=, matching the rest of the ecosystem, including BibTeX and LaTeX. +*** =ox-latex=: fixed =:with-title= and =:with-author= handling + +The LaTeX exporter will not include the author in the resulting +document if the =:with-author= property is ~nil~; the same will happen +for =:with-title=. These properties are set with the +~org-export-with-author~ and ~org-export-with-title~ global variables. + * Version 9.7 ** Important announcements and breaking changes diff --git a/testing/lisp/test-ox-latex.el b/testing/lisp/test-ox-latex.el index 892ac4437..be107f510 100644 --- a/testing/lisp/test-ox-latex.el +++ b/testing/lisp/test-ox-latex.el @@ -127,5 +127,49 @@ Column & Column \\\\ (search-forward "\\href{https://orgmode.org/worg/images/orgmode/org-mode-unicorn.svg}{\\includegraphics[width=.9\\linewidth]{/wallpaper.png}}")))) +(ert-deftest test-ox-latex/with-title-nil () + "Test suppressing title in exported LaTeX" + (let ((org-export-with-title nil)) + (org-test-with-exported-text + 'latex + "#+AUTHOR: me +#+TITLE: Supressed + +* A test +A wonderful text" + (goto-char (point-min)) + (should-not + (search-forward "\\maketitle" nil t)) + (goto-char (point-min)) + (should-not + (search-forward "\\title{Suppressed}" nil t)) + (goto-char (point-min)) + (should-not + (search-forward "pdftitle={Suppressed}," nil t)) + (goto-char (point-min)) + (should + (search-forward "pdftitle={},")) + ))) + +(ert-deftest test-ox-latex/with-author-nil () + "Test suppressing author in exported LaTeX" + (let ((org-export-with-author nil)) + (org-test-with-exported-text + 'latex + "#+AUTHOR: me +#+TITLE: Supressed + +* A test +A wonderful text" + (goto-char (point-min)) + (should-not + (search-forward "\\author{me}" nil t)) + (goto-char (point-min)) + (should-not + (search-forward "pdftitle={me}," nil t)) + (goto-char (point-min)) + (should + (search-forward "pdfauthor={},")) + ))) (provide 'test-ox-latex) ;;; test-ox-latex.el ends here -- 2.34.1
From adbd4d4d14659fd8930ed9947ffb97696c4289da Mon Sep 17 00:00:00 2001 From: "Pedro A. Aranda" <paag...@gmail.com> 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