Hi everyone, for the documentation of my LaTeX courses I use examples that show the output next to the source code. I'm contemplating whether I should convert the documentation and examples to org, and use org-babel to include the examples. I think this should be possible with org-babel. However, I cannot manage to get this to work: #+begin_example Blabla #+begin_src latex :file test.pdf \documentclass{article} \begin{document} This is a test \end{document} #+end_src Blabla #+end_example Looking at the temporary latex file (see below) the reason is clear: Org babel exports this as a complete latex file although the example itself is already complete. Can I tell org somehow that this is not a fragment and should be compiled as is? Best, Denis \documentclass{article} \usepackage[usenames]{color} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{graphicx} \usepackage{longtable} \usepackage{wrapfig} \usepackage{rotating} \usepackage[normalem]{ulem} \usepackage{amsmath} \usepackage{amssymb} \usepackage{capt-of} \pagestyle{empty} % do not remove % The settings below are copied from fullpage.sty \setlength{\textwidth}{\paperwidth} \addtolength{\textwidth}{-3cm} \setlength{\oddsidemargin}{1.5cm} \addtolength{\oddsidemargin}{-2.54cm} \setlength{\evensidemargin}{\oddsidemargin} \setlength{\textheight}{\paperheight} \addtolength{\textheight}{-\headheight} \addtolength{\textheight}{-\headsep} \addtolength{\textheight}{-\footskip} \addtolength{\textheight}{-3cm} \setlength{\topmargin}{1.5cm} \addtolength{\topmargin}{-2.54cm} \begin{document} \documentclass{article} \begin{document} This is a test \end{document} \end{document}
Hmmm, even this tells me "Code block produced no output"
#+begin_example
Test
#+begin_src latex :file asdf.pdf
Blabla
#+end_src
#+RESULTS:
#+begin_export latex
#+end_export
Test
#+begin_example
But I can compile the temporary tex file without problems.
I'm probably missing something fundamental...
Best,
Denis
Am 08.06.2022 um 09:43 schrieb Denis Maier:
> Hi everyone,
>
> for the documentation of my LaTeX courses I use examples that show the
> output next to the source code. I'm contemplating whether I should
> convert the documentation and examples to org, and use org-babel to
> include the examples. I think this should be possible with org-babel.
>
> However, I cannot manage to get this to work:
>
> #+begin_example
>
> Blabla
>
> #+begin_src latex :file test.pdf
> \documentclass{article}
> \begin{document}
> This is a test
> \end{document}
> #+end_src
>
> Blabla
>
> #+end_example
>
> Looking at the temporary latex file (see below) the reason is clear:
> Org babel exports this as a complete latex file although the example
> itself is already complete. Can I tell org somehow that this is not a
> fragment and should be compiled as is?
>
> Best,
> Denis
>
> \documentclass{article}
> \usepackage[usenames]{color}
> \usepackage[utf8]{inputenc}
> \usepackage[T1]{fontenc}
> \usepackage{graphicx}
> \usepackage{longtable}
> \usepackage{wrapfig}
> \usepackage{rotating}
> \usepackage[normalem]{ulem}
> \usepackage{amsmath}
> \usepackage{amssymb}
> \usepackage{capt-of}
> \pagestyle{empty} % do not remove
> % The settings below are copied from fullpage.sty
> \setlength{\textwidth}{\paperwidth}
> \addtolength{\textwidth}{-3cm}
> \setlength{\oddsidemargin}{1.5cm}
> \addtolength{\oddsidemargin}{-2.54cm}
> \setlength{\evensidemargin}{\oddsidemargin}
> \setlength{\textheight}{\paperheight}
> \addtolength{\textheight}{-\headheight}
> \addtolength{\textheight}{-\headsep}
> \addtolength{\textheight}{-\footskip}
> \addtolength{\textheight}{-3cm}
> \setlength{\topmargin}{1.5cm}
> \addtolength{\topmargin}{-2.54cm}
> \begin{document}
> \documentclass{article}
> \begin{document}
> This is a test
> \end{document}
> \end{document}
>
On Wednesday, 8 Jun 2022 at 09:43, Denis Maier wrote:
> However, I cannot manage to get this to work:
If you want to show the LaTeX, you need to add ":exports code" to the
src block, or ":exports both :results file" if you want to show both
code and the resulting PDF.
--
: Eric S Fraga, with org release_9.5.4-521-g1105da in Emacs 29.0.50
Am 08.06.2022 um 10:28 schrieb Fraga, Eric:
> On Wednesday, 8 Jun 2022 at 09:43, Denis Maier wrote:
>> However, I cannot manage to get this to work:
> If you want to show the LaTeX, you need to add ":exports code" to the
> src block, or ":exports both :results file" if you want to show both
> code and the resulting PDF.
>
:exports code works. But the problem with the other options is that the
compilation fails. But I cannot tell why. It just tells me "Code block
produced no output".
How can you diagnose such an issue?
On Wednesday, 8 Jun 2022 at 21:01, Denis Maier wrote: > :exports code works. But the problem with the other options is that the > compilation fails. But I cannot tell why. It just tells me "Code block > produced no output". This is not surprising as the LaTeX src blocks are expected to be LaTeX body only, not preamble etc. I.e. in your case, just the line that says "This is a test". You may wish to look at org-format-latex-header, org-babel-latex-preamble, org-babel-latex-end-env, ... > How can you diagnose such an issue? You can sometimes find the org babel files created in /tmp. -- : Eric S Fraga, with org release_9.5.4-521-g1105da in Emacs 29.0.50
Am 09.06.2022 um 09:47 schrieb Fraga, Eric: > On Wednesday, 8 Jun 2022 at 21:01, Denis Maier wrote: >> :exports code works. But the problem with the other options is that the >> compilation fails. But I cannot tell why. It just tells me "Code block >> produced no output". > This is not surprising as the LaTeX src blocks are expected to be LaTeX > body only, not preamble etc. I.e. in your case, just the line that says > "This is a test". You may wish to look at org-format-latex-header, > org-babel-latex-preamble, org-babel-latex-end-env, ... Exactly, I've found that out by looking at the file in temp. Testing with body only failed as well! I can however manually compile the temporary file. Anyway: This means you cannot switch to using complete files? I was hoping for something like :fragment nil or :complete-doc t > >> How can you diagnose such an issue? > You can sometimes find the org babel files created in /tmp. Anything else? I've found those files, but I was wondering whether Emacs could give me some more useful debug infos? (Especially since compiling the temporary files works...) Denis
On Thursday, 9 Jun 2022 at 09:58, Denis Maier wrote:
> Anything else? I've found those files, but I was wondering whether Emacs
> could give me some more useful debug infos? (Especially since compiling
> the temporary files works...)
Nothing else I know about. It's one of the weak points in the whole
babel ecosystem... If the underlying system writes to stderr, this does
get sent back to the user, but most src blocks fail silently when they
fail which is very frustrating.
--
: Eric S Fraga, with org release_9.5.4-521-g1105da in Emacs 29.0.50
Denis Maier <denismaier@mailbox.org> writes:
> Am 08.06.2022 um 10:28 schrieb Fraga, Eric:
>> On Wednesday, 8 Jun 2022 at 09:43, Denis Maier wrote:
>>> However, I cannot manage to get this to work:
>> If you want to show the LaTeX, you need to add ":exports code" to the
>> src block, or ":exports both :results file" if you want to show both
>> code and the resulting PDF.
>>
>
> :exports code works. But the problem with the other options is that the
> compilation fails. But I cannot tell why. It just tells me "Code block
> produced no output".
>
> How can you diagnose such an issue?
Hmm... Actually, I cannot reproduce the problem using emacs -Q and the
latest main.
Having bug.org:
-------------------
Blabla
#+begin_src latex :file test.pdf
\documentclass{article}
\begin{document}
This is a test
\end{document}
#+end_src
Blabla
-------------------
I ran C-c C-e l o
And got the expected pdf file open.
Best,
Ihor