From: Lawrence Mitchell <wence@gmx.li>
To: emacs-orgmode@gnu.org
Cc: Lawrence Mitchell <wence@gmx.li>
Subject: [PATCH 2/2] Allow option of using bare \ref links in LaTeX export
Date: Thu, 20 Jan 2011 13:23:23 +0000 [thread overview]
Message-ID: <ea1bc5f1b2b482e7e4dbe3136fb04254f7285191.1295529378.git.wence@gmx.li> (raw)
In-Reply-To: <cover.1295529378.git.wence@gmx.li>
In-Reply-To: <cover.1295529378.git.wence@gmx.li>
* lisp/org-latex.el (org-export-latex-unprettify-internal-links): New
variable.
(org-export-latex-links): Use it.
* org-mode/lisp/org-exp.el (org-export-plist-vars): Add
:LaTeX-bare-refs settable through the bare-ref option with default
given by `org-export-latex-unprettify-internal-links'.
(org-get-current-options): Deal with :LaTeX-bare-refs.
* org-mode/doc/org.texi (Export options, Header and sectioning):
Document `org-export-latex-unprettify-internal-links' and associated
option.
If org-export-latex-unprettify-internal-links is non-nil, then links
with an auto-generated raw-path (for example "sec-1_2_10") will be
exported to LaTeX as bare references with \ref{raw-path} rather than
textually with \hyperref[raw-path]{desc}.
This means you can write "As seen in section [[some section heading]]"
and have it exported to "As seen in section \ref{sec-number}".
---
doc/org.texi | 37 +++++++++++++++++++++++++++++++++++++
lisp/org-exp.el | 4 +++-
lisp/org-latex.el | 25 +++++++++++++++++++++----
3 files changed, 61 insertions(+), 5 deletions(-)
diff --git a/doc/org.texi b/doc/org.texi
index d37e3a2..8ad5029 100644
--- a/doc/org.texi
+++ b/doc/org.texi
@@ -9348,6 +9348,7 @@ settings. Here you can:
@cindex emphasized text
@cindex @TeX{} macros
@cindex @LaTeX{} fragments
+@cindex section labels, for LaTeX
@cindex author info, in export
@cindex time info, in export
@example
@@ -9370,6 +9371,7 @@ tags: @r{turn on/off inclusion of tags, may also be @code{not-in-toc}}
*: @r{turn on/off emphasized text (bold, italic, underlined)}
TeX: @r{turn on/off simple @TeX{} macros in plain text}
LaTeX: @r{configure export of @LaTeX{} fragments. Default @code{auto}}
+bare-ref: @r{turn on/off bare references in @TeX{} and @LaTeX{} export}
skip: @r{turn on/off skipping the text before the first heading}
author: @r{turn on/off inclusion of author name/email into exported file}
email: @r{turn on/off inclusion of author email into exported file}
@@ -9969,6 +9971,41 @@ can also use @code{#+LATEX_HEADER: \usepackage@{xyz@}} to add lines to the
header. See the docstring of @code{org-export-latex-classes} for more
information.
+By default, internal links in an Org document are exported and linked with
+@samp{\hyperref} in @LaTeX{}. If you would like bare references to headlines
+to be referred as plain references (by number with @samp{\ref}) then set the
+variable @code{org-export-latex-unprettify-internal-links} to @code{t}. As
+an example consider the following document
+
+@cindex org-export-latex-unprettify-internal-links
+@cindex section labels, for LaTeX
+@example
+* A header
+Here is some text referring to [[A header]]
+@end example
+
+When @code{org-export-latex-unprettify-internal-links} is @code{nil} (the
+default), this is exported as
+
+@example
+\section@{A header@}
+\label@{sec-1@}
+
+Here is some text referring to \hyperref[sec-1]@{A header@}
+@end example
+
+When @code{org-export-latex-unprettify-internal-links} is @code{t}, the
+export is
+@example
+\section@{A header@}
+\label@{sec-1@}
+
+Here is some text referring to \ref@{sec-1@}
+@end example
+
+This setting can also be set in the OPTIONS line through the @code{bare-ref}
+option (see @ref{Export options}).
+
@node Quoting LaTeX code, Tables in LaTeX export, Header and sectioning, LaTeX and PDF export
@subsection Quoting @LaTeX{} code
diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index d099c82..64b6671 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -606,6 +606,7 @@ table.el tables."
(:priority "pri" org-export-with-priority)
(:TeX-macros "TeX" org-export-with-TeX-macros)
(:LaTeX-fragments "LaTeX" org-export-with-LaTeX-fragments)
+ (:LaTeX-bare-refs "bare-ref" org-export-latex-unprettify-internal-links)
(:latex-listings nil org-export-latex-listings)
(:skip-before-1st-heading "skip" org-export-skip-text-before-1st-heading)
(:fixed-width ":" org-export-with-fixed-width)
@@ -2789,7 +2790,7 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
#+KEYWORDS:
#+LANGUAGE: %s
#+OPTIONS: H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s -:%s f:%s *:%s <:%s
-#+OPTIONS: TeX:%s LaTeX:%s skip:%s d:%s todo:%s pri:%s tags:%s
+#+OPTIONS: TeX:%s LaTeX:%s bare-ref:%s skip:%s d:%s todo:%s pri:%s tags:%s
%s
#+EXPORT_SELECT_TAGS: %s
#+EXPORT_EXCLUDE_TAGS: %s
@@ -2824,6 +2825,7 @@ Does include HTML export options as well as TODO and CATEGORY stuff."
org-export-with-timestamps
org-export-with-TeX-macros
org-export-with-LaTeX-fragments
+ org-export-latex-unprettify-internal-links
org-export-skip-text-before-1st-heading
org-export-with-drawers
org-export-with-todo-keywords
diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index ecaf1c0..b3829da 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -309,6 +309,18 @@ the link, the second with the link description."
:group 'org-export-latex
:type 'string)
+(defcustom org-export-latex-unprettify-internal-links nil
+ "If non-nil, turn internal section links [[some heading]] into \\ref{sec}.
+
+This allows us to write \"See section [[some section]]\" and have it
+formatted as \"See section \\ref{sec-number}\" in LaTeX. If this
+variable is nil, the references are formatted as hyperref links (see
+`org-export-latex-hyperref-format').
+
+This option can also be set with the +OPTIONS line, e.g. \"bare-ref:t\"."
+ :group 'org-export-latex
+ :type 'boolean)
+
(defcustom org-export-latex-tables-verbatim nil
"When non-nil, tables are exported verbatim."
:group 'org-export-latex
@@ -2066,10 +2078,15 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
(radiop (insert (format org-export-latex-hyperref-format
(org-solidify-link-text raw-path) desc)))
((not type)
- (insert (format org-export-latex-hyperref-format
- (org-remove-initial-hash
- (org-solidify-link-text raw-path))
- desc)))
+ (if (and (plist-get org-export-latex-options-plist :LaTeX-bare-refs)
+ ;; this is an auto-generated raw-path
+ (string-match "\\`sec-[0-9]+\\(?:_[0-9]+\\)*\\'"
+ raw-path))
+ (insert (format "\\ref{%s}" raw-path))
+ (insert (format org-export-latex-hyperref-format
+ (org-remove-initial-hash
+ (org-solidify-link-text raw-path))
+ desc))))
(path
(when (org-at-table-p)
;; There is a strange problem when we have a link in a table,
--
1.7.4.rc1.7.g2cf08
next prev parent reply other threads:[~2011-01-20 13:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-20 13:23 [PATCH 0/2] References auto-generated labels with \ref in LaTeX export Lawrence Mitchell
2011-01-20 13:23 ` [PATCH 1/2] Only match complete words in org-export-add-options-to-plist Lawrence Mitchell
2011-02-12 23:49 ` [Accepted] [Orgmode, " Bastien Guerry
2011-01-20 13:23 ` Lawrence Mitchell [this message]
2011-02-12 23:46 ` [PATCH 0/2] References auto-generated labels with \ref in LaTeX export Bastien
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ea1bc5f1b2b482e7e4dbe3136fb04254f7285191.1295529378.git.wence@gmx.li \
--to=wence@gmx.li \
--cc=emacs-orgmode@gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.