From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: using vref in latex export, and normal links in html export Date: Fri, 11 Mar 2016 09:02:22 -0500 Message-ID: References: <8737rxwa2i.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aeNe9-0004nX-7U for emacs-orgmode@gnu.org; Fri, 11 Mar 2016 09:02:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aeNe5-0002rN-5H for emacs-orgmode@gnu.org; Fri, 11 Mar 2016 09:02:29 -0500 Received: from mail-qk0-x22d.google.com ([2607:f8b0:400d:c09::22d]:36090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aeNe5-0002rH-1h for emacs-orgmode@gnu.org; Fri, 11 Mar 2016 09:02:25 -0500 Received: by mail-qk0-x22d.google.com with SMTP id s68so47838126qkh.3 for ; Fri, 11 Mar 2016 06:02:24 -0800 (PST) In-reply-to: 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: Alan Schmitt Cc: emacs-orgmode Try: (setq org-latex-prefer-user-labels t) I think this does what you want for org 8.3.4 at least. Alan Schmitt writes: > Hello Eric, > > On 2016-03-11 12:03, Eric S Fraga writes: > >> On Friday, 11 Mar 2016 at 11:20, Alan Schmitt wrote: >>> Hello, >>> >>> I'm converting a latex document into org-mode to easily export it both >>> to latex and html. I've just encountered something that I don't know how >>> to do: export a \vref reference. I would like to have something that >>> exports to \vref in latex, and to a normal link in html. >>> >>> I thought I could do this trick with a macro: >>> >>> #+macro: vref @@latex:\myvref{$1}{@@[[$1]]@@latex:}@@ >> >> I may be missing something but could you not simply use >> >> [[vref:fig:log-expt-7]] >> >> (along with description text if you wished) and define an org link as >> below? >> >> #+begin_src elisp >> (org-add-link-type "vref" nil >> (lambda (path desc format) >> (cond >> ((eq format 'latex) >> (format "\\vref{%s}" path))))) >> #+end_src >> >> (untested) > > Thank you for the suggestion, but I end up with the same thing as with > the macro: the reference generated is to "fig:log-expt-7", but this does > not work as the label assigned by org to the figure is > "fig:orgparagraph1". > > Here is a small example of a similar problem. Exporting this to latex > > This is a \ref{fig:foo} and this is a link [[fig:foo]] > > #+label: fig:foo > #+begin_figure > Test > #+end_figure > > results in > > #+begin_src latex > This is a \ref{fig:foo} and this is a link \ref{orgspecialblock1} > > \begin{figure} > Test > \label{orgspecialblock1} > \end{figure} > #+end_src > > Alan -- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu