emacs-orgmode@gnu.org archives
help / color / mirror / code / Atom feed
* LaTeX export: underscores and the syntax package
@ 2011-05-12 14:00 peter.frings
2011-05-14  2:51  Robert Love
From: peter.frings @ 2011-05-12 14:00 UTC (permalink / raw)
To: emacs-orgmode mailing list

Good afternoon all,

I spent the best part of the afternoon trying to figure out why an org-generated .tex file wouldn’t compile with my set-up. It turns out that the syntax’ package messes a bit with the definition of an underscore, making it impossible to use the underscore in a \label.

Unfortunately, the LaTeX exporter uses underscores in its section labels.

Actually, it is possible to have the _ in \label: use the nounderscore’ option with the syntax package. But you then do not get the tweaked underscore in plain text (unless you use \_ again).

Since I’d like to keep the syntax package and the ease of using plain underscores, I’d like to avoid the _ in labels.

Maybe I didn’t look hard enough, but I didn’t find an obvious way to change the way org generates the labels. Would it be an option to use the same label-generating code as AUCTeX mode? That would be very nice!

Thanks,
Peter.
--
c++;         // this makes c bigger but returns the old value

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

* Re: LaTeX export: underscores and the syntax package
2011-05-12 14:00 LaTeX export: underscores and the syntax package peter.frings
@ 2011-05-14  2:51  Robert Love
2011-05-14  3:12    Nick Dokos
2011-05-14  3:50    Nick Dokos
0 siblings, 2 replies; 7+ messages in thread
From: Robert Love @ 2011-05-14  2:51 UTC (permalink / raw)
To: peter.frings; +Cc: emacs-orgmode mailing list

And I find the same problem with export to HTML.  I have many variables and paths that have underscores in them.  The underscores all are shown as subscripts.   I don't want to have to go thru all my org files and escape the underscore.

How do I make the underscore be a subscript only in math mode?

On May 12, 2011, at 9:00 AM, peter.frings@agfa.com wrote:

> Good afternoon all,
>
> I spent the best part of the afternoon trying to figure out why an org-generated .tex file wouldn’t compile with my set-up. It turns out that the syntax’ package messes a bit with the definition of an underscore, making it impossible to use the underscore in a \label.
>
> Unfortunately, the LaTeX exporter uses underscores in its section labels.
>
>
> Actually, it is possible to have the _ in \label: use the nounderscore’ option with the syntax package. But you then do not get the tweaked underscore in plain text (unless you use \_ again).
>
> Since I’d like to keep the syntax package and the ease of using plain underscores, I’d like to avoid the _ in labels.
>
> Maybe I didn’t look hard enough, but I didn’t find an obvious way to change the way org generates the labels. Would it be an option to use the same label-generating code as AUCTeX mode? That would be very nice!
>
>
> Thanks,
> Peter.
> --
> c++;         // this makes c bigger but returns the old value
>
>

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

* Re: LaTeX export: underscores and the syntax package
2011-05-14  2:51  Robert Love
@ 2011-05-14  3:12    Nick Dokos
2011-05-14  3:50    Nick Dokos
1 sibling, 0 replies; 7+ messages in thread
From: Nick Dokos @ 2011-05-14  3:12 UTC (permalink / raw)
To: Robert Love; +Cc: nicholas.dokos, emacs-orgmode mailing list

Robert Love <rblove_lists@comcast.net> wrote:

> And I find the same problem with export to HTML.  I have many variables and paths that have underscores in them.  The underscores all are shown as subscripts.   I don't want to have to go thru all my org files and escape the underscore.
>
> How do I make the underscore be a subscript only in math mode?
>

Org mode knows nothing about math mode (a TeX concept only).  You can
turn off the subscript interpretation of underscores globally in the
file by using

#+OPTIONS: ^:nil

See section 12.2, "Export options", of the Org manual.

AFAIK, there is no way to make underscores be underscores in some cases
and trigger subscripts in other cases, in the same file.

Nick

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

* Re: LaTeX export: underscores and the syntax package
2011-05-14  2:51  Robert Love
2011-05-14  3:12    Nick Dokos
@ 2011-05-14  3:50    Nick Dokos
2011-05-18  7:23      Peter Frings
From: Nick Dokos @ 2011-05-14  3:50 UTC (permalink / raw)
To: Robert Love; +Cc: nicholas.dokos, emacs-orgmode mailing list

Robert Love <rblove_lists@comcast.net> wrote:

> And I find the same problem with export to HTML.  I have many variables and paths that have underscores in them.  The underscores all are shown as subscripts.   I don't want to have to go thru all my org files and escape the underscore.
>
> How do I make the underscore be a subscript only in math mode?
>
>
> On May 12, 2011, at 9:00 AM, peter.frings@agfa.com wrote:
>
> > Good afternoon all,
> >
> > I spent the best part of the afternoon trying to figure out why an org-generated .tex file wouldn’t compile with my set-up. It turns out that the syntax’ package messes a bit with the definition of an underscore, making it impossible to use the underscore in a \label.
> >
> > Unfortunately, the LaTeX exporter uses underscores in its section labels.
> >

I'm really replying to Peter here, not to Robert, but I cannot find
Peter's original mail.

You can change the underscore to e.g. a hyphen and get

,----
| \subsubsection{Experiment 1}
| \label{sec-1-1-1}
----

in the LaTeX output, by changing it in org-exp.el around line 1300 (I
don't want this to end up on patchwork, so I am trying to camouflage it
by boxquoting it - I hope that works for hiding the patch from patchwork
and also gives you enough context to make the change if you so desire):

,----
| diff --git a/lisp/org-exp.el b/lisp/org-exp.el
| index cda1f98..ac07c68 100644
| --- a/lisp/org-exp.el
| +++ b/lisp/org-exp.el
| @@ -1298,7 +1298,7 @@ Also find all ID and CUSTOM_ID properties and store them."
|  				       (org-outline-level))))
|  			(format "sec-%s" (replace-regexp-in-string
| -					  "\\." "_"
| +					  "\\." "-"
|  					  (org-section-number level)))))
|  	  (setq last-section-target target)
|  	  (push (cons target target) target-alist)
----

What I don't know is if this change will break something, either in
the LaTeX exporter or in the other exporters. So you might test it
and report any problems and if there are no problems, maybe you can
suggest it as a permanent fix. In my limited experimentation, exporting
a simple org file to latex/pdf, text and html, I did not observe any
problems, but that does not mean that they don't exist.

Nick

> >
> > Actually, it is possible to have the _ in \label: use the nounderscore’ option with the syntax package. But you then do not get the tweaked underscore in plain text (unless you use \_ again).
> >
> > Since I’d like to keep the syntax package and the ease of using plain underscores, I’d like to avoid the _ in labels.
> >
> > Maybe I didn’t look hard enough, but I didn’t find an obvious way to change the way org generates the labels. Would it be an option to use the same label-generating code as AUCTeX mode? That would be very nice!
> >
> >
> > Thanks,
> > Peter.
> > --
> > c++;         // this makes c bigger but returns the old value
> >
> >
>
>

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

* Re: LaTeX export: underscores and the syntax package
2011-05-14  3:50    Nick Dokos
@ 2011-05-18  7:23      Peter Frings
2011-05-18 16:44        Nick Dokos
2011-05-24 11:09        Carsten Dominik
0 siblings, 2 replies; 7+ messages in thread
From: Peter Frings @ 2011-05-18  7:23 UTC (permalink / raw)
To: nicholas.dokos; +Cc: emacs-orgmode mailing list

Good morning Nicholas,

Your suggested change in org-exp.el did the trick, thanks! I have not observed any side-effects, but then again, my files aren’t that complicated either, only using rather simple markup and a few floating images, no complex math or so…

I wouldn’t mind having it changed as a fix, if only to avoid clashes with the syntax package, which I use a lot. Furthermore, I personally dislike underscores: they’re ugly and harder to type than a hyphen, but since they’re generated automatically those arguments don’t stand a chance :-)

Anyway, now I know where to look I can always change it after installing a new release of org :-)

Cheers,
Peter.

On 14 May 2011, at 05:50, Nick Dokos wrote:

>> On May 12, 2011, at 9:00 AM, peter.frings@agfa.com wrote:
>>
>>> Good afternoon all,
>>>
>>> I spent the best part of the afternoon trying to figure out why an org-generated .tex file wouldn’t compile with my set-up. It turns out that the syntax’ package messes a bit with the definition of an underscore, making it impossible to use the underscore in a \label.
>>>
>>> Unfortunately, the LaTeX exporter uses underscores in its section labels.
>>>
>
> I'm really replying to Peter here, not to Robert, but I cannot find
> Peter's original mail.
>
> You can change the underscore to e.g. a hyphen and get
>
> ,----
> | \subsubsection{Experiment 1}
> | \label{sec-1-1-1}
> ----
>
> in the LaTeX output, by changing it in org-exp.el around line 1300 (I
> don't want this to end up on patchwork, so I am trying to camouflage it
> by boxquoting it - I hope that works for hiding the patch from patchwork
> and also gives you enough context to make the change if you so desire):
>
> ,----
> | diff --git a/lisp/org-exp.el b/lisp/org-exp.el
> | index cda1f98..ac07c68 100644
> | --- a/lisp/org-exp.el
> | +++ b/lisp/org-exp.el
> | @@ -1298,7 +1298,7 @@ Also find all ID and CUSTOM_ID properties and store them."
> |  				       (org-outline-level))))
> |  			(format "sec-%s" (replace-regexp-in-string
> | -					  "\\." "_"
> | +					  "\\." "-"
> |  					  (org-section-number level)))))
> |  	  (setq last-section-target target)
> |  	  (push (cons target target) target-alist)
> ----
>
> What I don't know is if this change will break something, either in
> the LaTeX exporter or in the other exporters. So you might test it
> and report any problems and if there are no problems, maybe you can
> suggest it as a permanent fix. In my limited experimentation, exporting
> a simple org file to latex/pdf, text and html, I did not observe any
> problems, but that does not mean that they don't exist.
>
> Nick

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

* Re: LaTeX export: underscores and the syntax package
2011-05-18  7:23      Peter Frings
@ 2011-05-18 16:44        Nick Dokos
2011-05-24 11:09        Carsten Dominik
1 sibling, 0 replies; 7+ messages in thread
From: Nick Dokos @ 2011-05-18 16:44 UTC (permalink / raw)
To: Peter Frings; +Cc: nicholas.dokos, emacs-orgmode mailing list

Peter Frings <peter.frings@agfa.com> wrote:

> Your suggested change in org-exp.el did the trick, thanks! I have not
> observed any side-effects, but then again, my files aren’t that
> complicated either, only using rather simple markup and a few floating
> images, no complex math or so…
>

OK, I'll submit it as a patch and we'll see if there any objections.
Thanks for checking.

> Anyway, now I know where to look I can always change it after
> installing a new release of org :-)
>

If you use git to keep up with org, then there is a fairly painless way
to maintain local changes like this. See the Org FAQ:

http://orgmode.org/worg/org-faq.html#keeping-local-changes-current-with-Org-mode-development

Nick

>
> Cheers,
> Peter.
>
>
> On 14 May 2011, at 05:50, Nick Dokos wrote:
>
> >> On May 12, 2011, at 9:00 AM, peter.frings@agfa.com wrote:
> >>
> >>> Good afternoon all,
> >>>
> >>> I spent the best part of the afternoon trying to figure out why an org-generated .tex file wouldn’t compile with my set-up. It turns out that the syntax’ package messes a bit with the definition of an underscore, making it impossible to use the underscore in a \label.
> >>>
> >>> Unfortunately, the LaTeX exporter uses underscores in its section labels.
> >>>
> >
> > I'm really replying to Peter here, not to Robert, but I cannot find
> > Peter's original mail.
> >
> > You can change the underscore to e.g. a hyphen and get
> >
> > ,----
> > | \subsubsection{Experiment 1}
> > | \label{sec-1-1-1}
> > ----
> >
> > in the LaTeX output, by changing it in org-exp.el around line 1300 (I
> > don't want this to end up on patchwork, so I am trying to camouflage it
> > by boxquoting it - I hope that works for hiding the patch from patchwork
> > and also gives you enough context to make the change if you so desire):
> >
> > ,----
> > | diff --git a/lisp/org-exp.el b/lisp/org-exp.el
> > | index cda1f98..ac07c68 100644
> > | --- a/lisp/org-exp.el
> > | +++ b/lisp/org-exp.el
> > | @@ -1298,7 +1298,7 @@ Also find all ID and CUSTOM_ID properties and store them."
> > |  				       (org-outline-level))))
> > |  	  (setq target (org-solidify-link-text
> > |  			(format "sec-%s" (replace-regexp-in-string
> > | -					  "\\." "_"
> > | +					  "\\." "-"
> > |  					  (org-section-number level)))))
> > |  	  (setq last-section-target target)
> > |  	  (push (cons target target) target-alist)
> > ----
> >
> > What I don't know is if this change will break something, either in
> > the LaTeX exporter or in the other exporters. So you might test it
> > and report any problems and if there are no problems, maybe you can
> > suggest it as a permanent fix. In my limited experimentation, exporting
> > a simple org file to latex/pdf, text and html, I did not observe any
> > problems, but that does not mean that they don't exist.
> >
> > Nick
>

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

* Re: LaTeX export: underscores and the syntax package
2011-05-18  7:23      Peter Frings
2011-05-18 16:44        Nick Dokos
@ 2011-05-24 11:09        Carsten Dominik
1 sibling, 0 replies; 7+ messages in thread
From: Carsten Dominik @ 2011-05-24 11:09 UTC (permalink / raw)
To: Peter Frings; +Cc: nicholas.dokos, emacs-orgmode mailing list

On May 18, 2011, at 9:23 AM, Peter Frings wrote:

> Good morning Nicholas,
>
> Your suggested change in org-exp.el did the trick, thanks! I have not observed any side-effects, but then again, my files aren’t that complicated either, only using rather simple markup and a few floating images, no complex math or so…
>
> I wouldn’t mind having it changed as a fix, if only to avoid clashes with the syntax package, which I use a lot. Furthermore, I personally dislike underscores: they’re ugly and harder to type than a hyphen, but since they’re generated automatically those arguments don’t stand a chance :-)
>
> Anyway, now I know where to look I can always change it after installing a new release of org :-)

Hi Peter, Nicolas,

to sections in HTML pages would become invalid.  For the rest, I don't care.

links to sections in HTML pages will use CUSTOM_ID rather than relying on section
numbers.

OK, I am applying Nicolas' patch.

- Carsten

P.S. I think it counts as a bug in the syntax package, that it makes labels with
underscore invalid.  Maybe you could investigate this and submit a bug report?

>
>
> Cheers,
> Peter.
>
>
> On 14 May 2011, at 05:50, Nick Dokos wrote:
>
>>> On May 12, 2011, at 9:00 AM, peter.frings@agfa.com wrote:
>>>
>>>> Good afternoon all,
>>>>
>>>> I spent the best part of the afternoon trying to figure out why an org-generated .tex file wouldn’t compile with my set-up. It turns out that the syntax’ package messes a bit with the definition of an underscore, making it impossible to use the underscore in a \label.
>>>>
>>>> Unfortunately, the LaTeX exporter uses underscores in its section labels.
>>>>
>>
>> I'm really replying to Peter here, not to Robert, but I cannot find
>> Peter's original mail.
>>
>> You can change the underscore to e.g. a hyphen and get
>>
>> ,----
>> | \subsubsection{Experiment 1}
>> | \label{sec-1-1-1}
>> ----
>>
>> in the LaTeX output, by changing it in org-exp.el around line 1300 (I
>> don't want this to end up on patchwork, so I am trying to camouflage it
>> by boxquoting it - I hope that works for hiding the patch from patchwork
>> and also gives you enough context to make the change if you so desire):
>>
>> ,----
>> | diff --git a/lisp/org-exp.el b/lisp/org-exp.el
>> | index cda1f98..ac07c68 100644
>> | --- a/lisp/org-exp.el
>> | +++ b/lisp/org-exp.el
>> | @@ -1298,7 +1298,7 @@ Also find all ID and CUSTOM_ID properties and store them."
>> |  				       (org-outline-level))))
>> |  			(format "sec-%s" (replace-regexp-in-string
>> | -					  "\\." "_"
>> | +					  "\\." "-"
>> |  					  (org-section-number level)))))
>> |  	  (setq last-section-target target)
>> |  	  (push (cons target target) target-alist)
>> ----
>>
>> What I don't know is if this change will break something, either in
>> the LaTeX exporter or in the other exporters. So you might test it
>> and report any problems and if there are no problems, maybe you can
>> suggest it as a permanent fix. In my limited experimentation, exporting
>> a simple org file to latex/pdf, text and html, I did not observe any
>> problems, but that does not mean that they don't exist.
>>
>> Nick
>
>

- Carsten

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

end of thread, other threads:[~2011-05-24 11:09 UTC | newest]

2011-05-12 14:00 LaTeX export: underscores and the syntax package peter.frings
2011-05-14  2:51  Robert Love
2011-05-14  3:12    Nick Dokos
2011-05-14  3:50    Nick Dokos
2011-05-18  7:23      Peter Frings
2011-05-18 16:44        Nick Dokos
2011-05-24 11:09        Carsten Dominik


Code repositories for project(s) associated with this public inbox

https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).