From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?B?Ik1hcnRpbiBHLiBTa2rDpnZlbGFuZCI=?= Subject: Re: Re: changing \href to \myhref in LaTex export Date: Wed, 20 Jan 2010 14:00:29 +0100 Message-ID: <4B56FE6D.7040606@ifi.uio.no> References: <4B55D04B.7050305@ifi.uio.no> <87ockpdv93.fsf@mundaneum.com> <4B56CAB8.7080706@ifi.uio.no> <87vdexav6q.fsf@mundaneum.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NXa95-000575-C5 for emacs-orgmode@gnu.org; Wed, 20 Jan 2010 07:58:51 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NXa8z-00053z-Sx for emacs-orgmode@gnu.org; Wed, 20 Jan 2010 07:58:50 -0500 Received: from [199.232.76.173] (port=35494 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXa8z-00053p-Nt for emacs-orgmode@gnu.org; Wed, 20 Jan 2010 07:58:45 -0500 Received: from mail-out2.uio.no ([129.240.10.58]:47683) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NXa8z-0004Ev-4w for emacs-orgmode@gnu.org; Wed, 20 Jan 2010 07:58:45 -0500 In-Reply-To: <87vdexav6q.fsf@mundaneum.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: =?UTF-8?B?U8OpYmFzdGllbiBWYXViYW4=?= Cc: emacs-orgmode@gnu.org Sébastien Vauban wrote: > Hi Martin, > > "Martin G. Skjæveland" wrote: >> Sébastien Vauban wrote: >>> "Martin G. Skjæveland" wrote: >>> >>>> is it possible to change how hyperlinks are exported to LaTex without >>>> going into to org-latex.el, but setting by a variable or similar in my >>>> .emacs file? >>>> >>>> I would like to export hyperlinks in Latex as \myhref (or something else) >>>> instead of \href, so that I can redefine \myhref using \href, like this >>>> >>>> \usepackage{ifthen} >>>> \newcommand{\myhref}[2]{ >>>> \ifthenelse{\equal{#1}{#2}} >>>> {\href{#1}{#2}} >>>> {\href{#1}{#2}\footnote{\url{#1}}} >>>> } >>>> >>>> and thus include the URLs of the links as footnotes. >>> Not answering clearly your question, but an alternative (that works) is to >>> redefine \href either in your private class (if you use one) or in your TeX >>> file. >>> >>> In the latter case, put the `renewcommand' in your Org source, so that it >>> gets exported every time. >>> >>> Example (with a `newcommand' here): >>> >>> --8<---------------cut here---------------start------------->8--- >>> #+LaTeX_HEADER: \newcommand{\figtext}[2]{\begin{tikzpicture} \draw (-#1/2,-#1/2) rectangle (#1/2,#1/2); \node[text width=#1] at (0,0) {\color{blue}\scriptsize{#2}}; \end{tikzpicture}} >>> --8<---------------cut here---------------end--------------->8--- >>> >>> I think, for this case, this offers more flexibility and allows you to get >>> what you want. >> yes, this looks like the flexibility I'm after, but my problem with your >> solution is that by using \renewcommand I would be defining a recursive >> command, which does not work. (I should have mentioned that in my first >> email, sorry.) This is the reason for renaming the \href command in the >> export, so I can define my own href command using the standard href. > > Nope! You can do that by simply renaming the old version first. > > In your case: > > --8<---------------cut here---------------start------------->8--- > \let\orig@href=\href > \renewcommand\href[2]{% > \ifthenelse{\equal{#1}{#2}} > {\orig@href{#1}{#2}} > {\orig@href{#1}{#2}\footnote{\url{#1}}} > }% href > > \href{http://www.mygooglest.com/}{Test} > \href{http://www.mygooglest.com/}{http://www.mygooglest.com/} > --8<---------------cut here---------------end--------------->8--- Thanks, what works perfect! Initially, it did not work, but moving the above code directly below \usepackage{hyperref} solved my problems. Martin