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.
Related
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
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.
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.
I need to include HTML code in LaTeX and I'm using the listings package for that.
The problem is that if there is a $ character in my HTML code the color of the word after $ is broken in Emacs. To get the correct color I need to use another $.
For example:
\begin{lstlisting}
var mapElement = $("#map")[0];
var mapOptions = {
center: new google.maps.LatLng(43.720741,10.408413),
zoom: 10
};
\end{lstlisting}
After the $ character the text in the rest of the document isn't highlighted correctly.
I'm not using AUCTeX but the default latex-mode of Emacs.
Any ideas?
I had the same problem and found a nice work around at http://www.latex-community.org/forum/viewtopic.php?f=31&t=25036
Use the following to output a $ each time you type 4> in the Latex code:
\lstset{
literate={4>}{\$}1
}
then put your listing code in as normal
\begin{lstlisting}
ruby -e "4>(curl -fsSL\ https://raw.github.com/Homebrew/homebrew/go/install)"
\end{lstlisting}
which will work around highlighting issues and AucTeX will still look nice and pretty! (:
Original Response:
I was trying to figure out how in auctex mode latex doesn't seem to highlight any latex functions with flyspell turned on. Is this a custom dictionary file or how is this implemented? Can this be easily incorporated into an org-mode file so it doesn't highlight inserted latex code that will get exported.
Edit:
Simple example taken from top of file and in the text. Basically so latex syntax like ref or label inside {} won't be spell checked (this has been fixed by using (setq ispell-parser tex). Then also setting up a function that specific labels with #+ as the first text on the line won't be checked. I would want the caption checked but not #+LABEL: or #+TYP_TODO: (not shown. Also a way to add TODO keywords to not get checked. I can think of a way to do this is on startup add these to the LOCALWORDS: ispell places at the bottom of the file if not already there but is there an easier or better way to do this.
#+TAGS: NOTE REPORT export noexport MEETING
#+TYP_TODO: TODO Weekly WAITING NEXT | Meeting DONE
#+STARTUP: hidestars content hideblocks
The exponential running mean is shown for various alpha values in Figure \ref{fig:saturation_varying_alphaval_00f6set2}.
#+CAPTION: Plot of varying alpha values for the exponential running mean ($EM$) with $S_{min} = 0.0008 \text{ and } P_m = 0.20$
#+LABEL: fig:saturation_varying_alphaval_00f6set2
#+ATTR_LaTeX: width=0.4\textwidth placement=[h!tb]
flyspell internally uses ispell-mode. To change the way that ispell parses files set the variable ispell-parser to 'tex.
(add-hook 'org-mode-hook (lambda () (setq ispell-parser 'tex)))
Most likely auctex is using flyspell-mode-predicate to define what portions of the buffer shouldn't be spellchecked. (This answer shows how to do something similar for MoinMoinWiki.) org-mode already has such a function, org-mode-flyspell-verify, which apparently doesn't work properly for you... A quick look at the source suggests that org-remove-flyspell-overlays-in should be called for buffer portions containing code samples etc.
Sorry about the handwavy answer; marking this as community wiki to invite improvements.