[Tex/LaTex] Guide for creating your own templates


Is there any guide on how to create your own template and typography style?

Surfing on the net I found a lot of templates that partly satisfied my typography tastes and ideas, but on the other hand there where certain things I would like to change.
However, since I'm quite a beginner, in the reading of the code I couldn't fully understand the functioning of certain commands which are aimed at creating a specific typography style.

So I wonder if there's any manual/guide on how to start creating your own template.

Best Answer

Short answer:

Any book about LaTeX is a guide to create your own template.

Long answer:

This is the general-purpose best template ever made for LaTeX, and the easiest to adapt to you personal requirements:


   Your text.

Now, the first question is for which type of document do you want this template. For example, if you want this template to write books, change article by book. This add hiddenly a lot of customizations (as allow \chapter commnads, will put the title automatically in a page title, etc.)

The second question is if there are alternative document classes for the same purpose. For example, you can use alternatively scrbook to obtain a similar book layout but with different style (headings in sans serif, etc.).

However, with the above template with so brief text you will not notice significant changes. Obviously you need some structured contents to see the changes in the default style. With the help of the blindtext package this is just insert \Blinddocument and the commands to make a title. It could be aso a good idea check the document layout with the package of the same name. MWE:

\usepackage{layout} % show a page layout
\usepackage{blindtext}  % dummy text
\title{Your Book Title}
\author{Your Name}

Obviously, the commands of both packages are only for testing (remove them in the final template).

Now is time to go with the optional arguments of the document class. Read the fine manual (RTFM) to know what is available. The program texdoc is your friend. Just add some keyword after the program name and press Enter (e.g., run texdoc scrbook). For instance, if you want allow chapters in odd and even pages, the first line could be:


The KOMA Script or memoir classes also have a lot of own commands for further customization. For example, said that you want only the sections headings in a serif font in a scrbook document. You might add to the preamble this line:


With standard classes like book this is also possible but with the help of packages as titlesec (easy way) or redefining the \section comand (hard way).

Select the right document class is the most important part of your own template, but even with the more rich classes as scrbook or memoir, at some point none of this is enough. For example, you want the section headings in blue. Then you should load also the package color or xcolor (better) to allow colouring commands, the customization then could be:


What more? Depends on what you need. For example, if you will show images you must load also the package graphicx (except if is already loaded by the document class or another package)- If you want hyperlinks suse the hyperref package, if you need fancy rounded boxes, load tcolorbox and so on.

See What packages do people load by default in LaTeX? to have some idea of most required enhancements. Only add what really is needed. Avoid load packages that only maybe you will use. Even following this rule, often you will end with a large preamble and some package conflict.

The last step is customize what is what is not planned by the document class nor any package. You need some experience here, but hopefully you have already several solutions to each problem in some question of this site. It could be simply set some lengths, make your own commands or even modify complex codes of the document class or some packages (typical \makeatletter ... \makeatother chunks of code in the preambles of many examples of this site). Is not possible cover every customization without a book, but my general rules are:

  1. Keep it simple, stupid! (KISS).
  2. Do not reinvent the wheel. Surely a simple command of some package already make what you are trying to do with that long and dirty code. CTAN is also your friend.
  3. Nonetheless, if you end with a huge preamble, consider clean it making your own class o package. See the Reference guide to begin writing a class and/or a package. Or simple, pass the preamble code to mypreamble.tex and load it with \input{mypreable}
  4. Remember the KISS principle.