Builtin Tex Mode in Emacs
I have been using the builtin Mode for a few months until I found out that Auctex is the ultimate Editor for Latex. I do not even know why people will use other Editor such as Lyx.
Emacs build in Tex Mode
Emacs provides special major modes for editing files written in TeX and its related formats. TeX mode has four variants: Plain TeX mode, LaTeX mode, DocTeX mode, and SliTeX mode. LaTeX is a simplified input format for TeX, implemented using TeX macros. DocTeX is a special file format in which the LaTeX sources are written, combining sources with documentation. SliTeX is an obsolete special form of LaTeX.
Latex Preview Panel for Emacs
1 2 3 |
git clone https://github.com/jsinglet/latex-preview-pane.git |
1 2 3 4 5 6 7 8 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;latex-preview-panel ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (add-to-list 'load-path "/home/tan/config/emacs/extend/latex-preview-pane") (require 'latex-preview-pane) (latex-preview-pane-enable) |
using xelatex engine instead of latex:
Click the “customize LaTeX Preview Pane” in the menus. You’ll see a box for the TeX command. Set it to “xelatex.”
Auctex -the ultimate Tex Editor with with buitlin Preview for Emacs
AUCTeX is an extensible package for writing and formatting TeX files in GNU Emacs and XEmacs. It supports many different TeX macro packages, including AMS-TeX, LaTeX, Texinfo, ConTeXt, and docTeX (dtx files). – from Auctex Official Site.
Installing Auctex
Install as Emacs package
M-x list -package -> search auctex version -> i -> x
Manual install
1 2 3 4 5 6 7 8 |
wget http://ftp.gnu.org/pub/gnu/auctex/auctex-11.91.tar.gz tar -zxvf auctex-11.91.tar.gz cd auctex-11.91 ./configure --prefix=/home/tan/config/emacs/extend/auctex --with-lispdir=/home/tan/config/emacs/extend/auctex --with-texmf-dir=/home/tan/texlive/texmf-local/ make make install |
Emacs configuration
Shamelessly taken from here, another good resource. The Auctex cheatsheet is very useful.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
(add-to-list 'load-path "~/config/emacs/extend/auctex") (load "auctex.el" nil t t) (load "preview-latex.el" nil t t) (setq TeX-auto-save t) (setq TeX-parse-self t) (setq TeX-save-query nil) (setq-default TeX-engine 'xetex) (setq TeX-PDF-mode t) ;; Use pdf-tools to open PDF files (setq TeX-view-program-selection '((output-pdf "PDF Tools")) TeX-source-correlate-start-server t) ;; Update PDF buffers after successful LaTeX runs (add-hook 'TeX-after-TeX-LaTeX-command-finished-hook #'TeX-revert-document-buffer) |
Preview issues due to Ghostscript
The preview-latex subsystem from Auctex is a state of the art Latex preview tool.
preview-latex equips your source buffer with a sophisticated WYSIWYG previewing and folding conglomerate that revolutionalizes the edit-compile-preview cycle. That means, instead of LaTeX constructs, images of their typeset output are placed in the buffer. It is therefore particularly suited for easing the creation of complex content like math formulas, programmed graphics, or text transcriptions.
I have wasted a couple of hours on this issue (reported here and here). Apparently ghostscripe removed the .runandhide operator in version 9.22, so it is likely that this causes the problem.
So what I did is to downgrade Ghostscript to 9.21.3 and everything goes back to normalcy.
1 2 3 4 5 |
pacaur -y downgrade sudo downgrade ghostscript # then pick version 9.21.3 |
Load a tex with some equation and figures etc, press C-c C-c C-p, you will see the beautifully rendered preview, move cursor to a section, it will automagically switch to Latex code for you to edit.
If you want to view PDF file in (Okular or PDF-Tools), press C-c C-c -> View, the PDF frame (or Okular window) will pop up. Make some changes and save your tex file with C-x C-s, you PDF will be updated automagically.
Works fine with Chinese too.
Postamble
Following code was used to generate the Auctex logo. It was modified from the original one.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
% Copyright (C) Free Software Foundation, Inc. % License: GNU GPLv3 or later % Modified from Auctex, Y. Tan \documentclass{article} \usepackage{crimson,listings,tikz,geometry} \geometry{paperwidth=7.5mm,paperheight=7.5mm} \definecolor{bg}{HTML}{454545}\pagecolor{bg} \definecolor{fg}{HTML}{66a7a7}\color{fg} \lstset{basicstyle=\color{fg!65!bg}\ttfamily, commentstyle=\itshape,language={[LaTeX]TeX}} \begin{document} \begin{tikzpicture}[overlay] \coordinate (a) at (-7.26pt,1.89098pt) {}; \node[inner sep=0pt] at (-0.265,0.07) {\resizebox{6.4mm}{!} {\lstinputlisting{\jobname}}}; \node[inner sep=0pt,align=center] at (a) {\hbox{\color[HTML]{008000}A}\kern-0.05em% \hbox{\color[HTML]{FF0000}U}\kern-0.03em% \hbox{\color[HTML]{1E90FF}C}\\[-0.7ex]% \hbox{\color[HTML]{FF5733}T}\kern-.15em\lower.46ex% \hbox{\color[HTML]{242320}E}\kern-.06em% \hbox{\color[HTML]{CCCC00}X}}; \end{tikzpicture} \end{document} %%% Local Variables: %%% mode: xelatex %%% TeX-master: t %%% End: |
NOV
About the Author:
Beyond 8 hours - Computer, Sports, Family...