From mboxrd@z Thu Jan  1 00:00:00 1970
From: Richard Lawrence <richard.lawrence@berkeley.edu>
Subject: Re: Avoid escaping braces in LaTeX export?
Date: Sat, 08 Jun 2013 10:45:58 -0700
Message-ID: <87a9n0h4x5.fsf@berkeley.edu>
References: <87bo7hkf20.fsf@berkeley.edu>
	<20130607204548.6fabee8f@aga-netbook> <87r4gdehmp.fsf@berkeley.edu>
	<877gi4n009.fsf@ucl.ac.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Return-path: <emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org>
Received: from eggs.gnu.org ([2001:4830:134:3::10]:48080)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geo-emacs-orgmode@m.gmane.org>) id 1UlNLA-0001Hg-Nr
	for emacs-orgmode@gnu.org; Sat, 08 Jun 2013 13:54:13 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <geo-emacs-orgmode@m.gmane.org>) id 1UlNL9-0000zC-K1
	for emacs-orgmode@gnu.org; Sat, 08 Jun 2013 13:54:12 -0400
Received: from plane.gmane.org ([80.91.229.3]:41411)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <geo-emacs-orgmode@m.gmane.org>) id 1UlNL9-0000z3-Dk
	for emacs-orgmode@gnu.org; Sat, 08 Jun 2013 13:54:11 -0400
Received: from list by plane.gmane.org with local (Exim 4.69)
	(envelope-from <geo-emacs-orgmode@m.gmane.org>) id 1UlNL8-0000PN-BF
	for emacs-orgmode@gnu.org; Sat, 08 Jun 2013 19:54:10 +0200
Received: from c-50-161-39-52.hsd1.ca.comcast.net ([50.161.39.52])
	by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
	id 1AlnuQ-0007hv-00
	for <emacs-orgmode@gnu.org>; Sat, 08 Jun 2013 19:54:10 +0200
Received: from richard.lawrence by c-50-161-39-52.hsd1.ca.comcast.net with
	local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00
	for <emacs-orgmode@gnu.org>; Sat, 08 Jun 2013 19:54:10 +0200
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
	<mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org
Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org
To: emacs-orgmode@gnu.org

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Richard Lawrence <richard.lawrence@berkeley.edu> writes:
> Org is not latex, for better or for worse.  However, it does allow you
> to mix the two in various ways.  The inline approach is limited to
> {text} that is on the same line.  You could try using visual-line-mode
> and have all paragraphs be single lines.
>
> Alternative, you could try (untested):
>
> blah blah blah
> #+LATEX: \ic{
> some text for the inline comment
> #+LATEX: }
> more blah

Thanks, Eric; that works, too.

I think for now the best thing is for me to put longer comments in a
custom environment.  Then I can use Org's block syntax, and have other
export backends do the right thing, if I ever use them instead of LaTeX.

I did dig into the exporter code a bit, so in case anyone is bitten by a
similar issue that doesn't have a ready workaround, the places to look
seem to be:
  - org-element.el:org-element-latex-or-entity-successor.  This is where
    LaTeX fragments are identified.  (As Eric notes, multi-line commands
    will not have their arguments parsed as part of a latex-fragment;
    instead, the argument and surrounding braces are parsed as text in
    the surrounding paragraph.) 
  - ox-latex.el:org-latex-plain-text.  This is where special characters
    that don't get parsed as part of a LaTeX fragment are
    protected/escaped.

I still think it might be nice if each of the protections in
org-latex-plain-text could be toggled via an #+OPTIONS keyword, since
more often than not, I find that characters are escaped in LaTeX export
when I would prefer they weren't.  But that might be a peculiar fact
about how I use Org.  Since for now I don't require this behavior, I'm
not going to try to implement it myself, but if anyone else would also
find it useful, let me know and I will take a stab at writing a patch.

Thanks, all, for the help!

-- 
Best,
Richard