emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] LaTeX export: underscores and the syntax package


From: Nick Dokos
Subject: Re: [O] LaTeX export: underscores and the syntax package
Date: Fri, 13 May 2011 23:50:57 -0400

Robert Love <address@hidden> 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, address@hidden 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

> > 
> > 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
> > 
> > 
> 
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]