1

What is the proper way to set document class by providing the path to the custom class file? Something like this:

\documentclass{../myclass/myclass}

This kind of works but I'm getting an error that my myclass.cls is not exporting ../myclass/myclass but myclass.

I'm working on three projects for which I need a custom class and I want them to share it as well. I'm also working on that custom class and am changing it so I want it to be in the same directory as those three projects.

Here's my dir structure:

Main Project Folder

+ MyClass
-- myclass.cls
+ Project 01
-+ Code
-+ Images
-- Project 01.tex
-- ...
+ Project 02
--+ Code
--+ Images
-- Project 01.tex
-- ...
+ Project 03
--+ Code
--+ Images
-- Project 01.tex
-- ...
  • 3
    you should just use \documentclass{myclass} the argument is a name not a file path, then arrange that the class file is in the input path. – David Carlisle Apr 01 '20 at 21:07
  • @DG' no. This is how to add new include path for LaTex machinery, instead of how to specify a document class by path file. Also, answer is 8 years old, and I've seen one 9 yr old answer which is related to my question, but I'd expect there has been some progress in such a long time. When I move my project directory to a different location I don't want to think about changing all the paths etc... – Maštarija Apr 01 '20 at 22:00
  • @DavidCarlisle I want to do it without modifying input path. If I want to share this with someone, I want them to be able to just open the tex file in my project and be able to build a PDF out of it without some ceremony and extra steps (assuming they have LaTex already on their system). – Maštarija Apr 01 '20 at 22:02
  • then put the class file in the same directory as the document. – David Carlisle Apr 01 '20 at 22:04
  • @DavidCarlisle then I'd have to duplicate this class to all 3 directories that should share it. And I'd have to do that every time I make modification to my class. Also, making symlinks is a no go, if I'm sharing this with someone, I don't want them to have to set up symlinks or env variables. – Maštarija Apr 01 '20 at 22:05
  • the standard way is to set the input path, if you don't want to do that then another option is to ignore the warning. The warning is just there to discourage you to use a path so that files are portable. the code will work – David Carlisle Apr 01 '20 at 22:07
  • both miktex and texlive have standard user input paths so if (on texlive) you put myclass.cls under ~/texmf/tex then you don't have to set any paths or environment variables it will just work. – David Carlisle Apr 01 '20 at 22:10
  • @DavidCarlisle ok, I was just wondering if there's an explicit command like \documentclassfile{path} so that I can state that it is my intention to not make this "portable". And it's annoying that warning pops up every time I build my document. Also, it is impractical to have my class file in another directory, especially if it's only supposed to be used within this specific projects I'm working on. – Maštarija Apr 01 '20 at 22:10
  • you could set \input@path although I wouldn't really recommand it. \def\input@path{{MyClass/}} \documentclass{myclass}but plasingmyclass.cls` in teh normal input path is much better really. – David Carlisle Apr 01 '20 at 22:12
  • 2
    why is that impractical? it works for millions of other users. The warning is there explicitly to discourage having paths in the document so that documents are portable, It is an intentionally added feature not a problem to be solved. – David Carlisle Apr 01 '20 at 22:14
  • 2
    the other way of course is to declare the name of the class to be ../MyClass/myclass in the \ProvidesClass declaration, then the names will match and the warning will go. – David Carlisle Apr 01 '20 at 22:17

0 Answers0