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