Skip to content

Visual Studio Code

Tieger, Balázs edited this page Nov 15, 2021 · 36 revisions

LaTeX workshop

LaTeX Workshop is an extension to handle LaTeX documents.

Installation

See the documentation of LaTeX Workshop.

If you want, you can put a LaTeX docker image on your local machine and configure LaTeX Workshop to use that, eliminating the need of installing LaTeX. Tested on Windows+WSL2 (using remote wsl and remote container plugins), see documentation.

NOTE: If syntax highlighting does not work, change the color scheme.

Spell Check

If working in English use the Code Spell Checker vs code extension. This extension does not support Hungarian, an alternative extension: Spell Right. This uses the dictionaries of your operating system.

Recommended workspace settings for Spell Right

{
    "spellright.language": [
        "en",
        "hu"
    ],
    "spellright.documentTypes": [
        "plaintext",
        "markdown",
        "latex"
    ]
}

Auto-formatting tables

Tables can be formatted using the latexindent Perl scripts. It's recommended to test it in the command line and fix missing dependencies. On Ubuntu 18.04, these were sufficient:

sudo cpan Unicode::GCString 
sudo cpan App::cpanminus
sudo cpan YAML::Tiny
sudo perl -MCPAN -e 'install "File::HomeDir"'
sudo cpan -fi Log::Log4perl #-fi might not be required?
sudo cpan Log::Dispatch
sudo cpan -fi File::HomeDir #-fi might not be required?
sudo cpan Log::Dispatch::File #?

On Fedora 32, this feature worked out-of-the-box with texlive-scheme-full installed.

See this issue for installation on other platforms.

Magic comment (e.g. pdflatex) overrides recipe

To use the recipe instead set the following in settings.json:

"latex-workshop.latex.build.forceRecipeUsage": true

The latexmk recipe fails to build the bibliography

  • Problem: When using the latexmk recipe, the build fails with the following message in the log (but there are no explicit errors in the Problems panel):

    bibtex: Not writing to /my/document.blg (openout_any = p).
    I couldn't open file name `/my/document.blg'

    Meanwhile, building the document from the command line with latexmk -pdf documentx.tex works.

  • Solution: Edit the TeX Live configuration file as suggested:

    sudo vim /usr/share/texlive/texmf-dist/web2c/texmf.cnf

    Change

    openout_any = p

    to

    openout_any = a

Troubleshooting

Cannot run Python files

Problem:

  • Running the file using the play button stalls
  • Using the "Run python file in terminal" command results in error "The active file is not a Python source file"

Solution: Go to Settings (Ctrl+,), and check whether the terminal is configured correctly. For me, the problem was caused by the "terminal.integrated.inheritEnv": false setting. Interestingly, this setting if offered by the Python extension.

According to Stack Overflow, the terminal.integrated.shell.* properties are also worth checking out.

Set terminal font

  • Problem: Changing tabs does not work with Ctrl + Page Up or Ctrl + Page Down.
  • Solution: The problem was that I have left the Drop Down Terminal open in another window. Seriously.

Settings

Set terminal font

Go to Settings (Ctrl+,), and set the Terminal | Integrated: Font Family key to e.g. Inconsolata-dz for Powerline. Alternatively, add the following entry to the settings.json file:

"terminal.integrated.fontFamily": "Inconsolata-dz for Powerline"

The text moves left and right while typing

When word wrap (default: Alt + Z) is activated and typing, the horizontal scrolling moves a bit left and right. To fix this, the relevant Stack Overflow page has two answers:

  • one: the problem might be caused by GitLens, set the gitlens.currentLine.scrollable setting to false.
  • two: set the editor.scrollBeyondLastColumn value to 0 (the default value is 5).

Smaller plugins

Privacy

Clone this wiki locally