emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Christian Moe <mail@christianmoe.com>
To: Carsten Dominik <carsten.dominik@gmail.com>
Cc: Emacs-orgmode@gnu.org
Subject: Re: Newbie: Custom link type formatting in LaTeX export?
Date: Wed, 12 May 2010 12:12:50 +0200	[thread overview]
Message-ID: <4BEA7F22.4060207@christianmoe.com> (raw)
In-Reply-To: <3D145F75-7633-4F98-A7CD-1300228A42FE@gmail.com>

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

Hi,

This patch (below and attached) seems to fix it. I've put the code at the
end of org-export-latex-links, which seems to be the right place (it doesn't
parallel the organization in the html exporter though).

Please check my work! I'm new to Lisp, and used git for the first time today.

Simple test: Export to LaTeX from an Org file including

[[bbdb:Jane Doe][Ms Doe]]

Currently it defaults to fixed-width (\texttt{Ms Doe}). When patched, it
should come out italicized (\textit{Ms Doe}) as per the export function
in org-bbdb.el.

Yours,
Christian


==========================================================================================
diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index 15d667e..eb293da 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -1876,6 +1876,11 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
  		(setq path (org-export-latex-protect-amp path)
  		      desc (org-export-latex-protect-amp desc)))
  	      (insert (format org-export-latex-hyperref-format path desc)))
+	     ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
+	      ;; The link protocol has a function for formatting the link
+	      (insert
+		    (save-match-data
+		      (funcall fnc (org-solidify-link-text raw-path) desc 'latex))))
  	     (t (insert "\\texttt{" desc "}")))))))


============================================================================================

 >> It looks like support for formatting custom link types in LaTeX export
 >> is broken?
(...)
 >> I've found that org-bbdb-export does not italicize bbdb links in
 >> LaTeX, nor does my own org-cite-export turn my custom =cite:= links
 >> into LaTeX =\cite{}= citations. Everything works fine in HTML export,
 >> but in LaTeX all custom link types get formatted as =\texttt{descr}=.
 >>
 >> I see that org-export-as-html and org-export-as-docbook look up
 >> org-link-protocols to get the function for formatting the link, but it
 >> seems that org-export-as-latex doesn't.
 >
 > Hi CHristian,
 >
 > this is correct.  Since you already looked into the code, would you like
 > to write a patch to this effect?
 >
 > - Carsten
 >

[-- Attachment #2: customlinkslatex.diff --]
[-- Type: text/plain, Size: 694 bytes --]

diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index 15d667e..eb293da 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -1876,6 +1876,11 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 		(setq path (org-export-latex-protect-amp path)
 		      desc (org-export-latex-protect-amp desc)))
 	      (insert (format org-export-latex-hyperref-format path desc)))
+	     ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
+	      ;; The link protocol has a function for formatting the link
+	      (insert
+		    (save-match-data
+		      (funcall fnc (org-solidify-link-text raw-path) desc 'latex))))
 	     (t (insert "\\texttt{" desc "}")))))))
 
 

[-- Attachment #3: Type: text/plain, Size: 201 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  reply	other threads:[~2010-05-12 11:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-11 10:13 Newbie: Custom link type formatting in LaTeX export? Christian Moe
2010-05-12  6:15 ` Carsten Dominik
2010-05-12 10:12   ` Christian Moe [this message]
2010-05-12 13:15     ` Carsten Dominik
2010-05-12 18:19       ` Christian Moe
2010-05-12 18:28       ` Christian Moe

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=4BEA7F22.4060207@christianmoe.com \
    --to=mail@christianmoe.com \
    --cc=Emacs-orgmode@gnu.org \
    --cc=carsten.dominik@gmail.com \
    /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).