From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: how to handle backend-specific types as fuzzy link targets during export Date: Tue, 24 Jun 2014 09:30:42 -0400 Message-ID: <87mwd2cu4d.fsf@gmail.com> References: <87pphyefo6.fsf@gmail.com> <87ha3aldw3.fsf@nicolasgoaziou.fr> <87d2dyeaqd.fsf@gmail.com> <87d2dylak0.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzQop-0000wG-Gd for emacs-orgmode@gnu.org; Tue, 24 Jun 2014 09:31:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WzQok-0003lT-MP for emacs-orgmode@gnu.org; Tue, 24 Jun 2014 09:31:27 -0400 Received: from mail-qc0-x229.google.com ([2607:f8b0:400d:c01::229]:33345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzQok-0003lP-G4 for emacs-orgmode@gnu.org; Tue, 24 Jun 2014 09:31:22 -0400 Received: by mail-qc0-f169.google.com with SMTP id c9so262164qcz.14 for ; Tue, 24 Jun 2014 06:31:22 -0700 (PDT) Received: from bagel (pool-74-111-105-28.pitbpa.fios.verizon.net. [74.111.105.28]) by mx.google.com with ESMTPSA id i31sm173255qgf.41.2014.06.24.06.31.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jun 2014 06:31:20 -0700 (PDT) In-Reply-To: <87d2dylak0.fsf@nicolasgoaziou.fr> (Nicolas Goaziou's message of "Tue, 24 Jun 2014 15:08:31 +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: Org Mode Mailing List --=-=-= Content-Type: text/plain Nicolas Goaziou writes: > Eric Schulte writes: > >> Sure. I have added a function to org-export-filter-parse-tree-functions >> which replaces a custom keyword with either a latex-fragment or an HTML >> link wrapped in a paragraph depending on the export backend. The latex >> fragment basically has the following content, >> >> "\\begin{figure} >> \\centering >> \\input{%s} >> \\caption[%s]{\\label{%s}%s} >> \\end{figure}\n\n" >> >> and I assign it a :name property to match the label in the above. I >> then have links elsewhere in the file which reference this label. > > I still do not get it. Could you show your (possibly simplified) filter > function? > Attached --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=tikz-figure-keywords.el Content-Transfer-Encoding: quoted-printable (defun org-export-tikz-figure (tree backend info) "Convert included TIKZ files into figures for HTML and LaTeX." (org-element-map tree 'keyword (lambda (object) (when (equal (org-element-property :key object) "TIKZ_FIGURE") (org-element-insert-before (cond ;; for latex just \input the file ((org-export-derived-backend-p backend 'latex) (list 'latex-fragment (list :value (format "\\begin{figure} \\centering \\input{%s} \\caption[%s]{\\label{%s}%s} \\end{figure}\n\n" (org-element-property :value object) (car (org-export-get-caption object t= )) (org-element-property :name object) (car (org-export-get-caption object))) :name (org-element-property :name object) :post-blank (org-element-property :post-blank object= )))) ((org-export-derived-backend-p backend 'html) (list 'paragraph (list :name (org-element-property :name object) :caption (org-element-property :caption object) :begin (org-element-property :begin object)) (list 'link (list :type "file" :path (let ((base (org-element-property :value objec= t))) (cond ((file-exists-p (concat base ".svg")) (concat base ".svg")) ((file-exists-p (concat base ".png")) (concat base ".png")) (:otherwise (warn "no file exists for %s" base) base))) :post-blank (org-element-property :post-blank = object)))))) object) (org-element-extract-element object)))) tree) (add-hook 'org-export-filter-parse-tree-functions 'org-export-tikz-figure) --=-=-= Content-Type: text/plain > > Also, what code do you want ox-latex to generate? > So something like the following #+name: technique-overview #+Caption[Overview of Technique]: Text. #+TIKZ_FIGURE: technique-overview Lorem ipsum dolor sit amet Figure [[technique-overview]] posuere. results in something like the following for latex export \begin{figure} \centering \input{technique-overview} \caption[Overview of Technique]{\label{technique-overview}Text.} \end{figure} Lorem ipsum dolor sit amet Figure \ref{technique-overview} posuere. Thanks, Eric > > Note that #+NAME is internal Org syntax. It cannot possibly be > compatible with random raw LaTeX code. IOW, even if you can write raw > LaTeX in an Org buffer, it doesn't mean that Org will understand the > LaTeX code you wrote. > > > Regards, -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D (see https://u.fsf.org/yw) --=-=-=--