Re: [O] Bug: dates in heading break beamer export

2013-10-04 Thread Nicolas Goaziou
Hello,

Daniele Pizzolli d...@toel.it writes:

 yes, the problem is fixed both for dates and footnotes in sections, and
 should be fixed for any of: bold footnote-reference italic strike-through
 timestamp underline if I understand it correctly. Nice! I hope you plan
 to merge it.

Done.


Regards,

-- 
Nicolas Goaziou



Re: [O] Bug: dates in heading break beamer export

2013-10-03 Thread Nicolas Goaziou
Hello,

Daniele Pizzolli d...@toel.it writes:

 On 10/02/2013 05:55 PM, Nicolas Goaziou wrote:
 Daniele Pizzolli writes:

 Yes, I think is fair to drop the markup.

 OK.

 I would also think that this is safe default when nested markup is
 bad.

The following patch should protect some fragile commands in
a section-like structure. It is Beamer-only since general LaTeX back-end
doesn't seem to encounter these problems.

Does it fix the problem?


Regards,

-- 
Nicolas Goaziou
From d8c37c9265fd6a3d45dce4ce86a12b634c9be0fd Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou n.goaz...@gmail.com
Date: Thu, 3 Oct 2013 15:11:03 +0200
Subject: [PATCH] ox-beamer: Protect fragile commands in sections

* lisp/ox-beamer.el (org-beamer--format-section): Protect fragile
  commands in sections.
---
 lisp/ox-beamer.el | 22 +++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
index a975d24..b812a75 100644
--- a/lisp/ox-beamer.el
+++ b/lisp/ox-beamer.el
@@ -444,9 +444,25 @@ INFO is a plist used as a communication channel.
   Format HEADLINE as a sectioning part.
 CONTENTS holds the contents of the headline.  INFO is a plist
 used as a communication channel.
-  ;; Use `latex' back-end output, inserting overlay specifications
-  ;; if possible.
-  (let ((latex-headline (org-export-with-backend 'latex headline contents info))
+  ;; Use `latex' back-end output, inserting overlay specifications if
+  ;; possible.  Also protect fragile commands.
+  (let ((latex-headline
+	 (org-export-data-with-backend
+	  headline
+	  (org-export-create-backend
+	   :parent 'latex
+	   :transcoders
+	   (let ((protected-output
+		  (function
+		   (lambda (object contents info)
+		 (let ((code (org-export-with-backend
+  'beamer object contents info)))
+		   (if (org-string-nw-p code) (concat \\protect code)
+			 code))
+	 (mapcar #'(lambda (type) (cons type protected-output))
+		 '(bold footnote-reference italic strike-through
+			timestamp underline
+	  info))
 	(mode-specs (org-element-property :BEAMER_ACT headline)))
 (if (and mode-specs
 	 (string-match \\`\\(.*?\\)\\(?:\\*\\|\\[.*\\]\\)?{
-- 
1.8.4



Re: [O] Bug: dates in heading break beamer export

2013-10-02 Thread Daniele Pizzolli

On 09/30/2013 06:02 PM, Daniele Pizzolli wrote:


But org-mode allow this!

I think that if something is allowed in org-mode syntax but not by the
underlining tools used for export, the exporter should take care to find
a suitable workaround.


Hello all,

I see all your interesting points on the discussion... I just want to
explain that my statement is my naïve interpretation of:

You can use intuitive markup then have it converted to HTML, LATEX,
ODT – and much more[fn:1].

I can understand that the markup can end in very complex cases, but I
hope that you agree with me that with this advertised feature an extra
care should be put in ensuring that every markup can be exported
without crashing some tool in the chain.

The latex and html exporters (the one I use most) do already a
wonderful job, but some important case are missing.

Since I found a healthy and friendly community I was thinking that was
worth reporting them.

In fact I use org-mode primarily to stay away from *tex
nuisances... and I think that I am not the only one.  I know enough
latex to find a workaround myself (not enough to offer a general
reliable solution) but I do not think that this will be a pleasant
experience for a newcomer or to somebody that choose org-mode for the
latex export capability.

Regards,
Daniele


[fn:1] http://orgmode.org/features.html#sec-7




Re: [O] Bug: dates in heading break beamer export

2013-10-02 Thread Nicolas Goaziou
Hello,

Daniele Pizzolli d...@toel.it writes:

 In fact I use org-mode primarily to stay away from *tex
 nuisances... and I think that I am not the only one.  I know enough
 latex to find a workaround myself (not enough to offer a general
 reliable solution) but I do not think that this will be a pleasant
 experience for a newcomer or to somebody that choose org-mode for the
 latex export capability.

Fair enough. What, exactly, do you suggest as generated LaTeX code?

IIUC, you want to drop any markup for timestamps when located in
a headline, ignoring `org-latex-active-timestamp-format' and al. Am
I missing something else?

BTW, the =verbatim=[fn:1] case is unrelated to export. See
`org-emphasis-regexp-components'.


Regards,

-- 
Nicolas Goaziou



Re: [O] Bug: dates in heading break beamer export

2013-10-02 Thread Daniele Pizzolli

On 10/02/2013 03:45 PM, Nicolas Goaziou wrote:

Hello,

Daniele Pizzolli writes:


In fact I use org-mode primarily to stay away from *tex
nuisances... and I think that I am not the only one.  I know enough
latex to find a workaround myself (not enough to offer a general
reliable solution) but I do not think that this will be a pleasant
experience for a newcomer or to somebody that choose org-mode for the
latex export capability.


Fair enough. What, exactly, do you suggest as generated LaTeX code?


Thanks Nicolas for following my arguments.


IIUC, you want to drop any markup for timestamps when located in
a headline, ignoring `org-latex-active-timestamp-format' and al. Am
I missing something else?


Yes, I think is fair to drop the markup.  I would also think that this
is safe default when nested markup is bad.
Maybe the exporter can emit a notice/warning.


BTW, the =verbatim=[fn:1] case is unrelated to export. See
`org-emphasis-regexp-components'.


Yes, sorry, I mixed two not-so-related problem.  The beamer exporter do not
work with this code:

#+OPTIONS: H:3
* title test[fn:1]
** section
*** subsection

[fn:1] text


The output is:
org-latex-compile: PDF file ./beamer-bug-footnote.pdf wasn't produced: 
[undefined control sequence] Runaway argument

The =verbatim=[fn:1] problem was discovered trying to find a
workaround for the footnotes in the headers...

Oh, in fact searching emphasis + footnote lead to some results.
The question hit this list periodically... so maybe it’s worth
documenting it better.  I will try found a general answer and
propose a patch for the docs.

It seems that I am going to drop latex nuisances to go into elisp
ones ;-)

Thanks again,
Daniele



Re: [O] Bug: dates in heading break beamer export

2013-10-02 Thread Nicolas Goaziou
Daniele Pizzolli d...@toel.it writes:

 Yes, I think is fair to drop the markup.

OK.

 I would also think that this is safe default when nested markup is
 bad.

Do you have an exhaustive list of such cases?

 Maybe the exporter can emit a notice/warning.

That it dropped the markup?

 Yes, sorry, I mixed two not-so-related problem. The beamer exporter do
 not work with this code:

 #+OPTIONS: H:3
 * title test[fn:1]
 ** section
 *** subsection

 [fn:1] text

Of course, that's a similar problem: footnotes are not allowed in
headlines. Though, in this case, it isn't possible to drop the markup.
What LaTeX code do you suggest?


Regards,

-- 
Nicolas Goaziou



Re: [O] Bug: dates in heading break beamer export

2013-10-02 Thread Daniele Pizzolli

On 10/02/2013 05:55 PM, Nicolas Goaziou wrote:

Daniele Pizzolli writes:


Yes, I think is fair to drop the markup.


OK.


I would also think that this is safe default when nested markup is
bad.


Do you have an exhaustive list of such cases?


No, not really but I try to report them as soon I found them.  I do
want to replace latex entirely with org, so I will use it extensively
in the near future.


Maybe the exporter can emit a notice/warning.


That it dropped the markup?


Yes, I do not know if there is already a standard in reporting back
but I would go for something like Latex-exporter: Warning: dropped
code markup at line XX of originalorgfile.org because it is not
supported by this exporter. More info at ... or even a shorter one
can be fine to me.


Yes, sorry, I mixed two not-so-related problem. The beamer exporter do
not work with this code:

#+OPTIONS: H:3
* title test[fn:1]
** section
*** subsection

[fn:1] text


Of course, that's a similar problem: footnotes are not allowed in
headlines. Though, in this case, it isn't possible to drop the markup.
What LaTeX code do you suggest?


Mmm, I think you are asking to the wrong person.  I do not know enough
about latex and its error reporting capabilities...

I would appreciate if the exporter does not break and/or a
notification to the user of the problem in and understandable
language, even for newcomers.

I know when latex do not know how to resolve some references put some
question marks... but I do not really know if this is the case to
follow this convention.

Regards,
Daniele



Re: [O] Bug: dates in heading break beamer export

2013-10-02 Thread Marcin Borkowski
Dnia 2013-10-02, o godz. 18:10:57
Daniele Pizzolli d...@toel.it napisał(a):

  Of course, that's a similar problem: footnotes are not allowed in
  headlines. Though, in this case, it isn't possible to drop the
  markup. What LaTeX code do you suggest?
 
 Mmm, I think you are asking to the wrong person.  I do not know enough
 about latex and its error reporting capabilities...

Well, LaTeX's error reporting capabilities are not very impressive...

 I would appreciate if the exporter does not break and/or a
 notification to the user of the problem in and understandable
 language, even for newcomers.
 
 I know when latex do not know how to resolve some references put some
 question marks... but I do not really know if this is the case to
 follow this convention.

Well, this is something different: it basically means that either (a)
you need another run or (b) you messed up with the references.

 Regards,
 Daniele

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University



Re: [O] Bug: dates in heading break beamer export

2013-10-02 Thread Suvayu Ali
On Wed, Oct 02, 2013 at 05:55:44PM +0200, Nicolas Goaziou wrote:
 Daniele Pizzolli d...@toel.it writes:
 
  Yes, I think is fair to drop the markup.
 
 OK.
 
  I would also think that this is safe default when nested markup is
  bad.
 
 Do you have an exhaustive list of such cases?
 
  Maybe the exporter can emit a notice/warning.
 
 That it dropped the markup?
 
  Yes, sorry, I mixed two not-so-related problem. The beamer exporter do
  not work with this code:
 
  #+OPTIONS: H:3
  * title test[fn:1]
  ** section
  *** subsection
 
  [fn:1] text
 
 Of course, that's a similar problem: footnotes are not allowed in
 headlines. Though, in this case, it isn't possible to drop the markup.
 What LaTeX code do you suggest?

Strange, it seems to work for me.

-- 
Suvayu

Open source is the future. It sets us free.



Re: [O] Bug: dates in heading break beamer export

2013-10-01 Thread Eric S Fraga
Daniele Pizzolli d...@toel.it writes:

[...]

 I think that if something is allowed in org-mode syntax but not by the
 underlining tools used for export, the exporter should take care to find
 a suitable workaround.

I think this is rather ambitious and would make life very difficult for
exporter maintainers.  LaTeX, for instance, is a very complex system.
-- 
: Eric S Fraga (0xFFFCF67D), Emacs 24.3.50.1, Org release_8.1.1-7-gaecdf5




Re: [O] Bug: dates in heading break beamer export

2013-10-01 Thread Nicolas Goaziou
Hello,

Marcin Borkowski mb...@wmi.amu.edu.pl writes:

 Daniele Pizzolli d...@toel.it napisał(a):
 Or why not drop \textit?

 Sounds good for me.  (NB: there's a similar problems with tags, AFAIR.
 And (AFAIR!) it's even worse, since the exporter uses a low-level TeX
 command \hfill.)

Well, there is `org-latex-active-timestamp-format',
`org-latex-inactive-timestamp-format' and even filters can do it.

It is also technically possible to write in ox-latex a section-local
specific export back-end that would translate differently some objects
in a \section{...} command. But that would make the export a bit more
unpredictable.

Of course, in a few cases, `latex' back-end does its best to circumvent
possible problems (i.e. nested footnotes), but this is nowhere near
a general rule. It's usually a lot of work for a tiny corner case.

  In general, putting formatting commands in \section title etc.,
  even if not erroneous, is considered a bad practice.
 
 But org-mode allow this!
 
 I think that if something is allowed in org-mode syntax but not by the
 underlining tools used for export, the exporter should take care to
 find a suitable workaround.

 Definitely agreed.  The point is, what is a suitable workaround?

I disagree. This is just unrealistic. There are many packages involving
many quirks. We cannot afford to provide a workaround to all (or even
most) of them, assuming one exists.

Also, the OP is making a false assumption. The underlining tool allows
\texit in the section \command, i.e., you can type it in a tex file.
You will get a compilation error, exactly as if you do the same mistake
in Org. Why Org should be smarter in this case?


Regards,

-- 
Nicolas Goaziou



Re: [O] Bug: dates in heading break beamer export

2013-10-01 Thread Marcin Borkowski
Dnia 2013-10-01, o godz. 18:01:51
Nicolas Goaziou n.goaz...@gmail.com napisał(a):

  Sounds good for me.  (NB: there's a similar problems with tags,
  AFAIR. And (AFAIR!) it's even worse, since the exporter uses a
  low-level TeX command \hfill.)
 
 Well, there is `org-latex-active-timestamp-format',
 `org-latex-inactive-timestamp-format' and even filters can do it.

Maybe, I was talking about the default.  (And I even don't know now how
to correct it, since LaTeX does not have a notion of a section tag -
so there's no obvious way to represent such an entity in it!)

 It is also technically possible to write in ox-latex a section-local
 specific export back-end that would translate differently some objects
 in a \section{...} command. But that would make the export a bit more
 unpredictable.

Sorry, I did not get that idea.  We are not talking about
converting /different/ objects into /sections/, are we?

 Of course, in a few cases, `latex' back-end does its best to
 circumvent possible problems (i.e. nested footnotes), but this is
 nowhere near a general rule. It's usually a lot of work for a tiny
 corner case.

Agreed.

   In general, putting formatting commands in \section title etc.,
   even if not erroneous, is considered a bad practice.
  
  But org-mode allow this!
  
  I think that if something is allowed in org-mode syntax but not by
  the underlining tools used for export, the exporter should take
  care to find a suitable workaround.
 
  Definitely agreed.  The point is, what is a suitable workaround?
 
 I disagree. This is just unrealistic. There are many packages
 involving many quirks. We cannot afford to provide a workaround to
 all (or even most) of them, assuming one exists.

Well, in this particular case I can definitely live with what Org
gives.  (The fact that I don't use the exporter too often helps;).)
In other words: the status quo *is* (more or less) a suitable
workaround, at least for me.

 Also, the OP is making a false assumption. The underlining tool allows
 \texit in the section \command, i.e., you can type it in a tex file.
 You will get a compilation error, exactly as if you do the same
 mistake in Org. Why Org should be smarter in this case?

Hm, I did not understand this point:(.

My opinion (as a LaTeX user and hacker, if I may say so) is that LaTeX
exporter may be not optimal, but it is decent enough.  I agree that
it is a lot of work to make it better, and even then it's not enough,
since there is no canonical way to transform some Org-specific things
(like tags) to LaTeX syntax - so someone will be unhappy anyway...

What is important here (as I hinted previously) is the point of having
a LaTeX exporter: do we aim at pdf, not caring about the readability
and elegance of the (then intermediate) LaTeX file, or do we aim at a
good quality LaTeX file to do further (manual!) work on it, including
(but not limited to) visual tuning.  I'm sure there are some people in
both camps, and satisfying all of them may be tricky.

Now that I think of it, writing a completely new LaTeX exporter might
actually be a lot of fun - I'm afraid, though, that I don't have enough
time for it now...

 Regards,

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University



Re: [O] Bug: dates in heading break beamer export

2013-09-30 Thread Marcin Borkowski
Dnia 2013-09-30, o godz. 18:02:51
Daniele Pizzolli d...@toel.it napisał(a):

  It's a LaTeX Beamer problem: it doesn't like
 
 \section{title \textit{[2013-09-29 Sun]}}
 
  produced by Org, although regular LaTeX accepts it.
 
  Do you know about a workaround for this?
 
 Not really.
 
  This is really a workaround: put a \protect before \textit.
 
 Or why not drop \textit?

Sounds good for me.  (NB: there's a similar problems with tags, AFAIR.
And (AFAIR!) it's even worse, since the exporter uses a low-level TeX
command \hfill.)

  In general, putting formatting commands in \section title etc.,
  even if not erroneous, is considered a bad practice.
 
 But org-mode allow this!
 
 I think that if something is allowed in org-mode syntax but not by the
 underlining tools used for export, the exporter should take care to
 find a suitable workaround.

Definitely agreed.  The point is, what is a suitable workaround?

One idea is to define a command \orgsection, with syntax like this:
\orgsection[timestamp=...,tags={...,...}]{title proper}
This could be even defined in a specialized package, call it org.sty,
which is then turned on by means of \usepackage in exported files.
This is probably the cleanest solution I can think of, but has one
disadvantage: it diverges from LaTeX syntax, so if I edit manually (or
worse, transform automatically) such a file, I can encounter problems:
the (non-TeX) parser (e.g. an editor's one) may not know that
\orgsection is in fact a flavor of \section.  For pdf export this is a
non-issue, but AFAIK people use Org LaTeX export to create a file for
further work on it.

Another idea is to redefine \section so that it either accepts optional
arguments (therefore breaking its default interface!), or allow
something like this:

\timestamp{...}
\tags{...,...}
\section{title proper}

This is easy to do, but far from elegant.  Also, it does not help
further maintenance of such a LaTeX file.

Yet another solution would be to forget about LaTeX and use ConTeXt,
where defining custom sections etc. is much easier.  Of course, this is
fine only assuming that (1) I do not want to e.g. submit my file to a
LaTeX-accepting journal and (2) I'm fine with learning ConTeXt, which -
even though much better than LaTeX in terms of UI (and also
featurewise, btw) - has its own learning curve.

 I just found that the same problem (work in latex, does not work in
 beamer) exists for footnotes in header!

Quite possible.  You can always use \footnotemark and \footnotetext.
(Beamer hacks deeply into LaTeX innards, so things like this are no
surprise.)

 A feature request would be to have some checks on org files a la
 flymake, at least for common potential sources of problems that
 usually break the export like:
 
 - missing two empty lines after footnotes
 - missing empty line after RESULTS:
 - =string=[footnote]

Just curious: what's the problem with =string=[footnote]?

 Maybe something already exists and I am simply not aware.
 
 Regards,
 Daniele

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University



Re: [O] Bug: dates in heading break beamer export

2013-09-29 Thread Nicolas Goaziou
Hello,

Daniele Pizzolli d...@toel.it writes:

 Dates in org-format in heading break the beamer export:

 Minimal case:

 #+OPTIONS: H:3
 * title [2013-09-29 Sun]
 ** section
 *** frame
 text

 Result for beamer export:

 org-latex-compile: PDF file ./beamer-bug-date.pdf wasn't produced:
 [undefined control sequence] Runaway argument

It's a LaTeX Beamer problem: it doesn't like

  \section{title \textit{[2013-09-29 Sun]}}

produced by Org, although regular LaTeX accepts it.

Do you know about a workaround for this?


Regards,

-- 
Nicolas Goaziou



Re: [O] Bug: dates in heading break beamer export

2013-09-29 Thread Marcin Borkowski
Dnia 2013-09-29, o godz. 16:53:14
Nicolas Goaziou n.goaz...@gmail.com napisał(a):

 Hello,
 
 Daniele Pizzolli d...@toel.it writes:
 
  Dates in org-format in heading break the beamer export:
 
  Minimal case:
 
  #+OPTIONS: H:3
  * title [2013-09-29 Sun]
  ** section
  *** frame
  text
 
  Result for beamer export:
 
  org-latex-compile: PDF file ./beamer-bug-date.pdf wasn't produced:
  [undefined control sequence] Runaway argument
 
 It's a LaTeX Beamer problem: it doesn't like
 
   \section{title \textit{[2013-09-29 Sun]}}
 
 produced by Org, although regular LaTeX accepts it.
 
 Do you know about a workaround for this?

This is really a workaround: put a \protect before \textit.

In general, putting formatting commands in \section title etc., even if
not erroneous, is considered a bad practice.

Hth,

 
 
 Regards,
 



-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University