[Tex/LaTex] How to create a command to load the own new .sty file

macrospackagesthemes

I have created my custom class myclass.cls and I've put it into the BASE folder on MiKTeX dis. (C:\Program Files\MiKTeX 2.9\tex\latex\base). Then I have created my xxx.sty file with some additional code, I've put it into the new folder OWNCLS (C:\Program Files\MiKTeX 2.9\tex\latex\owncls) and refreshed the file name database (FNDB) in MiKTeX settings. I hope I did everything how I should.

And my question is: How do I define \newcommand in myclass.cls that will load the xxx.sty file from its folder?

For example, when I want to create a new document, I will use command \loadmytheme{xxx} in the preamble. beamer class has got something similar \usetheme{Themename}.

I will appreciate any help.

Best Answer

If by base directory you mean the directory with article.cls in, then that is not a good place, the base directory indicates the core LaTeX distribution and will get overwritten on any update.

Using .sty is not what you want here, if you do use .sty then you could load your additional package with

 \usepackage{xxx}

as normal.

If you name the files for your class themes in a unique way, say theme xxx gets stored in the file xxx.mycls-def then you can define a custom loading command in your class file something like

\def\usetheme#1{\input{#1.mycls-def}}

Or perhaps adding \makeatletter if your theme files need to allow @.

Related Question