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

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.

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 to markup org mode src block results?

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

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.

Mark-up for bold and italic in emacs org-mode

In emacs org-mode, we can use mark-ups to set Emphasis and monospace.
e.g.
*bold*
/italic/
How can we make a word both bold and italic?
It seems neither */.../* nor /*...*/ works.
In fact, both of these do work.
/*test*/
exports to HTML as
<i><b>test</b></i>
*/test/* works similarly. LaTeX / PDF export also works as you expect.
Org itself doesn't fontify both the bold and italic, but the semantics are fine.
Expanding on #Chris answer covering semantics being there, if you're interested in visible fontification effect inside your org notes, you have three approaches:
Highlight parts of your text
Nesting works nicely as long as you don't need to start / end two tags at once.
Use multiple tags with escape symbols
The closest you can get is
The code is:
*\ /\ _\ ~fontification can be nested~\_\/\*
So you need \​​ ​ (backslash and space) to escape following opening tags and \ (backslash) to escape following closing tags.
The need for space is annoying, and in it looks like this when exported to html:
So yes, you can have multiple mark-ups at once, but you have to choose between seeing the effect in emacs or having it nicely formated on export.
Modify how markup looks in emacs
Alternatively you could change how mark-up looks in emacs without modyfing exporting format, i.e. to make bold look red you'd need this:
(add-to-list 'org-emphasis-alist
'("*" (:foreground "red")
))
as covered in this great question and answer.

FlySpell in Org-Mode recognize latex syntax like auctex

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.