Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
122

Preliminaries In this answer, I'll be discussing "objects" such as "Theorem 2", "Lemma 3", "Page 7", and "Section 4". Each object is assumed to be associated with a \label command, e.g., \label{thm:important} and \label{sec:results}. Classes of cross-references: Static, semi-dynamic, and fully dynamic Static or hard-coded cross-references. As the name "...


85

geometry: From the User manual: With mag <> 1000, no truedimen and hyperref, hyperref should be loaded before geometry. Otherwise the resulted PDF size will become wrong. robustindex hypdestopt, hypcap, hypbmsec attachfile showframe, showidx (which disables the \hrefs in the index but in this loading order at least documents compile at all) uri, ...


80

Once you get the error message: ! LaTeX Error: Option clash for package xcolor. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.17 type "h" (without the quotation marks, for help) in the output console and you get ? h The package xcolor has already ...


71

The very recent version of the subcaption package will even issue an error: ! Package caption Error: The `subcaption' package does not work correctly (caption) in compatibility mode. The only way to get around this is to specify the option compatibility=false to the caption package: \documentclass{cifa} \usepackage{subcaption} \...


66

You can use the internal LaTeX macro \@ifpackageloaded to test if a package was loaded: \@ifpackageloaded{<name>}{<true>}{<false>} There are also: \@ifpackagewith{<name>}{<option-list>}{<true>}{<false>} \@ifpackagelater{<name>}{<date YYYY/MM/DD>}{<true>}{<false>} For further macro see the ...


55

Load xcolor before tikz: \usepackage[table]{xcolor} \usepackage{tikz} The problem is that pgf/tikz already loads xcolor so loading it again with a new package option triggers the error message. Another option is to pass the table option to the class and not to the xcolor package. Then the packages can be loaded in any order: \documentclass[table]{article}...


52

If the class defines either a macro or an environment called proof, add the instructions \let\proof\relax and \let\endproof\relax before loading amsthm.


40

hyperref compatibility The hyperref package redefines many macros of LaTeX and LaTeX packages for generating hyperlinks in documents, for many kinds of references, such as citations, footnotes, captions, table of contents entries, and bookmarks. That's why it should usually be loaded after other packages, with some exceptions, such as some of the following ...


38

Load varioref first, then hyperref, then cleveref. See section 14.1 of the cleveref manual. \documentclass[ngerman]{scrartcl} \usepackage{babel} \usepackage{varioref} \usepackage{hyperref} \usepackage{cleveref} \begin{document} \section{Erster Abschnitt}\label{sec} \begin{figure} \rule{\textwidth}{1cm} \caption{bild}\label{bild} \end{figure} Siehe \...


33

The problem is that one of the subpackages loaded by datatool, namely datatool-base has the line \RequirePackage{amsmath} and mathspec sets up a (very poor) check for possible loading of amsmath after it, which triggers the error even if amsmath has already been loaded when another package requires it. The normal setup of LaTeX is not reloading packages, ...


33

Changing this tiny line of code \usepackage[usenames,dvipsnames]{color} to \usepackage[usenames,dvipsnames]{xcolor} fixed it, thanks @Ignasi


32

Load imakeidx before hyperref. Generally, hyperref should be loaded last, though there are some exceptions (see Which packages should be loaded after hyperref instead of before? ).


32

The degree to which something is 'stable enough' will depend on your requirements. I'll answer by taking this situation in roughly the order of stability as I see it. If you want 'will never change again', then plain TeX is probably your best bet. Knuth does still fix bugs periodically, but most things are now likely to be regarded as 'features' rather than ...


28

I see that I come some months to late but I want to present my approach to maybe solve the problem or at least to provide a workaround. The problem at my side is, the approach is so simple so that I can't imagine that there is no other people who had the same idea before. So my question is: Where is the catch in this approach? To explain the code: I ...


27

Package functionality The functionality provided by the various packages for cross-referencing may be divided as follows: Formatting references according to the type of label being referred to (i.e., typesetting "section 3" instead of only "3"). Packages like fancyref, prettyref or refstyle provide a semi-automatic solution as you must adhere to certain ...


25

I've never used this combination myself, but a search with your favorite engine should show you that there are some incompatibilities, e.g. (all in German): Paket titlesec und KOMA-Skript-Befehl \setindexpreamble (it was originally a usenet post, but the archived Google groups version is broken; with an interesting answer of Markus Kohm, the author of ...


25

Since the algorithm and algorithm2e packages both define an algorithm environment, simply loading both with no extra precaution will cause a name clash like you experienced. However, you can still use both packages (if you really need both), but you need to pass the option algo2e to algorithm: \usepackage[algo2e]{algorithm2e} This option changes the name ...


24

As you already mentioned, enumitem "disturbs" beamer. This is because the document class (beamer in this case) defines (or redefines) all the necessary commands/macros and environments to it's liking. Then, each loaded package does the same sequentially. As such, since enumitem follows the document class, it redefines the itemize (and other) environments, ...


22

Markus Kohm, the author of KOMA-Script (see his initials), utters about this frequently, but unluckily for TeX.SE usually in German. Also I would prefer to say, some packages are not fully compatible instead of they are incompatible, because in most cases they work partially and often there’s a workaround. Every package, that makes a redefinition of ...


21

The solution is to load geometry before fancyhdr and apply the settings, then configure fancyhdr, not the other way round. A working example: \documentclass{book} \usepackage[english]{babel} \usepackage{geometry} \geometry{a4paper} %paper format \geometry{left=27.5mm,right=27.5mm,bottom=27.5mm,top=27.5mm} %margins \usepackage{fancyhdr} \fancypagestyle{...


21

Loading fancyhdr and tweaking the header/footer content must be done after any margin changes effected by geometry, so that fancyhdr can detect those changes. In your example, \newgeometry after \begin{document} is not needed -- simply specify the margins changes as geometry package options. \documentclass{article} \usepackage[margin=0.5in,bottom=1in,top=...


21

Basically the package is only loaded once, with the options specified at that point. Any later uses of \RequirePackage or \usepackage are silently ignored if the options specified were specified earlier, or generate an error otherwise. Normally it works to put options on \documentclass, so they are global options seen by all packages. The help text for the ...


21

In usbthesis.cls change the line: \renewcommand{\year}[1]{\newcommand{\@year}{#1}} to, \newcommand{\myyear}[1]{\newcommand{\@year}{#1}} and use \myyear rather than \year in your document. It looks like pgfmathfunctions.random.code.tex uses \year to generate a random seed. Since the class redefines \year before it's use in that file, you're getting the ...


20

For chapters the incompatibility is not evident, as \titleformat{\chapter}... will redefine \@makechapterhead and \@makeschapterhead. However \documentclass{memoir} \usepackage{titlesec} will redefine \section in such a way that the second optional argument is not accepted; indeed \section[section toc][section head]{section title} will produce the ...


20

egreg answered the specific issue but the general issue of avoiding package loading as mentioned in comments: \documentclass{article} \ProvidesFile{longtable.sty} \usepackage{longtable} \typeout{longtable is: \meaning\longtable} \stop produces longtable is: undefined showing that the package is not loaded, despite the \usepackage.


19

This is actually a timing problem: The metadata has to be inserted before the final \clearpage command, otherwise, it isn't written to the PDF document any more. However, memoir issues a \clearpage with \AtBeginDocument{\AtEndDocument{\clearpage\dol@stsheet\dol@stpage}} so the code used by hyperxmp \AtBeginDocument{% % [...] \AtEndDocument{% ...


19

Tex/Latex have what is called monolithic state: you can't cleanly isolate the configuration done by one package from another, which is one of the reasons why incompatibilities are possible. This means there is no way to identify how to undo what changes the \usepackage command has caused. Think of installing software on your machine: if the software makes ...


Only top voted, non community-wiki answers of a minimum length are eligible