How I have setup my LaTeX-editor in Visual Studio Code
In this post I will show you how I have setup local LaTeX editing with full CAS-functionality and snippets in Visual Studio Code.
# LaTeX
First, a LaTeX distribution is of course necessary. It is essential to the plugins I use that the LaTeX distribution contains or supports Pearl. A good recommended distribution is TeX Live, which is what I use.
When I installed LaTeX the first time, I was quite discouraged when I discovered that installation took almost two hours. I therefore plan ahead whenever I need to reinstall LaTeX or setup a new device with LaTeX. I recommend that you also plan ahead if you decide to try it out yourself.
# Python
I have stumbled upon some pretty cool plugins in Visual Studio Code that can be utilized from within LaTeX. One of these plugins, Latex SymPy Calculator, gives a lot of CAS functionality. This plugin and some others require Python to work. Python can be downloaded here.
Furthermore, some required Python packages are SymPy, latex2sympy and Flask. These can all be installed via. pip. These are the packages that allow CAS functionality. You can read more about the requirements for CAS functionality here.
The command to install these packages with pip is
pip install Sympy latex2sympy2 Flask
GIF by OrangeX4 author of Latex SymPy Calculator.
# Setup in Visual Studio Code
In Visual Studio Code I have installed and downloaded the following extensions that allow to use LaTeX and CAS functionality through Sympy.
- LaTeX Workshop - this extension takes care of document compiling and other cool stuff.
- Latex Sympy Calculator - provides CAS functionality.
- Hypersnips - allows the use of super cool typing shortcuts with snippets (See the section below).
If you would like to test Latex SymPy Calculator, I recommend that you change the key bindings for to keybindings you like.
Below is an example of how I have set mine up.
Keybinding | |
---|---|
Append result of selected expression | Alt + B |
Assign variable defined in selected expression | Ctrl + Shift + Alt + D |
Calculate Python expression | Ctrl + Alt + P |
Calculate the numerical expression of selection | Alt + N |
Expand expression | Alt + E |
Factor expression | Alt + F |
Replace expression with its result | Ctrl + Shift + Alt + R |
Reset Current Variances | Alt + S |
# Snippets
Snippets are advanced shortcuts that automatically and dynamically change what you type, i.e. when I type dm
for display math it automatically changes to \[.\]
etc.
It is the Hypersnips extension that allows the use of snippets.
You can find my collection of snippets on GitHub.