emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH]: ox-latex: omit empty date
@ 2022-07-29 12:49 emacs--- via General discussions about Org-mode.
  2022-07-29 13:31 ` Ihor Radchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: emacs--- via General discussions about Org-mode. @ 2022-07-29 12:49 UTC (permalink / raw)
  To: Emacs Orgmode


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

 Dear list, 

In the attachment you can find a patch which omits an empty \date{} line in
a latex document when the option to include the date is set to nil or when 
no date is provided. This empty date line can cause problems is certain 
use cases. 
Kind regads,
Bob 

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

[-- Attachment #2: 0001-lisp-ox-latex-Omit-empty-date.patch --]
[-- Type: application/octet-stream, Size: 1431 bytes --]

From 120e4ca11f021fa2d7e7abf57187c2db71942302 Mon Sep 17 00:00:00 2001
From: Bob Vergauwen <emacs@vergauwen.me>
Date: Fri, 29 Jul 2022 14:28:21 +0200
Subject: [PATCH] lisp/ox-latex: Omit empty date

* lisp/ox-latex.el: (org-latex-template): When no date is provided or
the export option date is nil, the empty '\date{}' string is no
longer included in the exported latex document.

The default behaviour for ox-latex was to include an empty date line as
'\date{}'.  This empty date line can affect more complex latex templates
when the date is for example set by the template on compilation, or when
the date command is overwritten entirely.  In this new patch, the date
line is omitted from the exported document.

TINYCHANGE
---
 lisp/ox-latex.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 1ed988917..129b2dbf0 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1977,7 +1977,8 @@ holding export options."
 	     ((or author email) (format "\\author{%s}\n" (or author email)))))
      ;; Date.
      (let ((date (and (plist-get info :with-date) (org-export-get-date info))))
-       (format "\\date{%s}\n" (org-export-data date info)))
+       (cond date
+             (format "\\date{%s}\n" (org-export-data date info))))
      ;; Title and subtitle.
      (let* ((subtitle (plist-get info :subtitle))
 	    (formatted-subtitle
--
2.30.1 (Apple Git-130)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
  2022-07-29 12:49 [PATCH]: ox-latex: omit empty date emacs--- via General discussions about Org-mode.
@ 2022-07-29 13:31 ` Ihor Radchenko
       [not found] ` <87sfmkkptc.fsf@localhost-N898uXC--3-2>
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 17+ messages in thread
From: Ihor Radchenko @ 2022-07-29 13:31 UTC (permalink / raw)
  To: emacs; +Cc: Emacs Orgmode

emacs--- via "General discussions about Org-mode."
<emacs-orgmode@gnu.org> writes:

> From 120e4ca11f021fa2d7e7abf57187c2db71942302 Mon Sep 17 00:00:00 2001
> From: Bob Vergauwen <emacs@vergauwen.me>
> Date: Fri, 29 Jul 2022 14:28:21 +0200
> Subject: [PATCH] lisp/ox-latex: Omit empty date
>
> * lisp/ox-latex.el: (org-latex-template): When no date is provided or
> the export option date is nil, the empty '\date{}' string is no
> longer included in the exported latex document.
>
> The default behaviour for ox-latex was to include an empty date line as
> '\date{}'.  This empty date line can affect more complex latex templates
> when the date is for example set by the template on compilation, or when
> the date command is overwritten entirely.  In this new patch, the date
> line is omitted from the exported document.

Thanks! This looks reasonable.

>       (let ((date (and (plist-get info :with-date) (org-export-get-date info))))
> -       (format "\\date{%s}\n" (org-export-data date info)))
> +       (cond date
> +             (format "\\date{%s}\n" (org-export-data date info))))

This will give compilation error. Did you mean (when date ...)?

Best,
Ihor


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
       [not found] ` <87sfmkkptc.fsf@localhost-N898uXC--3-2>
@ 2022-07-29 18:49   ` emacs--- via General discussions about Org-mode.
  2022-07-30  5:49     ` Ihor Radchenko
  0 siblings, 1 reply; 17+ messages in thread
From: emacs--- via General discussions about Org-mode. @ 2022-07-29 18:49 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Emacs Orgmode


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

Hi Ihor, 
sorry for not testing my code!
 My test halted on the main branch with the message: Warning (python): 
Your `python-shell-interpreter' doesn't seem to support readline, yet 
`python-shell-completion-native-enable' was t and "python" is not part
 of the `python-shell-completion-native-disabled-interpreters' list.  
Native completions have been disabled locally. 
Shell native completion is disabled, using fallback
and I was not in the mood to fix this small problem with my python
installation.

The updated (and still untested) patch is attached to this mail.
Kind regards, 

Bob 



Jul 29, 2022, 15:31 by yantar92@gmail.com:

> emacs--- via "General discussions about Org-mode."
> <emacs-orgmode@gnu.org> writes:
>
>> From 120e4ca11f021fa2d7e7abf57187c2db71942302 Mon Sep 17 00:00:00 2001
>> From: Bob Vergauwen <emacs@vergauwen.me>
>> Date: Fri, 29 Jul 2022 14:28:21 +0200
>> Subject: [PATCH] lisp/ox-latex: Omit empty date
>>
>> * lisp/ox-latex.el: (org-latex-template): When no date is provided or
>> the export option date is nil, the empty '\date{}' string is no
>> longer included in the exported latex document.
>>
>> The default behaviour for ox-latex was to include an empty date line as
>> '\date{}'.  This empty date line can affect more complex latex templates
>> when the date is for example set by the template on compilation, or when
>> the date command is overwritten entirely.  In this new patch, the date
>> line is omitted from the exported document.
>>
>
> Thanks! This looks reasonable.
>
>> (let ((date (and (plist-get info :with-date) (org-export-get-date info))))
>> -       (format "\\date{%s}\n" (org-export-data date info)))
>> +       (cond date
>> +             (format "\\date{%s}\n" (org-export-data date info))))
>>
>
> This will give compilation error. Did you mean (when date ...)?
>
> Best,
> Ihor
>


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

[-- Attachment #2: 0001-lisp-ox-latex-Omit-empty-date.patch --]
[-- Type: application/octet-stream, Size: 1431 bytes --]

From 120e4ca11f021fa2d7e7abf57187c2db71942302 Mon Sep 17 00:00:00 2001
From: Bob Vergauwen <emacs@vergauwen.me>
Date: Fri, 29 Jul 2022 14:28:21 +0200
Subject: [PATCH] lisp/ox-latex: Omit empty date

* lisp/ox-latex.el: (org-latex-template): When no date is provided or
the export option date is nil, the empty '\date{}' string is no
longer included in the exported latex document.

The default behaviour for ox-latex was to include an empty date line as
'\date{}'.  This empty date line can affect more complex latex templates
when the date is for example set by the template on compilation, or when
the date command is overwritten entirely.  In this new patch, the date
line is omitted from the exported document.

TINYCHANGE
---
 lisp/ox-latex.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 1ed988917..129b2dbf0 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1977,7 +1977,8 @@ holding export options."
 	     ((or author email) (format "\\author{%s}\n" (or author email)))))
      ;; Date.
      (let ((date (and (plist-get info :with-date) (org-export-get-date info))))
-       (format "\\date{%s}\n" (org-export-data date info)))
+       (when date
+             (format "\\date{%s}\n" (org-export-data date info))))
      ;; Title and subtitle.
      (let* ((subtitle (plist-get info :subtitle))
 	    (formatted-subtitle
--
2.30.1 (Apple Git-130)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
  2022-07-29 18:49   ` emacs--- via General discussions about Org-mode.
@ 2022-07-30  5:49     ` Ihor Radchenko
  0 siblings, 0 replies; 17+ messages in thread
From: Ihor Radchenko @ 2022-07-30  5:49 UTC (permalink / raw)
  To: Bob Vergauwen; +Cc: Emacs Orgmode

emacs@vergauwen.me writes:

> The updated (and still untested) patch is attached to this mail.

Well. The patch is simple enough to not worry too much about checking.
And the tests are passing.

Applied onto main via a753d0dd2.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=a753d0dd26018a951fe21548ae6b513594b570a8

Also, we have a record that you have the FSF copyright assignment. Is it
still the case? If you have, you do not need to put TINYCHANGE cookie.

Best,
Ihor


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
  2022-07-29 12:49 [PATCH]: ox-latex: omit empty date emacs--- via General discussions about Org-mode.
  2022-07-29 13:31 ` Ihor Radchenko
       [not found] ` <87sfmkkptc.fsf@localhost-N898uXC--3-2>
@ 2022-07-30 16:13 ` Max Nikulin
  2022-07-31  0:53   ` Ihor Radchenko
  2022-07-31 15:25 ` Daniel Fleischer
  3 siblings, 1 reply; 17+ messages in thread
From: Max Nikulin @ 2022-07-30 16:13 UTC (permalink / raw)
  To: emacs-orgmode

On 29/07/2022 19:49, emacs--- via General discussions about Org-mode. wrote:
> 
> In the attachment you can find a patch which omits an empty \date{} line in
> a latex document when the option to include the date is set to nil or when
> no date is provided. This empty date line can cause problems is certain
> use cases.

>       (let ((date (and (plist-get info :with-date) (org-export-get-date info))))
> -       (format "\\date{%s}\n" (org-export-data date info)))
> +       (cond date

I would consider (plist-get info :with-date) instead of date here to 
allow to suppress date in the title by

#+options: title:t date:t
#+date:

With such approach to avoid \date{} in the latex file date:nil can be 
used in the options line.

> +             (format "\\date{%s}\n" (org-export-data date info))))




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
  2022-07-30 16:13 ` Max Nikulin
@ 2022-07-31  0:53   ` Ihor Radchenko
  2022-07-31  2:27     ` Max Nikulin
  0 siblings, 1 reply; 17+ messages in thread
From: Ihor Radchenko @ 2022-07-31  0:53 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

>>       (let ((date (and (plist-get info :with-date) (org-export-get-date info))))
>> -       (format "\\date{%s}\n" (org-export-data date info)))
>> +       (cond date
>
> I would consider (plist-get info :with-date) instead of date here to 
> allow to suppress date in the title by
>
> #+options: title:t date:t
> #+date:
>
> With such approach to avoid \date{} in the latex file date:nil can be 
> used in the options line.
>
>> +             (format "\\date{%s}\n" (org-export-data date info))))

I am sorry, but I do not understand.

I tried

#+options: title:t date:nil

No \date is exported.

#+options: title:t date:t

\date is exported

#+options: title:t date:t
#+date:

No date is export.

All the above makes sense. Do I miss something?

Best,
Ihor


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
  2022-07-31  0:53   ` Ihor Radchenko
@ 2022-07-31  2:27     ` Max Nikulin
  2022-07-31  2:38       ` Ihor Radchenko
  0 siblings, 1 reply; 17+ messages in thread
From: Max Nikulin @ 2022-07-31  2:27 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: emacs

On 31/07/2022 07:53, Ihor Radchenko wrote:
> Max Nikulin writes:
> 
>>>        (let ((date (and (plist-get info :with-date) (org-export-get-date info))))
>>> -       (format "\\date{%s}\n" (org-export-data date info)))
>>> +       (cond date
>>
>> I would consider (plist-get info :with-date) instead of date here to
>> allow to suppress date in the title by
>>
>> #+options: title:t date:t
>> #+date:
>>
>> With such approach to avoid \date{} in the latex file date:nil can be
>> used in the options line.
>>
>>> +             (format "\\date{%s}\n" (org-export-data date info))))
> 
> I am sorry, but I do not understand.
> 
> I tried
> 
> #+options: title:t date:nil
> 
> No \date is exported.
> 
> #+options: title:t date:t
> 
> \date is exported
> 
> #+options: title:t date:t
> #+date:
> 
> No date is export.
> 
> All the above makes sense. Do I miss something?

To be precise, \date is not exported to LaTeX file, but current date 
appears in PDF. That is why I consider the change as a breaking one.

Try to export to PDF the following document.

---- >8 ----
#+options: title:t
# #+options: date:nil
# #+date:
#+title: Title
test
---- 8< ----

PDF file is produced with current date. Before the patch it was possible 
to suppress date in PDF file by removing comment for either "#+options: 
date:nil" or for "#+date:". With current main branch HEAD some other 
workaround is required. I think, it is not what is expected from the 
description of the #+options: keyword:

> ‘date:’
>      Toggle inclusion of a date into exported file
>      (‘org-export-with-date’).

info "(org) Export Settings" https://orgmode.org/manual/Export-Settings.html


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
  2022-07-31  2:27     ` Max Nikulin
@ 2022-07-31  2:38       ` Ihor Radchenko
  2022-07-31  7:14         ` Max Nikulin
       [not found]         ` <eed45238-7cad-1752-9e98-688bd0ead08a@gmail.com-N8I60z3----2>
  0 siblings, 2 replies; 17+ messages in thread
From: Ihor Radchenko @ 2022-07-31  2:38 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode, emacs

Max Nikulin <manikulin@gmail.com> writes:

>> All the above makes sense. Do I miss something?
>
> To be precise, \date is not exported to LaTeX file, but current date 
> appears in PDF. That is why I consider the change as a breaking one.
>
> Try to export to PDF the following document.
>
> ---- >8 ----
> #+options: title:t
> # #+options: date:nil
> # #+date:
> #+title: Title
> test
> ---- 8< ----
>
> PDF file is produced with current date. Before the patch it was possible 
> to suppress date in PDF file by removing comment for either "#+options: 
> date:nil" or for "#+date:". With current main branch HEAD some other 
> workaround is required. I think, it is not what is expected from the 
> description of the #+options: keyword:

Agree. I did not know about this LaTeX default.

Bob, do you have any ideas? I am inclined to revert the patch.

Best,
Ihor


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
  2022-07-31  2:38       ` Ihor Radchenko
@ 2022-07-31  7:14         ` Max Nikulin
       [not found]         ` <eed45238-7cad-1752-9e98-688bd0ead08a@gmail.com-N8I60z3----2>
  1 sibling, 0 replies; 17+ messages in thread
From: Max Nikulin @ 2022-07-31  7:14 UTC (permalink / raw)
  To: Daniel Fleischer; +Cc: emacs-orgmode, emacs

On 31/07/2022 09:38, Ihor Radchenko wrote:
> Max Nikulin writes:
> 
>>> All the above makes sense. Do I miss something?
>>
>> To be precise, \date is not exported to LaTeX file, but current date
>> appears in PDF. That is why I consider the change as a breaking one.
>>
>> Try to export to PDF the following document.
>>
>> ---- >8 ----
>> #+options: title:t
>> # #+options: date:nil
>> # #+date:
>> #+title: Title
>> test
>> ---- 8< ----
>>
>> PDF file is produced with current date. Before the patch it was possible
>> to suppress date in PDF file by removing comment for either "#+options:
>> date:nil" or for "#+date:". With current main branch HEAD some other
>> workaround is required. I think, it is not what is expected from the
>> description of the #+options: keyword:
> 
> Agree. I did not know about this LaTeX default.
> 
> Bob, do you have any ideas? I am inclined to revert the patch.

We may ask the maintainer of ox-latex Daniel Fleischer if a better way 
to handle \date exists.

Bob, could you, please, provide more detail concerning your use case and 
the purpose of the patch?


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
  2022-07-29 12:49 [PATCH]: ox-latex: omit empty date emacs--- via General discussions about Org-mode.
                   ` (2 preceding siblings ...)
  2022-07-30 16:13 ` Max Nikulin
@ 2022-07-31 15:25 ` Daniel Fleischer
  2022-07-31 15:40   ` Daniel Fleischer
  3 siblings, 1 reply; 17+ messages in thread
From: Daniel Fleischer @ 2022-07-31 15:25 UTC (permalink / raw)
  To: emacs--- via General discussions about Org-mode.; +Cc: emacs

emacs--- via "General discussions about Org-mode." [2022-07-29 Fri 14:49] wrote:

> In the attachment you can find a patch which omits an empty \date{} line in
> a latex document when the option to include the date is set to nil or when 
> no date is provided. This empty date line can cause problems is certain 
> use cases. 

Sorry for the late response.

I would reckon people don't want the date displayed when they set it to
nil. But removing the line \date{} just prints today's date. I don't
understand the purpose of the patch.

Daniel


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
  2022-07-31 15:25 ` Daniel Fleischer
@ 2022-07-31 15:40   ` Daniel Fleischer
  2022-08-01  1:07     ` Ihor Radchenko
  0 siblings, 1 reply; 17+ messages in thread
From: Daniel Fleischer @ 2022-07-31 15:40 UTC (permalink / raw)
  To: emacs--- via General discussions about Org-mode.; +Cc: emacs

Daniel Fleischer [2022-07-31 Sun 18:25] wrote:

> I would reckon people don't want the date displayed when they set it to
> nil. But removing the line \date{} just prints today's date. I don't
> understand the purpose of the patch.

In other words \date{} is what prevents from the date being printed. Or
put differently \date{\today} and not putting \date is equivalent. See
http://www.emerson.emory.edu/services/latex/latex_125.html.

Daniel


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
  2022-07-31 15:40   ` Daniel Fleischer
@ 2022-08-01  1:07     ` Ihor Radchenko
  2022-08-05 12:42       ` Ihor Radchenko
  0 siblings, 1 reply; 17+ messages in thread
From: Ihor Radchenko @ 2022-08-01  1:07 UTC (permalink / raw)
  To: Daniel Fleischer; +Cc: emacs--- via General discussions about Org-mode., emacs

Daniel Fleischer <danflscr@gmail.com> writes:

> Daniel Fleischer [2022-07-31 Sun 18:25] wrote:
>
> In other words \date{} is what prevents from the date being printed. Or
> put differently \date{\today} and not putting \date is equivalent. See
> http://www.emerson.emory.edu/services/latex/latex_125.html.

Would you mind adding a short comment to the code of
`org-latex-template' explaining this pitfall?

Best,
Ihor


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
       [not found]         ` <eed45238-7cad-1752-9e98-688bd0ead08a@gmail.com-N8I60z3----2>
@ 2022-08-01 10:09           ` emacs--- via General discussions about Org-mode.
  2022-08-01 10:28             ` Daniel Fleischer
  0 siblings, 1 reply; 17+ messages in thread
From: emacs--- via General discussions about Org-mode. @ 2022-08-01 10:09 UTC (permalink / raw)
  To: Max Nikulin; +Cc: Daniel Fleischer, emacs-orgmode

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

On 31/07/2022 09:38, Ihor Radchenko wrote:

>> Max Nikulin writes:
>>
>>>> All the above makes sense. Do I miss something?
>>>>
>>>
>>> To be precise, \date is not exported to LaTeX file, but current date
>>> appears in PDF. That is why I consider the change as a breaking one.
>>>
>>> Try to export to PDF the following document.
>>>
>>> ---- >8 ----
>>> #+options: title:t
>>> # #+options: date:nil
>>> # #+date:
>>> #+title: Title
>>> test
>>> ---- 8< ----
>>>
>>> PDF file is produced with current date. Before the patch it was possible
>>> to suppress date in PDF file by removing comment for either "#+options:
>>> date:nil" or for "#+date:". With current main branch HEAD some other
>>> workaround is required. I think, it is not what is expected from the
>>> description of the #+options: keyword:
>>>
>>
>> Agree. I did not know about this LaTeX default.
>>
>> Bob, do you have any ideas? I am inclined to revert the patch.
>>
>
> We may ask the maintainer of ox-latex Daniel Fleischer if a better way to handle \date exists.
>
> Bob, could you, please, provide more detail concerning your use case and the purpose of the patch?
>
I was only looking at removing the empty date command string from my tex files. 
But I acknowledge the fact that it now generates an unwanted default date in the 
latex pdf file when "date:nil" is provided. 

In my use case, my template overwrites the date command and a date should be 
passed as 
\date{day}{month}{year}.
My template uses different formats for the date in different locations of the text. 
E.g. copyright notice, front cover, preface,...

My use case is very niche and be solved by changing my custom latex date 
command by renaming it as for example \mydate.

Adding extra options like with_date:nil seems overkill for this small issue. 

A second option would be is to analyze the data format in the org file.
If for example the date is specified as 
#+date: {day}{something}
and the regex \{.*\}  matches, then the date can be used as
and we use 
             (format "\\date%s\n" (org-export-data date info))))
instead of 
             (format "\\date{%s}\n" (org-export-data date info))))

This is non breaking and would not require any extra options to be passed on to the exporter. 
In this case, the date can also be suppressed by using 
#+date: {}

Kind regards,
Bob

[-- Attachment #2: Type: text/html, Size: 3930 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
  2022-08-01 10:09           ` emacs--- via General discussions about Org-mode.
@ 2022-08-01 10:28             ` Daniel Fleischer
  2022-08-01 10:55               ` emacs--- via General discussions about Org-mode.
  0 siblings, 1 reply; 17+ messages in thread
From: Daniel Fleischer @ 2022-08-01 10:28 UTC (permalink / raw)
  To: emacs--- via General discussions about Org-mode.; +Cc: Max Nikulin, emacs

emacs--- via "General discussions about Org-mode."
<emacs-orgmode@gnu.org> writes:

> My use case is very niche and be solved by changing my custom latex date 
> command by renaming it as for example \mydate.
>
> Adding extra options like with_date:nil seems overkill for this small issue. 

I agree; I think we shouldn't change basic behavior for more advanced
usages unless it's something many people are interested in and we keep a
backward compatibility.

> A second option would be is to analyze the data format in the org file.
> If for example the date is specified as 
> #+date: {day}{something}

The thing is \date is a macro with one parameter, a string. That's way
\date{} doesn't do anything and \date{\today} prints today's date where
\today return today's date as a string. Starting to introduce new kinds
of inputs - e.g. {y}{m}{d} - to the \date macro would just confuse
people, I think.

Daniel


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
  2022-08-01 10:28             ` Daniel Fleischer
@ 2022-08-01 10:55               ` emacs--- via General discussions about Org-mode.
  2022-08-01 16:47                 ` Max Nikulin
  0 siblings, 1 reply; 17+ messages in thread
From: emacs--- via General discussions about Org-mode. @ 2022-08-01 10:55 UTC (permalink / raw)
  To: Daniel Fleischer
  Cc: emacs--- viaGeneral discussions about Org-mode., Max Nikulin

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




> emacs--- via "General discussions about Org-mode."
> <emacs-orgmode@gnu.org> writes:
>
>> My use case is very niche and be solved by changing my custom latex date 
>> command by renaming it as for example \mydate.
>>
>> Adding extra options like with_date:nil seems overkill for this small issue.
>>
>
> I agree; I think we shouldn't change basic behavior for more advanced
> usages unless it's something many people are interested in and we keep a
> backward compatibility.
>
>> A second option would be is to analyze the data format in the org file.
>> If for example the date is specified as 
>> #+date: {day}{something}
>>
>
> The thing is \date is a macro with one parameter, a string. That's way
> \date{} doesn't do anything and \date{\today} prints today's date where
> \today return today's date as a string. Starting to introduce new kinds
> of inputs - e.g. {y}{m}{d} - to the \date macro would just confuse
> people, I think.
>

It is an optional use pattern and the old options wil still work. 
The following code would "mostly" does the trick (I come back at the mostly term
later in this mail)     ;; Date.
     (let ((date (and (plist-get info :with-date) (org-export-get-date info))))
       (if (string-match-p "^\{.*\}$" (org-export-data date info))
           (format "\\date%s\n" (org-export-data date info))
         (format "\\date{%s}\n" (org-export-data date info))))

Dates can now de set as, and exported to: 
#+date: some date  -> \date{some date}
#+date: my {date} -> \date{my \{date\}}
#+date: {my}{fancy}{date} -> \date{my}{fancy}{date}
#+date: {} -> \date{}

Why mostly:
At the moment the code escapes the provided brackets and the current behaviour is 
#+date: {my}{fancy}{date} -> \date\{my\}\{fancy\}\{date\}
#+date: {} -> \date\{\}
which is not correct and I cant seem to find a good way to alter the format command to 
not escape the special characters. Tips are appreciated. 

A general Remark: I feel that passing latex options by their literal value i.e. including all 
latex formatting and brackets, would be a good general addition to the exporter. I can 
imagine use cases where the author command is also overwritten to format names differently
at different locations in the document. As in 
#+author: {title}{name}{sir name}
#+author: {name}{thanks}{special thanks}
It gives the end user way more control over the final document and does not break any
backward compatibility.

Kind regards 
Bob 







[-- Attachment #2: Type: text/html, Size: 4299 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
  2022-08-01 10:55               ` emacs--- via General discussions about Org-mode.
@ 2022-08-01 16:47                 ` Max Nikulin
  0 siblings, 0 replies; 17+ messages in thread
From: Max Nikulin @ 2022-08-01 16:47 UTC (permalink / raw)
  To: emacs, Org Mode List

On 01/08/2022 17:55, emacs--- via General discussions about Org-mode. wrote:
> *later in this mail)*
>       ;; Date.
>       (let ((date (and (plist-get info :with-date) (org-export-get-date 
> info))))
>         (if (string-match-p "^\{.*\}$" (org-export-data date info))
>             (format "\\date%s\n" (org-export-data date info))
>           (format "\\date{%s}\n" (org-export-data date info))))

I am against such code.

> _Why mostly:_
> At the moment the code escapes the provided brackets and the current 
> behaviour is
> #+date: {my}{fancy}{date} -> \date\{my\}\{fancy\}\{date\}

     #+date: @@latex:{my}{fancy}{date}@@

Anyway such date is not suitable for other backends.

I think, custom command name and "#+latex_header:" with such command is 
proper solution.

It is possible to choose some combination of existing options like

     #+options: date:t
     #+date:

as instruction to not add the \date command, but I think it would be 
confusing for users and anyway a breaking change for some of them.

I suppose, reverting the patch was the proper step.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH]: ox-latex: omit empty date
  2022-08-01  1:07     ` Ihor Radchenko
@ 2022-08-05 12:42       ` Ihor Radchenko
  0 siblings, 0 replies; 17+ messages in thread
From: Ihor Radchenko @ 2022-08-05 12:42 UTC (permalink / raw)
  To: Daniel Fleischer; +Cc: emacs--- via General discussions about Org-mode., emacs

Ihor Radchenko <yantar92@gmail.com> writes:

> Daniel Fleischer <danflscr@gmail.com> writes:
>
>> Daniel Fleischer [2022-07-31 Sun 18:25] wrote:
>>
>> In other words \date{} is what prevents from the date being printed. Or
>> put differently \date{\today} and not putting \date is equivalent. See
>> http://www.emerson.emory.edu/services/latex/latex_125.html.
>
> Would you mind adding a short comment to the code of
> `org-latex-template' explaining this pitfall?

For record, this comment has been added in 5a49cc5f4.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5a49cc5f4f09910fd03d5db590ae2b80f5981a66

Best,
Ihor


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-08-05 12:42 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-29 12:49 [PATCH]: ox-latex: omit empty date emacs--- via General discussions about Org-mode.
2022-07-29 13:31 ` Ihor Radchenko
     [not found] ` <87sfmkkptc.fsf@localhost-N898uXC--3-2>
2022-07-29 18:49   ` emacs--- via General discussions about Org-mode.
2022-07-30  5:49     ` Ihor Radchenko
2022-07-30 16:13 ` Max Nikulin
2022-07-31  0:53   ` Ihor Radchenko
2022-07-31  2:27     ` Max Nikulin
2022-07-31  2:38       ` Ihor Radchenko
2022-07-31  7:14         ` Max Nikulin
     [not found]         ` <eed45238-7cad-1752-9e98-688bd0ead08a@gmail.com-N8I60z3----2>
2022-08-01 10:09           ` emacs--- via General discussions about Org-mode.
2022-08-01 10:28             ` Daniel Fleischer
2022-08-01 10:55               ` emacs--- via General discussions about Org-mode.
2022-08-01 16:47                 ` Max Nikulin
2022-07-31 15:25 ` Daniel Fleischer
2022-07-31 15:40   ` Daniel Fleischer
2022-08-01  1:07     ` Ihor Radchenko
2022-08-05 12:42       ` Ihor Radchenko

Code repositories for project(s) associated with this 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).