Re: [O] LaTeX export with section number, name and page in internal links
John Kitchinwrites: >> 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
Re: [O] LaTeX export with section number, name and page in internal links
> 03.12.2015, 16:31, "John Kitchin": > > 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.
Re: [O] LaTeX export with section number, name and page in internal links
Hi Ilya, Ilyawrites: > 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.)
Re: [O] LaTeX export with section number, name and page in internal links
> 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
Re: [O] LaTeX export with section number, name and page in internal links
Thank you, it is work, but I hope to use something like (setq org-export-latex-hyperref-format "\\ref{%s}") for hyperref customization. (I want join \\ref{%s} and \\pageref{%s} for org-export-latex-hyperref-format). If it will be work we may simple use [[#section-1]] to different templates for internal references, also like ''Section 1.1 [Section name], page 99''.03.12.2015, 16:31, "John Kitchin":Try this.* Chapter 1** Section 1.1 \label{manual-section-1} :PROPERTIES: :CUSTOM_ID: section-1 :END:* Chapter 2** Section 2.1I 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 A207FDepartment of Chemical EngineeringCarnegie Mellon UniversityPittsburgh, PA 15213412-268-7803@johnkitchinhttp://kitchingroup.cheme.cmu.edu On Thu, Dec 3, 2015 at 6:08 AM, Ilya 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. - - - - - - - - - - -Ilya FilippovYugra State University (Chekhova str. 16, Khanty-Mansiysk, Tyumen' Region, Russian Federation, 628012): 1. Environmental Dynamics & Global Climate Change Research Centre, Senior Engineer2. Biology Chair, Docent3. Journal of Environmental Dynamics & Global Climate Change, Editorial Board MemberGoogleScholar profile: http://scholar.google.ru/citations?user=Prc5qkMJ Tel: +79088817605
Re: [O] LaTeX export with section number, name and page in internal links
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, Ilyawrote: > 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. > > >