Search code examples
visual-studio-codelatex

Specify the file to be compiled in VSCode Latex Workshop


I have a folder with two .tex files, say a.tex and b.tex opened in VSCode. When launching Recipe: latexmk (Latex Workshop extension) from the Commands tab, or Ctrl+Alt+B, it always compiles a.tex even when b.tex is focused in the editor.

How do I specify which .tex file I'd like to be compiled, if not by focusing in the editor?


Solution

  • According to the documentation They search in multiple steps:

    1. magic comment % !TEX root =path to root.tex -> I recommend to put it in every tex-file to assure the right file is used
    2. the file with \documentclass[...]{...}
    3. ...