* Possible LaTeX export bug: Footnotes in items
@ 2024-01-22 20:42 Eric Anderson
2024-01-24 12:11 ` [BUG] Footnotes in section titles Ihor Radchenko
0 siblings, 1 reply; 24+ messages in thread
From: Eric Anderson @ 2024-01-22 20:42 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 976 bytes --]
Hi All,
I'm new to the developers' mailing list, so I hope this is the right place
to post potential bugs. I don't claim to know exactly why, but at least
for certain TOC options, the LaTeX exporter produces invalid code for item
titles containing footnotes. I've attached a minimal (non)working example.
The resulting LaTeX code (also attached) uses \footnote inside \section and
\paragraph macros, producing compiler errors. A little googling turns up
the following comp.text.tex usenet post
https://comp.text.tex.narkive.com/lkZWQYaS/using-footnotes-in-paragraph,
explaining that \footnote is fragile and cannot be used in those contexts
without \protect. Manually adding \protect before \footnote in the
automatically-generated tex file appears to produce correct results.
I don't know if the best fix is to always \protect \footnotes in LaTeX
export, or if more contextual smarts are required, but this seems like an
issue worth addressing.
Cheers!
Eric Anderson
[-- Attachment #1.2: Type: text/html, Size: 1237 bytes --]
[-- Attachment #2: org-bug-mwe.org --]
[-- Type: application/octet-stream, Size: 73 bytes --]
#+OPTIONS: toc:nil H:6
* a [fn:: note a]
** b
*** b
**** d [fn:: note b]
[-- Attachment #3: org-bug-mwe.tex --]
[-- Type: application/octet-stream, Size: 847 bytes --]
% Created 2024-01-22 Mon 15:34
% Intended LaTeX compiler: pdflatex
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage{tabularx}
\author{Eric Anderson}
\date{\today}
\title{}
\hypersetup{
pdfauthor={Eric Anderson},
pdftitle={},
pdfkeywords={},
pdfsubject={},
pdfcreator={Emacs 27.2 (Org mode 9.6.9)},
pdflang={English}}
\usepackage[style=ieee]{biblatex}
\begin{document}
\section{a \footnote{note a}}
\label{sec:orgc7711ed}
\subsection{b}
\label{sec:orgc167c8a}
\subsubsection{b}
\label{sec:org14707a4}
\paragraph{d \footnote{note b}}
\label{sec:org6daeb07}
\end{document}
^ permalink raw reply [flat|nested] 24+ messages in thread
* [BUG] Footnotes in section titles
2024-01-22 20:42 Possible LaTeX export bug: Footnotes in items Eric Anderson
@ 2024-01-24 12:11 ` Ihor Radchenko
2024-01-24 14:14 ` Max Nikulin
0 siblings, 1 reply; 24+ messages in thread
From: Ihor Radchenko @ 2024-01-24 12:11 UTC (permalink / raw)
To: Eric Anderson, Timothy; +Cc: emacs-orgmode
Eric Anderson <kluwak@gmail.com> writes:
> The resulting LaTeX code (also attached) uses \footnote inside \section and
> \paragraph macros, producing compiler errors. A little googling turns up
> the following comp.text.tex usenet post
> https://comp.text.tex.narkive.com/lkZWQYaS/using-footnotes-in-paragraph,
> explaining that \footnote is fragile and cannot be used in those contexts
> without \protect. Manually adding \protect before \footnote in the
> automatically-generated tex file appears to produce correct results.
>
> I don't know if the best fix is to always \protect \footnotes in LaTeX
> export, or if more contextual smarts are required, but this seems like an
> issue worth addressing.
Confirmed.
\protect is not a good idea. There is a reason why LaTeX refuses
footnotes in titles - titles can appear in multiple places in the
document (TOC, page footer, etc) and thus references to the footnotes
are non-deterministic.
https://texfaq.org/FAQ-ftnsect suggests to use
\usepackage[stable]{footmisc}
or to pass optional argument to \section without footnote
\section[title]{title\footnote{title ftnt}}
The footmisc package is a nice solution, but it has certain requirements
about loading order. In particular, it must be loaded after certain
packages (setspace, memoir). We cannot yet control the \usepackage
ordering in LaTeX preamble and always place default LaTeX packages first
- something we cannot do for footmisc.
The \section[...]{...} approach may work, but it is tricky - it is
completely up to the `org-latex-classes'. So, we may have to use regexp
replacement, which might be fragile.
So, I prefer the first approach with footmisc. But we can only do it
after Timothy's patch introducing more flexible templating system is
landed.
CCing Timothy.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [BUG] Footnotes in section titles
2024-01-24 12:11 ` [BUG] Footnotes in section titles Ihor Radchenko
@ 2024-01-24 14:14 ` Max Nikulin
2024-01-24 15:23 ` Juan Manuel Macías
2024-01-26 12:09 ` [BUG] Footnotes in section titles Ihor Radchenko
0 siblings, 2 replies; 24+ messages in thread
From: Max Nikulin @ 2024-01-24 14:14 UTC (permalink / raw)
To: Eric Anderson, Timothy; +Cc: emacs-orgmode
On 24/01/2024 19:11, Ihor Radchenko wrote:
> The \section[...]{...} approach may work, but it is tricky - it is
> completely up to the `org-latex-classes'. So, we may have to use regexp
> replacement, which might be fragile.
ox supports the ALT_TITLE property and ox-latex already adds it using
regexp. So it should possible to define this property with stripped
footnote by an export filter. I have not tested it, but ALT_TITLE and
@@latex:\protect@@ might be a workaround.
I recall some tricks with \footnotemark and \footnotetext, but I do not
remember details and whether it may work for section titles.
Complications may arise if a heading title has several footnotes.
Perhaps it is better to avoid footnotes in titles and to add some phrase
to the body instead.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [BUG] Footnotes in section titles
2024-01-24 14:14 ` Max Nikulin
@ 2024-01-24 15:23 ` Juan Manuel Macías
2024-01-24 15:31 ` Colin Baxter
2024-01-26 12:09 ` [BUG] Footnotes in section titles Ihor Radchenko
1 sibling, 1 reply; 24+ messages in thread
From: Juan Manuel Macías @ 2024-01-24 15:23 UTC (permalink / raw)
To: Max Nikulin; +Cc: Eric Anderson, ihor Timothy, Ihor Radchenko, orgmode
Max Nikulin writes:
> I recall some tricks with \footnotemark and \footnotetext, but I do
> not remember details and whether it may work for section titles.
> Complications may arise if a heading title has several footnotes.
ox-latex has 'org-latex--delayed-footnotes-definitions': "[...] This
function is used within constructs that don't support \footnote{}
command (e.g., an item tag). In that case, \footnotemark is used within
the construct and the function just outside of it."
The \footnotetext/\footnotemark option works well for specific cases,
but in general I don't like to abuse this method.
> Perhaps it is better to avoid footnotes in titles and to add some
> phrase to the body instead.
That is the ideal scenario. I also believe that footnotes should be
avoided in section headings, if possible. Or at least, have another type
of numbering (symbols, letters...). The manyfoot and bigfoot packages
allow constructions of this type, with various footnote apparatus.
Best regards,
Juan Manuel
--
Juan Manuel Macías --
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [BUG] Footnotes in section titles
2024-01-24 15:23 ` Juan Manuel Macías
@ 2024-01-24 15:31 ` Colin Baxter
2024-01-24 15:41 ` Juan Manuel Macías
0 siblings, 1 reply; 24+ messages in thread
From: Colin Baxter @ 2024-01-24 15:31 UTC (permalink / raw)
To: Juan Manuel Macías
Cc: Max Nikulin, Eric Anderson, ihor Timothy, Ihor Radchenko, orgmode
>>>>> Juan Manuel Macías <maciaschain@posteo.net> writes:
> Max Nikulin writes:
>> I recall some tricks with \footnotemark and \footnotetext, but I
>> do not remember details and whether it may work for section
>> titles. Complications may arise if a heading title has several
>> footnotes.
> ox-latex has 'org-latex--delayed-footnotes-definitions': "[...]
> This function is used within constructs that don't support
> \footnote{} command (e.g., an item tag). In that case,
> \footnotemark is used within the construct and the function just
> outside of it."
> The \footnotetext/\footnotemark option works well for specific
> cases, but in general I don't like to abuse this method.
>> Perhaps it is better to avoid footnotes in titles and to add some
>> phrase to the body instead.
> That is the ideal scenario. I also believe that footnotes should
> be avoided in section headings, if possible. Or at least, have
> another type of numbering (symbols, letters...). The manyfoot and
> bigfoot packages allow constructions of this type, with various
> footnote apparatus.
Indeed, but many journals *require* footnotes in titles, especially for
affiliation, email, etc.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [BUG] Footnotes in section titles
2024-01-24 15:31 ` Colin Baxter
@ 2024-01-24 15:41 ` Juan Manuel Macías
2024-01-26 12:53 ` Ihor Radchenko
0 siblings, 1 reply; 24+ messages in thread
From: Juan Manuel Macías @ 2024-01-24 15:41 UTC (permalink / raw)
To: Colin Baxter
Cc: Max Nikulin, Eric Anderson, ihor Timothy, Ihor Radchenko, orgmode
Colin Baxter writes:
> >> Perhaps it is better to avoid footnotes in titles and to add some
> >> phrase to the body instead.
>
> > That is the ideal scenario. I also believe that footnotes should
> > be avoided in section headings, if possible. Or at least, have
> > another type of numbering (symbols, letters...). The manyfoot and
> > bigfoot packages allow constructions of this type, with various
> > footnote apparatus.
>
> Indeed, but many journals *require* footnotes in titles, especially for
> affiliation, email, etc.
Notes on article titles (and even on the author name) are a slightly
different case from notes on section titles. In LaTeX there is the
"\thanks" command, which inserts footnotes for title and author,
numbered with fnsymbol. For example:
...
\title{Lorem ipsum dolor\thanks{blah blah}}
...
Org does not have support for this type of notes in the #+title or
#+author keywords. For LaTeX you can use a macro. For backends like odt
it is trickier. Look at this thread:
https://lists.gnu.org/archive/html/emacs-humanities/2024-01/msg00000.html
I think it would be nice if Org had some kind of support for notes in
#+title and #+author...
Best regards,
Juan Manuel
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [BUG] Footnotes in section titles
2024-01-24 15:41 ` Juan Manuel Macías
@ 2024-01-26 12:53 ` Ihor Radchenko
2024-01-26 13:17 ` Juan Manuel Macías
2024-01-26 16:43 ` Max Nikulin
0 siblings, 2 replies; 24+ messages in thread
From: Ihor Radchenko @ 2024-01-26 12:53 UTC (permalink / raw)
To: Juan Manuel Macías
Cc: Colin Baxter, Max Nikulin, Eric Anderson, ihor Timothy, orgmode
Juan Manuel Macías <maciaschain@posteo.net> writes:
> ...
> \title{Lorem ipsum dolor\thanks{blah blah}}
> ...
>
> Org does not have support for this type of notes in the #+title or
> #+author keywords. For LaTeX you can use a macro.
Hmm.
The reason footnotes are not allowed in #+title and other keywords is
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=7ebe87e2d5fb6c
Inserting footnote references in parsed keywords (e.g., TITLE or
CAPTION) can lead to subtle bugs. Indeed, it is impossible to know in
time if that particular footnote is going to be used in the output,
and, therefore, if it should count, e.g., in
`org-export-get-footnote-number'.
However, I am not sure about that line of reasoning - we generally don't
know if *any* given footnote reference is going to be used in the output
or not because export backend may skip references or whole parts of the
original Org file. Same for user filters.
So, I am leaning towards reverting that commit - that will allow things
like
#+TITLE: This is a test title[fn::This is test]
If we need special handling for footnotes in title (like using \thanks
instead of \footnote), it is easy.
> ... For backends like odt
> it is trickier. Look at this thread:
>
> https://lists.gnu.org/archive/html/emacs-humanities/2024-01/msg00000.html
>
> I think it would be nice if Org had some kind of support for notes in
> #+title and #+author...
No idea about how to do it in ODT. If someone familiar with OpenDocument
spec can help, it would be welcome.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [BUG] Footnotes in section titles
2024-01-26 12:53 ` Ihor Radchenko
@ 2024-01-26 13:17 ` Juan Manuel Macías
2024-01-26 16:43 ` Max Nikulin
1 sibling, 0 replies; 24+ messages in thread
From: Juan Manuel Macías @ 2024-01-26 13:17 UTC (permalink / raw)
To: Ihor Radchenko
Cc: Colin Baxter, Max Nikulin, Eric Anderson, ihor Timothy, orgmode
Ihor Radchenko writes:
> Juan Manuel Macías <maciaschain@posteo.net> writes:
>
>> ...
>> \title{Lorem ipsum dolor\thanks{blah blah}}
>> ...
>>
>> Org does not have support for this type of notes in the #+title or
>> #+author keywords. For LaTeX you can use a macro.
>
> Hmm.
> The reason footnotes are not allowed in #+title and other keywords is
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=7ebe87e2d5fb6c
>
> Inserting footnote references in parsed keywords (e.g., TITLE or
> CAPTION) can lead to subtle bugs. Indeed, it is impossible to know in
> time if that particular footnote is going to be used in the output,
> and, therefore, if it should count, e.g., in
> `org-export-get-footnote-number'.
>
> However, I am not sure about that line of reasoning - we generally don't
> know if *any* given footnote reference is going to be used in the output
> or not because export backend may skip references or whole parts of the
> original Org file. Same for user filters.
>
> So, I am leaning towards reverting that commit - that will allow things
> like
>
> #+TITLE: This is a test title[fn::This is test]
>
> If we need special handling for footnotes in title (like using \thanks
> instead of \footnote), it is easy.
I completely agree. I think it would be a great improvement, since, as
Colin Baxter says, in academic articles it is a very common practice to
add foot notes to the title of the article or the name of the author.
As for the \thanks{} command, org exports the keyword #+email within a
\thanks{} command as '\author{Name\thanks{email}}0. I don't think two
\thanks macros collide within author (assuming the user adds the email
and puts a footnote in #+author. Anyway, I think the most common thing
is to put the email below the author's name, not as a footnote, but that
is another topic and also depends on the style of each publication,
journal, etc.
>> ... For backends like odt
>> it is trickier. Look at this thread:
>>
>> https://lists.gnu.org/archive/html/emacs-humanities/2024-01/msg00000.html
>>
>> I think it would be nice if Org had some kind of support for notes in
>> #+title and #+author...
>
> No idea about how to do it in ODT. If someone familiar with OpenDocument
> spec can help, it would be welcome.
I don't have much idea about odt, but I think the problem comes from a
type of nesting that is not allowed in the odt xml. I think org exports
#+author inside the initial-creator tag:
(format "<meta:initial-creator>%s</meta:initial-creator>\n" author)
And within that tag the code for a footnote produces an error when
opening the document. If the footnote is placed right after
</meta:initial-creator>, there would be no problem.
Best regards,
Juan Manuel
--
Juan Manuel Macías -- Composición tipográfica, tratamiento de datos, diseño editorial y ortotipografía
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [BUG] Footnotes in section titles
2024-01-26 12:53 ` Ihor Radchenko
2024-01-26 13:17 ` Juan Manuel Macías
@ 2024-01-26 16:43 ` Max Nikulin
2024-02-01 14:44 ` [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc) (was: [BUG] Footnotes in section titles) Ihor Radchenko
1 sibling, 1 reply; 24+ messages in thread
From: Max Nikulin @ 2024-01-26 16:43 UTC (permalink / raw)
To: emacs-orgmode
On 26/01/2024 19:53, Ihor Radchenko wrote:
> So, I am leaning towards reverting that commit - that will allow things
> like
>
> #+TITLE: This is a test title[fn::This is test]
I hope, document metadata will be generated with stripped footnotes.
^ permalink raw reply [flat|nested] 24+ messages in thread
* [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc) (was: [BUG] Footnotes in section titles)
2024-01-26 16:43 ` Max Nikulin
@ 2024-02-01 14:44 ` Ihor Radchenko
2024-02-01 17:44 ` [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc) Juan Manuel Macías
0 siblings, 1 reply; 24+ messages in thread
From: Ihor Radchenko @ 2024-02-01 14:44 UTC (permalink / raw)
To: Max Nikulin; +Cc: emacs-orgmode
Max Nikulin <manikulin@gmail.com> writes:
> On 26/01/2024 19:53, Ihor Radchenko wrote:
>> So, I am leaning towards reverting that commit - that will allow things
>> like
>>
>> #+TITLE: This is a test title[fn::This is test]
>
> I hope, document metadata will be generated with stripped footnotes.
This is a good point.
For now, [fn::This is test], when passed to exporters, is simply treated
as plain text.
If we change the parser nesting rules, Org will pass footnote-reference
objects instead.
Then, in a number of parsers, if something like
(org-export-data (plist-get info :title) info) or
(org-export-data author info)
is used, footnotes may break export because metadata fields often have
special rules about markup that is allowed inside.
In particular, ox-odt will be broken; ox-latex will be broken.
Of course, we can adjust built-in backends to take into account the new
parsing rules, but we have no control over the third-party backends.
On the other hand, when user exports something like
#+AUTHOR: John Doe[fn::935 Pennsylvania Avenue, NW Washington, D.C. 20535-0001]
it is probably not exported as expected anyway.
So, changing things from unexpected export to failing export may not be
a critical regression.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc)
2024-02-01 14:44 ` [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc) (was: [BUG] Footnotes in section titles) Ihor Radchenko
@ 2024-02-01 17:44 ` Juan Manuel Macías
2024-02-01 17:57 ` Marvin Gülker
2024-02-02 17:00 ` Ihor Radchenko
0 siblings, 2 replies; 24+ messages in thread
From: Juan Manuel Macías @ 2024-02-01 17:44 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Max Nikulin, emacs-orgmode
Ihor Radchenko writes:
> Max Nikulin <manikulin@gmail.com> writes:
>
>> On 26/01/2024 19:53, Ihor Radchenko wrote:
>>> So, I am leaning towards reverting that commit - that will allow things
>>> like
>>>
>>> #+TITLE: This is a test title[fn::This is test]
>>
>> I hope, document metadata will be generated with stripped footnotes.
>
> This is a good point.
>
> For now, [fn::This is test], when passed to exporters, is simply treated
> as plain text.
>
> If we change the parser nesting rules, Org will pass footnote-reference
> objects instead.
>
> Then, in a number of parsers, if something like
> (org-export-data (plist-get info :title) info) or
> (org-export-data author info)
> is used, footnotes may break export because metadata fields often have
> special rules about markup that is allowed inside.
>
> In particular, ox-odt will be broken; ox-latex will be broken.
>
> Of course, we can adjust built-in backends to take into account the new
> parsing rules, but we have no control over the third-party backends.
>
> On the other hand, when user exports something like
>
> #+AUTHOR: John Doe[fn::935 Pennsylvania Avenue, NW Washington, D.C. 20535-0001]
> it is probably not exported as expected anyway.
How about using dedicated keywords? Something like:
#+FN_AUTHOR: footnote text
#+FN_TITLE: footnote text
I give these two examples because they are the two places where a
footnote of this type is expected. I know: it's ugly and corseted (what
to do if a title has more than one footnote or an "inner" footnote?).
But I suppose it would be safe for a basic case, since it would only be
necessary to modify org-latex-template, org-odt-template, etc., without
risk of unexpected results.
Best regards,
Juan Manuel
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc)
2024-02-01 17:44 ` [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc) Juan Manuel Macías
@ 2024-02-01 17:57 ` Marvin Gülker
2024-02-02 17:00 ` Ihor Radchenko
1 sibling, 0 replies; 24+ messages in thread
From: Marvin Gülker @ 2024-02-01 17:57 UTC (permalink / raw)
To: emacs-orgmode
Am Donnerstag, dem 01. Februar 2024 schrieb Juan Manuel Macías:
> How about using dedicated keywords? Something like:
>
> #+FN_AUTHOR: footnote text
> #+FN_TITLE: footnote text
For reference -- I do not know if this prompted the discussion here --
just a few days ago I asked about footnotes in author information
because such footnotes are just so common in the field I write in. They
are used to give a short description of the author's position usually
("XY is a researcher at the chair of Foo Bar..."). Since in my field I
have to submit DOCX to journals, such footnotes should be properly
exported by ox-odt in particular.
Here is the thread over at emacs-humanities:
https://lists.gnu.org/archive/html/emacs-humanities/2024-01/msg00000.html
It includes an ugly workaround I applied in form of an advice. A proper
solution directly in org would of course be much preferable.
I like the dedicated keyword solution. This way third party backends
will probably ignore the new keywords, because for them they will look
like a comment.
Marvin
--
Dipl.-Jur. M. Gülker | https://mg.guelker.eu | PGP: Siehe Webseite
Passau, Deutschland | kontakt@guelker.eu | O<
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc)
2024-02-01 17:44 ` [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc) Juan Manuel Macías
2024-02-01 17:57 ` Marvin Gülker
@ 2024-02-02 17:00 ` Ihor Radchenko
2024-02-02 17:12 ` Marvin Gülker
2024-02-02 18:10 ` Juan Manuel Macías
1 sibling, 2 replies; 24+ messages in thread
From: Ihor Radchenko @ 2024-02-02 17:00 UTC (permalink / raw)
To: Juan Manuel Macías; +Cc: Max Nikulin, emacs-orgmode
Juan Manuel Macías <maciaschain@posteo.net> writes:
>> #+AUTHOR: John Doe[fn::935 Pennsylvania Avenue, NW Washington, D.C. 20535-0001]
>> it is probably not exported as expected anyway.
>
> How about using dedicated keywords? Something like:
>
> #+FN_AUTHOR: footnote text
> #+FN_TITLE: footnote text
What if you have multiple authors?
If you mean
#+AUTHOR: author1
#+FN_AUTHOR: footnote for author 1
#+AUTHOR: author2
#+FN_AUTHOR: footnote for author 2
, it is actually problematic because the code concatenates the values of
#+AUTHOR keywords before processing, and it is hard to know which author
corresponds to which footnote.
If we really need something safe, pre-processing values in ox.el and
producing backward-compatible :author value and addition
:author-w-footnotes value in the export INFO plist would be more
reasonable and less ugly. Still ugly though.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc)
2024-02-02 17:00 ` Ihor Radchenko
@ 2024-02-02 17:12 ` Marvin Gülker
2024-02-02 17:49 ` Ihor Radchenko
2024-02-02 18:10 ` Juan Manuel Macías
1 sibling, 1 reply; 24+ messages in thread
From: Marvin Gülker @ 2024-02-02 17:12 UTC (permalink / raw)
To: emacs-orgmode
Am Freitag, dem 02. Februar 2024 schrieb Ihor Radchenko:
> What if you have multiple authors?
At least in my discipline, we only have one footnote even in such a
case, which then is a little longer and describes each author
individually in a separate sentence. So, one AUTHOR_FN keyword would be
enough for me.
Marvin
--
Dipl.-Jur. M. Gülker | https://mg.guelker.eu | PGP: Siehe Webseite
Passau, Deutschland | kontakt@guelker.eu | O<
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc)
2024-02-02 17:12 ` Marvin Gülker
@ 2024-02-02 17:49 ` Ihor Radchenko
0 siblings, 0 replies; 24+ messages in thread
From: Ihor Radchenko @ 2024-02-02 17:49 UTC (permalink / raw)
To: Marvin Gülker; +Cc: emacs-orgmode
Marvin Gülker <post+orgmodeml@guelker.eu> writes:
> Am Freitag, dem 02. Februar 2024 schrieb Ihor Radchenko:
>> What if you have multiple authors?
>
> At least in my discipline, we only have one footnote even in such a
> case, which then is a little longer and describes each author
> individually in a separate sentence. So, one AUTHOR_FN keyword would be
> enough for me.
Single footnote is certainly not always a standard.
You may check a random article from ScienceDirect:
https://www.sciencedirect.com/science/article/pii/S2090123221001491
Or, as a terminal case, https://arxiv.org/abs/2310.04277 with 1000+
authors. (well, they do put a single footnote there and move all the
authors to separate page).
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc)
2024-02-02 17:00 ` Ihor Radchenko
2024-02-02 17:12 ` Marvin Gülker
@ 2024-02-02 18:10 ` Juan Manuel Macías
2024-02-02 20:21 ` Exporting multiple #+AUTHOR keywords (was: [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc)) Ihor Radchenko
1 sibling, 1 reply; 24+ messages in thread
From: Juan Manuel Macías @ 2024-02-02 18:10 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Max Nikulin, emacs-orgmode
Ihor Radchenko writes:
> #+AUTHOR: author1
> #+FN_AUTHOR: footnote for author 1
>
> #+AUTHOR: author2
> #+FN_AUTHOR: footnote for author 2
Sorry if this is off topic, but something like this:
#+AUTHOR: Fred Astaire
#+AUTHOR: Ginger Rogers
is exported to LaTeX as:
\author{Fred Astaire Ginger Rogers}
Shouldn't there be some separation? In LaTeX the usual thing is:
\author{Fred Astaire \and Ginger Rogers}
Best regards,
Juan Manuel
--
Juan Manuel Macías -- Composición tipográfica, tratamiento de datos, diseño editorial y ortotipografía
^ permalink raw reply [flat|nested] 24+ messages in thread
* Exporting multiple #+AUTHOR keywords (was: [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc))
2024-02-02 18:10 ` Juan Manuel Macías
@ 2024-02-02 20:21 ` Ihor Radchenko
2024-02-02 22:26 ` Exporting multiple #+AUTHOR keywords Juan Manuel Macías
0 siblings, 1 reply; 24+ messages in thread
From: Ihor Radchenko @ 2024-02-02 20:21 UTC (permalink / raw)
To: Juan Manuel Macías; +Cc: Max Nikulin, emacs-orgmode
Juan Manuel Macías <maciaschain@posteo.net> writes:
> Sorry if this is off topic, but something like this:
>
> #+AUTHOR: Fred Astaire
> #+AUTHOR: Ginger Rogers
>
> is exported to LaTeX as:
>
> \author{Fred Astaire Ginger Rogers}
>
> Shouldn't there be some separation? In LaTeX the usual thing is:
>
> \author{Fred Astaire \and Ginger Rogers}
You can do
#+AUTHOR: Fred
#+AUTHOR: Astaire
#+AUTHOR: and Ginger
#+AUTHOR: Rogers
The values are simply concatenated before passing to the exporter.
Can we concatenate with "\and"? Sure. But not by default or it would be
a breaking change.
In fact, you can already concatenate with "\and" when exporting
subtrees:
(push '("EXPORT_AUTHOR" . "\\and ") org-property-separators)
then
* This is test
:PROPERTIES:
:EXPORT_AUTHOR: John Doe
:EXPORT_AUTHOR+: David Stefanson
:END:
Text.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Exporting multiple #+AUTHOR keywords
2024-02-02 20:21 ` Exporting multiple #+AUTHOR keywords (was: [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc)) Ihor Radchenko
@ 2024-02-02 22:26 ` Juan Manuel Macías
2024-02-04 15:21 ` Ihor Radchenko
0 siblings, 1 reply; 24+ messages in thread
From: Juan Manuel Macías @ 2024-02-02 22:26 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Max Nikulin, emacs-orgmode
Ihor Radchenko writes:
> Juan Manuel Macías <maciaschain@posteo.net> writes:
>
>> Sorry if this is off topic, but something like this:
>>
>> #+AUTHOR: Fred Astaire
>> #+AUTHOR: Ginger Rogers
>>
>> is exported to LaTeX as:
>>
>> \author{Fred Astaire Ginger Rogers}
>>
>> Shouldn't there be some separation? In LaTeX the usual thing is:
>>
>> \author{Fred Astaire \and Ginger Rogers}
>
> You can do
>
> #+AUTHOR: Fred
> #+AUTHOR: Astaire
>
> #+AUTHOR: and Ginger
> #+AUTHOR: Rogers
>
> The values are simply concatenated before passing to the exporter.
>
> Can we concatenate with "\and"? Sure. But not by default or it would be
> a breaking change.
Thanks for the explanation. I've never made documents with more than one
author, so I've never thought about this scenario. For a moment I
thought org supported more than one author (explicitly, I mean).
Anyway, \and is just a formatting command: add a space between two
authors. Some people may prefer to put a line break \\ or anything else.
Of course, \and (and any other format command) will have a negative
effect on the pdfauthor metadata, which only collects text strings. It
is a similar problem to the one with footnotes, which Maxim commented
on. I think the basic problem is that org uses #+author, #+title, etc.
as a single source for both the metadata strings and the exported
format, i.e. the title, the author, the date that is printed somewhere.
Perhaps the ideal would be to distinguish in some way between
author-metadata and author-exported-format. For example something like:
#+AUTHOR[John Doe and Luke Skywalker]: John Doe @@latex:\and@@ Luke
Skywalker
The optional string in square brackets would be the metadata; the rest
would be the direct exported format. If there is no optional string, the
value is used for both metadata and format. Could this be also a
possible solution to the footnote problem?
Best regards,
Juan Manuel
--
Juan Manuel Macías -- Composición tipográfica, tratamiento de datos, diseño editorial y ortotipografía
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Exporting multiple #+AUTHOR keywords
2024-02-02 22:26 ` Exporting multiple #+AUTHOR keywords Juan Manuel Macías
@ 2024-02-04 15:21 ` Ihor Radchenko
2024-02-04 16:16 ` Max Nikulin
0 siblings, 1 reply; 24+ messages in thread
From: Ihor Radchenko @ 2024-02-04 15:21 UTC (permalink / raw)
To: Juan Manuel Macías; +Cc: Max Nikulin, emacs-orgmode
Juan Manuel Macías <maciaschain@posteo.net> writes:
> ... I think the basic problem is that org uses #+author, #+title, etc.
> as a single source for both the metadata strings and the exported
> format, i.e. the title, the author, the date that is printed somewhere.
>
> Perhaps the ideal would be to distinguish in some way between
> author-metadata and author-exported-format. For example something like:
>
> #+AUTHOR[John Doe and Luke Skywalker]: John Doe @@latex:\and@@ Luke
> Skywalker
>
> The optional string in square brackets would be the metadata; the rest
> would be the direct exported format. If there is no optional string, the
> value is used for both metadata and format. Could this be also a
> possible solution to the footnote problem?
Another option is to have a new set of keywords:
#+LATEX_AUTHOR: <author with formatting goes here>
#+HTML_AUTHOR: ...
For multiple authors, we may introduce something like
#+AUTHOR: John Doe
#+AUTHOR+: Luke Skywalker
That should be fully backwards-compatible.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Exporting multiple #+AUTHOR keywords
2024-02-04 15:21 ` Ihor Radchenko
@ 2024-02-04 16:16 ` Max Nikulin
2024-02-04 22:13 ` Juan Manuel Macías
2024-02-05 14:57 ` Ihor Radchenko
0 siblings, 2 replies; 24+ messages in thread
From: Max Nikulin @ 2024-02-04 16:16 UTC (permalink / raw)
To: Juan Manuel Macías; +Cc: emacs-orgmode
On 04/02/2024 22:21, Ihor Radchenko wrote:
>
> Another option is to have a new set of keywords:
> #+LATEX_AUTHOR: <author with formatting goes here>
> #+HTML_AUTHOR: ...
>
> For multiple authors, we may introduce something like
>
> #+AUTHOR: John Doe
> #+AUTHOR+: Luke Skywalker
Another idea:
#+metadata:
- author ::
- John Doe
- Luke Skywalker
- title :: Some text
With overrides for specific backends
#+metadata: :backend latex
- author :: ....
Perhaps backends may declare if they support footnotes, etc. by defining
some backend property.
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Exporting multiple #+AUTHOR keywords
2024-02-04 16:16 ` Max Nikulin
@ 2024-02-04 22:13 ` Juan Manuel Macías
2024-02-05 14:57 ` Ihor Radchenko
1 sibling, 0 replies; 24+ messages in thread
From: Juan Manuel Macías @ 2024-02-04 22:13 UTC (permalink / raw)
To: Max Nikulin; +Cc: Ihor Radchenko, orgmode
Max Nikulin writes:
> On 04/02/2024 22:21, Ihor Radchenko wrote:
>>
>> Another option is to have a new set of keywords:
>> #+LATEX_AUTHOR: <author with formatting goes here>
>> #+HTML_AUTHOR: ...
>>
>> For multiple authors, we may introduce something like
>>
>> #+AUTHOR: John Doe
>> #+AUTHOR+: Luke Skywalker
>
> Another idea:
>
> #+metadata:
> - author ::
> - John Doe
> - Luke Skywalker
> - title :: Some text
>
> With overrides for specific backends
>
> #+metadata: :backend latex
> - author :: ....
>
> Perhaps backends may declare if they support footnotes, etc. by defining
> some backend property.
I like both ideas. If I had to choose, perhaps I would prefer Ihor's
approach since it separates the formatting value and the metadata value
using simple keywords. I understand that in the former you could add any
direct format (LaTeX, odt, html...), macros and even footnotes. And if
the former is not explicitly included in the document, then the latter
is used to populate both the formatting value and the metadata value.
Anyway, I think your approach would work very well for more complex pdf
metadata like xmp. Maybe using the hyperxmp package, which you mentioned
in a thread months ago?
Maybe something like this:
#+latex_xmp
...
#+end
?
Best regards,
Juan Manuel
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: Exporting multiple #+AUTHOR keywords
2024-02-04 16:16 ` Max Nikulin
2024-02-04 22:13 ` Juan Manuel Macías
@ 2024-02-05 14:57 ` Ihor Radchenko
1 sibling, 0 replies; 24+ messages in thread
From: Ihor Radchenko @ 2024-02-05 14:57 UTC (permalink / raw)
To: Max Nikulin; +Cc: Juan Manuel Macías, emacs-orgmode
Max Nikulin <manikulin@gmail.com> writes:
>> Another option is to have a new set of keywords:
>> #+LATEX_AUTHOR: <author with formatting goes here>
>> #+HTML_AUTHOR: ...
> ...
> Another idea:
>
> #+metadata:
> - author ::
> - John Doe
> - Luke Skywalker
> - title :: Some text
>
> With overrides for specific backends
This implies that #+AUTHOR may contain markup, while #+metadata should
not; as opposed to my idea with #+AUTHOR being reserved to "plain"
author and #+BACKEND_AUTHOR defining more specific markup.
I feel that my approach is slightly better because you can have
different author markup for different backends when using my suggestion.
> Perhaps backends may declare if they support footnotes, etc. by defining
> some backend property.
The comment about footnotes belongs to parent thread, not to this
branch.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [BUG] Footnotes in section titles
2024-01-24 14:14 ` Max Nikulin
2024-01-24 15:23 ` Juan Manuel Macías
@ 2024-01-26 12:09 ` Ihor Radchenko
2024-02-09 16:41 ` Ihor Radchenko
1 sibling, 1 reply; 24+ messages in thread
From: Ihor Radchenko @ 2024-01-26 12:09 UTC (permalink / raw)
To: Max Nikulin; +Cc: Eric Anderson, Timothy, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 583 bytes --]
Max Nikulin <manikulin@gmail.com> writes:
> On 24/01/2024 19:11, Ihor Radchenko wrote:
>> The \section[...]{...} approach may work, but it is tricky - it is
>> completely up to the `org-latex-classes'. So, we may have to use regexp
>> replacement, which might be fragile.
>
> ox supports the ALT_TITLE property and ox-latex already adds it using
> regexp. So it should possible to define this property with stripped
> footnote by an export filter. I have not tested it, but ALT_TITLE and
> @@latex:\protect@@ might be a workaround.
Good point.
See the attached tentative patch.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-latex-headline-Prevent-footnotes-in-TOC-footers.patch --]
[-- Type: text/x-patch, Size: 3667 bytes --]
From b4d896f7daf5e7b2cf8dabfba5b9dbf212f0c54c Mon Sep 17 00:00:00 2001
Message-ID: <b4d896f7daf5e7b2cf8dabfba5b9dbf212f0c54c.1706270932.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Fri, 26 Jan 2024 13:07:13 +0100
Subject: [PATCH] org-latex-headline: Prevent footnotes in TOC/footers
* lisp/ox-latex.el (org-latex-headline): When headline contains
footnotes and does not have ALT_TITLE, arrange alternative title that
will appear in TOC and footers to not have any footnotes.
Reported-by: Eric Anderson <kluwak@gmail.com>
Link: https://orgmode.org/list/691643eb-49d0-45c3-ab7f-a1edbd093bef@gmail.com
---
lisp/ox-latex.el | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index df20345f8..4f5258ea1 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2312,9 +2312,22 @@ (defun org-latex-headline (headline contents info)
;; with \texttt.
(code . (lambda (o _ _) (org-latex--protect-texttt (org-element-property :value o))))
(verbatim . (lambda (o _ _) (org-latex--protect-texttt (org-element-property :value o)))))))
+ ;; Create a temporary export backend that strips footnotes from title.
+ ;; Footnotes are not allowed in \section and similar
+ ;; commands that contribute to TOC and footers.
+ ;; See https://orgmode.org/list/691643eb-49d0-45c3-ab7f-a1edbd093bef@gmail.com
+ ;; https://texfaq.org/FAQ-ftnsect
+ (section-no-footnote-backend
+ (org-export-create-backend
+ :parent section-backend
+ :transcoders
+ `((footnote-reference . ignore))))
(text
(org-export-data-with-backend
(org-element-property :title headline) section-backend info))
+ (text-no-footnote
+ (org-export-data-with-backend
+ (org-element-property :title headline) section-no-footnote-backend info))
(todo
(and (plist-get info :with-todo-keywords)
(let ((todo (org-element-property :todo-keyword headline)))
@@ -2328,6 +2341,9 @@ (defun org-latex-headline (headline contents info)
;; The latter is required to remove tags from toc.
(full-text (funcall (plist-get info :latex-format-headline-function)
todo todo-type priority text tags info))
+ (full-text-no-footnote
+ (funcall (plist-get info :latex-format-headline-function)
+ todo todo-type priority text-no-footnote tags info))
;; Associate \label to the headline for internal links.
(headline-label (org-latex--label headline info t t))
(pre-blanks
@@ -2385,10 +2401,14 @@ (defun org-latex-headline (headline contents info)
(string-match-p "\\<local\\>" v)
(format "\\stopcontents[level-%d]" level)))))
info t)))))
- (if (and opt-title
- (not (equal opt-title full-text))
+ (if (and (or (and opt-title (not (equal opt-title full-text)))
+ ;; Heading contains footnotes. Add optional title
+ ;; version without footnotes to avoid footnotes in
+ ;; TOC/footers.
+ (and (not (equal full-text-no-footnote full-text))
+ (setq opt-title full-text-no-footnote)))
(string-match "\\`\\\\\\(.+?\\){" section-fmt))
- (format (replace-match "\\1[%s]" nil nil section-fmt 1)
+ (format (replace-match "\\1[%s]" nil nil section-fmt 1)
;; Replace square brackets with parenthesis
;; since square brackets are not supported in
;; optional arguments.
--
2.43.0
[-- Attachment #3: Type: text/plain, Size: 224 bytes --]
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply related [flat|nested] 24+ messages in thread
end of thread, other threads:[~2024-02-09 16:39 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-22 20:42 Possible LaTeX export bug: Footnotes in items Eric Anderson
2024-01-24 12:11 ` [BUG] Footnotes in section titles Ihor Radchenko
2024-01-24 14:14 ` Max Nikulin
2024-01-24 15:23 ` Juan Manuel Macías
2024-01-24 15:31 ` Colin Baxter
2024-01-24 15:41 ` Juan Manuel Macías
2024-01-26 12:53 ` Ihor Radchenko
2024-01-26 13:17 ` Juan Manuel Macías
2024-01-26 16:43 ` Max Nikulin
2024-02-01 14:44 ` [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc) (was: [BUG] Footnotes in section titles) Ihor Radchenko
2024-02-01 17:44 ` [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc) Juan Manuel Macías
2024-02-01 17:57 ` Marvin Gülker
2024-02-02 17:00 ` Ihor Radchenko
2024-02-02 17:12 ` Marvin Gülker
2024-02-02 17:49 ` Ihor Radchenko
2024-02-02 18:10 ` Juan Manuel Macías
2024-02-02 20:21 ` Exporting multiple #+AUTHOR keywords (was: [DISCUSSION] Allowing footnote-references inside parsed keywords (#+AUTHOR, #+TITLE, etc)) Ihor Radchenko
2024-02-02 22:26 ` Exporting multiple #+AUTHOR keywords Juan Manuel Macías
2024-02-04 15:21 ` Ihor Radchenko
2024-02-04 16:16 ` Max Nikulin
2024-02-04 22:13 ` Juan Manuel Macías
2024-02-05 14:57 ` Ihor Radchenko
2024-01-26 12:09 ` [BUG] Footnotes in section titles Ihor Radchenko
2024-02-09 16:41 ` Ihor Radchenko
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).