GNU bug report logs - #50555
[BUG] Org Latex export doesn't handle src blocks correctly

Previous Next

Package: org-mode;

Reported by: Younes Ben El <younes.brovi <at> gmail.com>

Date: Sun, 12 Sep 2021 20:53:02 UTC

Severity: normal

Tags: moreinfo, patch

Done: Daniel Fleischer <danflscr <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50555 in the body.
You can then email your comments to 50555 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#50555; Package emacs. (Sun, 12 Sep 2021 20:53:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Younes Ben El <younes.brovi <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 12 Sep 2021 20:53:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Younes Ben El <younes.brovi <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [BUG] Org Latex export doesn't handle src blocks correctly
Date: Sun, 12 Sep 2021 21:25:55 +0100
[Message part 1 (text/plain, inline)]
When exporting from org to latex , src blocks are not handled correctly.
This happens when you specify a prog-language name after #+BEGIN_SRC
Which results to an extra *[]* in exported latex file thus when
compiling it to pdf , it won't display the code block.
- How it produces the code block in latex

\begin{minted}[]{lisp}
>   (defun Fib (n)
>     (if (< n 2) n (+ (Fib (- n 1)) (Fib (- n 2)))))
> \end{minted}


- how it should produce it in latex

>
> \begin{minted}{lisp}
>   (defun Fib (n)
>     (if (< n 2) n (+ (Fib (- n 1)) (Fib (- n 2)))))
> \end{minted}


This also happens when not using minted package to highlight code
blocks.
- *To produce this bug*, (optional) set (setq org-latex-listings 'minted)
open org file and add

> #+BEGIN_SRC shell
> echo test
> #+END_SRC

And run org-latex-export-to-pdf or org-latex-export-to-latex.
- *To Resolve this issue* , remove [] in tex file and it will compile to
pdf with code blocks and syntax highlighting (This requires manually
editing each time you export to latex). Second way is to no specify
prog-language after #+BEGIN_SRC however this doesn't show code
highlighting since minted requires defining a prog-language in order to
work.
- Technical Info

> Emacs  : GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version
> 3.24.27, cairo version 1.17.4)

 of 2021-03-26
Package: Org mode version 9.5 (9.5-b83ae59 @
/home/ybenel/.emacs.d/.local/straight/build-27.2/org/)

>
>
[Message part 2 (text/html, inline)]

Information forwarded to emacs-orgmode <at> gnu.org:
bug#50555; Package org-mode. (Sat, 18 Sep 2021 10:58:01 GMT) Full text and rfc822 format available.

Message #8 received at 50555 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Fleischer <danflscr <at> gmail.com>
To: Younes Ben El <younes.brovi <at> gmail.com>
Cc: 50555 <at> debbugs.gnu.org
Subject: Re: bug#50555: [BUG] Org Latex export doesn't handle src blocks
 correctly
Date: Sat, 18 Sep 2021 13:57:27 +0300
Younes Ben El [2021-09-12 Sun 21:25] wrote:

> When exporting from org to latex , src blocks are not handled correctly.
> This happens when you specify a prog-language name after #+BEGIN_SRC
> Which results to an extra *[]* in exported latex file thus when
> compiling it to pdf , it won't display the code block.

It's true that there are empty [] argument list for the minted package
in the latex code; however I am able to compile your (and my) latex code
into PDF with and without it so I'm not sure that something needs to be
done in org-mode. Can you send the resulting latex file and/or specify
why it's not compiling?

-- 

Daniel Fleischer




Added tag(s) moreinfo. Request was from Daniel Fleischer <danflscr <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 18 Sep 2021 10:58:02 GMT) Full text and rfc822 format available.

Information forwarded to emacs-orgmode <at> gnu.org:
bug#50555; Package org-mode. (Sat, 18 Sep 2021 14:25:02 GMT) Full text and rfc822 format available.

Message #13 received at 50555 <at> debbugs.gnu.org (full text, mbox):

From: Younes Ben El <younes.brovi <at> gmail.com>
To: Daniel Fleischer <danflscr <at> gmail.com>
Cc: 50555 <at> debbugs.gnu.org
Subject: Re: bug#50555: [BUG] Org Latex export doesn't handle src blocks
 correctly
Date: Sat, 18 Sep 2021 15:07:22 +0100
[Message part 1 (text/plain, inline)]

[Message part 2 (text/html, inline)]

Information forwarded to emacs-orgmode <at> gnu.org:
bug#50555; Package org-mode. (Sat, 18 Sep 2021 14:41:01 GMT) Full text and rfc822 format available.

Message #16 received at 50555 <at> debbugs.gnu.org (full text, mbox):

From: Younes Ben El <younes.brovi <at> gmail.com>
To: Daniel Fleischer <danflscr <at> gmail.com>
Cc: 50555 <at> debbugs.gnu.org
Subject: Re: bug#50555: [BUG] Org Latex export doesn't handle src blocks
 correctly
Date: Sat, 18 Sep 2021 15:38:13 +0100
[Message part 1 (text/plain, inline)]
I Apologize for the previous mail, seems like it didn't go through
correctly .
Actually it does compile and produces a pdf file , however there's some
issue with it as it doesn't display the code_block.
if we set our emacs config to
#+begin_src emacs-lisp
(require 'ox-latex)
(setq org-latex-listings 'minted)
#+end_src
Then Set In Our org file
#+begin_src org
#+LATEX_CLASS: article
#+LATEX_CLASS_OPTIONS: [letterpaper]
#+LATEX_HEADER: \usepackage{minted}
#+OPTIONS: toc:t
#+end_src
and edit our org file and then compile it , it will not produce a code_block.
probably because of empty options [] like i tested , after we remove them it works.
Digging little into the issue, if we specfied a pdf-export-commands , it will result into
the expected exported pdf.
#+begin_src emacs-lisp
(with-eval-after-load 'ox-latex
  (add-to-list 'org-latex-packages-alist '("" "minted"))
  (setq org-latex-listings 'minted)
  (setq org-latex-pdf-process
        '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
          "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
          "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f")))
#+end_src
Not sure why it needs these in order to export correctly.
Here's some screenshots of the issue,[[https://i.imgur.com/VB1leIW.png][Exported_pdf]],[[https://i.imgur.com/x8lIIFW.png][org_file]],[[https://i.imgur.com/Tm0lzp4.png][exported_tex]],[[https://i.imgur.com/bxdI7Ja.png][Removing_Brackets]]
[Message part 2 (text/html, inline)]

Information forwarded to emacs-orgmode <at> gnu.org:
bug#50555; Package org-mode. (Sat, 18 Sep 2021 19:46:01 GMT) Full text and rfc822 format available.

Message #19 received at 50555 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Fleischer <danflscr <at> gmail.com>
To: Younes Ben El <younes.brovi <at> gmail.com>
Cc: 50555 <at> debbugs.gnu.org
Subject: Re: bug#50555: [BUG] Org Latex export doesn't handle src blocks
 correctly
Date: Sat, 18 Sep 2021 22:45:44 +0300
I verified again, this time with emacs -Q; the empty argument list []
does NOT stop you from compiling org into PDF.

> (with-eval-after-load 'ox-latex
>   (add-to-list 'org-latex-packages-alist '("" "minted"))
>   (setq org-latex-listings 'minted)
>   (setq org-latex-pdf-process
>         '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
>           "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
>           "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f")))
>

Here is the hint: since "minted" is using a python package (pygments) for
the highlighting, one need to add the "-shell-escape" to the call. Other
than that, everything works as planned. Since it's a specific
configuration for using "minted", I'll add a comment in the manual.

If you feel that there is still an issue with the [], please provide an
emacs -Q recipe that shows it, after adding the "-shell-escape" flag. 

-- 

Daniel Fleischer




Information forwarded to emacs-orgmode <at> gnu.org:
bug#50555; Package org-mode. (Sat, 18 Sep 2021 19:56:02 GMT) Full text and rfc822 format available.

Message #22 received at 50555 <at> debbugs.gnu.org (full text, mbox):

From: Younes Ben El <younes.brovi <at> gmail.com>
To: Daniel Fleischer <danflscr <at> gmail.com>
Cc: 50555 <at> debbugs.gnu.org
Subject: Re: bug#50555: [BUG] Org Latex export doesn't handle src blocks
 correctly
Date: Sat, 18 Sep 2021 20:53:01 +0100
[Message part 1 (text/plain, inline)]
Daniel Fleischer <danflscr <at> gmail.com> writes:

> Here is the hint: since "minted" is using a python package (pygments) for
> the highlighting, one need to add the "-shell-escape" to the call. Other
> than that, everything works as planned. Since it's a specific
> configuration for using "minted", I'll add a comment in the manual.
>
> If you feel that there is still an issue with the [], please provide an
> emacs -Q recipe that shows it, after adding the "-shell-escape" flag.

Ah, That's the deal. Updating The Manual Will do the trick Thanks for
taking time and looking up at this issue .
[Message part 2 (text/html, inline)]

Information forwarded to emacs-orgmode <at> gnu.org:
bug#50555; Package org-mode. (Sat, 18 Sep 2021 20:06:01 GMT) Full text and rfc822 format available.

Message #25 received at 50555 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Fleischer <danflscr <at> gmail.com>
To: Younes Ben El <younes.brovi <at> gmail.com>
Cc: 50555 <at> debbugs.gnu.org
Subject: [PATCH] Re: bug#50555: [BUG] Org Latex export doesn't handle src
 blocks correctly
Date: Sat, 18 Sep 2021 23:04:58 +0300
[Message part 1 (text/plain, inline)]
Younes Ben El <younes.brovi <at> gmail.com> writes:

> Daniel Fleischer <danflscr <at> gmail.com> writes: 
>
>     Here is the hint: since “minted” is using a python package (pygments) for the highlighting, one need to add the
>     “-shell-escape” to the call. Other than that, everything works as planned. Since it’s a specific configuration for
>     using “minted”, I’ll add a comment in the manual. 
>
>     If you feel that there is still an issue with the [], please provide an emacs -Q recipe that shows it, after adding
>     the “-shell-escape” flag. 
>
> Ah, That’s the deal. Updating The Manual Will do the trick Thanks for taking time and looking up at this issue . 
>

Patch: comment suggesting the usage of the flag; many changes due to the
footnote numbering "push".

[0001-org-manual-comment-about-latex-code-block-export.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
-- 

Daniel Fleischer

Added tag(s) patch. Request was from Daniel Fleischer <daniel.fleischer <at> amobee.com> to control <at> debbugs.gnu.org. (Sun, 19 Sep 2021 15:29:03 GMT) Full text and rfc822 format available.

Information forwarded to emacs-orgmode <at> gnu.org:
bug#50555; Package org-mode. (Mon, 27 Sep 2021 08:38:01 GMT) Full text and rfc822 format available.

Message #30 received at 50555 <at> debbugs.gnu.org (full text, mbox):

From: Bastien <bzg <at> gnu.org>
To: Daniel Fleischer <danflscr <at> gmail.com>
Cc: 50555 <at> debbugs.gnu.org, Younes Ben El <younes.brovi <at> gmail.com>
Subject: Re: bug#50555: [PATCH] Re: bug#50555: [BUG] Org Latex export
 doesn't handle src blocks correctly
Date: Mon, 27 Sep 2021 10:29:33 +0200
Hi Daniel,

Daniel Fleischer <danflscr <at> gmail.com> writes:

> Patch: comment suggesting the usage of the flag; many changes due to the
> footnote numbering "push".

Applied, thanks.

-- 
 Bastien




bug closed, send any further explanations to 50555 <at> debbugs.gnu.org and Younes Ben El <younes.brovi <at> gmail.com> Request was from Daniel Fleischer <danflscr <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 03 Oct 2021 20:00:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 01 Nov 2021 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 176 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.