LaTex with Vim
What is LaTeX
LaTex
is a document preparation system for high-quality typesettingIt 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 anythingIt 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 protipInstallation details are below
- Mac OS - http://www.tug.org/mactex/
- Linux - http://linuxandfriends.com/install-latex-in-ubuntu-linux/
- Windows - http://www.tug.org/protext/
- http://latex-project.org/ftp.html
LaTeX and Vim
I'm gonna use Vim as the LaTex file editing IDE
There is a vim plugin call
vim-latex-live-preview
https://github.com/xuhdev/vim-latex-live-preview#readmeThis plugin provides a live preview of the output PDF of your LaTeX files
Install vim-latex-live-preview
I have installed the plugin by using vim
pathogen
(I have already configured/synchronized my vim plugin withgit submodule
andpathogen
)More information about installing vim plugins with
pathogen
http://vimcasts.org/episodes/synchronizing-plugins-with-git-submodules-and-pathogen/Following is the plugin installation commands
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
configurationsSet 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'
More information about PDF viewer setting can be find from here
https://github.com/xuhdev/vim-latex-live-preview/wiki/Known-Working-PDF-ViewersFollowing is a screenshot of my
~/. vimrc
configuration file
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}
- Use following command to get the PDF preview of the document
:LLPStartPreview
- This command will generates the PDF preview of you LaTeX document
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
References
- http://computers.tutsplus.com/tutorials/the-beginners-guide-to-using-tex-in-os-x--mac-45177
- http://www.topbug.net/blog/2013/06/13/live-preview-of-latex-in-vim/
- https://github.com/xuhdev/vim-latex-live-preview#readme
- https://github.com/xuhdev/vim-latex-live-preview/wiki/Known-Working-PDF-Viewers
- LaTeX templates - http://www.latextemplates.com/
- Online LaTeX editor - https://www.writelatex.com/
Related protips:
Written by eranga bandara
Related protips
2 Responses
Nice explanation.
~ 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