Visual Studio Latex



LaTeX Workshop is an extension for Visual Studio Code, aiming to provide core features for LaTeX typesetting with Visual Studio Code.

This project won't be successful without contributions from the community, especially from the current and past key contributors:

  • Jerome Lelong @jlelong
  • Takashi Tamura @tamuratak
  • Tecosaur @tecosaur
  • James Booth @jabooth

Thank you so much!

Note that the latest version of LaTeX-Workshop requires at least VSCode 1.50.0.

Manual

Visual Studio Code の設定. ここからは Visual Studio Code の設定をしていきます。 拡張機能 LaTeX Workshop のインストール. LaTeX Workshop は VSCode で TeX ソースを書くに必須と言っても過言ではない拡張機能です。シンタックスハイライトや補完、PDFのプレビューなど様々な. How to enable `shell escape' (or `write18') - Visual Studio Code (Latex Workshop extension) Ask Question Asked 1 year, 5 months ago. Active 6 months ago. Viewed 3k times 2. I am working on a.tex file inside Visual Studio Code with the Latex Workshop extension installed. I get following.

The manual of the extension is maintained as a wiki

Table of Contents

  • Installation and basic settings
    • Usage
  • Compiling
  • Viewing & SyncTeX
    • Internal PDF viewer
    • External PDF viewer
  • Formatting
  • Intellisense
  • Snippets and shortcuts
  • Hovering and previewing features
  • Playing with environments
  • Extra features

Features (Taster)

This is not a complete list but rather a preview of some of the coolest features.

  • Build LaTeX (including BibTeX) to PDF automatically on save.

  • View PDF on-the-fly (in VS Code or browser).

  • Direct and reverse SyncTeX. Click to jump between location in .tex source and PDF and vice versa.

  • Intellisense, including completions for bibliography keys (cite{}) and labels (ref{}).

  • LaTeX log parser, with errors and warnings in LaTeX build automatically reported in VS Code.

    • Linting
    • A lot of LaTeX commands can be typed using snippets starting in , then type part of the command to narrow the search.

    • Surround some selected text with a LaTeX command using ctrl+l, ctrl+w (⌘+l, ⌘+w on Mac). A new menu pops up to select the command. This works with multi selections. The former approach using has been deprecated.

    • We also provide a few other snippets mechanisms

      • Greek letters are obtained as @ + letter. Some letters have variants, which are available as @v + letter. See here.

      • Common environments can be obtained by BXY where XY are the first two letters of the environment name, eg. BEQ gives the equation environment. If you want the star version of the environment, use BSXX, eg. BSEQ gives the equation* environment. See here.

      • Common font commands can be obtained by FXY where XY are the last two letters of the font command name, eg. FIT gives textit{}. See here.

      • Many other maths symbols can be obtained with the @ prefix. See here.

    • In addition to snippets, there are shortcuts provided by the extension that allow you to easily format text (and one or two other things).

  • When the current line starts with item or item[], hitting Enter automatically adds a newline starting in the same way. For a better handling of the last item, hitting Enter on a line only containing item or item[] actually deletes the content of the line. The alt+Enter is bind to the standard newline command. This automatic insertion of item can be deactivated by setting latex-workshop.bind.enter.key to false.

  • Preview on hover. Hovering over the start tag of a math environment causes a mathjax preview to pop up.

GitHub

Visual Studio Code Latex Miktex

The code for this extension is available on github at: https://github.com/James-Yu/LaTeX-Workshop

Like this work?

  • :smile: Star this project on GitHub and Visual Studio Marketplace
  • :blush: Leave a comment
  • :relaxed: Spare me some coffee via Paypal

License

LaTeX is one of those things you are sort of forced to learn when preparing technical documents, especially for academia. It is an old (but highly effective) typesetting system, and it is, at its core, complex as hell to use.

In my day to day I jump between plaforms and operating systems so I always dreamed with a LaTeX editor that rule them all, sadly I had not found such thing (yet) but the closest has been, so far, Visual Studio Code so I took some time to prepare an environment and ensure I can work in the same document in the same way in any platform and, well, document the experience.

Latex workshop vscode

First we need to install the fantastic LaTeX Workshop, a Visual Studio Code extension designed to make your life with LaTeX easier (of course you need to have VS Code installed first). Now there is the big question, what about LaTeX? well, we have plenty of options, yes, you need to decide what LaTeX distribution to install and run in each of your operating systems and platforms, this is where I have most of my problems in the past, mostly because I got into a point where my installation was corrupted in macOS and I cannot compile Tex documents. Another problem I would like to avoid is to have global applications in my operating system; for example, I use minted a lot and this requires Pygments to be installed in your system, because this is a Python library I would prefer if it is installed in a virtual environment and all of that… As you see it could be daunting and I wanted to have a single and unique way to do it.

Visual Studio Latex

Containers to the rescue

Visual Studio Code Latex

If there were a way to isolate (and distribute) a process from all the rest of your processes… Wait a minute, such thing exists! It is called Docker! What if I use a container with all the dependencies I need to do the typesetting of a document in a container and just use it to compile the document and simple reuse the container all over again!

Visual Studio Code has an extension for this, Remote Containers, I just need to configure it to do what I need and make it work with LaTeX Workshop. This was a lot simpler than I thought but it required a few steps, especially for those that never used the extension before.

First, after installed the mentioned extension, we need to create a folder, .devcontainer in the directory where our document project is located, this directory with its content needs to be version controlled if you want to share your experience, it behaves pretty much like your settings for the project. Inside this directory we have to create a Dockerfile with the instructions to assemble our LaTeX container with our requirements, in my case it is very simple:

Feel free to change it to whatever you want to include in your LaTeX distribution, I prefer not to use texlive-full because, well, it will require to install 2GB of packages and I don’t need them all (yet).

Now that we have the instructions to assemble our container I build it locally to avoid delay when running the whole process:

Feel free to use whatever name you want for your image.

Now we create another file, devcontainer.json with the instructions of how to use a container for our project root:

Visual Studio 2019 Latex

The dockerFile and image tell to VSCode to use the image we already built, if this image does not exists it will build it from scratch (and this will probably take some time). We tell it to automatically install the LaTeX Workshop extension in this container (if not, later VSCode will ask us if we want to install it or not) and opening the port 36887 from the container, we need to do this to enable the native preview used by the extension.

And this is all! When we open the directory with our LaTeX project VSCode will just ask us if we want to do this in the container, just follow the prompts and it will be set, our project will be compiled with our container and generate our document, if you need something else installed just do it in the container image instead of your machine.





Comments are closed.