TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm fairly new to LaTeX so I don't really know much yet.

Is there a way I can make a custom document class that embeds an external document containing custom macros?

For example, I have right now a MyBook.cls file with a few small changes from the default Book document class. I would also like to define a bunch of \newcommand{} macros, but I don't want to have to do it in every custom document class.

share|improve this question
You can put your \newcommand in a mycommands.sty or mycommands.tex file and then load it using, respectively \usepackage{mycommands} or \input{mycommands.tex} – Guido Dec 11 '12 at 20:30
Do you mean you want to create a file (or 'package' --- say mycustomcmds.sty) that contains several macros you want to use in many different documents that all use MyBook.cls? I think this can be done with \usepackage{mycustomcmds}. But perhaps you have something trickier in mind..? – jon Dec 11 '12 at 20:31
A package did the job, thanks. Had no idea I could easily make my own package like that. Now I can just \usepackage on my custom list of commands. – agent154 Dec 11 '12 at 20:47
up vote 2 down vote accepted

A package is what I was looking for. I just made a custom .sty file and now I can load it whenever I wish.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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