* LaTeX export with section number, name and page in internal links
@ 2015-12-03 5:36 Ilya Filippov
0 siblings, 0 replies; 9+ messages in thread
From: Ilya Filippov @ 2015-12-03 5:36 UTC (permalink / raw
To: emacs-orgmode
I export my Org-Mode notes with internal links to LaTeX and I want it to look like this ''Section 1.1 [Section name], page 99'' (Like in the Org Manual). I use this construction:
#+BEGIN_EXAMPLE
* Chapter 1
** Section 1.1
:PROPERTIES:
:CUSTOM_ID: section-1
:END:
* Chapter 2
** Section 2.1
I want reference to Section 1.1 from here (See #section-1)
#+END_EXAMPLE
But as a result I get only the number of the section ''1.1'', not the ''Section 1.1 [Section name], page 99''.
What options I need to use?
Here (http://emacs.stackexchange.com/questions/18547/org-mode-latex-export-with-section-number-name-and-page-in-internal-links), I was advised to use a Fancyref, but I have no idea how I may use it with Org-Mode syntax.
- - - - - - - - - - -
Ilya Filippov
Yugra State University (Khanty-Mansiysk)
^ permalink raw reply [flat|nested] 9+ messages in thread
* LaTeX export with section number, name and page in internal links
@ 2015-12-03 11:08 Ilya
2015-12-03 11:31 ` John Kitchin
2015-12-08 16:48 ` Richard Lawrence
0 siblings, 2 replies; 9+ messages in thread
From: Ilya @ 2015-12-03 11:08 UTC (permalink / raw
To: emacs-orgmode
I export my Org-Mode notes with internal links to LaTeX and I want it to
look like this ''Section 1.1 [Section name], page 99'' (Like in the Org
Manual). I use this construction:
#+BEGIN_EXAMPLE
* Chapter 1
** Section 1.1
:PROPERTIES:
:CUSTOM_ID: section-1
:END:
* Chapter 2
** Section 2.1
I want reference to Section 1.1 from here (See #section-1)
#+END_EXAMPLE
But as a result I get only the number of the section ''1.1'', not the
''Section 1.1 [Section name], page 99''.
What options I need to use?
Here
(http://emacs.stackexchange.com/questions/18547/org-mode-latex-export-with-section-number-name-and-page-in-internal-links),
I was advised to use a Fancyref, but I have no idea how I may use it with
Org-Mode syntax.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: LaTeX export with section number, name and page in internal links
2015-12-03 11:08 LaTeX export with section number, name and page in internal links Ilya
@ 2015-12-03 11:31 ` John Kitchin
2015-12-03 13:30 ` Ilya Filippov
2015-12-03 14:27 ` Fwd: " Ilya Filippov
2015-12-08 16:48 ` Richard Lawrence
1 sibling, 2 replies; 9+ messages in thread
From: John Kitchin @ 2015-12-03 11:31 UTC (permalink / raw
To: Ilya; +Cc: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 1354 bytes --]
Try this.
* Chapter 1
** Section 1.1 \label{manual-section-1}
:PROPERTIES:
:CUSTOM_ID: section-1
:END:
* Chapter 2
** Section 2.1
I want reference to Section 1.1 from here (See Section
\ref{manual-section-1} on page \pageref{manual-section-1})
John
-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
On Thu, Dec 3, 2015 at 6:08 AM, Ilya <filip83pov@yandex.ru> wrote:
> I export my Org-Mode notes with internal links to LaTeX and I want it to
> look like this ''Section 1.1 [Section name], page 99'' (Like in the Org
> Manual). I use this construction:
>
> #+BEGIN_EXAMPLE
> * Chapter 1
> ** Section 1.1
> :PROPERTIES:
> :CUSTOM_ID: section-1
> :END:
> * Chapter 2
> ** Section 2.1
> I want reference to Section 1.1 from here (See #section-1)
> #+END_EXAMPLE
>
> But as a result I get only the number of the section ''1.1'', not the
> ''Section 1.1 [Section name], page 99''.
> What options I need to use?
>
> Here
> (
> http://emacs.stackexchange.com/questions/18547/org-mode-latex-export-with-section-number-name-and-page-in-internal-links
> ),
> I was advised to use a Fancyref, but I have no idea how I may use it with
> Org-Mode syntax.
>
>
>
[-- Attachment #2: Type: text/html, Size: 2344 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: LaTeX export with section number, name and page in internal links
2015-12-03 11:31 ` John Kitchin
@ 2015-12-03 13:30 ` Ilya Filippov
2015-12-08 14:19 ` Ken Mankoff
2015-12-03 14:27 ` Fwd: " Ilya Filippov
1 sibling, 1 reply; 9+ messages in thread
From: Ilya Filippov @ 2015-12-03 13:30 UTC (permalink / raw
To: John Kitchin; +Cc: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/html, Size: 3638 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Fwd: LaTeX export with section number, name and page in internal links
2015-12-03 11:31 ` John Kitchin
2015-12-03 13:30 ` Ilya Filippov
@ 2015-12-03 14:27 ` Ilya Filippov
1 sibling, 0 replies; 9+ messages in thread
From: Ilya Filippov @ 2015-12-03 14:27 UTC (permalink / raw
To: emacs-orgmode
[-- Attachment #1: Type: text/html, Size: 2998 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: LaTeX export with section number, name and page in internal links
2015-12-03 13:30 ` Ilya Filippov
@ 2015-12-08 14:19 ` Ken Mankoff
0 siblings, 0 replies; 9+ messages in thread
From: Ken Mankoff @ 2015-12-08 14:19 UTC (permalink / raw
To: Ilya Filippov; +Cc: emacs-orgmode@gnu.org, John Kitchin
> 03.12.2015, 16:31, "John Kitchin" <jkitchin@andrew.cmu.edu>:
>
> Try this.
>
> * Chapter 1
> ** Section 1.1 \label{manual-section-1}
> :PROPERTIES:
> :CUSTOM_ID: section-1
> :END:
> * Chapter 2
> ** Section 2.1
> I want reference to Section 1.1 from here (See Section \ref
> {manual-section-1} on page \pageref{manual-section-1})
This, and its limitations (what if the pageref is on the same page?) is why fancyref was created. I think the solution here is to have a
#+LATEX_HEADER: \renewcommand{\fref}{\ref}
or something like that, but I'm not sure of the exact syntax.
-k.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: LaTeX export with section number, name and page in internal links
2015-12-03 11:08 LaTeX export with section number, name and page in internal links Ilya
2015-12-03 11:31 ` John Kitchin
@ 2015-12-08 16:48 ` Richard Lawrence
2015-12-08 20:29 ` John Kitchin
1 sibling, 1 reply; 9+ messages in thread
From: Richard Lawrence @ 2015-12-08 16:48 UTC (permalink / raw
To: Ilya, emacs-orgmode
Hi Ilya,
Ilya <filip83pov@yandex.ru> writes:
> I export my Org-Mode notes with internal links to LaTeX and I want it to
> look like this ''Section 1.1 [Section name], page 99'' (Like in the Org
> Manual). I use this construction:
>
> #+BEGIN_EXAMPLE
> * Chapter 1
> ** Section 1.1
> :PROPERTIES:
> :CUSTOM_ID: section-1
> :END:
> * Chapter 2
> ** Section 2.1
> I want reference to Section 1.1 from here (See #section-1)
> #+END_EXAMPLE
>
> But as a result I get only the number of the section ''1.1'', not the
> ''Section 1.1 [Section name], page 99''.
> What options I need to use?
I do something like this with custom link types.
First of all, have a look at the variable
org-latex-prefer-user-labels
if you haven't already. Setting it will cause Org to use CUSTOM_ID
properties to generate labels, so you don't need to manually insert your
own.
I use the following bit of Elisp to define some link types for referring
to sections this way. You could modify this to insert the LaTeX command
you're interested in (as opposed to just \ref{}). With your example
above, you'd write something like
#+BEGIN_EXAMPLE
I want reference to Section 1.1 from here (See [[sec:section-1]]).
#+END_EXAMPLE
Here's the code:
#+BEGIN_SRC elisp
;; Link types for targeting sections, tables, etc.
;; These assume that headlines with CUSTOM_ID defined will export using
;; that value as their \label keys.
(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)))
; 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)))
; etc. etc.
#+END_SRC elisp
Best,
Richard
OpenPGP Key ID: CF6FA646
Fingerprint: 9969 43E1 CF6F A646
(See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: LaTeX export with section number, name and page in internal links
2015-12-08 16:48 ` Richard Lawrence
@ 2015-12-08 20:29 ` John Kitchin
2015-12-09 17:47 ` Richard Lawrence
0 siblings, 1 reply; 9+ messages in thread
From: John Kitchin @ 2015-12-08 20:29 UTC (permalink / raw
To: Richard Lawrence; +Cc: Ilya, emacs-orgmode
> I do something like this with custom link types.
Aha! I am not the only one ;)
>
> First of all, have a look at the variable
>
> org-latex-prefer-user-labels
Is this a new 8.3 variable? It doesn't seem to be in my 8.2.10 MELPA
version.
>
> if you haven't already. Setting it will cause Org to use CUSTOM_ID
> properties to generate labels, so you don't need to manually insert your
> own.
>
> I use the following bit of Elisp to define some link types for referring
> to sections this way. You could modify this to insert the LaTeX command
> you're interested in (as opposed to just \ref{}). With your example
> above, you'd write something like
I like your idea. I think you could simplify it to just:
(org-add-link-type
"sec"
(lambda (path)
(org-open-link-from-string (format "[[#%s]]" path)))
(lambda (path desc format)
(cond
((eq format 'latex)
(format "%s~\\ref{%s}" (or desc "Section") path)))))
and refer to [[sec:section-1]] that looks like this below.
** some title
:PROPERTIES:
:CUSTOM_ID: section-1
:END:
>
> #+BEGIN_EXAMPLE
> I want reference to Section 1.1 from here (See [[sec:section-1]]).
> #+END_EXAMPLE
>
> Here's the code:
> #+BEGIN_SRC elisp
> ;; Link types for targeting sections, tables, etc.
> ;; These assume that headlines with CUSTOM_ID defined will export using
> ;; that value as their \label keys.
> (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)))
>
> ; 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)))
>
> ; etc. etc.
> #+END_SRC elisp
>
> Best,
> Richard
>
> OpenPGP Key ID: CF6FA646
> Fingerprint: 9969 43E1 CF6F A646
>
> (See http://www.ocf.berkeley.edu/~rwl/encryption.html for more information.)
--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: LaTeX export with section number, name and page in internal links
2015-12-08 20:29 ` John Kitchin
@ 2015-12-09 17:47 ` Richard Lawrence
0 siblings, 0 replies; 9+ messages in thread
From: Richard Lawrence @ 2015-12-09 17:47 UTC (permalink / raw
To: John Kitchin; +Cc: Ilya, emacs-orgmode
John Kitchin <jkitchin@andrew.cmu.edu> writes:
>> I do something like this with custom link types.
> Aha! I am not the only one ;)
>
>>
>> First of all, have a look at the variable
>>
>> org-latex-prefer-user-labels
>
> Is this a new 8.3 variable? It doesn't seem to be in my 8.2.10 MELPA
> version.
Yes, I believe it is new in 8.3, although it originated in a patch I
wrote quite a while ago (February 2014?) when I needed this behavior.
> I like your idea. I think you could simplify it to just:
>
> (org-add-link-type
> "sec"
> (lambda (path)
> (org-open-link-from-string (format "[[#%s]]" path)))
> ...
Ah, nice, that is way simpler. Thanks!
Best,
Richard
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-12-09 17:47 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-03 11:08 LaTeX export with section number, name and page in internal links Ilya
2015-12-03 11:31 ` John Kitchin
2015-12-03 13:30 ` Ilya Filippov
2015-12-08 14:19 ` Ken Mankoff
2015-12-03 14:27 ` Fwd: " Ilya Filippov
2015-12-08 16:48 ` Richard Lawrence
2015-12-08 20:29 ` John Kitchin
2015-12-09 17:47 ` Richard Lawrence
-- strict thread matches above, loose matches on Subject: below --
2015-12-03 5:36 Ilya Filippov
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.