How can I find out (in AUCTeX) if \frac{}{}
and \bm{}
have predefined keyboard shortcuts?
I couldn't find these two.
[Tex/LaTex] emacs auctex: how to get \frac{}{} and \bm{}
auctexemacs
Related Solutions
I have everything mostly working now. I neglected to actually load the packages in my .emacs
file. I still can't get preview-latex
to work right (keeps bombing out), but I'm going to keep researching that issue. I've also modified my default pdf viewer. Below is the relevant portion of my .emacs
file:
;; Adds stuff to my PATH (LaTeX, etc)
(setenv "PATH" (concat (getenv "PATH") ":/usr/texbin"))
;; Set the default LaTeX exec to pdfTeX
(setq TeX-PDF-mode t)
;; Load AucTeX!! :D
(load "auctex.el" nil t t) ;; loads tex-site in such a way so that it can be undone
(load "preview-latex.el" nil t t) ;; actual preview-latex
;; Sets the default PDF viewer to, well, the default PDF viewer.
(setq TeX-view-program-list '(("Shell Default" "open %o")))
(setq TeX-view-program-selection '((output-pdf "Shell Default")))
Then, I figured out that GhostScript was in fact not installed on my machine (as MacTeX 2012 should have done), so I just installed it. Now it's saying 'no preview images'. Working on that.
This procedure will set up Emacs, AUCTeX, and the Okular viewer to handle integrated forward and inverse search. (These instructions were tested on a Debian system)
Install Emacs. To install Emacs, open up the terminal and type the command:
sudo apt-get install emacs
Install AUCTeX.
Within Emacs, run
M-x package install RET auctex RET
.To test for a successful installation, just open up a
.tex
file Emacs with and you will see new menus concerning LaTeX.Install Okular.
sudo apt-get install okular
If not already done, open a tex file with emacs.
- In the LaTeX menu, go to "Customize AUCTeX" and click on "Extend this menu".
- Then go again to LaTeX, "Customize AUCTeX", go to the "Tex Command" submenu and click on the included "Tex command" item.
From within Emacs, run
M-x customize-group RET TeX-command RET
You are now in the "Tex command group" configuration buffer. Scroll down until you reach "Tex Pdf Mode". Its value is off (nil); click on the "Toggle" button to activate this mode. Click on the "State" button and select "Save for Future Sessions". AUCTeX will now compile your TeX file using
pdflatex
.You should see something like this:
For the "Save for Future Sessions", the button with the green down arrow can also be selected. When this is done, your
.emacs
will be updated accordingly.Still in the "Tex command group" configuration buffer, scroll all the way down and click on the special item called "Tex View". In the "Tex view group" buffer, you have two things to do:
- activate the correlate mode between the PDF and the TeX file, and
- declare a PDF viewer which can read these correlations.
To activate the correlate mode:
- item "Tex Source Correlate Method", click on the "Value Menu" button and select "synctex" and save for future sessions,
- item "Tex Source Correlate Start Server", select "Always" and save,
- item "Tex Source Correlate Mode", toggle it on and save.
To set Okular as the default PDF viewer:
- (NOTE: this is necessary only if you are using AUCTeX 11.87 or lower, in which case you really should upgrade the package to a more recent version) item
Tex View Program List
then clickINS
- name:
Okular
- choice:
Command
- command:
okular --unique %o#src:%n%b
- name:
item
Tex View Program Selection
then clickINS
- choice:
Single predicate
- single predicate:
output-pdf
viewer:
Okular
If you just added Okular to the Tex View Program List, this choice might not appear. Restart Emacs or
Set for Current Session
to have it show up.
- choice:
- (NOTE: this is necessary only if you are using AUCTeX 11.87 or lower, in which case you really should upgrade the package to a more recent version) item
Set and save both for future sessions.
To configure Okular: in the Okular window, go to the "Settings" menu, item "Configure Okular", "Editor", select Emacs client.
To use Forward search from Emacs to Okular, just hit
C-c C-v
or click on the glasses button of the tool-bar to call the viewer. Okular will center its display on the intended line of the pdf.To use Inverse search from Okular to Emacs, make sure that the Browse Tool (in the Tools menu of Okular) is enabled; then just hit Shift+Left mouse click on the pdf. Emacs will come up and position the cursor at the intended line of the TeX source.
As a sidenote, AUCTeX can also jump-to errors generated in the log file with a C-c `
.
If this keystroke throws an error, see Uninformative error message when using AUCTeX for
an Emacs-based (i.e. cross-platform, works with the major distributions) solution.
Best Answer
I can't find anything like that in the auctex documentation, but if you'd like to have shortcuts for them, add the following lines to your .xemacs/init.el file (if you use xemacs) or your .emacs file (if you use emacs):
You can then insert
\frac{}{}
and put point inside the first pair of braces by typingControl-c f
and you can insert\bm{}
and put point inside the braces by typingControl-c b
.