I am writing a .cls file so that I can maintain consistency across many documents. The cls file is soooo long, and I would like to split it up into parts, in a similar fashion that one does when writing a document. Can I do this, the \input{...} command doesn't seem to recognize a sub-folder of the parent .cls file in my TEXMFHOME tree structure.

  • 2
    What are you calling the subfiles? The directory structure for TeX files requires that they are in the 'right' place in order to find them, and that depends on the extension used. – Joseph Wright Aug 21 '13 at 6:16
  • when the .cls file is a single file, and put into ./home/<user>/texmf/latex/MYCLASS/myclass.cls, it works fine, however, not if myclass.cls refers to files in ./home/<user>/texmf/latex/MYCLASS/SUBFILES/ – Nicholas Hamilton Aug 21 '13 at 6:21
  • 2
    Please consider to look for appropriate existing tags before creating new ones. – lockstep Aug 21 '13 at 6:27
  • 1
    @ADP Not unless it's a package. I'd use either .tex or .def here. – Joseph Wright Aug 21 '13 at 6:28
  • 2
    I am sure your long class file has some functionalities you can outsource in a package, for example your standard macros. Advantage: your class is not so long and you can use this small package in every tex file you want with \usepackage{my-macros} if you call it my-macros.sty. In your class you need to write \RequirePackage{my-macros}. – Mensch Aug 21 '13 at 15:58

If you write a new/own class use a local directory to develop it. Inside the directory you write a file myclass.cls to be called as document class in a test document in the same directory. Think over the functionality of your class and outsource logical units into packages like file mypackage.sty (in the same directory). Now you can load this package with \RequirePackage{mypackage} in your class. The advantage of outsourcing functionality to packages is that you can use them in other classes or—if needed—in other documents (\usepackage{mypackage}) without loading the own class.

After you finished development of your class, create a new directory in your local TeXMF tree, copy all .cls and .sty to it. If you do not know how to create and use a local TeXMF please see the questions create-a-local-texmf-tree-in-miktex and/or how-to-make-latex-see-local-texmf-tree.

To learn more about writing classes read the clsguide (texdoc clsguide).

A class or a package is never loaded with \input{...} as it seems you are trying to do.

| improve this answer | |

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.