emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [Bug] ~Verbatim~ in headlines breaks LaTeX
@ 2015-05-30  3:38 Titus von der Malsburg
  2015-05-30  4:32 ` Nick Dokos
  0 siblings, 1 reply; 13+ messages in thread
From: Titus von der Malsburg @ 2015-05-30  3:38 UTC (permalink / raw)
  To: Org Mode

[-- Attachment #1: Type: text/plain, Size: 967 bytes --]



#+BEGIN_EXAMPLE
* The variable ~JAVA_HOME~
…
#+END_EXAMPLE

Exporting this to LaTeX and then compiling to PDF, produces the
following error:

  ! Missing $ inserted.
  <inserted text> 
                  $
  l.35 \section{The variable \verb~JAVA_HOME~}

Apparently, \verb is not allow in command arguments:

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

One solution is uses \cprotect:

  \cprotect\section{The variable \verb~JAVA_HOME~}

I don’t know how the exporter works but I wouldn’t be surprised if it
wasn’t entirely trivial to implement this.

The problem also exists in other situations where ~verbatim~ is used in
embedded contexts, for example when used in link descriptions:

  [[https://encrypted.google.com/search?q=JAVA_HOME][Google
  ~JAVA_HOME~]]

Is there anything that speaks against using \texttt for ~verbatim~?  The
HTML exporter uses the code tag for ~verbatim~ and =code=.

  Titus

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

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

* Re: [Bug] ~Verbatim~ in headlines breaks LaTeX
  2015-05-30  3:38 [Bug] ~Verbatim~ in headlines breaks LaTeX Titus von der Malsburg
@ 2015-05-30  4:32 ` Nick Dokos
  2015-05-30  5:18   ` Titus von der Malsburg
  0 siblings, 1 reply; 13+ messages in thread
From: Nick Dokos @ 2015-05-30  4:32 UTC (permalink / raw)
  To: emacs-orgmode

Titus von der Malsburg <malsburg@posteo.de> writes:

> #+BEGIN_EXAMPLE
> * The variable ~JAVA_HOME~
> &
> #+END_EXAMPLE
>
> Exporting this to LaTeX and then compiling to PDF, produces the
> following error:
>
>   ! Missing $ inserted.
>   <inserted text> 
>                   $
>   l.35 \section{The variable \verb~JAVA_HOME~}
>
> Apparently, \verb is not allow in command arguments:
>
>   http://www.tex.ac.uk/cgi-bin/texfaq2html?label=verbwithin
>
> One solution is uses \cprotect:
>
>   \cprotect\section{The variable \verb~JAVA_HOME~}
>
> I don’t know how the exporter works but I wouldn’t be surprised if it
> wasn’t entirely trivial to implement this.
>
> The problem also exists in other situations where ~verbatim~ is used in
> embedded contexts, for example when used in link descriptions:
>
>   [[https://encrypted.google.com/search?q=JAVA_HOME][Google
>   ~JAVA_HOME~]]
>
> Is there anything that speaks against using \texttt for ~verbatim~?  The
> HTML exporter uses the code tag for ~verbatim~ and =code=.
>
>   Titus

I don't know what \cprotect does but there was a discussion of this a
long time ago:

    http://thread.gmane.org/gmane.emacs.orgmode/14256/focus=14257

and back then, Carsten changed it so that verbatim in headlines used
\texttt - but that was the old latex exporter: I take it things are
different now?

Nick

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

* Re: [Bug] ~Verbatim~ in headlines breaks LaTeX
  2015-05-30  4:32 ` Nick Dokos
@ 2015-05-30  5:18   ` Titus von der Malsburg
  2015-05-30  8:09     ` Nicolas Goaziou
  0 siblings, 1 reply; 13+ messages in thread
From: Titus von der Malsburg @ 2015-05-30  5:18 UTC (permalink / raw)
  To: Nick Dokos; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1830 bytes --]


On 2015-05-29 Fri 21:32, Nick Dokos wrote:
> Titus von der Malsburg <malsburg@posteo.de> writes:
>
>> #+BEGIN_EXAMPLE
>> * The variable ~JAVA_HOME~
>> &
>> #+END_EXAMPLE
>>
>> Exporting this to LaTeX and then compiling to PDF, produces the
>> following error:
>>
>>   ! Missing $ inserted.
>>   <inserted text> 
>>                   $
>>   l.35 \section{The variable \verb~JAVA_HOME~}
>>
>> Apparently, \verb is not allow in command arguments:
>>
>>   http://www.tex.ac.uk/cgi-bin/texfaq2html?label=verbwithin
>>
>> One solution is uses \cprotect:
>>
>>   \cprotect\section{The variable \verb~JAVA_HOME~}
>>
>> I don’t know how the exporter works but I wouldn’t be surprised if it
>> wasn’t entirely trivial to implement this.
>>
>> The problem also exists in other situations where ~verbatim~ is used in
>> embedded contexts, for example when used in link descriptions:
>>
>>   [[https://encrypted.google.com/search?q=JAVA_HOME][Google
>>   ~JAVA_HOME~]]
>>
>> Is there anything that speaks against using \texttt for ~verbatim~?  The
>> HTML exporter uses the code tag for ~verbatim~ and =code=.
>>
>>   Titus
>
> I don't know what \cprotect does but there was a discussion of this a
> long time ago:
>
>     http://thread.gmane.org/gmane.emacs.orgmode/14256/focus=14257
>
> and back then, Carsten changed it so that verbatim in headlines used
> \texttt - but that was the old latex exporter: I take it things are
> different now?

Yes, I saw this thread after sending the previous email.  According to
`org-latex-text-markup-alist', protectedtexttt should be used, which
seems like a good-enough solution for this problem.  But for some reason
that doesn’t happen.

BTW, I used the latest development versions of Emacs (-Q) and Org-mode
to test this.

  Titus


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

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

* Re: [Bug] ~Verbatim~ in headlines breaks LaTeX
  2015-05-30  5:18   ` Titus von der Malsburg
@ 2015-05-30  8:09     ` Nicolas Goaziou
  2015-05-30 15:19       ` Titus von der Malsburg
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2015-05-30  8:09 UTC (permalink / raw)
  To: Titus von der Malsburg; +Cc: Nick Dokos, emacs-orgmode

Hello,

Titus von der Malsburg <malsburg@posteo.de> writes:

> Yes, I saw this thread after sending the previous email.  According to
> `org-latex-text-markup-alist', protectedtexttt should be used, which
> seems like a good-enough solution for this problem.  But for some reason
> that doesn’t happen.

It happens. However, verbatim is =...= whereas ~...~ is code. The former
uses protectedtexttt while the latter uses \verb.

Note that we could do better anyway and switch command depending on
context.


Regards,

-- 
Nicolas Goaziou

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

* Re: [Bug] ~Verbatim~ in headlines breaks LaTeX
  2015-05-30  8:09     ` Nicolas Goaziou
@ 2015-05-30 15:19       ` Titus von der Malsburg
  2015-05-31  8:40         ` Nicolas Goaziou
  0 siblings, 1 reply; 13+ messages in thread
From: Titus von der Malsburg @ 2015-05-30 15:19 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Nick Dokos, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 889 bytes --]


On 2015-05-30 Sat 01:09, Nicolas Goaziou wrote:
> Hello,
>
> Titus von der Malsburg <malsburg@posteo.de> writes:
>
>> Yes, I saw this thread after sending the previous email.  According to
>> `org-latex-text-markup-alist', protectedtexttt should be used, which
>> seems like a good-enough solution for this problem.  But for some reason
>> that doesn’t happen.
>
> It happens. However, verbatim is =...= whereas ~...~ is code. The former
> uses protectedtexttt while the latter uses \verb.

Huh, ~code~ is translated to \verb and =verbatim= is translated to
\texttt (plus escaping of some special characters)?  If \verb is used at
all, shouldn’t it be generated by =verbatim= instead of by ~code~?

> Note that we could do better anyway and switch command depending on
> context.

Yes, I suppose anything is better than producing malformed LaTeX.

  Titus



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

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

* Re: [Bug] ~Verbatim~ in headlines breaks LaTeX
  2015-05-30 15:19       ` Titus von der Malsburg
@ 2015-05-31  8:40         ` Nicolas Goaziou
  2015-06-05 19:28           ` Titus von der Malsburg
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2015-05-31  8:40 UTC (permalink / raw)
  To: Titus von der Malsburg; +Cc: Nick Dokos, emacs-orgmode

Titus von der Malsburg <malsburg@posteo.de> writes:

> Huh, ~code~ is translated to \verb and =verbatim= is translated to
> \texttt (plus escaping of some special characters)?

Correct.

> If \verb is used at all, shouldn’t it be generated by =verbatim=
> instead of by ~code~?

Why is that? Because \verb reminds =verbatim=? Really, both "code" and
"verbatim" syntax produces verbatim contents. Therefore both are
eligible for "\verb".

Anyway, you can customize `org-latex-text-markup-alist' to your liking.

>> Note that we could do better anyway and switch command depending on
>> context.
>
> Yes, I suppose anything is better than producing malformed LaTeX.

Could you give the list of all contexts requiring such a switch, and
what the result should be in each case?

Thank you.


Regards,

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

* Re: [Bug] ~Verbatim~ in headlines breaks LaTeX
  2015-05-31  8:40         ` Nicolas Goaziou
@ 2015-06-05 19:28           ` Titus von der Malsburg
  2015-06-05 21:27             ` Nicolas Goaziou
  0 siblings, 1 reply; 13+ messages in thread
From: Titus von der Malsburg @ 2015-06-05 19:28 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Nick Dokos, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1808 bytes --]


On 2015-05-31 Sun 01:40, Nicolas Goaziou wrote:
> Titus von der Malsburg <malsburg@posteo.de> writes:
>
>> Huh, ~code~ is translated to \verb and =verbatim= is translated to
>> \texttt (plus escaping of some special characters)?
>
> Correct.
>
>> If \verb is used at all, shouldn’t it be generated by =verbatim=
>> instead of by ~code~?
>
> Why is that? Because \verb reminds =verbatim=? Really, both "code" and
> "verbatim" syntax produces verbatim contents. Therefore both are
> eligible for "\verb".

Well, \verb is short for verbatim.  So, yeah, it is pretty unexpected
that =verbatim= is translated to testtt and ~code~ to \verb.

>>> Note that we could do better anyway and switch command depending on
>>> context.
>>
>> Yes, I suppose anything is better than producing malformed LaTeX.
>
> Could you give the list of all contexts requiring such a switch, and
> what the result should be in each case?

Below is a list of things that I tested.  This list of test cases is
probably not exhaustive.

Things that don't work with \verb (produce malformed LaTeX):

    #+TITLE: ~test~

    #+CAPTION: ~test~
    [[/tmp/img.png]]

    * ~test~
    ** ~test~
    …

These two did not produce the intended results (sub and super script
don’t work) but the LaTeX is not malformed:

    test^~test~
    test_~test~

Things that did work as expected with \verb:

    ~test~

    | ~test~ |

    [[http://www.fsf.org/][~test~]]

    - ~test~ :: this is a ~test~

    [fn:1]
    [fn:1] ~test~

    *~test~*
    =~test~=
    /~test~/
    +~test~+
    _~test~_



-- 
Dr Titus von der Malsburg
Feodor Lynen Research Fellow
Dept. Psychology & Dept. Linguistics
University of California, San Diego
http://pages.ucsd.edu/~tvondermalsburg/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

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

* Re: [Bug] ~Verbatim~ in headlines breaks LaTeX
  2015-06-05 19:28           ` Titus von der Malsburg
@ 2015-06-05 21:27             ` Nicolas Goaziou
  2015-06-05 22:58               ` Titus von der Malsburg
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Goaziou @ 2015-06-05 21:27 UTC (permalink / raw)
  To: Titus von der Malsburg; +Cc: Nick Dokos, emacs-orgmode

Titus von der Malsburg <malsburg@posteo.de> writes:

> Below is a list of things that I tested.  This list of test cases is
> probably not exhaustive.

Thanks.

> Things that don't work with \verb (produce malformed LaTeX):
>
>     #+TITLE: ~test~
>
>     #+CAPTION: ~test~
>     [[/tmp/img.png]]
>
>     * ~test~
>     ** ~test~
>     …
>
> These two did not produce the intended results (sub and super script
> don’t work) but the LaTeX is not malformed:
>
>     test^~test~
>     test_~test~

What should be produced by "ox-latex.el" in all the cases above?

Regards,

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

* Re: [Bug] ~Verbatim~ in headlines breaks LaTeX
  2015-06-05 21:27             ` Nicolas Goaziou
@ 2015-06-05 22:58               ` Titus von der Malsburg
  2015-06-06  7:28                 ` Nicolas Goaziou
  0 siblings, 1 reply; 13+ messages in thread
From: Titus von der Malsburg @ 2015-06-05 22:58 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Nick Dokos, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1190 bytes --]


On 2015-06-05 Fri 14:27, Nicolas Goaziou wrote:
> Titus von der Malsburg <malsburg@posteo.de> writes:
>
>> Below is a list of things that I tested.  This list of test cases is
>> probably not exhaustive.
>
> Thanks.
>
>> Things that don't work with \verb (produce malformed LaTeX):
>>
>>     #+TITLE: ~test~
>>
>>     #+CAPTION: ~test~
>>     [[/tmp/img.png]]
>>
>>     * ~test~
>>     ** ~test~
>>     …

Thee can be handled by protectedtexttt.  The obvious questions is of
course: Wouldn’t it be more consistent to handle all instances of ~code~
using protectedtexttt?  And if you want to support the use of \verb at
all, shouldn’t that be done via =verbatim= not ~code~?

>> These two did not produce the intended results (sub and super script
>> don’t work) but the LaTeX is not malformed:
>>
>>     test^~test~
>>     test_~test~

This really seems to be an independent issue (because test^*test*
doesn’t work either) but I think it should produce this LaTeX:

    test\(^{\text{\texttt{test}}}\)
    test\(_{\text{\texttt{test}}}\)

But this works, too:

    test\(^{\text{\verb~test~}}\)
    test\(_{\text{\verb~test~}}\)

Titus

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

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

* Re: [Bug] ~Verbatim~ in headlines breaks LaTeX
  2015-06-05 22:58               ` Titus von der Malsburg
@ 2015-06-06  7:28                 ` Nicolas Goaziou
  2015-06-06 17:32                   ` Titus von der Malsburg
  2015-06-06 22:15                   ` Suvayu Ali
  0 siblings, 2 replies; 13+ messages in thread
From: Nicolas Goaziou @ 2015-06-06  7:28 UTC (permalink / raw)
  To: Titus von der Malsburg; +Cc: Nick Dokos, emacs-orgmode

Titus von der Malsburg <malsburg@posteo.de> writes:

> Thee can be handled by protectedtexttt.  The obvious questions is of
> course: Wouldn’t it be more consistent to handle all instances of ~code~
> using protectedtexttt?

One option would be indeed to remove \verb altogether. Note that it is
also used in inline source blocks. 

However, I assume \verb put less limitations than \texttt on its
contents, so I'd rather keep \verb around.

> And if you want to support the use of \verb at all, shouldn’t that be
> done via =verbatim= not ~code~?

I fail to see how it would solve the problem at hand. It would simply
move it elsewhere.

My question is how to handle \verb at the LaTeX level, not at the Org
one.

>>> These two did not produce the intended results (sub and super script
>>> don’t work) but the LaTeX is not malformed:
>>>
>>>     test^~test~
>>>     test_~test~
>
> This really seems to be an independent issue (because test^*test*
> doesn’t work either)

Actually, I just realized this is not valid syntax for sub/superscript
in Org anyway. It should be

  test^{~test~}

Regards,

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

* Re: [Bug] ~Verbatim~ in headlines breaks LaTeX
  2015-06-06  7:28                 ` Nicolas Goaziou
@ 2015-06-06 17:32                   ` Titus von der Malsburg
  2015-06-06 22:15                   ` Suvayu Ali
  1 sibling, 0 replies; 13+ messages in thread
From: Titus von der Malsburg @ 2015-06-06 17:32 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Nick Dokos, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1537 bytes --]


On 2015-06-06 Sat 00:28, Nicolas Goaziou wrote:
> Titus von der Malsburg <malsburg@posteo.de> writes:
>
>> Thee can be handled by protectedtexttt.  The obvious questions is of
>> course: Wouldn’t it be more consistent to handle all instances of ~code~
>> using protectedtexttt?
>
> One option would be indeed to remove \verb altogether. Note that it is
> also used in inline source blocks. 
>
> However, I assume \verb put less limitations than \texttt on its
> contents, so I'd rather keep \verb around.
>
>> And if you want to support the use of \verb at all, shouldn’t that be
>> done via =verbatim= not ~code~?
>
> I fail to see how it would solve the problem at hand. It would simply
> move it elsewhere.

I didn’t say it would.  I said that using protectedtexttt solves
the issue in problematic environments.

The issue that =verbatim= maps to \texttt and ~code~ to \verb is
independent, but since it affects the same code, it might make
sense to solve both at the same time.

  Titus

> My question is how to handle \verb at the LaTeX level, not at the Org
> one.
>
>>>> These two did not produce the intended results (sub and super script
>>>> don’t work) but the LaTeX is not malformed:
>>>>
>>>>     test^~test~
>>>>     test_~test~
>>
>> This really seems to be an independent issue (because test^*test*
>> doesn’t work either)
>
> Actually, I just realized this is not valid syntax for sub/superscript
> in Org anyway. It should be
>
>   test^{~test~}
>
> Regards,


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

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

* Re: [Bug] ~Verbatim~ in headlines breaks LaTeX
  2015-06-06  7:28                 ` Nicolas Goaziou
  2015-06-06 17:32                   ` Titus von der Malsburg
@ 2015-06-06 22:15                   ` Suvayu Ali
  2015-06-06 23:20                     ` Nicolas Goaziou
  1 sibling, 1 reply; 13+ messages in thread
From: Suvayu Ali @ 2015-06-06 22:15 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Nick Dokos, Titus von der Malsburg

On Sat, Jun 06, 2015 at 09:28:12AM +0200, Nicolas Goaziou wrote:
> Titus von der Malsburg <malsburg@posteo.de> writes:
> 
> > Thee can be handled by protectedtexttt.  The obvious questions is of
> > course: Wouldn’t it be more consistent to handle all instances of ~code~
> > using protectedtexttt?
> 
> One option would be indeed to remove \verb altogether. Note that it is
> also used in inline source blocks. 
> 
> However, I assume \verb put less limitations than \texttt on its
> contents, so I'd rather keep \verb around.

This TeX.SX post discourages the use of \verb.

  http://tex.stackexchange.com/a/83894/4416

It cites the following FAQ from UK TeX.

  http://www.TeX.ac.uk/cgi-bin/texfaq2html?label=verbwithin

Maybe it is worth to consider dropping \verb entirely?

Hope this helps,

-- 
Suvayu

Open source is the future. It sets us free.

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

* Re: [Bug] ~Verbatim~ in headlines breaks LaTeX
  2015-06-06 22:15                   ` Suvayu Ali
@ 2015-06-06 23:20                     ` Nicolas Goaziou
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Goaziou @ 2015-06-06 23:20 UTC (permalink / raw)
  To: Suvayu Ali; +Cc: Nick Dokos, Titus von der Malsburg, emacs-orgmode

Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:

> On Sat, Jun 06, 2015 at 09:28:12AM +0200, Nicolas Goaziou wrote:
>> Titus von der Malsburg <malsburg@posteo.de> writes:
>> 
>> > Thee can be handled by protectedtexttt.  The obvious questions is of
>> > course: Wouldn’t it be more consistent to handle all instances of ~code~
>> > using protectedtexttt?
>> 
>> One option would be indeed to remove \verb altogether. Note that it is
>> also used in inline source blocks. 
>> 
>> However, I assume \verb put less limitations than \texttt on its
>> contents, so I'd rather keep \verb around.
>
> This TeX.SX post discourages the use of \verb.
>
>   http://tex.stackexchange.com/a/83894/4416
>
> It cites the following FAQ from UK TeX.
>
>   http://www.TeX.ac.uk/cgi-bin/texfaq2html?label=verbwithin
>
> Maybe it is worth to consider dropping \verb entirely?

Done in b8ade2e79e92dad10f2b045bc55fbeaf133e5598. Thanks to you both.


Regards,

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

end of thread, other threads:[~2015-06-06 23:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-30  3:38 [Bug] ~Verbatim~ in headlines breaks LaTeX Titus von der Malsburg
2015-05-30  4:32 ` Nick Dokos
2015-05-30  5:18   ` Titus von der Malsburg
2015-05-30  8:09     ` Nicolas Goaziou
2015-05-30 15:19       ` Titus von der Malsburg
2015-05-31  8:40         ` Nicolas Goaziou
2015-06-05 19:28           ` Titus von der Malsburg
2015-06-05 21:27             ` Nicolas Goaziou
2015-06-05 22:58               ` Titus von der Malsburg
2015-06-06  7:28                 ` Nicolas Goaziou
2015-06-06 17:32                   ` Titus von der Malsburg
2015-06-06 22:15                   ` Suvayu Ali
2015-06-06 23:20                     ` 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).