henry atting <s...@online.de> writes:

> I have this latex code block:
>
> #+begin_src latex  :file foo.pdf
> \documentclass{article}
> \begin{document}
> ...some text...
> \end{document}
> #+end_src
>
> After evaluation the resulting file looks like this:
>
>
> article ...some text...
>
> I do not understand this. As far as I know it is possible to define the
> latex documentclass within a code block.

Currently the machinery used to generate images of inline latex
equations is used to evaluate latex code blocks.  So e.g., the following
works as "expected".

    #+begin_src latex :file write-fisher.pdf :results raw
    \begin{equation*}
      P_{i} = \frac{(2N)!}{i! (2N-i)!} p^{i}q^{2N-i}
    \end{equation*}
    #+end_src

    #+RESULTS:
    [[file:write-fisher.pdf]]

In this case it is all a matter of balancing what the majority of users
think is "expected".  If specifying a particular document class is
important, than I am sure that it shouldn't be hard to update the
org-babel-execute:latex function to check for the presence of
\begin{document} and handle those cases differently (in a similar way to
how org-babel-execute:C checks for a main function).

If specifying the document class is not required your example could be
converted to the (arguably preferable) example below.

    #+begin_src latex  :file foo.pdf :results raw
    ...some text...
    #+end_src

    #+RESULTS:
    [[file:foo.pdf]]

Cheers,

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

Reply via email to