From mboxrd@z Thu Jan 1 00:00:00 1970 From: Richard Lawrence Subject: Re: Changed behaviours of LaTeX exporter in version 8.0+ Date: Thu, 18 Sep 2014 09:10:15 -0700 Message-ID: <87lhpg3o60.fsf@berkeley.edu> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUeMl-00037L-Nb for emacs-orgmode@gnu.org; Thu, 18 Sep 2014 12:15:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUeMX-0004rm-J9 for emacs-orgmode@gnu.org; Thu, 18 Sep 2014 12:15:31 -0400 Received: from plane.gmane.org ([80.91.229.3]:58296) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUeMX-0004r9-Cj for emacs-orgmode@gnu.org; Thu, 18 Sep 2014 12:15:17 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XUeJ1-0001P7-Lj for emacs-orgmode@gnu.org; Thu, 18 Sep 2014 18:11:39 +0200 Received: from c-67-169-117-151.hsd1.ca.comcast.net ([67.169.117.151]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 18 Sep 2014 18:11:39 +0200 Received: from richard.lawrence by c-67-169-117-151.hsd1.ca.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 18 Sep 2014 18:11:39 +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: emacs-orgmode@gnu.org Cc: "Kyeong Soo (Joseph) Kim" Hi Joseph, "Kyeong Soo (Joseph) Kim" writes: > Sorry for asking another question; this time it is for the > cross-referencing in LaTeX export, which existed before (e.g., Sec. 16 of > manual for <8.0) but is gone now. > ... > Now with 8.2.7c and the following org internal link to a section > > ... described in Sec. [[*SectionOne][SectionOne]] ... > > LaTeX export generates the following code: > > ... described in Sec. \texttt{SectionOne}, ... I think the problem here is that you don't have a link type, and the new LaTeX exporter doesn't convert links it doesn't understand into references. I use a series of custom link types to make references to document parts in my dissertation. Here's the code I use; you will probably want to adapt it to your use case: #+BEGIN_SRC elisp ;; use CUSTOM_ID properties to generate labels (setq org-latex-custom-id-as-label t) (defun org-find-headline-by-custom-id (prefix path) "Find a headline in the current buffer by CUSTOM_ID value PREFIX:PATH." (save-excursion (goto-char (point-min)) (and ; borrowed from org.el; there doesn't seem to be a function that searches ; for a headline with a specific property value (re-search-forward (concat "^[ \t]*:CUSTOM_ID:[ \t]+" prefix ":" path "[ \t]*$") nil t) (setq pos (match-beginning 0)))) (if pos (progn (goto-char pos) (org-back-to-heading t)) (message (format "Headline with CUSTOM_ID %s:%s not found." prefix path)))) (defun org-export-dissertation-link (prefix path desc format) "Export a link to a dissertation section, etc. In LaTeX, the exported link will look like: DESC~\\ref{PREFIX:PATH} " (when (member format '(latex linguistics)) (format "%s~\\ref{%s:%s}" desc prefix path))) ; Parts: (org-add-link-type "part" (lambda (path) (org-find-headline-by-custom-id "part" path)) (lambda (path desc format) (org-export-dissertation-link "part" path (or desc "Part") format))) ; Chapters: (org-add-link-type "chap" (lambda (path) (org-find-headline-by-custom-id "chap" path)) (lambda (path desc format) (org-export-dissertation-link "chap" path (or desc "Chapter") format))) ; Sections: (org-add-link-type "sec" (lambda (path) (org-find-headline-by-custom-id "sec" path)) (lambda (path desc format) (org-export-dissertation-link "sec" path (or desc "Section") format))) ; Tables: (org-add-link-type "tab" (lambda (path) (org-link-search (concat "tab:" path))) (lambda (path desc format) (org-export-dissertation-link "tab" path (or desc "Table") format))) #+END_SRC So a link like "[[sec:foo]]" renders as "Section~\ref{sec:foo}", "[[chap:foo]]" renders as "Chapter~\ref{chap:foo}", etc. when exported to LateX, and you can follow links to jump to the appropriate document headline. Note that this works by giving my document sections fixed labels by setting the CUSTOM_ID property. I give headlines a descriptive name in this property, using the LaTeX convention of prefixing "sec:", etc. to keep my labels straight; Org then generates \label commands for document parts using the CUSTOM_ID property. This requires setting org-latex-custom-id-as-label. For example, a headline like *** Another interesting section :PROPERTIES: :CUSTOM_ID: sec:interesting :END: is exported as \section{Another interesting section} \label{sec:interesting} (The prefixes are important, since they function both as link types and as parts of label/ref keys. As you'll notice, the org-export-dissertation-link function adds them back in to the key.) I find this setup keeps things working well across revisions, re-ordering and re-naming of sections, etc. Hope that helps! Best, Richard