How to markup org mode src block results? - emacs

In emacs org-mode, is it possible to apply markup to the RESULTS section of a SRC block output when exporting to PDF (or any export format)?
For example, here is a src code block:
#+BEGIN_SRC python :results output :exports both
print '*I would like this line to be bold*'
#+END_SRC
#+RESULTS:
: *I would like this line to be bold*
The RESULTS section is generated by the usual C-c C-c.
Normally org-mode will mark up text in * as bold, but it obviously doesn't do this if that text is in a RESULTS block (or, it appears in a SRC block). In my example, if I export this (PDF via Latex) then I just get the exact output of
*I would like this line to be bold*
...there's no markup.

Answering my own question.
There are formatting modifiers you can add in the header section of the SRC block to do what I want. One of them is 'raw'.
#+BEGIN_SRC python :results output raw
print '*I would like this line to be bold*'
#+END_SRC
#+RESULTS:
*I would like this line to be bold*
(Ironically on Stack Overflow I'm not sure how to mix code blocks and bold face, but the bold line is the result of running the code block in org-mode).
There is a full list of ways to format output here:
http://orgmode.org/manual/results.html#results

Related

How to use `reveal-code-focus` within `org-mode` in Emacs?

I would like to use reveal-code-focus within org-mode in Emacs (https://bnjmnt4n.github.io/reveal-code-focus/#/reveal-code-focus). Is there an example that someone could walk me through on how to do it? I have looked and looked but not found any help.
#+BEGIN_SRC python :results output
import random
random.seed(1)
print("Hello World! Here's a random number: %f" % random.random())
#+END_SRC
In the above example I want the background color for random.seed(1) to be highlighted when exporting to HTML using reveal.js.
Please note that, it is not for syntax highlighting but for code focus.

How can I stop org mode from moving my figures to the last page?

I'm currently trying to write up my thesis in emacs org-mode, and have run into some problems with file inclusions.
When I include figures with:
#+NAME: fig:banana
#+CAPTION: this is a figure caption
[[/path/to/image.png]]
(or using a pdf) it works fine. But when I insert another image, it is somehow moved to the end of the file instead of being inserted where it is called.
My pdf-export process (in my ~/.emacs file) looks like this:
(setq org-latex-pdf-process
'("latexmk -pdflatex='pdflatex -interaction nonstopmode' -pdf -bibtex -f %f"))
Any ideas on how to fix this?
A friend of mine pointed me to the LaTex package placeins.
#+LATEX_HEADER: \usepackage{placeins}
* section 1
** hi!
#+TITLE: fig:banana
#+CAPTION: this is a banana figure
[[/link/to/banana.png]]
\FloatBarrier
* section 2
The FloatBarrier stops floats (figures are floats) from jumping over them. I will need to look into passing [tbh] options to figures from org mode further.
Check the org-mode manual on how to pass placement options such as [h], [t] etc. to theLaTeX compiler.
If you're not sure how to control where figures (more precisely, floats) get placed by LaTeX, please refer to any introduction.
Or do you want the figure to be placed where you include it? If so, you might not need it to be a float.

how to highlight latex-syntax in org-mode but no effect on the produced PDF

I use org-mode+LaTex to take scientific notes and produce them to PDFs, I can use
#+BEGIN_src latex:
\begin{equation}
\int_\text{Birth}^{Death} work \mathrm{d} t = \text{LIFT}
\end{equation}
#+END_src
to highlight all latex codes between codes #+BEGIN_src latex .... #+END but if I don't delete this codes before I produce my org-document to PDF, I will get the unexpected #+BEGIN_src latex and #+END in the PDF.
Is there a more convenient way that can make latex syntax highlighted in org-mode with no unexpected codes left in PDF?
I searched some info about highlight source codes in org-mode, however, it seem no one concerns my demand that I simply only need the function of highlights of the latex syntax to make me edit easily, not the highlights in the resulting PDF.
Thanks a lot.
The (first?) problem is the colon after "latex" on the first line.

org-mode re-read header configuration

When I create a new org-mode file, I create a header similar to this:
#+TITLE: Some title
#+AUTHOR: Me
#+CATEGORY: things
#+STARTUP: align fold nodlcheck oddeven lognotestate
#+OPTIONS: H:4 num:nil toc:t \n:nil #:t ::t |:t ^:{} -:t f:t *:t
#+OPTIONS: skip:nil d:(HIDE) tags:not-in-toc
#+LANGUAGE: en
#+PROPERTY: header-args :results code :exports both :noweb yes
However, when I specify the #+PROPERTY setting, it doesn't take effect until I reopen the file.
How can I force org-mode to re-read header configuration without closing the buffer and reopening it?
You could do a M-x revert-buffer. This is, in short, a „re-open file from disk” macro.

Escaping org-mode footnote like text

I've got "[16]" in an org-mode file that is the text you would see in an ipython shell. How do I escape that text so that it does not generate an org-mode footnote? It's fine inside of an example block, but not in the general text. The first [16] is trouble and everything I've tried so far has not produced just straight normal "[16]" in the html output when I export the file.
#+BEGIN_SRC python
def setfrequency():
print 'Setting frequency'
# Write code here to set the frequency
setfrequency()
#+END_SRC
# This next line is the footnote problem
Run it again and you should see this, but the command number [16]
will be different for you:
#+BEGIN_EXAMPLE
In [16]: run sonar # This does not export as a footnote.
Setting frequency
#+END_EXAMPLE
Thanks!
You can escape syntax using =[1]= (code) or ~[1]~ (verbatim) blocks. See the Org-Manual section on Emphasis and Monospace.
* This will export the footnote style brackets verbatim
[1] by itself will fail
=[1]= and ~[1]~ will export as is.
The relevant portion of HTML export for this is
<p class="footnote"><sup><a class="footnum" name="fn.1" href="#fnr.1">1</a>
</sup> by itself will fail
<code>[1]</code> and <code>[1]</code> will export as is.
</p>
<p class="footnote"><sup><a class="footnum" name="fn.1" href="#fnr.1">1</a>
</sup> DEFINITION NOT FOUND: 1
I tried this way.
Run it again and you should see this, but the command number
#+latex: [16]
will be different for you: