-
-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Caption with cite results in cite appearing in list of figures #956
Comments
Apologies, forgot to provide some version details.
|
I have managed to progress my investigation on this, and I think the problem may be related to org-mode itself and potentially the new citations. I found a way of dumping the org-mode tree, like so: (setq test/my_results (org-element-parse-buffer)) It shows org-mode is already confused about captions after parse: (org-data nil
(section
(:begin 1 :end 253 :contents-begin 1 :contents-end 253 :post-blank 0 :post-affiliated 1 :parent #0)
(paragraph
(:begin 1 :end 12 :contents-begin 1 :contents-end 11 :post-blank 1 :post-affiliated 1 :parent #1)
#("some text\n" 0 10
(:parent #2)))
(paragraph
(:begin 12 :end 203 :contents-begin 154 :contents-end 202 :post-blank 1 :post-affiliated 154 :name "Figure1" :caption
(((#("Some text " 0 10
(:parent #6))
(link
(:type "cite" :path "&johnson-2010-great-paper" :format plain :raw-link "cite:&johnson-2010-great-paper" :application nil :search-option nil :begin 55 :end 86 :contents-begin nil :contents-end nil :post-blank 1 :parent #6))
#("some more text." 0 15
(:parent #6)))
#("&johnson-2010-great-paper" 0 25
(:parent
(#6)))))
<snip> In particular, the |
Short summary of my experimentation thus far. Case 1: no citeOrg-mode:
Tree: (paragraph
(:begin 12 :end 172 :contents-begin 123 :contents-end 171 :post-blank 1 :post-affiliated 123 :name "Figure1" :caption
(((#("Some text some more text." 0 25
(:parent #6)))
#("test" 0 4
(:parent
(#6)))))
:attr_org
(":width 300px")
:attr_latex
(":height 20cm")
:parent #1) Latex: \caption[test]{\label{fig:org625be63}Some text some more text.} This seems to do what is expected. Case 2: cite as a org-mode linkOrg-mode:
Tree: (:begin 12 :end 207 :contents-begin 158 :contents-end 206 :post-blank 1 :post-affiliated 158 :name "Figure1" :caption
(((#("Some text " 0 10
(:parent #6))
(link
(:type "cite" :path "&johnson-2010-great-paper" :format bracket :raw-link "cite:&johnson-2010-great-paper" :application nil :search-option nil :begin 55 :end 90 :contents-begin nil :contents-end nil :post-blank 1 :parent #6))
#("some more text." 0 15
(:parent #6)))))
:attr_org
(":width 300px")
:attr_latex
(":height 20cm")
:parent #1) Latex: \caption{\label{fig:org4aca667}Some text \cite{johnson-2010-great-paper} some more text.} Citation is processed correctly, but list of figures now contains the same text as the figure, e.g. Case 3: "plain" citeOrg-mode:
Tree: (:begin 12 :end 203 :contents-begin 154 :contents-end 202 :post-blank 1 :post-affiliated 154 :name "Figure1" :caption
(((#("Some text " 0 10
(:parent #6))
(link
(:type "cite" :path "&johnson-2010-great-paper" :format plain :raw-link "cite:&johnson-2010-great-paper" :application nil :search-option nil :begin 55 :end 86 :contents-begin nil :contents-end nil :post-blank 1 :parent #6))
#("some more text." 0 15
(:parent #6)))
#("&johnson-2010-great-paper" 0 25
(:parent
(#6)))))
:attr_org
(":width 300px")
:attr_latex
(":height 20cm")
:parent #1) Latex: \caption[\&johnson-2010-great-paper]{\label{fig:org85c4803}Some text \cite{johnson-2010-great-paper} some more text.} "Plain" cite now shows up in the list of figures (e.g. |
I did some googling, and this issue seems rather similar to this one: Doing a quick blame to see what the fix was, and if its not in org-mode 9.3... Update: Actually the commit is fairly old: https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/ My blame says:
Maybe a red herring. |
Argh, I forget just how far behind mainline Emacs is from latest :-) OK it turns out I was right. This has been patched in org-mode a very long time ago, but if like me you are running Emacs 27.1 then you do not have the fix. My solution was to manually update diff --git a/test.el b/test.el
index e8f86d3..0ee1511 100644
--- a/test.el
+++ b/test.el
@@ -36,7 +36,8 @@ When PARSE is non-nil, values from keywords belonging to
(skip-chars-backward " \t")
(point))))
(if parsed?
- (org-element--parse-objects beg end nil restrict)
+ (save-match-data
+ (org-element--parse-objects beg end nil restrict))
(org-trim (buffer-substring-no-properties beg end)))))
;; If KWD is a dual keyword, find its secondary value.
;; Maybe parse it. After applying this patch, I now get: Org-mode:
Latex: \caption[test]{\label{fig:org5b272e4}Some text \cite{johnson-2010-great-paper} some more text.} For anyone facing a similar issue, your best bet is to update Emacs or org-mode. Else you can patch the function like I did. |
For completeness, here is a proper (appliable) patch for Emacs 27.1. Just copy this one file locally, apply the patch and read in the lisp. diff --git a/org-element.el b/org-element.el
index 4b5f9a1..ca7be16 100644
--- a/org-element.el
+++ b/org-element.el
@@ -4024,7 +4024,8 @@ When PARSE is non-nil, values from keywords belonging to
(skip-chars-backward " \t")
(point))))
(if parsed?
- (org-element--parse-objects beg end nil restrict)
+ (save-match-data
+ (org-element--parse-objects beg end nil restrict))
(org-trim (buffer-substring-no-properties beg end)))))
;; If KWD is a dual keyword, find its secondary value.
;; Maybe parse it. |
Best issue report of the year! |
Hi org-ref developers,
thanks very much for an amazing tool. I am on the process of updating my org-mode files to v3 and I stumbled into a problem. I am sure its something I am doing wrong, but can't quite see what I'm afraid. The long and short of it is, my captions are showing up as "cites" in the list of figures. At first, I thought my problems were related to #945, but now I don't think so.
For example, if we take:
This produces the following latex:
Please notice how the caption contains the cite and ignores the text in square brackets (e.g.
test
). However, if I remove the cite, I get:I think I am not doing something related to citations, but not yet sure what. I will keep reading the manual, but if you have any pointers it would be very helpful.
The text was updated successfully, but these errors were encountered: