From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: Target and link text normalised to `orgtargetn' Date: Fri, 24 Apr 2015 15:35:03 +0200 Message-ID: <87d22t1wfs.fsf@gmx.us> References: <20150414092530.GC2957@chitra.no-ip.org> <87egnk9ycz.fsf@gmx.us> <87k2x9cddu.fsf@nicolasgoaziou.fr> <20150419121305.GZ14328@chitra.no-ip.org> <87618smg2i.fsf@nicolasgoaziou.fr> <87d230rzak.fsf@gmx.us> <87vbgsdw2c.fsf@nicolasgoaziou.fr> <87pp70qi9w.fsf@gmx.us> <87oamkdu5v.fsf@nicolasgoaziou.fr> <87lhhoqbsc.fsf@gmx.us> <87fv7wdkz2.fsf@nicolasgoaziou.fr> <87383vqiuh.fsf@gmx.us> <87618rdv3w.fsf@nicolasgoaziou.fr> <87wq17p2x1.fsf@gmx.us> <87wq17ce98.fsf@nicolasgoaziou.fr> <87oamjce2q.fsf@gmx.us> <87sibvccnc.fsf@nicolasgoaziou.fr> <87618rc595.fsf@gmx.us> <87fv7ubyn6.fsf@nicolasgoaziou.fr> <87618qblv8.fsf@gmx.us> <87bniibjgz.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yldl9-0000HD-9r for emacs-orgmode@gnu.org; Fri, 24 Apr 2015 09:35:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yldl4-0007K8-9K for emacs-orgmode@gnu.org; Fri, 24 Apr 2015 09:35:11 -0400 Received: from mout.gmx.net ([212.227.15.19]:65393) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yldl3-0007Hm-Uz for emacs-orgmode@gnu.org; Fri, 24 Apr 2015 09:35:06 -0400 Received: from x200s ([109.201.152.241]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0M2ts6-1Zd35q3dgM-00sc1b for ; Fri, 24 Apr 2015 15:35:04 +0200 In-Reply-To: <87bniibjgz.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Mon, 20 Apr 2015 23:03:40 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Nicolas Goaziou 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. =E2=80=94Rasmus --=20 Need more coffee. . . --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ox-latex-Use-standard-LaTeX-label-prefixes.patch >From 5442c61a0ab793d0a0cb3507d4355a5d1fb2f623 Mon Sep 17 00:00:00 2001 From: Rasmus 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 --=-=-=--