emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* LaTeX export: {} on separate lines are escaped, why?
@ 2013-07-27 13:41 James Harkins
  2013-07-27 18:40 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: James Harkins @ 2013-07-27 13:41 UTC (permalink / raw)
  To: orgmode

Just wondering if there's a better way to handle LaTeX commands written inline, when the command arguments span a line break. Currently, LaTeX export preserves curly braces as is if a pair of them is on a single line, but it escapes them if there's a line break in between:

~~ org
Sections may be created as subpatches, using \inpcode{[route go
stop]} to start or stop the section, as in the very simple example in
Figure \ref{pd_comp}a.
~~

~~ Exported LaTeX:
Sections may be created as subpatches, using \codeident\{[route go
stop]\} to start or stop the section, as in the very simple example in
Figure \ref{pd_comp}a.
~~

(\codeident is a custom command I defined in the preamble, as semantic markup for \texttt.)

In the PDF, \ref{pd_comp} turns into a figure number, as I would expect, but \codeident\{...\} sets the enclosed string in the normal font rather than fixed-width (with visible {}, which shouldn't be in the printed output).

I do have a workaround:

~~ org
Sections may be created as subpatches, using
#+LaTeX: \inpcode{[route go stop]}
to start or stop the section, as in the very simple example in
Figure \ref{pd_comp}a.
~~

... where "#+LaTeX:" prevents M-q from breaking the braces onto separate lines, but -- this has tripped me up a few dozen times working on this article, so I thought it would be worth asking if this is really the ideal behavior.

hjh

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

* Re: LaTeX export: {} on separate lines are escaped, why?
  2013-07-27 13:41 LaTeX export: {} on separate lines are escaped, why? James Harkins
@ 2013-07-27 18:40 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2013-07-27 18:40 UTC (permalink / raw)
  To: James Harkins; +Cc: orgmode

Hello,

James Harkins <jamshark70@gmail.com> writes:

> Just wondering if there's a better way to handle LaTeX commands
> written inline, when the command arguments span a line break.
> Currently, LaTeX export preserves curly braces as is if a pair of them
> is on a single line, but it escapes them if there's a line break in
> between:
>
> ~~ org
> Sections may be created as subpatches, using \inpcode{[route go
> stop]} to start or stop the section, as in the very simple example in
> Figure \ref{pd_comp}a.
> ~~
>
> ~~ Exported LaTeX:
> Sections may be created as subpatches, using \codeident\{[route go
> stop]\} to start or stop the section, as in the very simple example in
> Figure \ref{pd_comp}a.
> ~~

Org syntax has a very limited support for LaTeX commands. Usual regexp
used is:

  "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\\|\\({[^{}\n]*}\\)\\)*"

As you can see, newline characters are explicitly forbidden.

We could extend quite easily this support to more complex commands, but
I'm not sure we should encourage this. By essence, LaTeX macros are not
very portable. Luckily, there's a syntax for non-portable code: export
snippets. Thus, you can write:

  Sections may be created as subpatches, using @@latex:\inpcode{[route go
  stop]}@@ to start or stop the section, as in the very simple example in
  Figure \ref{pd_comp}a.

I think it is better than improving LaTeX commands support.

As a side note, I suggest to use Org cross reference syntax instead of
writing \ref{...} explicitly.


Regards,

-- 
Nicolas Goaziou

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

end of thread, other threads:[~2013-07-27 18:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-27 13:41 LaTeX export: {} on separate lines are escaped, why? James Harkins
2013-07-27 18:40 ` Nicolas Goaziou

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