## LaTeX forum ⇒ Document Classes ⇒ Best way to use commands in a separated file.

Information and discussion about specific document classes and how to create your own document classes.
knosence
Posts: 1
Joined: Thu Sep 24, 2020 8:23 am

### Best way to use commands in a separated file.

Hello,
I am kinda newish to latex, and I am in love with all of the features that It has. I am a hobbyist programmer (who is seeking employment as a full-stack dev ) and I am a big user of the D.R.Y. principle. So With that being said, is there a way to access and use newcommands from another file for the purpose of using it in another file?
I have tried the import command and making it a class file (which every other tutorial leads me back to these ideas).
For more context; the newcommands are titles that would be used in a multi part manual that I am rewriting in latex. These titles will be frequalty called upon and are long, so I used shorter names for them and broken up the names with similar parts (for example, "District" "Deputy Master" "Gunnery" "Sergeant", those that are in quotes are parts used in other titles)

I hope I don't offend anyone for over explaining, (or in some cases and opinions, under explain) my case. Thank you and have a wonder day!!

Ijon Tichy
Posts: 333
Joined: Mon Dec 24, 2018 10:12 am
You can put the commands in a
• tex file and load this with `\input` or `\InputIfFileExists`,
• a package (extension .sty) and load the package with `\usepackge` (or inside another package or class using `\RequirePackage`.
See a mostly complete LaTeX introduction for more information to those commands.

And if you want to use the file/package not only with one main file but with several you can put the file in you personal or local TEXMF tree (see the TDS manual and the manual of your TeX distribution on how to find/define a new TEXMF tree).