emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Pedro Andres Aranda Gutierrez <paaguti@gmail.com>
To: Org Mode List <emacs-orgmode@gnu.org>, mail@antr.me
Subject: Re: [BUG] Latex exporter should consider export settings [9.6.15 (release_9.6.15 @ /usr/share/emacs/29.3/lisp/org/)]
Date: Tue, 28 Jan 2025 13:59:44 +0100	[thread overview]
Message-ID: <CAO48Bk9CTASsa+4y+DtdT-0o08xGXgXOJXsUUa6XQaWWCP3Zrw@mail.gmail.com> (raw)
In-Reply-To: <CAO48Bk847i3Se7v-PNH0H3Ds=CAqHYFHLd6kK+iu+2qCFhdjqQ@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2104 bytes --]

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 <
paaguti@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 <
> paaguti@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

[-- Attachment #1.2: Type: text/html, Size: 3652 bytes --]

[-- Attachment #2: 0002-Test-last-patch-and-announce-it-in-ORG-NEWS.patch --]
[-- Type: text/x-patch, Size: 3297 bytes --]

From 46eedaf8c71446c2d12f5484ecced491ae7ae760 Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda" <paaguti@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


[-- Attachment #3: 0001-obey-with-title-and-with-author.patch --]
[-- Type: text/x-patch, Size: 2688 bytes --]

From adbd4d4d14659fd8930ed9947ffb97696c4289da Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda" <paaguti@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


  reply	other threads:[~2025-01-28 13:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-28  7:31 [BUG] Latex exporter should consider export settings [9.6.15 (release_9.6.15 @ /usr/share/emacs/29.3/lisp/org/)] Pedro Andres Aranda Gutierrez
2025-01-28  8:02 ` Pedro Andres Aranda Gutierrez
2025-01-28 12:59   ` Pedro Andres Aranda Gutierrez [this message]
2025-01-28 19:19     ` Antero Mejr
2025-01-29  6:04       ` Pedro Andres Aranda Gutierrez
2025-01-29 21:06         ` Antero Mejr
2025-01-30  5:43           ` Pedro Andres Aranda Gutierrez
2025-01-30  6:56             ` Pedro Andres Aranda Gutierrez
2025-01-30  8:31               ` Pedro Andres Aranda Gutierrez
  -- strict thread matches above, loose matches on Subject: below --
2025-01-28  1:38 Antero Mejr

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=CAO48Bk9CTASsa+4y+DtdT-0o08xGXgXOJXsUUa6XQaWWCP3Zrw@mail.gmail.com \
    --to=paaguti@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@antr.me \
    /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).