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.
- 250,273
- 13,173
1 Answers
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.
./home/<user>/texmf/latex/MYCLASS/myclass.cls, it works fine, however, not ifmyclass.clsrefers to files in./home/<user>/texmf/latex/MYCLASS/SUBFILES/– Nicholas Hamilton Aug 21 '13 at 06:21.texor.defhere. – Joseph Wright Aug 21 '13 at 06:28Also, .def needed to be in same directory as the .cls file, to use \input{XXX.def} in the .cls file and having it recognised by texstudio (for convenience).
My system Ubuntu 12.04 LTS, I use texstudio, and generally compile with LuaLatex.
– Nicholas Hamilton Aug 21 '13 at 08:23texfile you want with\usepackage{my-macros}if you call itmy-macros.sty. In your class you need to write\RequirePackage{my-macros}. – Mensch Aug 21 '13 at 15:58texmfdirectory structure more precisely. I'd use~/texmf/tex/latexfor things LaTeX-related. The fact that you had to runtexhashsuggests to me thatKpathseais not searching~/texmf/latexon its own initiative, as it would~/texmf/tex/latex. (But I haven't really looked into this.) – jon Sep 08 '13 at 18:57