# Is there any way to tell the compiler, inside the main file body, how to find the class?

I would like to use a class that belongs not found in my MiKTeX database. I know I might as well pick up this class and put it in some directory inside the base and update MiKTeX, but I do not want to do that. What I want is to organize it into a subdirectory within the same directory as my main tex file. However, when compiling the tex file, the class is not found. Of course, if I put the direct class in the same directory as the main file I will solve the problem, but that's not what I want. So, I ask: Is there any way to tell the compiler, inside the main file body, how to find the class?

Note: I'm using MiKTeX as an example, but I'm really having the problem in overleaf. There was a revtex upgrade from version 4.1 to 4.2. However, overleaf does not find revtex4-2.cls, which is, in fact, the class I'd like to use.

Below, I show an example of how I would like to organize the files. Note that the class is in a subdirectory.

• You can use relative paths in \documentclass, for example \documentclass{mysubdirectory/myclass} or going to the parent directory \documentclass{../myclass}. You can also use the full path as in \documentclass{/home/you/some/further/directory/myclass}. Is that what you mean, or do you have a different issue? – Marijn May 24 '19 at 12:48
• You do not have to put the class in the main miktex folders, tex will find the file anywhere so long as that folder is in your TEXINPUTS path (it would be possible to set \input@path before the \documentclass but not normally recommended) – David Carlisle May 24 '19 at 12:53
• @Marijn , it would be something like that. However, I have tested this way and I have seen that it does not work. – lucenalex May 24 '19 at 12:59
• The easiest solution would be to copy the .cls file (only that file, the other files are not needed) to your main folder, but if that is not what you want then \documentclass{revtex4-2/source/revtex4-2} should work from your main.tex file. Maybe on Overleaf it works differently, there could be access restrictions in place or something - you could try to click on the specified the file location correctly link to see if there is some more information, or ask the Overleaf support staff. – Marijn May 24 '19 at 14:05
• @DavidCarlisle then you change the class file to include the relative path for supporting files - I'm not saying that it is a clean or advisable solution, but it will not work is a bit overstated. – Marijn May 24 '19 at 14:19

If you must you can use the same \input@path mechanism used for \graphicspath,

I tested the following document with texlive 2016 (which does not have revtex 4.2) but with a copy of the texlive 2019 revtex directory below the current directory.

\makeatletter
\def\input@path{{revtex/}}
\makeatother
\documentclass{revtex4-2}

\begin{document}
zzz
\end{document}


The terminal log starts

This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
(./bb768.tex
LaTeX2e <2017-04-15>
Babel <3.9r> and hyphenation patterns for 83 language(s) loaded.
(./revtex/revtex4-2.cls
Document Class: revtex4-2 2019/01/18/14:29:48 4.2c (https://journals.aps.org/re
vtex/ for documentation)


After some research, I found on the overleaf website the answer. See figure below:

The overleaf itself cites a stackexchange answear an example.

Following the guidance above, my solution then was: