How to use Auctex + preview-latex + orgmode in emacs - emacs

I use Emacs orgmode exclusively. I installed auctex from Melpa. My understanding is that preview-latex is packaged with auctex with no special setup required.
I can't seem to summon preview-latex on any inline latex equations
It seems like I have to change from orgmode to latex-mode to get the "latex" option in the toolbar.
What am I doing wrong here?
Thank you

You are not doing anything wrong: org-mode has its own latex preview mechanism and does not use (indeed, cannot use) preview-latex. There was talk a long time ago on the ML about integrating preview-latex into org-mode, but it has never been done.

The best method I found to preview latex in orgmode is:
sudo apt-get install dvipng
Restart emacs
Place point at the beg of a latex inline equation in one of my .org files
C-c C-x C-l
Equation goes from this:
$$\frac{a}{b} \cdot \frac{c}{d} = \frac{a \cdot c}{b \cdot d} = \frac{product\ of\ numerators}{product\ of\ denominators}$$
To this:
Use C-c C-x C-l to revert.
I do have Auctex installed (though I don't think dvipng uses it at all. And in my emacs init file I have:
* AucTex: Require AucTex
(require 'tex-site')
* LaTeX: Enable LaTeX Math mode by default
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
This is very sweet!

make sure dvipng dvisvgm installed correctly
(executable-find "dvipng")
(executable-find "dvisvgm")
then add
(setq org-latex-compiler "xelatex")
to your init.el
to make default latex compiler as xelatex

Related

Emacs org-mode export markdown

I have some weird behavior, I don't actually know if it's a bug or something else.
When I do C-c C-e the option to convert to markdown doesn't appear. Nonetheless I can type the option M-x org-md-export-as-markdown and after I do that, the option export to markdown appears in the C-c C-e menu.
Any Ideas?
If you are using Org-mode version 8.0 or later (check with M-x org-version), the export framework is broken up into several libraries that are not necessarily loaded by default.
Something like this in your Emacs configuration can load the Markdown exporter automatically with Org-mode:
(eval-after-load "org"
'(require 'ox-md nil t))
After emacs 25,you just need add a line in your emacs configuration file: .emacs
(require 'ox-md nil t)
M-x customize-variable <Ret> org-export-backends <Ret>
check option 'md', then save.

What is the difference of tex-mode and latex-mode and LaTeX-mode in emacs

I am configuring AUCTeX in emacs.
Most of the configurations are put in a LaTeX-mode-hook. When I open a main.tex file, I notice that the major mode is latex-mode and my hooked configurations are not activated. I have to M-x Tex-latex-mode to activate them. But the major-mode is still latex-mode.
(add-hook 'LaTeX-mode-hook
(lambda ()
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; auctex
(setq TeX-auto-save t)
(setq TeX-parse-self t)
))
So I would like to know what is the difference of these modes and how can I turn on AUCTeX automatically when I open a *.tex file.
The modes provided by AUCTeX are listed at https://www.gnu.org/software/auctex/manual/auctex.html#Modes-and-Hooks and they are
plain-TeX-mode
LaTeX-mode
ams-TeX-mode
ConTeXt-mode
Texinfo-mode
docTeX-mode
Instead,
tex-mode
plain-tex-mode
latex-mode
slitex-mode
doctex-mode
(note the different capitalization) are the major modes provided by the TeX mode package shipped with Emacs.
If you want to open all *.tex files with AUCTeX LaTeX mode add this to your .emacs:
(add-to-list 'auto-mode-alist '("\\.tex$" . LaTeX-mode))
Actually, this shouldn't be necessary, because AUCTeX defines the tex-mode.el mode names as alias of its own modes.
TLDR: Use latex-mode or LaTeX-mode (they mean the same thing), no need to change auto-mode-alist, and use LaTeX-mode-hook for hooking into AucTeX.
Setting up AucTeX can be quite confusing, because it uses advice to override Emacs' built-in support for TeX and friends.
So, after installing AucTeX from ELPA, you should see the following in C-h f latex-mode:
This function has :override advice: ‘TeX-latex-mode’.
Same for all the other tex modes, though the list of modes that AucTeX overrides depends on the value of the TeX-modes variable.
The function LaTeX-mode is not defined in AucTeX (any more?): it's defined in core Emacs, with a cryptic comment about compatibility:
;; The following three autoloaded aliases appear to conflict with
;; AUCTeX. However, even though AUCTeX uses the mixed case variants
;; for all mode relevant variables and hooks, the invocation function
;; and setting of `major-mode' themselves need to be lowercase for
;; AUCTeX to provide a fully functional user-level replacement. So
;; these aliases should remain as they are, in particular since AUCTeX
;; users are likely to use them.
;; Note from Stef: I don't understand the above explanation, the only
;; justification I can find to keep those confusing aliases is for those
;; users who may have files annotated with -*- LaTeX -*- (e.g. because they
;; received them from someone using AUCTeX).
;;;###autoload
(defalias 'TeX-mode #'tex-mode)
;;;###autoload
(defalias 'plain-TeX-mode #'plain-tex-mode)
;;;###autoload
(defalias 'LaTeX-mode #'latex-mode)
What this all means is that, at least in 2021, you do not need to change auto-mode-alist to use AucTeX; just installing it is enough for it to override Emacs' builtin functionality.
Unfortunately, there's one last source of confusion. Even though LaTeX-mode is now mostly just a useless alias for latex-mode, it turns out that code in AucTeX that overrides latex-mode does not call latex-mode-hook (it calls LaTeX-mode-hook, which is different. So the LaTeX- variables, which are the AucTeX ones (as opposed to the lowercase ones that are builtin with Emacs), are still useful.

Quiet mode for pdfLaTeX in emacs

I've begun to use emacs as a pdfLaTeX writer/compiler, which is just brilliant.
However, whenever I execute TeX file (C-c C-f), which currently executes the following:
(setq latex-run-command "pdflatex")
I get an awful lot of verbose output from pdfLaTeX.
Is there a way to change this behaviour? I thought of (setq latex-run-command "pdflatex -interaction=batchmode") but this doesn't seem to do the trick.
When doing LaTex in emacs you should use the package named AUCTeX. This fixes your problem and has a lot of extra functionality.

running scheme from emacs

I'm a newbie to LISP.
I am attempting to invoke the scheme interpreter from within emacs (version 23 running on windows). I loaded the xscheme library by telling emacs to M-x load-library and then entering xscheme at the prompt in the minibuffer. The library loaded, and then I issued the M-x run-scheme command. (I realize that all this loading can be done from .emacs at startup, but I am not concerned with that at the moment.)
So far so good - the *scheme* buffer has been created, and now I'm hoping that I'm able to talk to the scheme interpreter.
However, when I try to evaluate something in that *scheme*buffer (e.g. (define shoe-size 14)), I get this Output file descriptor of scheme is closed message in the minibuffer.
Does anybody know how to fix this in emacs?
(Also, how does one set the major-mode as REPL in the *scheme* buffer?)
Thank you.
Try setting the scheme-program-name variable to the path to your Scheme interpreter. The major-mode of the scheme buffer is probably just comint and you cannot do much about it unless you switch to something more capable like Geiser - something that I'd recommend you do.
Add this line to your .emacs file:
(setq scheme-program-name "gsi")
(Replace "gsi" with the name of your Scheme interpreter.)
You can then start the interpreter with M-x run-scheme. You can evaluate pieces of code by using C-x C-e (to evaluate the sexp before the point) or with C-M-x to evaluate the sexp you're in right now. You can also load a file with C-c C-l.
I'll start by saying that I'm very new to programming, scheme and SICP, but I'm trying to work through the course and watch the lectures that are online.
I'm running emacs on Ubuntu 12.10 and I really wanted to get MIT scheme working in emacs instead of relying on Edwin.
The above tips didn't work for me, but here's the step-by-step instructions that did work:
Install emacs 24 from the Ubuntu Software Center (search "emacs" and install it!)
Open a terminal (ALT + CTRL + t)
Go to your home directory (cd ~)
Open the hidden file .emacs in gedit (gedit .emacs)
On the first line of the file, type exactly what's after the colon: (require 'xscheme)
Save the changes to .emacs
That's it!!!
You can now open .scm files in emacs and use commands like C-x C-e.
*directions courtesy of http://alexott.net/en/writings/emacs-devenv/EmacsScheme.html#sec14
My guess is that it's just a known issue I still dunno how to sort that out (it's out of my current skills) but I got a macro that probably helps: just after writing the s-exp you can do Cc-Cz (it calls the geiser REPL) then C-spc, C-M-b, M-w, C-x-o, C-y and RET.
There are a variation (same, placed just after writing the s-exp): C-spc, C-M-b, M-w, C-c Cz, C-y and RET

Customizing Literate Haskell + LaTeX mode

I'm having a hard time forcing literate-haskell-mode to produce PDFlatex output by default. When I use C-c C-t C-f it just parses the lhs file with latex binary producing dvi. I know I can always use the shell to manually run pdflatex whatever.lhs, but that's not the emacs way. There must be a way of customizing the default C-c C-t C-f behavior, but I've been googling and searching, and I still haven't found what I'm looking for.
Anyone?
Cheers;
Piotr
I guess this uses LaTeX-mode in the backend so probably something like this should help:
(setq TeX-PDF-mode t)
This tell LaTeX-mode to use pdflatex by default.