Re: [O] LaTeX-export: letters after $..$ turn off math-mode

2013-02-16 Thread Nicolas Goaziou
Completing myself,

 IMO, I would call that an Org limitation. Org is not LaTeX, even if it
 provides many LaTeX facilities. Also, the OP's problem can be solved in
 many ways under Emacs. For example, I use mt (both m and t are on
 my home row) as a snippet to insert \(\) in an Org buffer and put
 point inside.

I would even go further. The following text has been in documentation
for years:

   * Text within the usual LaTeX math delimiters.  To avoid conflicts
 with currency specifications, single `$' characters are only
 recognized as math delimiters if the enclosed text contains at
 most two line breaks, is directly attached to the `$' characters
 with no whitespace in between, and if the closing `$' is followed
 by whitespace, punctuation or a dash.  For the other delimiters,
 there is no such restriction, so when in doubt, use `\(...\)' as
 inline math delimiters.

and so has been this excerpt from `org-inside-LaTeX-fragment-p'
docstring:

   Even though the matchers for math are configurable, this function assumes
   that \\begin, \\(, \\[, and $$ are always used.  Only the single dollar
   delimiters are skipped when they have been removed by customization.

   This function does a reasonably good job, but can locally be fooled by
   for example currency specifications.  For example it will assume being in
   inline math after \$22.34\.  The LaTeX fragment formatter will only format
   fragments that are properly closed, but during editing, we have to live
   with the uncertainty caused by missing closing delimiters.

We cannot afford two maintain two implementations, one of them being
frail, of the _same concept_. It's way better to focus on one of them,
and make sure it is solid. It also means a slightly lighter Org, and
less code to debug, which is always good.

Thus, I suggest to announce that $ (both $ and $$, even though $$ don't
have problems /per se/) symbols for should be avoided. Then, in a year
or so, we can remove them completely from code base.


Regards,

-- 
Nicolas Goaziou



Re: [O] LaTeX-export: letters after $..$ turn off math-mode

2013-02-16 Thread Bastien
Hi Nicolas,

Nicolas Goaziou n.goaz...@gmail.com writes:

 IMO, I would call that an Org limitation. 

I'm fine with the current limitation -- if that's just one email
per year, I think we can handle this :)

FWIW I'm not in favor of removing the ability to inline $x^2$
and to deprecate the use of $ completely.  If this flexibility
is not too problematic (from a maintainance point of view), I'd
say it's fine to keep it.

Thanks,

-- 
 Bastien



Re: [O] LaTeX-export: letters after $..$ turn off math-mode

2013-02-16 Thread Rasmus
Bastien b...@altern.org writes:

 FWIW I'm not in favor of removing the ability to inline $x^2$
 and to deprecate the use of $ completely.  If this flexibility
 is not too problematic (from a maintainance point of view), I'd
 say it's fine to keep it.

While I agree that \(·\) is the preferred and Rightᵀᴹ delimiter pair I
almost always use $·$ in place if I can get away with it.  Thus, if
the maintenance cost is low I would prefer if it stayed.

Using the patch posted by Nicolas last week (i.e. (re)introducing
org-highlight-latex-and-special) there's even visual feedback as to
when Org will correctly identify $·$.

/If/ a mechanism existed to easily use \(·\) I would be all for
ditching $·$ as it clearly inferior (legacy documents can quickly be
fixed via a regexp replacement, if needed).  For instance, in ESS
there is ess-smart-underscore where, depending on the context,
pressing _ will usually do the right thing.  For Instance $ could
insert \(·\) or $ first (depending on the variable
org-export-care-about-usd).  On region it would always put it inside
\(·\).  But it might be messy, I'm not really sure. 

–Rasmus

-- 
C is for Cookie




Re: [O] LaTeX-export: letters after $..$ turn off math-mode

2013-02-16 Thread Nick Dokos
Nicolas Goaziou n.goaz...@gmail.com wrote:

 ...
 Thus, I suggest to announce that $ (both $ and $$, even though $$ don't
 have problems /per se/) symbols for should be avoided. Then, in a year
 or so, we can remove them completely from code base.
 

Agree. Also $$ may not cause problems to org, but according to Lamport
(see p. 233 of Lamport (2nd ed)) it does not work properly in LaTeX.

Nick






Re: [O] LaTeX-export: letters after $..$ turn off math-mode

2013-02-16 Thread Nick Dokos
Nick Dokos nicholas.do...@hp.com wrote:

 Nicolas Goaziou n.goaz...@gmail.com wrote:
 
  ...
  Thus, I suggest to announce that $ (both $ and $$, even though $$ don't
  have problems /per se/) symbols for should be avoided. Then, in a year
  or so, we can remove them completely from code base.
  
 
 Agree. Also $$...$$ may not cause problems to org, but according to Lamport
 (see p. 233 of Lamport (2nd ed)) it does not work properly in LaTeX.
 

See also

http://www.tex.ac.uk/cgi-bin/texfaq2html?label=dolldoll

for some details.

Nick



Re: [O] LaTeX-export: letters after $..$ turn off math-mode

2013-02-15 Thread Bastien
Hi Greg,

Greg Minshall minsh...@umich.edu writes:

 i'd like to plead the case of allowing the user to suppress dollar-sign
 behavior (or, force dollar-signs to mean math-mode).

I'm attaching a patch that introduces `org-latex-escape-chars' which
would allow you to bind it to something different for each buffer --
e.g., without the dollar sign.

Nicolas, let me know if this looks okay for you.

Thanks,

diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 9d5b5c5..805eeb7 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -510,6 +510,14 @@ default we use here encompasses both.
   :group 'org-export-latex
   :type 'string)
 
+(defcustom org-latex-escape-chars %$#{}~^_
+  Characters to escape.
+Each character in this string will be escaped.
+E.g., _ will be escaped into \_.
+  :group 'org-export-latex
+  :version 24.3
+  :type 'string)
+
 
  Tables
 
@@ -1942,8 +1950,11 @@ TEXT is the string to transcode.  INFO is a plist holding
 contextual information.
   (let ((specialp (plist-get info :with-special-strings))
 	(output text))
-;; Protect %, #, , $, ~, ^, _,  { and }.
-(while (string-match \\([^\\]\\|^\\)\\([%$#{}~^_]\\) output)
+;; Protect characters from `org-latex-escape-chars', i.e.,
+;; %, #, , $, ~, ^, _, { and } by default.
+(while (string-match
+	(concat \\([^\\]\\|^\\)\\([ org-latex-escape-chars ]\\))
+	output)
   (setq output
 	(replace-match
 	 (format \\%s (match-string 2 output)) nil t output 2)))

-- 
 Bastien


Re: [O] LaTeX-export: letters after $..$ turn off math-mode

2013-02-15 Thread Nicolas Goaziou
Hello,

Bastien b...@altern.org writes:

 Greg Minshall minsh...@umich.edu writes:

 i'd like to plead the case of allowing the user to suppress dollar-sign
 behavior (or, force dollar-signs to mean math-mode).

 I'm attaching a patch that introduces `org-latex-escape-chars' which
 would allow you to bind it to something different for each buffer --
 e.g., without the dollar sign.

 Nicolas, let me know if this looks okay for you.

I think this solution is not appropriate.

Even if you patch latex back-end, the rest of Org still doesn't
recognize the construct as a math snippet. So, this would be a mere
hack.

A correct solution would be to modify `org-latex-regexps' so math
snippets can be followed by a letter. But you may find yourself opening
a can of worm. Getting there regexps right is difficult, as can probably
testify Carsten.

IMO, I would call that an Org limitation. Org is not LaTeX, even if it
provides many LaTeX facilities. Also, the OP's problem can be solved in
many ways under Emacs. For example, I use mt (both m and t are on
my home row) as a snippet to insert \(\) in an Org buffer and put
point inside.


Regards,

-- 
Nicolas Goaziou



Re: [O] LaTeX-export: letters after $..$ turn off math-mode

2013-02-04 Thread Greg Minshall
hi.  this was on the list a year ago (see below).

i'd like to plead the case of allowing the user to suppress dollar-sign
behavior (or, force dollar-signs to mean math-mode).

the main reason is convenience: when trying to quickly write up
thoughts, typing $ a = b^2 $ is just that much more convenient/easier
than typing \( a = b^2 \).  (maybe because the former uses half the
number of off-home-row keys?  maybe just because my fingers are
programmed to do this?)

second, (this is rhetoric) why privilege the dollar currency?  third
(more rhetoric), there are certainly many communities that believe that
$..$ is equivalent to \(..\), so new users will continually show up thus
programmed.

so, if there were a way of disabling the current dollar sign processing,
that would be great!

cheers, Greg

http://lists.gnu.org/archive/html/emacs-orgmode/2012-02/msg00269.html

 Daniel Schoepe address@hidden writes:
 I have the following issue: If I write something like `$n$th' in an
 org file and then export it to LaTeX, it will produce `\$n\$th',
 whereas I would like it to export this as `$n$th'. Is there some way
 I can disable escaping of dollar signs entirely (Leaving it to me to
 escape them, when I don't use them as math-mode delimiters)?

 Using proper LaTeX math delimiters instead of that TeXism works
 nicely: \(n\)th (the other TeXism, $n${}th also doesn't work).  In an
 UTF-8 document, a zero-width space would probably work too, but that's
 devious.

 HTH,
 Achim.



[O] LaTeX-export: letters after $..$ turn off math-mode

2012-02-06 Thread Daniel Schoepe
Hi,

I have the following issue: If I write something like `$n$th' in an org
file and then export it to LaTeX, it will produce `\$n\$th', whereas I
would like it to export this as `$n$th'. Is there some way I can disable
escaping of dollar signs entirely (Leaving it to me to escape them, when
I don't use them as math-mode delimiters)?

I did not find any option to that end in the documentation, but it's of
course possible that I just overlooked it.

Cheers,
Daniel



pgpn8BUV09jkx.pgp
Description: PGP signature


Re: [O] LaTeX-export: letters after $..$ turn off math-mode

2012-02-06 Thread Achim Gratz
Daniel Schoepe dan...@schoepe.org writes:
 I have the following issue: If I write something like `$n$th' in an org
 file and then export it to LaTeX, it will produce `\$n\$th', whereas I
 would like it to export this as `$n$th'. Is there some way I can disable
 escaping of dollar signs entirely (Leaving it to me to escape them, when
 I don't use them as math-mode delimiters)?

Using proper LaTeX math delimiters instead of that TeXism works nicely:
\(n\)th (the other TeXism, $n${}th also doesn't work).  In an UTF-8
document, a zero-width space would probably work too, but that's
devious.


HTH,
Achim.
-- 
+[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]+

Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds