Re: [O] Target and link text normalised to `orgtargetn'
Rasmus ras...@gmx.us writes: Pushed with your recommendations. Thanks. Thank you. Regards,
Re: [O] Target and link text normalised to `orgtargetn'
Nicolas Goaziou m...@nicolasgoaziou.fr writes: Here's an updated patch. Thank you. Some comments follow. Pushed with your recommendations. Thanks. -- May the Force be with you
Re: [O] Target and link text normalised to `orgtargetn'
Nicolas Goaziou m...@nicolasgoaziou.fr writes: Yeah, I though of that, but that require us to maintain a list of latex math environments, which may or may not be annoying. Well, if an environment is not recognized as a math one, it still gets a label. So, that's not a big deal to miss some of them. If we add such a variable where should it live? org.el or ox-latex.el? ox-latex.el. This is a hack. There's no need to leak it elsewhere. Here's an updated patch. —Rasmus -- Need more coffee. . . From 5442c61a0ab793d0a0cb3507d4355a5d1fb2f623 Mon Sep 17 00:00:00 2001 From: Rasmus ras...@gmx.us Date: Mon, 20 Apr 2015 15:06:55 +0200 Subject: [PATCH] ox-latex: Use standard LaTeX label prefixes * ox-latex.el (org-latex--label): Use standard LaTeX prefixes. (org-latex-math-environments-re): New defconst. --- lisp/ox-latex.el | 29 - 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 2727f1c..2d7ffe5 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -209,6 +209,17 @@ (kbordermatrix . )) Alist between matrix macros and their row ending.) +(defconst org-latex-math-environments-re + (concat (regexp-opt + '(equation eqnarray math displaymath + align gather multline flalign alignat + xalignat xxalignat + subequations + ;; breqn + dmath dseries dgroup darray + ;; empheq + empheq)) *?) + Regexp of LaTeX math environments.) ;;; User Configurable Variables @@ -1067,7 +1078,23 @@ Eventually, if FULL is non-nil, wrap label within \\\label{}\. (and (or user-label force) (if (and user-label (plist-get info :latex-prefer-user-labels)) user-label - (org-export-get-reference datum info) + (concat (case type + (headline sec:) + (table tab:) + (latex-environment + (save-match-data + (let ((string (org-element-property :value datum))) +(string-match + (nth 1 (assoc begin org-latex-regexps)) + string) +(and (org-string-match-p + org-latex-math-environments-re + (match-string 2 string)) + eq: + (paragraph + (and (org-element-property :caption datum) + fig:))) + (org-export-get-reference datum info)) (cond ((not full) label) (label (format \\label{%s}%s label -- 2.3.6
Re: [O] Target and link text normalised to `orgtargetn'
Rasmus ras...@gmx.us writes: Here's an updated patch. Thank you. Some comments follow. +(defconst org-latex-math-environments-re + (concat (regexp-opt +'(equation eqnarray math displaymath + align gather multline flalign alignat + xalignat xxalignat + subequations + ;; breqn + dmath dseries dgroup darray + ;; empheq + empheq)) *?) ITYM \\*?, not *?. Moreover, I think it is better to check only first line, i.e., (format \\` *\\begin{%s} (concat (regexp-opt ...) \\*?)) + (save-match-data + (let ((string (org-element-property :value datum))) + (string-match + (nth 1 (assoc begin org-latex-regexps)) + string) + (and (org-string-match-p + org-latex-math-environments-re + (match-string 2 string)) + eq: This is not needed. Choose an appropriate regexp for `org-latex-math-environments-re' and forget about `org-latex-regexps'. Regards,
Re: [O] Target and link text normalised to `orgtargetn'
Rasmus ras...@gmx.us writes: Yeah, I though of that, but that require us to maintain a list of latex math environments, which may or may not be annoying. Well, if an environment is not recognized as a math one, it still gets a label. So, that's not a big deal to miss some of them. If we add such a variable where should it live? org.el or ox-latex.el? ox-latex.el. This is a hack. There's no need to leak it elsewhere. Regards,
Re: [O] Target and link text normalised to `orgtargetn'
Nicolas Goaziou m...@nicolasgoaziou.fr writes: Rasmus ras...@gmx.us writes: Can we have conditional dependence on texmathp? I guess it doesn't hurt. You need to declare it as an external function in order to silence byte-compiler, tho. You are right. Thanks. If so, maybe something like the attached, though the latex-environment part is ugly. Another option is to simply extract environment from :value and decide if it is a math environment or not. This is what `texmathp' does (i.e., `texmathp-tex-commands-default') although the list is configurable (through `texmathp-tex-commands'). Nesting is not a problem here since you're only interested if the top-most environment. Yeah, I though of that, but that require us to maintain a list of latex math environments, which may or may not be annoying. If we add such a variable where should it live? org.el or ox-latex.el? —Rasmus -- This message is brought to you by the department of redundant departments
Re: [O] Target and link text normalised to `orgtargetn'
Nicolas Goaziou m...@nicolasgoaziou.fr writes: Rasmus ras...@gmx.us writes: Nicolas Goaziou m...@nicolasgoaziou.fr writes: However, tab:orgtable1 or sec:orgheadline1 are fine, IMO, since org part can keep the label out of userland. That's fine with me as well. Fair enough. Do you want to take care of extending `org-latex--label' appropriately? Can we have conditional dependence on texmathp? If so, maybe something like the attached, though the latex-environment part is ugly. Results areq pretty ugly. E.g. for headline, table, figure, latex-math env, latex-env: \ref{sec:orgheadline1}, \ref{tab:orgtable1}, \ref{fig:orgparagraph1}, \ref{eq:orglatexenvironment1}, \ref{orglatexenvironment2} —Rasmus -- Vote for proprietary math! From cc2c027ab611c3abcdc5c7cac46b6f45d682657f Mon Sep 17 00:00:00 2001 From: Rasmus ras...@gmx.us Date: Mon, 20 Apr 2015 15:06:55 +0200 Subject: [PATCH] ox-latex: Use standard LaTeX label prefixes. * ox-latex.el (org-latex--label): Use standard LaTeX prefixes. --- lisp/ox-latex.el | 17 - 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 2727f1c..075f4e4 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1067,7 +1067,22 @@ Eventually, if FULL is non-nil, wrap label within \\\label{}\. (and (or user-label force) (if (and user-label (plist-get info :latex-prefer-user-labels)) user-label - (org-export-get-reference datum info) + (concat (case type + (headline sec:) + (table tab:) + (latex-environment + (and (featurep 'texmathp) + (with-temp-buffer + (insert (org-element-property :value datum)) + (goto-char (point-min)) + (search-forward } nil t) + (latex-mode) + (texmathp)) + eq:)) + (paragraph + (when (org-element-property :caption datum) + fig:))) + (org-export-get-reference datum info)) (cond ((not full) label) (label (format \\label{%s}%s label -- 2.3.5
Re: [O] Target and link text normalised to `orgtargetn'
Rasmus ras...@gmx.us writes: Nicolas Goaziou m...@nicolasgoaziou.fr writes: However, tab:orgtable1 or sec:orgheadline1 are fine, IMO, since org part can keep the label out of userland. That's fine with me as well. Fair enough. Do you want to take care of extending `org-latex--label' appropriately? Regards,
Re: [O] Target and link text normalised to `orgtargetn'
Rasmus ras...@gmx.us writes: So we could replace ^org with a mapping, e.g. headline → sec: and table → tab:. Then there's the added safety of TYPE-NUMBER and the expected prefix. Do you mean orgheadline1 becomes orgsec:1 and orgtable1 becomes orgtab:1? In this case, I don't mind, as long as it is limited to ox-latex and derived back-ends. Regards,
Re: [O] Target and link text normalised to `orgtargetn'
Nicolas Goaziou m...@nicolasgoaziou.fr writes: However, tab:orgtable1 or sec:orgheadline1 are fine, IMO, since org part can keep the label out of userland. That's fine with me as well. —Rasmus -- Evidence suggests Snowden used a powerful tool called monospaced fonts
Re: [O] Target and link text normalised to `orgtargetn'
Nicolas Goaziou m...@nicolasgoaziou.fr writes: Rasmus ras...@gmx.us writes: That's what I meant. Or rather a wrapper like org-latex--label. A mapping like the one that was reverted for ox-latex only. Or are there pitfalls in that approach? It will not give you predictability either since you cannot guess 4 in sec:4. That's fine. Also, it is dangerous since a user could use \label{sec:4} for something different. So we could replace ^org with a mapping, e.g. headline → sec: and table → tab:. Then there's the added safety of TYPE-NUMBER and the expected prefix. What is the real benefit of sec:4 over orgheadline4? Aesthetics? Mostly aesthetics. sec:4 is expected, though I have no numbers to back this claim. I would expect breakage following the change to be pretty rare, but one example of breakage is fancyref: \documentclass{article} \usepackage{fancyref} \begin{document} \section{h1} \label{sec:h1} \section{h2} \label{orgheading2} See \fref{sec:h1} and \fref{orgheading2} \end{document} It does not IMO. I would rather not label sections manually. I don't understand that part. Would you mind elaborating a bit? Given my taste for standard prefixes, I would rather not have to label every section with some custom id to get a standard prefix in the output. —Rasmus -- I almost cut my hair, it happened just the other day
Re: [O] Target and link text normalised to `orgtargetn'
Nicolas Goaziou m...@nicolasgoaziou.fr writes: Rasmus ras...@gmx.us writes: So we could replace ^org with a mapping, e.g. headline → sec: and table → tab:. Then there's the added safety of TYPE-NUMBER and the expected prefix. Do you mean orgheadline1 becomes orgsec:1 and orgtable1 becomes orgtab:1? In this case, I don't mind, as long as it is limited to ox-latex and derived back-ends. No, like orgheadline1 → sec:headline1 and orgtable1 → tab:table1. It seems a bit repetitive. —Rasmus -- Bang bang
Re: [O] Target and link text normalised to `orgtargetn'
Rasmus ras...@gmx.us writes: No, like orgheadline1 → sec:headline1 and orgtable1 → tab:table1. It seems a bit repetitive. I think this is no good. tab:table1 is something a user can use for its own LaTeX code, e.g. in a latex block or environment. In this case, it might interfere with Org's tab:table1, which could label a different element. However, tab:orgtable1 or sec:orgheadline1 are fine, IMO, since org part can keep the label out of userland. Regards,
Re: [O] Target and link text normalised to `orgtargetn'
Rasmus ras...@gmx.us writes: Can we have conditional dependence on texmathp? I guess it doesn't hurt. You need to declare it as an external function in order to silence byte-compiler, tho. If so, maybe something like the attached, though the latex-environment part is ugly. Another option is to simply extract environment from :value and decide if it is a math environment or not. This is what `texmathp' does (i.e., `texmathp-tex-commands-default') although the list is configurable (through `texmathp-tex-commands'). Nesting is not a problem here since you're only interested if the top-most environment. WDYT? Results areq pretty ugly. E.g. for headline, table, figure, latex-math env, latex-env: \ref{sec:orgheadline1}, \ref{tab:orgtable1}, \ref{fig:orgparagraph1}, \ref{eq:orglatexenvironment1}, \ref{orglatexenvironment2} OK. +(paragraph + (when (org-element-property :caption datum) + fig:))) Nitpick: (and (org-element-property ...) fig:) Regards,
Re: [O] Target and link text normalised to `orgtargetn'
Hello, Suvayu Ali fatkasuvayu+li...@gmail.com writes: Sorry, I don't think I quite understand. AFAIU, targets like interesting have to be unique even inside the Org buffer for links like this to work: [[interesting][very cool]], regardless of export. So then why rename them during export? There's no guarantee that, e.g., \label{interesting} is a valid syntax. Think about 100% for LaTeX. Actually such links were broken for non-ASCII characters before the patch. Note that this is transparent for the user: if interesting becomes \label{foo}, [[interesting][very cool]] automatically becomes \hyperref[foo]{very cool}. Your problem is different AFAIU. You are relying on the internal pattern of generated labels, i.e., you are eating Org's dog food. I advise against it. If you need explicitly \label{interesting}, ask Org to write it with, e.g., @@latex:\label{foo}@@ or even better #+MACRO: lbl @@latex:\label{$1}@@ {{{lbl(foo)}}} How does the above solve the issue? I was not having problems with getting to export \label{foo}, my problem was what do I put as `foo' since in the exported TeX file foo was different. Hopefully I made myself clear, or I'm not misunderstanding something. Again target are for [[target]], \label{...} are for \whateverref{..}. IOW, you are mixing two different concepts. Since you write \secref{fig:1} in your documents, you can also write \label{fig:1} there. Org can only ensures you that [[target]] always point to target. No more, no less. There is another data point to consider: internal label scheme must not follow a simple pattern, as a user might use the same and introduce a label collision. E.g., if foo becomes par:foo, the following line is problematic: foo \label{par:foo} \ref{par:foo} [[foo]] This is why I suggest to rever commit cf7d64f. It also introduces a non-alphanumeric character :, even though `org-export-get-reference' uses only alphanumeric ones by portability concern (it is even specified in its docstring). Commit f1548e1 is different. I actually mostly agree with it (though I was confused at first with the docstring change, which needs to be fixed), but it breaks radio targets. It doesn't need to be reverted. Regards, -- Nicolas Goaziou
Re: [O] Target and link text normalised to `orgtargetn'
Hi Nicolas, On Sat, Apr 18, 2015 at 11:53:01PM +0200, Nicolas Goaziou wrote: Hello, Rasmus ras...@gmx.us writes: Suvayu Ali fatkasuvayu+li...@gmail.com writes: Hi Rasmus, On Thu, Apr 16, 2015 at 12:57:46AM +0200, Rasmus wrote: Could you try the attached patches and see if they solve your issues? Seems to work nicely. I'll keep using them rest of the week. Pushed. I removed support for radio targets as I don't really see the point in those supporting custom labeling. They are transcoded as target → \hyperref{label}{target} It makes little sense to label be the same as target, though it probably would not create problems. I don't see the point of this change. The naming scheme is internal anyway. Users are not supposed to use it directly. Sorry, I don't think I quite understand. AFAIU, targets like interesting have to be unique even inside the Org buffer for links like this to work: [[interesting][very cool]], regardless of export. So then why rename them during export? If you want \label{foo} in the output, you can write @@latex:\label{foo}@@. Targets are for Org links and are expected to work across all back-ends, so the problem they solve is slightly different. How does the above solve the issue? I was not having problems with getting to export \label{foo}, my problem was what do I put as `foo' since in the exported TeX file foo was different. Hopefully I made myself clear, or I'm not misunderstanding something. Cheers, -- Suvayu Open source is the future. It sets us free.
Re: [O] Target and link text normalised to `orgtargetn'
Hi Nicolas, On Sun, Apr 19, 2015 at 02:57:09PM +0200, Nicolas Goaziou wrote: Suvayu Ali fatkasuvayu+li...@gmail.com writes: Sorry, I don't think I quite understand. AFAIU, targets like interesting have to be unique even inside the Org buffer for links like this to work: [[interesting][very cool]], regardless of export. So then why rename them during export? There's no guarantee that, e.g., \label{interesting} is a valid syntax. Think about 100% for LaTeX. Actually such links were broken for non-ASCII characters before the patch. Note that this is transparent for the user: if interesting becomes \label{foo}, [[interesting][very cool]] automatically becomes \hyperref[foo]{very cool}. Your problem is different AFAIU. You are relying on the internal pattern of generated labels, i.e., you are eating Org's dog food. I advise against it. Yes indeed. I wanted to use the location information provided by refstyle, and varioref. By using \secref or \vpageref I would get references like: section §3, on page 5, etc. If you need explicitly \label{interesting}, ask Org to write it with, e.g., @@latex:\label{foo}@@ or even better #+MACRO: lbl @@latex:\label{$1}@@ {{{lbl(foo)}}} Okay I see it now, in your last email I got a bit confused, but now I follow. With your solution I use both label and reference using LaTeX, bypassing Org. Of course this leaves me with links not working inside Org. I was eventually going to use filters to transform the ref commands to the alternate ones from refstyle and varioref to get both LaTeX and Org side working as I wanted. Something like this: sec:interesting [[sec:interesting]] Then transform \ref{sec:interesting} → \secref{sec:interesting} with a filter; that way I would have my cake and eat it too! I see your point though. Thanks a lot for the comments. :) Cheers, -- Suvayu Open source is the future. It sets us free.
Re: [O] Target and link text normalised to `orgtargetn'
Suvayu Ali fatkasuvayu+li...@gmail.com writes: Okay I see it now, in your last email I got a bit confused, but now I follow. With your solution I use both label and reference using LaTeX, bypassing Org. Of course this leaves me with links not working inside Org. I was eventually going to use filters to transform the ref commands to the alternate ones from refstyle and varioref to get both LaTeX and Org side working as I wanted. Something like this: sec:interesting [[sec:interesting]] Then transform \ref{sec:interesting} → \secref{sec:interesting} with a filter; that way I would have my cake and eat it too! I see your point though. You can do that with a non-nil `org-latex-prefer-user-labels'. Otherwise, sec:interesting becomes \label{whatever}, defeating your filter. Regards,
Re: [O] Target and link text normalised to `orgtargetn'
Hi Nicolas, On Sun, Apr 19, 2015 at 03:40:07PM +0200, Nicolas Goaziou wrote: Suvayu Ali fatkasuvayu+li...@gmail.com writes: Okay I see it now, in your last email I got a bit confused, but now I follow. With your solution I use both label and reference using LaTeX, bypassing Org. Of course this leaves me with links not working inside Org. I was eventually going to use filters to transform the ref commands to the alternate ones from refstyle and varioref to get both LaTeX and Org side working as I wanted. Something like this: sec:interesting [[sec:interesting]] Then transform \ref{sec:interesting} → \secref{sec:interesting} with a filter; that way I would have my cake and eat it too! I see your point though. You can do that with a non-nil `org-latex-prefer-user-labels'. Otherwise, sec:interesting becomes \label{whatever}, defeating your filter. Ah, that was my report, that option did not work for me completely. See: http://thread.gmane.org/gmane.emacs.orgmode/96887/focus=96888. To summarise quickly, with the above option set to t all references/links behave as I expect, except the ones where the target is a `bare target'. Does that mean there was indeed a bug? Cheers, -- Suvayu Open source is the future. It sets us free.
Re: [O] Target and link text normalised to `orgtargetn'
Suvayu Ali fatkasuvayu+li...@gmail.com writes: Ah, that was my report, that option did not work for me completely. See: http://thread.gmane.org/gmane.emacs.orgmode/96887/focus=96888. To summarise quickly, with the above option set to t all references/links behave as I expect, except the ones where the target is a `bare target'. Does that mean there was indeed a bug? Yes, Rasmus fixed it in f1548e11fe2972819bc48b88c6094b11150e5c8a. I just fixed Rasmus' fix wrt radio targets. Regards,
Re: [O] Target and link text normalised to `orgtargetn'
Rasmus ras...@gmx.us writes: That's what I meant. Or rather a wrapper like org-latex--label. A mapping like the one that was reverted for ox-latex only. Or are there pitfalls in that approach? It will not give you predictability either since you cannot guess 4 in sec:4. Also, it is dangerous since a user could use \label{sec:4} for something different. Hence the `gensym'-like approach: we're pretty safe with orgheadline4. What is the real benefit of sec:4 over orgheadline4? Aesthetics? It does not IMO. I would rather not label sections manually. I don't understand that part. Would you mind elaborating a bit? Regards,
Re: [O] Target and link text normalised to `orgtargetn'
Hi Nicolas, I hope you had a nice time offline. Nicolas Goaziou m...@nicolasgoaziou.fr writes: This is why I suggest to rever commit cf7d64f. It also introduces a non-alphanumeric character :, even though `org-export-get-reference' uses only alphanumeric ones by portability concern (it is even specified in its docstring). I think the label naming is worse now, and I think it's important to produce good quality labels akin to what you would expect from e.g. AUCTeX. However, I have reverted cf7d64fgit per your request. Perhaps a solution for high-quality labels in ox-latex can be introduced later a la org-latex--label. Commit f1548e1 is different. I actually mostly agree with it (though I was confused at first with the docstring change, which needs to be fixed), I guess the fix is 88108f652f0d4ddb4250cb89c2453df1fc9ee671. Yes? but it breaks radio targets. I agree, and I actually though I had left out that part when pushing. Thanks for fixing. —Rasmus -- However beautiful the theory, you should occasionally look at the evidence
Re: [O] Target and link text normalised to `orgtargetn'
Nicolas Goaziou m...@nicolasgoaziou.fr writes: I realize. /I/ think we should do better. The only way to do better I can think of is to let ox-latex.el implements its own labelling scheme, without relying on `org-export-get-reference', which is not mandatory anyway. That's what I meant. Or rather a wrapper like org-latex--label. A mapping like the one that was reverted for ox-latex only. Or are there pitfalls in that approach? Anyway, I'm not sure we need to bother since `org-latex-prefer-user-labels' fills the gap. It does not IMO. I would rather not label sections manually. —Rasmus -- Enough with the bla bla!
Re: [O] Target and link text normalised to `orgtargetn'
Rasmus ras...@gmx.us writes: I hope you had a nice time offline. Yes I had, thank you. I think the label naming is worse now, and I think it's important to produce good quality labels akin to what you would expect from e.g. AUCTeX. The goal is completely different. AUCTeX generates good quality labels because they are meant for user consumption. OTOH, `org-export-get-reference' creates impossible to guess labels, for internal use only, e.g., much like what `gensym' does. However, I have reverted cf7d64fgit per your request. Thank you. Regards,
Re: [O] Target and link text normalised to `orgtargetn'
Hi, Nicolas Goaziou m...@nicolasgoaziou.fr writes: I hope you had a nice time offline. Yes I had, thank you. Cool! I think the label naming is worse now, and I think it's important to produce good quality labels akin to what you would expect from e.g. AUCTeX. The goal is completely different. AUCTeX generates good quality labels because they are meant for user consumption. I think it's very important that ox-latex outputs are also consumable. I don't want to create another LyX. Of course we are very far from this point. OTOH, `org-export-get-reference' creates impossible to guess labels, for internal use only, e.g., much like what `gensym' does. I realize. /I/ think we should do better. Cheers, Rasmus -- Lasciate ogni speranza o voi che entrate: siete nella mani di'machellaio
Re: [O] Target and link text normalised to `orgtargetn'
On Sun, Apr 19, 2015 at 03:56:22PM +0200, Nicolas Goaziou wrote: Suvayu Ali fatkasuvayu+li...@gmail.com writes: Ah, that was my report, that option did not work for me completely. See: http://thread.gmane.org/gmane.emacs.orgmode/96887/focus=96888. To summarise quickly, with the above option set to t all references/links behave as I expect, except the ones where the target is a `bare target'. Does that mean there was indeed a bug? Yes, Rasmus fixed it in f1548e11fe2972819bc48b88c6094b11150e5c8a. I just fixed Rasmus' fix wrt radio targets. Ah, okk. Up to speed now. Cheers, -- Suvayu Open source is the future. It sets us free.
Re: [O] Target and link text normalised to `orgtargetn'
Rasmus ras...@gmx.us writes: I think it's very important that ox-latex outputs are also consumable. I don't want to create another LyX. Of course we are very far from this point. [...] I realize. /I/ think we should do better. The only way to do better I can think of is to let ox-latex.el implements its own labelling scheme, without relying on `org-export-get-reference', which is not mandatory anyway. Anyway, I'm not sure we need to bother since `org-latex-prefer-user-labels' fills the gap. Regards,
Re: [O] Target and link text normalised to `orgtargetn'
Hello, Rasmus ras...@gmx.us writes: Suvayu Ali fatkasuvayu+li...@gmail.com writes: Hi Rasmus, On Thu, Apr 16, 2015 at 12:57:46AM +0200, Rasmus wrote: Could you try the attached patches and see if they solve your issues? Seems to work nicely. I'll keep using them rest of the week. Pushed. I removed support for radio targets as I don't really see the point in those supporting custom labeling. They are transcoded as target → \hyperref{label}{target} It makes little sense to label be the same as target, though it probably would not create problems. I don't see the point of this change. The naming scheme is internal anyway. Users are not supposed to use it directly. If you want \label{foo} in the output, you can write @@latex:\label{foo}@@. Targets are for Org links and are expected to work across all back-ends, so the problem they solve is slightly different. Please revert f1548e1 and cf7d64f, they are not a correct solution. Thank you. Regards, -- Nicolas Goaziou
Re: [O] Target and link text normalised to `orgtargetn'
Suvayu Ali fatkasuvayu+li...@gmail.com writes: Hi Rasmus, On Thu, Apr 16, 2015 at 12:57:46AM +0200, Rasmus wrote: Could you try the attached patches and see if they solve your issues? Seems to work nicely. I'll keep using them rest of the week. Pushed. I removed support for radio targets as I don't really see the point in those supporting custom labeling. They are transcoded as target → \hyperref{label}{target} It makes little sense to label be the same as target, though it probably would not create problems. —Rasmus -- A clever person solves a problem. A wise person avoids it
Re: [O] Target and link text normalised to `orgtargetn'
Hi, Could you try the attached patches and see if they solve your issues? Thanks, Rasmus -- C is for Cookie From 8951c689a7812d6557ba65888e549013814e5f8a Mon Sep 17 00:00:00 2001 From: Rasmus ras...@gmx.us Date: Wed, 15 Apr 2015 21:50:53 +0200 Subject: [PATCH 2/2] ox: Change label naming scheme * ox.el (org-export-get-reference): Change labeling scheme. 160820bc94 and later changed the label naming scheme to follow types. This commit maps to types to more standard names, e.g. 'headline' to 'sec'. --- lisp/ox.el | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/ox.el b/lisp/ox.el index d6dcc82..f7d0ef5 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -4149,9 +4149,18 @@ alphanumeric characters only. h (or (gethash datum cache) (puthash datum - (format org%s%d + (format %s:%d (if type - (replace-regexp-in-string - (symbol-name type)) + (case type + (headline sec) + (paragraph +(if (org-element-property :caption datum) +fig paragraph)) + (latex-environment eq) + (table tbl) + (otherwise +(replace-regexp-in-string - + (symbol-name type secondarystring) (incf (gethash type cache 0))) cache -- 2.3.5 From a01e6759a6a016fd4c684eaaa56544d8507c897f Mon Sep 17 00:00:00 2001 From: Rasmus ras...@gmx.us Date: Wed, 15 Apr 2015 21:46:57 +0200 Subject: [PATCH 1/2] ox-latex: Wider user-label support * ox-latex.el (org-latex--label): Add user-labels for targets and radio-target. (org-latex--wrap-label, org-latex-link, org-latex-target) (org-latex-radio-target): Use org-latex--label. --- lisp/ox-latex.el | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 61d16b1..b22b0a7 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -1056,9 +1056,10 @@ return a unique label. Eventually, if FULL is non-nil, wrap label within \\\label{}\. (let* ((user-label (org-element-property - (if (memq (org-element-type element) '(headline inlinetask)) - :CUSTOM_ID - :name) + (case (org-element-type element) + ((headline inlinetask) :CUSTOM_ID) + ((target radio-target) :value) + (otherwise :name)) element)) (label (and (or user-label force) @@ -1176,7 +1177,7 @@ should not be used for floats. See (if (not (and (org-string-nw-p output) (org-element-property :name element))) output (concat (format \\phantomsection\n\\label{%s}\n - (org-export-get-reference element info)) + (org-latex--label element info)) output))) (defun org-latex--text-markup (text markup info) @@ -2088,7 +2089,7 @@ INFO is a plist holding contextual information. See (let ((destination (org-export-resolve-radio-link link info))) (if (not destination) desc (format \\hyperref[%s]{%s} - (org-export-get-reference destination info) + (org-latex--label destination info) desc ;; Links pointing to a headline: Find destination and build ;; appropriate referencing command. @@ -2416,7 +2417,7 @@ holding contextual information. Transcode a RADIO-TARGET object from Org to LaTeX. TEXT is the text of the target. INFO is a plist holding contextual information. - (format \\label{%s}%s (org-export-get-reference radio-target info) text)) + (format \\label{%s}%s (org-latex--label radio-target info) text)) Section @@ -3029,7 +3030,7 @@ a communication channel. Transcode a TARGET object from Org to LaTeX. CONTENTS is nil. INFO is a plist holding contextual information. - (format \\label{%s} (org-export-get-reference target info))) + (format \\label{%s} (org-latex--label target info))) Timestamp -- 2.3.5
Re: [O] Target and link text normalised to `orgtargetn'
Hi Rasmus, On Thu, Apr 16, 2015 at 12:57:46AM +0200, Rasmus wrote: Could you try the attached patches and see if they solve your issues? Seems to work nicely. I'll keep using them rest of the week. Thanks, :) -- Suvayu Open source is the future. It sets us free.
[O] Target and link text normalised to `orgtargetn'
Hello everyone, I am exporting Org files to LaTeX. I noticed something strange happening. The text of all my target text gets changed to `orgtargetn' where n is some number. This breaks a lot of my LaTeX specific links. For example, I use the varioref package to get entity specific references, so \secref{sec:foo}, \figref{fig:bar}, \tabref{sec:baz} (it even takes care of language, or punctuation as needed!). Now if the target text changes from sec:foo to orgtarget1, of course the link breaks. I thought I would simply put the references into a normal org link, [[sec:foo]], and use a filter to put the sec, fig, tab, etc. But of course that doesn't work since I can't tell which is which as the text has changed! Is this intended? What is the rational? Can I switch this off with a setting somewhere? I think this is a very recent change, afaict, it was working as expected before. Thanks for any response, -- Suvayu Open source is the future. It sets us free.
Re: [O] Target and link text normalised to `orgtargetn'
Hi, I found a partial answer. On Tue, Apr 14, 2015 at 11:25:30AM +0200, Suvayu Ali wrote: I am exporting Org files to LaTeX. I noticed something strange happening. The text of all my target text gets changed to `orgtargetn' where n is some number. This breaks a lot of my LaTeX specific links. For example, I use the varioref package to get entity specific Typo here, the package name is actually refstyle. references, so \secref{sec:foo}, \figref{fig:bar}, \tabref{sec:baz} (it even takes care of language, or punctuation as needed!). Now if the target text changes from sec:foo to orgtarget1, of course the link breaks. The commit 4bbc054 introduces a variable org-latex-prefer-user-labels. which is reponsible for this behaviour. Setting this variable to t doesn't entirely solve my problem though. Normal targets like par:interesting are still altered. I think the docstring hints at that already. For headlines that do not define the CUSTOM_ID property or elements without a NAME, Org will continue to use its default labeling scheme to generate labels and resolve links into proper references. I guess a bare target is an element without a NAME. I find this a bit strange, since the user already adds the target manually. So I think it is already the user's responsibility to ensure it is consistent. Shouldn't then Org leave this unchanged? Thanks, -- Suvayu Open source is the future. It sets us free.
Re: [O] Target and link text normalised to `orgtargetn'
Rasmus ras...@gmx.us writes: Hi, Suvayu Ali fatkasuvayu+li...@gmail.com writes: references, so \secref{sec:foo}, \figref{fig:bar}, \tabref{sec:baz} (it even takes care of language, or punctuation as needed!). Now if the target text changes from sec:foo to orgtarget1, of course the link breaks. The commit 4bbc054 introduces a variable org-latex-prefer-user-labels. which is reponsible for this behaviour. Setting this variable to t doesn't entirely solve my problem though. Normal targets like par:interesting are still altered. The change in behavior is approximately 160820bc9498e9364103e72b55a27cf92576dbb8 to 4bbc054bd252b975f483a29515495a9af9329c71. IMO the issue is that org-export-get-reference does not map back to default-type references (sec:·, fig:·). I think this should be fixed. I think the docstring hints at that already. For headlines that do not define the CUSTOM_ID property or elements without a NAME, Org will continue to use its default labeling scheme to generate labels and resolve links into proper references. I guess a bare target is an element without a NAME. I find this a bit strange, since the user already adds the target manually. So I think it is already the user's responsibility to ensure it is consistent. Shouldn't then Org leave this unchanged? That seems like a bug. Seems both, self-fixing and Rasmus-fixing. (Sorry, could not resist.) Andreas
Re: [O] Target and link text normalised to `orgtargetn'
Hi, Suvayu Ali fatkasuvayu+li...@gmail.com writes: references, so \secref{sec:foo}, \figref{fig:bar}, \tabref{sec:baz} (it even takes care of language, or punctuation as needed!). Now if the target text changes from sec:foo to orgtarget1, of course the link breaks. The commit 4bbc054 introduces a variable org-latex-prefer-user-labels. which is reponsible for this behaviour. Setting this variable to t doesn't entirely solve my problem though. Normal targets like par:interesting are still altered. The change in behavior is approximately 160820bc9498e9364103e72b55a27cf92576dbb8 to 4bbc054bd252b975f483a29515495a9af9329c71. IMO the issue is that org-export-get-reference does not map back to default-type references (sec:·, fig:·). I think this should be fixed. I think the docstring hints at that already. For headlines that do not define the CUSTOM_ID property or elements without a NAME, Org will continue to use its default labeling scheme to generate labels and resolve links into proper references. I guess a bare target is an element without a NAME. I find this a bit strange, since the user already adds the target manually. So I think it is already the user's responsibility to ensure it is consistent. Shouldn't then Org leave this unchanged? That seems like a bug. —Rasmus -- To err is human. To screw up 10⁶ times per second, you need a computer