all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Include LaTeX source and compiled result
@ 2022-06-08  7:43 Denis Maier
  2022-06-08  7:48 ` Denis Maier
  2022-06-08  8:28 ` Fraga, Eric
  0 siblings, 2 replies; 8+ messages in thread
From: Denis Maier @ 2022-06-08  7:43 UTC (permalink / raw)
  To: Org Mode List

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}



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

* Re: Include LaTeX source and compiled result
  2022-06-08  7:43 Include LaTeX source and compiled result Denis Maier
@ 2022-06-08  7:48 ` Denis Maier
  2022-06-08  8:28 ` Fraga, Eric
  1 sibling, 0 replies; 8+ messages in thread
From: Denis Maier @ 2022-06-08  7:48 UTC (permalink / raw)
  To: Org Mode List

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}
>



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

* Re: Include LaTeX source and compiled result
  2022-06-08  7:43 Include LaTeX source and compiled result Denis Maier
  2022-06-08  7:48 ` Denis Maier
@ 2022-06-08  8:28 ` Fraga, Eric
  2022-06-08 19:01   ` Denis Maier
  1 sibling, 1 reply; 8+ messages in thread
From: Fraga, Eric @ 2022-06-08  8:28 UTC (permalink / raw)
  To: Denis Maier; +Cc: Org Mode List

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

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

* Re: Include LaTeX source and compiled result
  2022-06-08  8:28 ` Fraga, Eric
@ 2022-06-08 19:01   ` Denis Maier
  2022-06-09  7:47     ` Fraga, Eric
  2022-06-11  8:38     ` Ihor Radchenko
  0 siblings, 2 replies; 8+ messages in thread
From: Denis Maier @ 2022-06-08 19:01 UTC (permalink / raw)
  To: Org Mode List

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?


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

* Re: Include LaTeX source and compiled result
  2022-06-08 19:01   ` Denis Maier
@ 2022-06-09  7:47     ` Fraga, Eric
  2022-06-09  7:58       ` Denis Maier
  2022-06-11  8:38     ` Ihor Radchenko
  1 sibling, 1 reply; 8+ messages in thread
From: Fraga, Eric @ 2022-06-09  7:47 UTC (permalink / raw)
  To: Denis Maier; +Cc: Org Mode List

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

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

* Re: Include LaTeX source and compiled result
  2022-06-09  7:47     ` Fraga, Eric
@ 2022-06-09  7:58       ` Denis Maier
  2022-06-09 11:49         ` Fraga, Eric
  0 siblings, 1 reply; 8+ messages in thread
From: Denis Maier @ 2022-06-09  7:58 UTC (permalink / raw)
  To: Org Mode List



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


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

* Re: Include LaTeX source and compiled result
  2022-06-09  7:58       ` Denis Maier
@ 2022-06-09 11:49         ` Fraga, Eric
  0 siblings, 0 replies; 8+ messages in thread
From: Fraga, Eric @ 2022-06-09 11:49 UTC (permalink / raw)
  To: Denis Maier; +Cc: Org Mode List

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

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

* Re: Include LaTeX source and compiled result
  2022-06-08 19:01   ` Denis Maier
  2022-06-09  7:47     ` Fraga, Eric
@ 2022-06-11  8:38     ` Ihor Radchenko
  1 sibling, 0 replies; 8+ messages in thread
From: Ihor Radchenko @ 2022-06-11  8:38 UTC (permalink / raw)
  To: Denis Maier; +Cc: Org Mode List

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


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

end of thread, other threads:[~2022-06-11  8:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-08  7:43 Include LaTeX source and compiled result Denis Maier
2022-06-08  7:48 ` Denis Maier
2022-06-08  8:28 ` Fraga, Eric
2022-06-08 19:01   ` Denis Maier
2022-06-09  7:47     ` Fraga, Eric
2022-06-09  7:58       ` Denis Maier
2022-06-09 11:49         ` Fraga, Eric
2022-06-11  8:38     ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.