Last Updated: November 19, 2020
·
24.97K
· itseranga

LaTex with Vim

What is LaTeX

  • LaTex is a document preparation system for high-quality typesetting

  • It can also introduce as a document markup language

  • LaTeX is based on Tex

  • More info - http://www.latex-project.org/

What is TeX?

  • TeX is a very powerful typesetting language that can be used to write almost anything

  • It was designed and developed by Donald Knuth, a professor at Stanford University

  • TeX is used heavily in the academic and scientific world

How to install LaTex

  • LaTeX version available for Mac is MacTex

  • Please note that, I'm using MacTeX on rest of this protip

  • Installation details are below

  1. Mac OS - http://www.tug.org/mactex/
  2. Linux - http://linuxandfriends.com/install-latex-in-ubuntu-linux/
  3. Windows - http://www.tug.org/protext/
  4. http://latex-project.org/ftp.html

LaTeX and Vim

Install vim-latex-live-preview

cd ~/.vim
git submodule add https://github.com/xuhdev/vim-latex-live-preview.git bundle/vim-latex-live-preview
  • You have to specify vim-latex-live-preview plugin related configurations in your ~/. vimrc file

vimrc configurations

  • Following are the ~/. vimrc configurations

  • Set the vim option updatetime to a smaller value, which is the frequency that the output PDF is updated

autocmd Filetype tex setl updatetime=1
  • Set the PDF viewer. I'm using Preview viewer here
let g:livepreview_previewer = 'open -a Preview'

Picture

Working example

  • First goto your workspace and create a LaTeX document (LaTeX document should be with .tex format)
cd ~/Documents/senzors
touch introduction.tex
  • Add following sample text to the introduction.tex
\documentclass{article}

\title{SenZors}
\author{Sustainable Computing Research}
\date{October 2014}
\maketitle

\begin{document}

\section{Introduction}

Real time communication platform for sensor devices

\subsection{What is SneZors}

Secured platform to share your sensor data

\subsection{Why SneZors}

Keep sharing your sensors

\section{Technologies}

\begin{enumerate}
\item Websockets 
\item Android
\item IOS
\end{enumerate}

\section{Downloads}

\hyperref{''https://play.google.com/store/apps/details?id=com.score.senzors&hl=en''}

\end{document}

Picture

  • Use following command to get the PDF preview of the document
:LLPStartPreview
  • This command will generates the PDF preview of you LaTeX document

Picture

  • Now when you changing the text in your LaTeX document, you can see the live update of the changes (in PDF document)

  • Following is an example preview

Picture

References

Related protips:

Basic Vim commands - For getting started

2 Responses
Add your response

Nice explanation.

over 1 year ago ·

~ cd .vim
āžœ .vim git submodule add https://github.com/xuhdev/vim-latex-live-preview.git bundle/vim-latex-live-preview
fatal: Not a git repository (or any of the parent directories): .git

over 1 year ago ·