{preamble} is everything before \begin{document} in a LaTeX document. It contains commands loading packages, definitions, and usually most style settings for a document.

learn more… | top users | synonyms

104
votes
5answers
5k views

Best practice on organising your preamble

I am putting together a large document and my preamble is unwieldly and disorganised. What order does it make sense to load packages. Obviously, hyperref goes last, apart from things that have to go ...
37
votes
5answers
4k views

How to make a standard preamble into a package

I have a preamble that I copy and paste into nearly all of my documents. Is there a nice way to turn this into a package than I can use? I would prefer to do this in a way that doesn't depend on my ...
36
votes
7answers
2k views

Should I place \title, \author, \date in the preamble or after \begin{document}?

The motivation for this question Forgive me if this looks very basic to you but nobody has pointed out to me yet until now in a comment to a question that the \title command (and thus the other two ...
23
votes
2answers
569 views

Multi-line options with the `\usepackage` command

When including a package using the \usepackage command that has a lot of options, are there: Any restrictions on how the options can be split across multiple lines? Any best practices for formatting ...
22
votes
0answers
939 views

Speeding up compilation using precompiled preamble with LuaTeX

Compiling my documents with lualatex takes quite long. I have a complex preamble, and noticed it takes long to process this part of the file. Today I came across this website, which proposes a trick ...
21
votes
1answer
2k views

ultrafast pdflatex with precompiling

I try to improve the time pdflatex needs to compile my book. Really working example book.tex %&preamble \begin{document} Hi \end{document} and preamble.tex \documentclass{article} I run ...
18
votes
4answers
604 views

Avoid repeating [hbt] and \centering for every table

In a document I'm writing, I'm using the familiar [hbt] option for my floating tables, and I center them. I'd like to avoid repeating that every time I'm creating a table. I assume it's easy to add ...
18
votes
2answers
391 views

Load package after other package with \AfterPackage

I want to group packages together (in the real document, I load many more packages) and want to solve the sorting of the packages with commands like \AfterPackage from KOMA-Script. I am using this ...
18
votes
6answers
8k views

where to put .sty and .cls file for project

I want to use my own .sty and .cls file in a project. I know of the following two possibilities of placing them: in my local tex tree (or the general tex tree, which is worse) in the same directory ...
16
votes
2answers
354 views

Should I make a package or class for my usual preamble, or include it in every document?

This TeX.SE thread is a good resource for how to make your usual preamble into a package or document class. I would like to know why I should do that. What are the pros and cons of doing so, as ...
15
votes
1answer
143 views

Should babel package call be placed at the end of the preamble?

I remember to have read few year ago1 that babel line2 should be placed at the end of the preamble in order to avoid problems with other packages. (I believe hyperref package should also be placed at ...
15
votes
1answer
415 views

Sorting preamble packages thematically while accounting for compulsory load orders

Within a document's preamble (or a custom "preamble" package), at times there's the need to take compulsory load orders for certain packages into account. Most packages must be loaded before the ...
15
votes
1answer
380 views

Leveraging a dynamic preamble to generate multiple output formats

Background The diagram below shows an architecture for generating books using a dynamic preamble. The top part of the image shows the database relations between a book theme and its preamble. The top ...
13
votes
4answers
2k views

Make align* number the last equation

I am using the align* environment to write equations expanding several lines. I would like to define a command sequence in the preamble, such that the last equation of this block will always be ...
13
votes
4answers
890 views

meta packages and typesetting

Background(just ignore): Is there an exhaustive list of packages that you should load and of things you should do to improve your document? Here I mean packages and things that have to do with the ...
13
votes
2answers
394 views

Is it possible to define a `multicols{2}` preamble switch that works for \chapter?

With standard LaTeX, issuing \twocolumn in the preambe causes the document to be typeset in two columns -- except that \chapter will produce separate one-column chapter headings. \documentclass{book} ...
13
votes
2answers
4k views

Create new paragraph style in LyX

Background In OpenOffice and Microsoft Word it takes seconds to create a new paragraph style. Here is how I currently use LyX with the KOMA Script document class to mark text as a quotation: Type ...
12
votes
2answers
2k views

Placing items before \documentclass

When looking in books or at sample code, I always see \documentclass appearing first. Is that absolutely necessary? I have created some test code which seems to compile fine: \def\SetClass{article} ...
12
votes
2answers
392 views

How does one detect whether one is in the preamble or not?

In LaTeX, I'd like to know whether a documentclass has been loaded and whether code is inside a \begin{document}. In other words, is there a \ifpreamble similar to \ifvmode and friends? ...
12
votes
2answers
338 views

How can I easily use the same preamble on all my documents?

I use multiple computers (Mac and PC), so creating a path (e.g. \input{c:/folder/Preamble}) won't work. I really want to assign a URL (in Dropbox) to the file and input the file via the URL, but I ...
11
votes
2answers
4k views

How do I add something to the preamble in LyX?

I'm trying to add something to the preamble, but don't know how. I tried Insert -> Latex Code and just picked places on my article, but I guess they were never in the preamble? I guess I cannot ...
11
votes
2answers
377 views

Using breakable hyphen "= in \newcommand

I want to use a breakable hyphen "= in a command: \documentclass[a4paper]{article} \usepackage[ngerman]{babel} \newcommand{\TT}{Test"=Text } \begin{document} This is a test whether the hyphen in \TT ...
11
votes
2answers
4k views

Precompiled preamble with TikZ/Externalize

I'm using the externalize capability of TikZ (external library) to speed up compilation of my TikZ pictures (as explained in Script to automate externalizing tikz graphics). In addition, I would like ...
10
votes
2answers
749 views

Are there any situtations where it is better to load a package after other code?

I always place all my packages immediately following the document class, followed by setting information (\hypersetup for example) and customization to my documents (header and footer customization ...
10
votes
2answers
4k views

Where to put a custom macros file?

I have a bunch of common commands I put in document preambles. I don't always use them all, but it makes the preamble too long for my tastes. I want to put them all in an external file (preferably in ...
10
votes
1answer
171 views

Different styles for the same document

Suppose I am writing a paper, which I plan to submit to a journal/conference, but also put on a preprint server like the arXiv. Each publisher has its own style files required for typesetting the ...
9
votes
2answers
563 views

Precompile header with xelatex

I read about precompiling the preamble in http://tex.stackexchange.com/a/15606/4918 and it worked fine with pdflatex but how can I do this for xelatex? I tried xelatex -ini -shell-escape ...
8
votes
1answer
4k views

Using Palatino and Euler Math

I'm using Palatino font for my thesis calling in the preamble \usepackage[sc]{mathpazo} \linespread{1.05} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[english,italian]{babel} ...
8
votes
1answer
4k views

Strange “There's no line here to end” error

I am starting my adventure with LaTeX. I have following code on my preamble: \usepackage{graphicx} \usepackage{setspace} \onehalfspacing \usepackage{indentfirst} \usepackage{titlesec} On third and ...
8
votes
1answer
217 views

Can I amend the preamble from outside the preamble?

I am writing a document (mydoc.tex) that will include a section as a separate document (mysection.tex) using \input{mysection.tex}. If I want to include something in the preamble (specifically ...
7
votes
3answers
2k views

Good LaTeX preambles for math thesis

Can someone provide me an example of a nice preamble to write a math thesis? I am currently using \documentclass[12pt]{article} \topmargin -15mm \textheight 24truecm \textwidth 16truecm ...
7
votes
2answers
126 views

Amend tabular environment in preamble: different font

I'd like to put some lines in the preamble to change the font of all tabulars in the document. I know that I can easily define my own environment »mytabular«. But for different reasons I need to ...
7
votes
3answers
614 views

Disable babel's shorthands

I want to disable babel's shorthands in my own sty file. But since I can use \shorthands{off} only inside the document environment, I struggle with this. Is there a way to disable babel's shorthands ...
7
votes
2answers
1k views

Automatically define macros in LyX documents

I'm using LyX all the time and over the last 2 years I've accumulated some very handy macros for my lecture notes. As it is today, every time I start a new document, I copy and paste the macros from ...
7
votes
1answer
724 views

Compiling partial documents (without document tags)

I am getting some colleagues to migrate from Word to LaTeX for technical documents, but old habits die hard. I am looking for a way to compile each LaTeX document partially without document tags, so ...
7
votes
1answer
142 views

What are the pros and cons of packages versus \input for a preamble?

For a some simple cases it seems to me that there would be no important difference between putting some code in a file preamble.tex and having \input{preamble.tex} in the main .tex file putting it ...
7
votes
1answer
588 views

Why does LaTeX make \DeclareMathSymbol and \DeclareSymbolFont preamble-only?

Is there any good and convincing reason to explain why LaTeX restricts usage of \DeclareSymbolFont and \DeclareMathSymbol to the preamble? and I could also ask the question for many other macros. ...
7
votes
2answers
1k views

Hide all images, listings and equations?

is there any way to hide all images, equations and all listings (embedded by using lstlisting package) manually by setting a certain command in the preamble? It would just be interesting to see how ...
7
votes
1answer
133 views

TikZ compiles in body, but not as command [duplicate]

Possible Duplicate: Problem with defining shortcuts for TikZ matrices. When I use the code below to draw a tikzpicture in the body of my document, it works just fine. However, when I define ...
7
votes
0answers
322 views

What's the right order when loading packages? [duplicate]

Possible Duplicate: Non-commutative packages I remember reading in some reference guide that the order of loading packages with \usepackage in principle doesn't matter. Real life, however, ...
6
votes
2answers
251 views

\dimexpr gives 0pt

Why on earth does the following expression give me 0.0pt? \edef\x{\the\dimexpr 3ex-1ex\relax} I assume ex is a LaTeX unit, as it isn't in the TeXbook. Please where is it defined in the kernel? ...
6
votes
2answers
312 views

What preamble does math.stackexchange.com use?

I am trying to use Anki to create calculus flash cards. I use the input box on the math.stackexchange.com site since it is the easiest LaTex editor I know of to use for math equations. However, I ...
6
votes
2answers
284 views

Preamble anywhere

If I want to use a set of macros in my tex document, I have to obviously include the appropriate packages IN THE PREAMBLE. So now, i write a 100 page document, with 55 packages already included (in a ...
6
votes
2answers
718 views

“Double use” of a4paper (geometry/KOMA)?

In my preamble, should I give the a4paper option just once or twice, i. e. once for the KOMA-script document class (scrartcl) and once for geometry? Is this redundant or does scrartcl need the option ...
6
votes
2answers
3k views

Is it possible to create a LaTeX preamble “header”?

Is it possible to create a header in LaTeX containing my usual preamble, functioning similar to a header in C? Specifically, can I write a text document (or something similar) with the preamble that I ...
6
votes
4answers
685 views

TeX daemon for Windows

A simple question (in theory): is there any (La)TeX distribution for Windows that is capable of running as a daemon? I am not aware that either MiKTeX or TeX Live are capable as running as daemons on ...
6
votes
1answer
51 views

Why hyperref's \url may be used in preamble within a macro but not within a box?

The following MWE, where a macro involving hyperref's \url is defined in the preamble, works like a charm: \documentclass{article} \usepackage{hyperref} % ...
6
votes
1answer
872 views

Bibliography preamble \bibpreamble natbib

I am trying to produce some text after the "References" heading, but before the numbered references themselves. I had read that using the natbib package and the command \bibpreamble{...insert preamble ...
6
votes
1answer
4k views

How does \include work in terms of preamble? And is \input better?

When you have different files; say different chapters of a book, that are written in separate Tex files, all having their own preamble packages and document class options, how does it work when you ...
6
votes
0answers
145 views

Need commands for creating manual “pre-compile” of preamble in Windows, perhaps by pressing a button [duplicate]

I would like to manually create a separate file with preamble "pre-compiled". I found a very simple example at: ultrafast pdflatex with precompiling where Jonas Stein describes their example: ...