How to only export results of code blocks and not the code that generates it - org-mode

I'd expect
#+begin_src plantuml :file foo.png :exports results
foo -> bar: JSON request
foo -> batz : instantiate batz\npassing resources from request
#+end_src
to only produce the resulting image in the exported document, but it exports both the plantuml code that produces it and the resulting image.
Any ideas what I can do to only export the images that are generated by the code block short of commenting out the code blocks after first generating the images?

I'm not allowed to comment so will provide an answer: this works fine for me with org 9.3.7 (i.e. only the image is exported, at least to PDF via LaTeX) so maybe it's a bug in the version of org you are using?
If posting this annoys anybody, I will delete.

Related

what does means #+keyword: means in org buffer

in emacs org mode, I saw #+ prefix many times. I think this is like option but I don't know what it is. I have tried to know them, I have been googling, but I couldn't find any good document. anybody know these symbol? is this org macros?
It is just plain text that you write in an org mode file. It may have two different functions:
1.- If you write it at the beginning of the file, it serves as a metadata descriptor or to include options for the file [1]. For example:
#+TITLE: This is the title of this file
#+AUTHOR: Loretta
#+DATE: 2022-10-15
#+STARTUP: content <--- option for displaying the contents
#+OPTIONS: H:3 toc:nil \n:nil #:t ::t |:t <--- different export options
2.- To create a block inside the file. This block may be code meant to be executed [2], a quotation, a comment, etc:
#+begin_src emacs-lisp
(+ 1 2 3 4 5 6 7)
#+end_src
#+begin_comment
Check the following paragraph. I am not really sure if it
has taken into account all the variables.
#+end_comment
[1] See https://orgmode.org/manual/In_002dbuffer-Settings.html for buffer settings and https://orgmode.org/manual/Export-Settings.html for export settings.
[2] See https://orgmode.org/manual/Literal-Examples.html for code blocks.

Stopping orgmode #+INCLUDE command showing up in PDF export

I have an orgmode file that I'm exporting to PDF via LaTeX. It imports another file containing tikz code to create a diagram using the #+INCLUDE "./tikz-code.org" command. This works fine and the diagram is included in the PDF with no problems. However the #+INCLUDE "./tikz-code.org" command is also included in the PDF file. Is there a way for me to stop this happening?
Many thanks,
David
Many thanks #Nick. I'm using version 8.2.10 (which comes with Ubuntu 17.04). I'm using the apa6 LaTeX class and my code is:
#+INCLUDE "./flow-chart.org"
#+ATTR_LATEX: :width 12cm
#+CAPTION: Chart Caption
#+LABEL: fig:flow-chart
#+RESULTS:
[[file:flow-chart.pdf]]

Embed contents of source file inside source block in an org mode document (latex)

In pseudo-code I'd like to do the following in my org-mode file:
#+BEGIN_src python
[[./a_python_script_whose_contents_i_want_in_my_document.py]]
#+END_src
i.e. have the entire contents of a separate file be embedded in my org-mode document when I export it to latex.
How do I embed the contents of a separate file within an org-mode document, and have that content be formatted as source code when exporting?
There is no way to do that in org-mode with a source block that I know of. This will give you what you want if you have minted setup:
\inputminted{python}{your-script.py}
or if you use lsting
\lstinputlisting[language=Python]{source_filename.py}

how can I display knitR markdown in a pandoc rendered pdf

I wish to show the knitR code in the final PDF together with its execution result.
I did not find yet a working way to fence "tripple-backticks"{r}..."tripple-backticks" blocks in the knitR code and see them as-is in the final PDF.
The backticks get interpreted whatever I do.
This is for tutorial purpose so that people see how to write knitR markdown. The use of html "pre" tags around the block of code leads to removal of the code.
for instance I wish to see this example fully first and then the result thereof
adding 4 spaces before each line like here does not work in RStudio and knit HTML fails
```{r test-haskell, engine='haskell', engine.path='ghc', cache=TRUE}
[x | x <- [1..10], odd x]
```
follow-up addition
I include here some RStudio Rmd code that leads to unexpected PDF content
in the pdf, the pre-code block simply disappeared.
The only fix I found is to invent a fake tag 'rmd' to fence the pieces of markdown I wish to keep as-is. I suspect this is a pandoc issue rather than knitr, unless there is a better way to fence code in knitr. The code I wish to keep can be any of bash, perl, R, or any other manguage used to process the data in the knitr tutorial.
my pandoc command was:
pandoc --variable=geometry:'top=1.5cm, bottom=1.5cm, left=2cm,
right=1cm' --variable=papersize:'a4paper' --number-sections
--table-of-contents --template=default.latex --highlight-style tango testrmd.md -o testrmd.pdf
Can it come from the template I used (default.latex)? It is the only template I found that meets my needs for vignette-like output. Same about 'tango' which is the only coloring scheme that shows some light background in code blocks.
As you see from the screenshots above I am a new-bee here (both in markdown and latex). Thanks for any help

How to define latex format conveniently in org-mode?

In the latex-mode, we can make a tex file to fill it with all settings we want, e.g.call it as usual.tex, and put its location at the head of all tex files we would like to debug, as follow:
\input{path_of_usual.tex/usual}
we can type codes simply between
\begin{document}
and
\end{document}
with the all settings filled in usual.tex.
And here my purpose is to do the similar thing in org-mode -xelatex, what commands I need to add into .emacs ?
It seem to add such commands in .emacs
(add-to-list 'org-export-latex-classes
'("my-article"
"\\documentclass......
\\usepackage{.....
can define the latex format via the code in org-file : #+LATEX_CLASSES my-article.
but I replaced all \\.... of \\input{location_of_usual.tex/usual}, the org-file can't produce PDF-file, giving the message:
No definition of class 'usual' in 'org-export-classes'
What is the correct set-up?
I made a lot tries to deal with, but failed, such as:
#+LaTeX:\input{location}
emacs still shows the error message, saying:
no definition of class 'usual' in 'org-export-classes'
can define the latex format via the code in org-file :
#+LATEX_CLASSES my-article.
This is a typo, the file header directive is #+LATEX_CLASS:. Changing
that should let you export to pdf.
but I replaced all \\.... of \\input{location_of_usual.tex/usual},
the org-file can't produce PDF-file, giving the message:
No definition of class 'usual' in 'org-export-classes'
I think you are mixing up things, earlier you said you added your own
export class called my-article, but the above error message suggests you
used "usual".
What is the correct set-up?
I made a lot tries to deal with, but failed, such as:
#+LaTeX:\input{location}
Here if you wish the \input{..} line to appear outside the
\begin{document}...\end{document} you should use the #+LATEX_HEADER:
directive instead.
PS: I think these are more appropriate for the org-mode mailing list.