all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [new exporter] what is the label syntax for LaTeX export?
@ 2012-11-05 22:05 Myles English
  2012-11-05 22:18 ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Myles English @ 2012-11-05 22:05 UTC (permalink / raw)
  To: Emacs-orgmode


Hi,

If my org file has:

#+CAPTION[Here is a table]: A nice table
#+NAME: tab:niceone
| a     |

Look at my \ref{tab:niceone}.

then M-x org-export-dispatch l L gives me:

\begin{table}[htb]
\caption[Here is a table]{\label{tab-niceone}A nice table}
\begin{center}
\begin{tabular}{l}
a\\
\end{tabular}
\end{center}
\end{table}

Look at my \ref{tab:niceone}.

So, the label tab:niceone exports as \label{tab-niceone}.  Is that right
or am I using the wrong syntax somewhere?

Thanks,

Myles

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [new exporter] what is the label syntax for LaTeX export?
  2012-11-05 22:05 [new exporter] what is the label syntax for LaTeX export? Myles English
@ 2012-11-05 22:18 ` Nicolas Goaziou
  2012-11-06  7:30   ` Carsten Dominik
  2012-11-06 21:08   ` Myles English
  0 siblings, 2 replies; 8+ messages in thread
From: Nicolas Goaziou @ 2012-11-05 22:18 UTC (permalink / raw)
  To: Myles English; +Cc: Emacs-orgmode

Hello,

Myles English <mylesenglish@gmail.com> writes:

> If my org file has:
>
> #+CAPTION[Here is a table]: A nice table
> #+NAME: tab:niceone
> | a     |
>
> Look at my \ref{tab:niceone}.
>
> then M-x org-export-dispatch l L gives me:
>
> \begin{table}[htb]
> \caption[Here is a table]{\label{tab-niceone}A nice table}
> \begin{center}
> \begin{tabular}{l}
> a\\
> \end{tabular}
> \end{center}
> \end{table}
>
> Look at my \ref{tab:niceone}.
>
> So, the label tab:niceone exports as \label{tab-niceone}.  Is that right
> or am I using the wrong syntax somewhere?

The correct syntax is:

  [[tab:niceone]]

It will allow to move back and forth between the link and the target and
it will work across back-ends.

The new exporter comes with a cross-referencing system. Another example:

  1. item 1
  2. <<itm>>item 3

  As one can see in item [[itm]], ...

will be exported as "As one can see in item 2, ...".


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [new exporter] what is the label syntax for LaTeX export?
  2012-11-05 22:18 ` Nicolas Goaziou
@ 2012-11-06  7:30   ` Carsten Dominik
  2012-11-06 21:08   ` Myles English
  1 sibling, 0 replies; 8+ messages in thread
From: Carsten Dominik @ 2012-11-06  7:30 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Myles English, Emacs-orgmode


On 5 nov. 2012, at 23:18, Nicolas Goaziou <n.goaziou@gmail.com> wrote:

> Hello,
> 
> Myles English <mylesenglish@gmail.com> writes:
> 
>> If my org file has:
>> 
>> #+CAPTION[Here is a table]: A nice table
>> #+NAME: tab:niceone
>> | a     |
>> 
>> Look at my \ref{tab:niceone}.
>> 
>> then M-x org-export-dispatch l L gives me:
>> 
>> \begin{table}[htb]
>> \caption[Here is a table]{\label{tab-niceone}A nice table}
>> \begin{center}
>> \begin{tabular}{l}
>> a\\
>> \end{tabular}
>> \end{center}
>> \end{table}
>> 
>> Look at my \ref{tab:niceone}.
>> 
>> So, the label tab:niceone exports as \label{tab-niceone}.  Is that right
>> or am I using the wrong syntax somewhere?
> 
> The correct syntax is:
> 
>  [[tab:niceone]]
> 
> It will allow to move back and forth between the link and the target and
> it will work across back-ends.
> 
> The new exporter comes with a cross-referencing system. Another example:
> 
>  1. item 1
>  2. <<itm>>item 3
> 
>  As one can see in item [[itm]], ...
> 
> will be exported as "As one can see in item 2, ...".
> 

I had not fully realized this, this is great Nicolas!

- Carsten

> 
> Regards,
> 
> -- 
> Nicolas Goaziou
> 

- Carsten

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [new exporter] what is the label syntax for LaTeX export?
  2012-11-05 22:18 ` Nicolas Goaziou
  2012-11-06  7:30   ` Carsten Dominik
@ 2012-11-06 21:08   ` Myles English
  2012-11-07  9:24     ` Nicolas Goaziou
  1 sibling, 1 reply; 8+ messages in thread
From: Myles English @ 2012-11-06 21:08 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Emacs-orgmode


Hi Nicolas,


Nicolas Goaziou writes:

> Myles English <mylesenglish@gmail.com> writes:
>
[..]
>> So, the label tab:niceone exports as \label{tab-niceone}.  Is that right
>> or am I using the wrong syntax somewhere?
>
> The correct syntax is:
>
>   [[tab:niceone]]
>
> It will allow to move back and forth between the link and the target and
> it will work across back-ends.

Thanks for correcting me.

One problem I am having is that the exported LaTeX replaces the ":" with
a "-" to become \ref{tab-niceone} which precludes the use of (e.g.)
\autoref which would need to know that the thing being referenced was a
table by recognising the "tab:", no?  I am sure there is a good reason
for this, can you say why?  In the meantime I will investigate filters.
I only really use \autoref out of laziness anyway so I could just
replace the ":" in all my currently defined labels.

> The new exporter comes with a cross-referencing system. Another example:
>
>   1. item 1
>   2. <<itm>>item 3
>
>   As one can see in item [[itm]], ...
>
> will be exported as "As one can see in item 2, ...".

That will definately be useful.

Thanks,

Myles

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [new exporter] what is the label syntax for LaTeX export?
  2012-11-06 21:08   ` Myles English
@ 2012-11-07  9:24     ` Nicolas Goaziou
  2012-11-07 22:46       ` Myles English
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2012-11-07  9:24 UTC (permalink / raw)
  To: Myles English; +Cc: Emacs-orgmode

> One problem I am having is that the exported LaTeX replaces the ":" with
> a "-" to become \ref{tab-niceone} which precludes the use of (e.g.)
> \autoref which would need to know that the thing being referenced was a
> table by recognising the "tab:", no?  I am sure there is a good reason
> for this, can you say why?

This is due to one of the few functions that was brought from the old
exporter: `org-export-solidify-link-text'.

That's because targets (that is <<...>> or #+NAME: ...) have no
limitation on the characters allowed in their value, which can lead to
problems when translated into foreign code (i.e. an % sign in the target
when using the latex back-end).

So, the function replaces forbidden characters with hyphens.

Besides using filters, a solution might be either:

1. to remove colons from the forbidden characters.
2. to limit the characters allowed in targets and remove
   `org-export-solidify-link-text' altogether.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [new exporter] what is the label syntax for LaTeX export?
  2012-11-07  9:24     ` Nicolas Goaziou
@ 2012-11-07 22:46       ` Myles English
  2012-11-07 23:39         ` Nicolas Goaziou
  0 siblings, 1 reply; 8+ messages in thread
From: Myles English @ 2012-11-07 22:46 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Emacs-orgmode


Nicolas Goaziou writes:

>> One problem I am having is that the exported LaTeX replaces the ":" with
>> a "-" to become \ref{tab-niceone} which precludes the use of (e.g.)
>> \autoref which would need to know that the thing being referenced was a
>> table by recognising the "tab:", no?  I am sure there is a good reason
>> for this, can you say why?
>
> This is due to one of the few functions that was brought from the old
> exporter: `org-export-solidify-link-text'.
>
> That's because targets (that is <<...>> or #+NAME: ...) have no
> limitation on the characters allowed in their value, which can lead to
> problems when translated into foreign code (i.e. an % sign in the target
> when using the latex back-end).

Thanks for the explanation.

> So, the function replaces forbidden characters with hyphens.
>
> Besides using filters, a solution might be either:

(I haven't actually made any progress on a solution using filters.  I
was expecting it to be a little convoluted though; splitting on the
first hyphen and joining on a colon.)

Not sure if you are showing me two options you are thinking of
implementing here or suggesting two things I can do myself:

> 1. to remove colons from the forbidden characters.

If no backends would mind dealing with a colon (I don't know them well
enough to be able to decide) then this would be preferable.

> 2. to limit the characters allowed in targets and remove
>    `org-export-solidify-link-text' altogether.

This option could restrict future backends, or other (future?) latex
packages.

The first option seems most appropriate because a character should only
be restricted if there is a good reason (e.g. a backend would not like
it) rather than forbidding every character and only allowing it if there
is a good reason to.

As to whether my use case is a good reason to allow colons: I have no
idea how many people use the \autoref or \nameref thing.

>
>
> Regards,

Myles

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [new exporter] what is the label syntax for LaTeX export?
  2012-11-07 22:46       ` Myles English
@ 2012-11-07 23:39         ` Nicolas Goaziou
  2012-11-08  3:27           ` Myles English
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Goaziou @ 2012-11-07 23:39 UTC (permalink / raw)
  To: Myles English; +Cc: Emacs-orgmode

Colons are now allowed in targets.

Thanks for submitting the suggestion.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [new exporter] what is the label syntax for LaTeX export?
  2012-11-07 23:39         ` Nicolas Goaziou
@ 2012-11-08  3:27           ` Myles English
  0 siblings, 0 replies; 8+ messages in thread
From: Myles English @ 2012-11-08  3:27 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Emacs-orgmode


Nicolas Goaziou writes:

> Colons are now allowed in targets.
>
> Thanks for submitting the suggestion.

Thanks a lot Nicolas.

In case anyone else finds this useful, here is the filter I'll use to replace \ref
with \autoref:

  (defun my-autoref-filter-link-func (output backend info)
    (when (and (memq backend '(e-latex))
               (string-match
                "\\\\ref\{\\(.*\\)\}"
                output))
        (replace-match (concat "\\\\autoref{" (match-string 1 output) "}") nil nil output)))
  
  (add-to-list 'org-export-filter-link-functions
               'my-autoref-filter-link-func)
  

Myles

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-11-08  3:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-05 22:05 [new exporter] what is the label syntax for LaTeX export? Myles English
2012-11-05 22:18 ` Nicolas Goaziou
2012-11-06  7:30   ` Carsten Dominik
2012-11-06 21:08   ` Myles English
2012-11-07  9:24     ` Nicolas Goaziou
2012-11-07 22:46       ` Myles English
2012-11-07 23:39         ` Nicolas Goaziou
2012-11-08  3:27           ` Myles English

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.