Did you use graphical editor for LaTeX such as Texmaker? Ever wondering if Emacs can have the same feature (two vertical panels, one for code and one for real-time preview)? Yes, now you can have it in Emacs by using LaTeX Preview Pane extension. This Emacs extension is a work by John Singleton, big thanks for him.
Subscribe to UbuntuBuzz Telegram Channel https://telegram.me/ubuntubuzz to get article updates directly. 


Requirements

  1. Emacs (GUI mode)
  2. texlive-latex-base package installed
  3. pdflatex binary (satisfied by texlive-latex-binary)
  4. LaTeX Preview Pane extension in Emacs
Note: you can not use LaTeX previewing in Emacs console mode. Please read issue report 34.


Install pdflatex


To have pdflatex program installed in your Ubuntu system, you need to install texlive-latex-base package from official repository. Here is the command:

$ sudo apt-get install texlive-latex-base



Add LaTeX Preview Pane Repository


To install LaTeX Preview Pane, you need to enable MELPA, an extensions repository for Emacs. It's because this extension is available online at MELPA. To do it, edit your ~/.emacs file and add these configuration lines and restart Emacs. 

(require 'package) 
(add-to-list 'package-archives 
    '("melpa" . "http://melpa.milkbox.net/packages/") t)




Install LaTeX Preview Pane


To install LaTeX Preview Pane extension, do these steps inside Emacs:

Do this Emacs command:
M-x package-install
Then Emacs asks you for:
Install package:

Type there:
latex-preview-pane

Press Enter, and then Emacs downloads the package from the internet.


While installation is successful, you will see this message:



Configure The Pane


Add one another configuration line to your ~/.emacs file so the LaTeX Preview Pane will automatically show up whenever you open a LaTeX file document.

(latex-preview-pane-enable)



Using LaTeX Preview Pane


To use LaTeX preview in Emacs, you must start Emacs in GUI mode not in console mode. The easiest way is open Emacs from the desktop menu. Then, write a LaTeX (.tex) file and try to save it (C-x C-s) and you should see the preview on the right panel. If you don't know what LaTeX source code to write, just copy-paste my code below to your Emacs.


\documentclass[12pt]{article}
\title{Welcome To GNU Emacs \& \LaTeX}
\author{Ade Malsasa Akbar \\ teknoloid@gmail.com }
\date{27 December 2016}
\begin{document}
\maketitle
This article shows you the power of Emacs with \LaTeX{} preview support.
\end{document}

Bonus


You may see the special menu for LaTeX Preview Pane activated every time you activate LaTeX mode now.


References



, ,