1 min read

LaTeX autocompletion in RStudio

When I was working on my Masters thesis, I needed the latex autocompletion feature in Rsudio, but could not find it anywhere. There is no option to create custom snippet either. But recently I found some basic and necessary auto-completion for latex is available in RStudio. Following are some of the these you want to use, but remember to press Shift + Tab for autocomplete. Further this will only work on sweave or knitr file only, which is pretty obvious. But we can always create snippets for rmarkdown documents.

Section

keyword: sec

\section{section name}
\label{sec:section name}

Part

keyword: part

\part{part name} % (fold)
\label{prt:part name}

% part part name (end) 

Chapter

keyword: chap

\chapter{chapter name}
\label{cha:chapter name}

Equation

keyword: eq

\begin{equation}
  
\end{equation}

Figure

keyword: fig

\begin{figure}
\begin{center}
    \includegraphics[scale=]{Figures/}
\end{center}
\caption{}
\label{fig:}
\end{figure}

Tabular

keyword: tab

\begin{tabular}{c}

\end{tabular}

Matrix

keyword: mat

\begin{p/b/v/V/B/smallmatrix}
  
\end{p/b/v/V/B/smallmatrix}

Description List

keyword: desc

\begin{description}
  \item[] 
\end{description}

Enumerate List

keyword: enum

\begin{enumerate}
  \item 
\end{enumerate}

General Environment

keyword: begin

\begin{env}
  
\end{env}

Figure Reference

keyword: figure

Figure~\ref{fig:}

Table Reference

keyword: table

Table~\ref{tab:}

Citation

keyword: cite

\cite[]{}

Apart from these basic formatting options such as bf, sc, it and tt will also work.