I am writing a package, which is growing very rapidly.

I would like to split into multiple files, and so I thought for example, that I could define all my counters in a separate file.




So this is my first question: which one should I use and why?

But I'd rather use the input syntax because that way, I could do the following:


And thus separate my style latex files into a new directory.

But for some reason, it's not working.

Any advice?

  • 1
    Look at packages like babel or glossaries or biblatex. All of these load extra files. – Johannes_B May 27 at 4:55
  • If mycounters could also be (used as) a stand-alone package, then it might make sense to use \usepackage. If it can only be used as part of your bigger package, \input seems slightly more sensible. AFAIK the \input path is not relative to the file that contains it, but instead relative to the LaTeX call. If your package lives in a directory searched by kpathsea, then \input{mycounters} should work whether the file lives in a subdirectory or not. Of course this requires that you choose a unique name unlikely to clash with user-decided file names of their own projects. – moewe May 27 at 5:32
  • If any of the sub-packages can be loaded separately, and all require mycounters, you might consider \RequirePackage{...} that doesn't repeat loading if the package is already loaded. – barbara beeton May 27 at 11:41
  • Typically one places each \chapter in a separate file using \include then selects which one to work on using \includeonly. This allows \ref to work across files. – John Kormylo May 27 at 15:17

Inside your myclass.cls, you can include mypackage.sty files:

Inside myclass.cls:



Inside mypackage.sty:



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.