emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: emacs-orgmode@gnu.org
Subject: Re: Target and link text normalised to `orgtargetn'
Date: Fri, 24 Apr 2015 15:35:03 +0200	[thread overview]
Message-ID: <87d22t1wfs.fsf@gmx.us> (raw)
In-Reply-To: <87bniibjgz.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Mon, 20 Apr 2015 23:03:40 +0200")

[-- Attachment #1: Type: text/plain, Size: 544 bytes --]

Nicolas Goaziou <mail@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. . .

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-latex-Use-standard-LaTeX-label-prefixes.patch --]
[-- Type: text/x-diff, Size: 1931 bytes --]

From 5442c61a0ab793d0a0cb3507d4355a5d1fb2f623 Mon Sep 17 00:00:00 2001
From: Rasmus <rasmus@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.")
 
 \f
 ;;; 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


  reply	other threads:[~2015-04-24 13:35 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-14  9:25 Target and link text normalised to `orgtargetn' Suvayu Ali
2015-04-14 12:08 ` Suvayu Ali
2015-04-14 12:59   ` Rasmus
2015-04-14 13:37     ` Andreas Leha
2015-04-15 22:57   ` Rasmus
2015-04-16  0:18     ` Suvayu Ali
2015-04-16 10:11       ` Rasmus
2015-04-18 21:53         ` Nicolas Goaziou
2015-04-19 12:13           ` Suvayu Ali
2015-04-19 12:57             ` Nicolas Goaziou
2015-04-19 13:24               ` Suvayu Ali
2015-04-19 13:40                 ` Nicolas Goaziou
2015-04-19 13:49                   ` Suvayu Ali
2015-04-19 13:56                     ` Nicolas Goaziou
2015-04-19 14:06                       ` Suvayu Ali
2015-04-19 14:02               ` Rasmus
2015-04-19 14:36                 ` Nicolas Goaziou
2015-04-19 14:55                   ` Rasmus
2015-04-19 15:17                     ` Nicolas Goaziou
2015-04-19 17:16                       ` Rasmus
2015-04-19 18:36                         ` Nicolas Goaziou
2015-04-20  8:55                           ` Rasmus
2015-04-20  9:09                             ` Nicolas Goaziou
2015-04-20  9:25                               ` Rasmus
2015-04-20  9:58                                 ` Nicolas Goaziou
2015-04-20 10:02                                   ` Rasmus
2015-04-20 10:33                                     ` Nicolas Goaziou
2015-04-20 13:13                                       ` Rasmus
2015-04-20 15:35                                         ` Nicolas Goaziou
2015-04-20 20:11                                           ` Rasmus
2015-04-20 21:03                                             ` Nicolas Goaziou
2015-04-24 13:35                                               ` Rasmus [this message]
2015-04-24 19:42                                                 ` Nicolas Goaziou
2015-04-27 22:08                                                   ` Rasmus
2015-04-27 22:15                                                     ` Nicolas Goaziou

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=87d22t1wfs.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).