From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: Bug: When exporting to PDF an Org file where multiple footnotes share the same definition, only the first footnote is clickable [8.3.4 (8.3.4-39-ge0acd8-elpaplus @ /home/jorge/.emacs.d/elpa/org-plus-contrib-20160418/)]
Date: Sun, 22 May 2016 22:16:04 +0200 [thread overview]
Message-ID: <87r3ctalx7.fsf@gmx.us> (raw)
In-Reply-To: 87a8kh4wpp.fsf@saiph.selenimh
[-- Attachment #1: Type: text/plain, Size: 903 bytes --]
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> Rasmus <rasmus@gmx.us> writes:
>
>> Could we inject labels in all footnotes? If so we could simply use
>>
>> \textsuperscript{\ref{FN-LABEL}}
>>
>> In place of
>>
>> \footnotemark[FN-GUESS]{}
>>
>> It seems \footref of scrextend.sty has some extra robustness built into it
>> but until someone complains I think the \textsuperscript hack should be
>> enough and better then what we’ve got.
>
> That's a bit hackish, but definitely possible. Do yo want to provide
> a patch?
With the attached patch ox-latex seems to behave in this way. Though
perhaps there’s a more efficient way to get the first footnote-reference
to a given definition than trawling through with
org-export--footnote-reference-map.
Nicolas, where is the info plist documented or defined/populated?
Rasmus
--
Together we will make the possible totalllly impossible!
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-latex-More-robust-footnote-referencing.patch --]
[-- Type: text/x-diff, Size: 4732 bytes --]
From 07f15d538aa02d5b45fa545395442f5663260430 Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@gmx.us>
Date: Sun, 22 May 2016 20:33:06 +0200
Subject: [PATCH] ox-latex: More robust footnote referencing
* lisp/ox-latex.el (org-latex--label): Prefix footnote with "fn".
(org-latex--delayed-footnotes-definitions): Fix typo in docstring.
(org-latex-footnote-reference): Use \ref{.} and \label{.} for repeated
references.
---
lisp/ox-latex.el | 72 ++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 47 insertions(+), 25 deletions(-)
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 9c31645..3c66a32 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1246,6 +1246,8 @@ Eventually, if FULL is non-nil, wrap label within \"\\label{}\"."
org-latex-math-environments-re
(org-element-property :value datum))
"eq:"))
+ (footnote-reference "fn:")
+ (footnote-definition "fn:")
(paragraph
(and (org-element-property :caption datum)
"fig:")))
@@ -1498,7 +1500,7 @@ INFO is a plist used as a communication channel. See
INFO is a plist used as a communication channel.
-Footnotes definitions are returned within \"\\footnotetxt{}\"
+Footnotes definitions are returned within \"\\footnotetext{}\"
commands.
This function is used within constructs that don't support
@@ -1803,30 +1805,50 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(defun org-latex-footnote-reference (footnote-reference _contents info)
"Transcode a FOOTNOTE-REFERENCE element from Org to LaTeX.
CONTENTS is nil. INFO is a plist holding contextual information."
- (concat
- ;; Insert separator between two footnotes in a row.
- (let ((prev (org-export-get-previous-element footnote-reference info)))
- (when (eq (org-element-type prev) 'footnote-reference)
- (plist-get info :latex-footnote-separator)))
- (cond
- ;; Use \footnotemark if the footnote has already been defined.
- ((not (org-export-footnote-first-reference-p footnote-reference info))
- (format "\\footnotemark[%s]{}"
- (org-export-get-footnote-number footnote-reference info)))
- ;; Use \footnotemark if reference is within another footnote
- ;; reference, footnote definition or table cell.
- ((org-element-lineage footnote-reference
- '(footnote-reference footnote-definition table-cell))
- "\\footnotemark")
- ;; Otherwise, define it with \footnote command.
- (t
- (let ((def (org-export-get-footnote-definition footnote-reference info)))
- (concat
- (format "\\footnote{%s}" (org-trim (org-export-data def info)))
- ;; Retrieve all footnote references within the footnote and
- ;; add their definition after it, since LaTeX doesn't support
- ;; them inside.
- (org-latex--delayed-footnotes-definitions def info)))))))
+ (let ((label (org-element-property :label footnote-reference)))
+ (concat
+ ;; Insert separator between two footnotes in a row.
+ (let ((prev (org-export-get-previous-element footnote-reference info)))
+ (when (eq (org-element-type prev) 'footnote-reference)
+ (plist-get info :latex-footnote-separator)))
+ (cond
+ ;; Use \footnotemark if the footnote has already been defined.
+ ((not (org-export-footnote-first-reference-p footnote-reference info))
+ (format "\\textsuperscript{\\ref{%s}}"
+ (org-latex--label
+ (catch 'exit
+ (org-export--footnote-reference-map
+ (lambda (f)
+ (let ((l (org-element-property :label f)))
+ (when (and l label (string= label l))
+ (throw 'exit f))))
+ (plist-get info :parse-tree) info))
+ info t)))
+ ;; Use \footnotemark if reference is within another footnote
+ ;; reference, footnote definition or table cell.
+ ((org-element-lineage footnote-reference
+ '(footnote-reference footnote-definition table-cell))
+ "\\footnotemark")
+ ;; Otherwise, define it with \footnote command.
+ (t
+ (let ((def (org-export-get-footnote-definition footnote-reference info)))
+ (concat
+ (format "\\footnote{%s%s}" (org-trim (org-export-data def info))
+ (if (catch 'exit
+ (org-export--footnote-reference-map
+ (lambda (f)
+ (let ((l (org-element-property :label f)))
+ (when (and l label
+ (not (eq f footnote-reference))
+ (string= label l))
+ (throw 'exit t))))
+ (plist-get info :parse-tree) info))
+ (org-latex--label footnote-reference info t t)
+ ""))
+ ;; Retrieve all footnote references within the footnote and
+ ;; add their definition after it, since LaTeX doesn't support
+ ;; them inside.
+ (org-latex--delayed-footnotes-definitions def info))))))))
;;;; Headline
--
2.8.2
next prev parent reply other threads:[~2016-05-22 20:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-23 20:54 Bug: When exporting to PDF an Org file where multiple footnotes share the same definition, only the first footnote is clickable [8.3.4 (8.3.4-39-ge0acd8-elpaplus @ /home/jorge/.emacs.d/elpa/org-plus-contrib-20160418/)] Jorge Peixoto de Morais Neto
2016-04-25 8:38 ` Rasmus
2016-04-25 8:58 ` Nicolas Goaziou
2016-04-25 10:53 ` Rasmus
2016-04-25 11:41 ` Nicolas Goaziou
2016-04-25 13:36 ` Rasmus
2016-04-25 13:57 ` Nicolas Goaziou
2016-04-25 14:04 ` Rasmus
2016-04-25 14:07 ` Rasmus
2016-05-22 20:16 ` Rasmus [this message]
2016-05-23 21:41 ` Nicolas Goaziou
2016-05-24 20:59 ` [patch] more robust footnotes (was: Bug: When exporting to PDF an Org file where multiple footnotes share the same definition, only the first footnote is clickable [8.3.4 (8.3.4-39-ge0acd8-elpaplus @ /home/jorge/.emacs.d/elpa/org-plus-contrib-20160418/)]) Rasmus
2016-05-24 21:31 ` [patch] more robust footnotes Nicolas Goaziou
2016-05-24 21:38 ` Rasmus
2016-05-24 21:54 ` Nicolas Goaziou
2016-05-25 7:16 ` Rasmus
2016-05-25 16:50 ` Nicolas Goaziou
2016-05-25 17:51 ` Rasmus
2016-08-10 21:09 ` Bug: When exporting to PDF an Org file where multiple footnotes share the same definition, only the first footnote is clickable [8.3.4 (8.3.4-39-ge0acd8-elpaplus @ /home/jorge/.emacs.d/elpa/org-plus-contrib-20160418/)] Kaushal Modi
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=87r3ctalx7.fsf@gmx.us \
--to=rasmus@gmx.us \
--cc=emacs-orgmode@gnu.org \
/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).