1

Introduction

I like to build LaTeX documents using the LaTeX Workshop extension in VSCode. I'm using MiKTeX as a package manager. I know I can add a particular TDS compliant folder as a texmf directory by adding it through the MiKTeX console or running initexmf --register-root="path\to\texmf" in the command prompt.

However, I don't want to do this for every project, and I read here that I can add a local texmf folder by adding the following to settings.json:

{ "latex-workshop.latex.tools": [ { "name": "latexmk", "command": "latexmk", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "-pdf", "-outdir=%OUTDIR%", "%DOC%" ], "env": { "TEXMFHOME": "%DIR%/texmf" } } ] } 

Minimal working example

This is my local folder structure:

home/ main.tex settings.json texmf/ tex/ latex/ myclass/ myclass.cls 

The content of settings.json is exactly what's displayed above. Content of main.tex:

\documentclass{myclass} \begin{document} Hello! \end{document} 

Content of myclass.cls:

\NeedsTeXFormat{LaTeX2e} \ProvidesClass{yomama}[2014/08/16 Example LaTeX class] \LoadClass[a4paper]{article} 

Problem statement

I'm trying to compile main.tex but it doesn't succeed. Whatever's in my local texmf folder cannot be found when I compile a document. The output file states ! LaTeX Error: File 'myclass.cls' not found.

Why? Do I misunderstand what I'm supposed to do? Am I required to do something else as well?

6
  • If it is just the class file that you need, you can put it in the same folder as the .tex file and the compiler will find it. Commented Oct 17 at 12:00
  • The problem might be that you do not refresh the filename database of MikTeX, so it does not actually know of any files contained in the new tree. Commented Oct 17 at 12:05
  • TEXMFHOME sounds as if the instruction are for texlive (people writing such instruction normally do not know miktex). I don't think that miktex supports that variable, imho it only know TEXINPUTS. Generally, registering a new root (which you can do in texlive too) is only sensible if you don't do it to often as it is not fast. Commented Oct 17 at 12:11
  • This is just a MWE, my local texmf folder contains more than this one class. And yea I was wondering whether it was a MiKTeX vs texlive thingy, that's also why I added this piece of info to the post. Though the link I referenced mentions MiKTeX, not texlive. @UlrikeFischer yea registering a root on-the-fly every time might slow it down a lot? Then maybe I'll consider a different approach. Commented Oct 17 at 12:23
  • Simply test it yourself how fast it is on your machine, I haven't done it for miktex for quite some time. Do not forget that you have to unregister again when you quit the project. In texlive it is not superfast so not something I would do before every compilation or if I switch between projects a lot. I mostly use that for permanent roots. Commented Oct 17 at 12:41

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.