emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Stefan Nobis <stefan-ml@snobis.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: using vref in latex export, and normal links in html export
Date: Sat, 12 Mar 2016 16:27:22 -0500	[thread overview]
Message-ID: <m2k2l74cat.fsf@Johns-MacBook-Air.local> (raw)
In-Reply-To: <m1k2l8krvo.fsf@nobis-it.eu>

you could also try redefining the export of a ref link like this.

#+BEGIN_SRC emacs-lisp
(setf (elt  (assoc "ref" org-link-protocols) 2)
      (lambda (keyword desc format)
        (cond
         ((eq format 'latex)
          "\\vref{keyword}")
         ((eq format 'html)
          (format
           "<a href=\"%s\">%s</a>"
           keyword (or desc ""))))))
#+END_SRC

I am not sure if that is the kind of html export you want, but you could
adapt it to something else.

Stefan Nobis writes:

> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> 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 solve this with the help of an export filter:
>
> --8<---------------cut here---------------start------------->8---
> (defun sn/ox-latex-filter-varioref (text backend info)
>   (when (org-export-derived-backend-p backend 'latex)
>     (replace-regexp-in-string "\\\\ref{" "\\\\vref{" text)))
>
> (eval-after-load "ox-latex"
>   '(progn
>      (add-to-list 'org-export-filter-link-functions 'sn/ox-latex-filter-varioref)))
> --8<---------------cut here---------------end--------------->8---


--
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

  reply	other threads:[~2016-03-12 21:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-11 10:20 using vref in latex export, and normal links in html export Alan Schmitt
2016-03-11 11:03 ` Eric S Fraga
2016-03-11 13:11   ` Alan Schmitt
2016-03-11 14:02     ` John Kitchin
2016-03-11 15:05       ` Alan Schmitt
2016-03-11 15:20         ` Alan Schmitt
2016-03-12 21:36           ` John Kitchin
2016-03-14  9:33             ` Alan Schmitt
2016-03-12  8:44 ` Stefan Nobis
2016-03-12 21:27   ` John Kitchin [this message]
2016-03-14  9:29   ` Alan Schmitt

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=m2k2l74cat.fsf@Johns-MacBook-Air.local \
    --to=jkitchin@andrew.cmu.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=stefan-ml@snobis.de \
    /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).