LaTeX package conflicts are a common source of frustration: (1) (2) (3) (4) (5) (6). To quote Freek Dijkstra:
Package conflicts in LaTeX are a hell.
I've been looking around, but I don't think anyone has worked on what would seem, to me, the obvious solution: a package which automates conflict resolution for LateX packages.
As it happens, my PhD research (Delta Modeling) matches this problem closely, so I've made a quick start on that package and I would like some feedback on the idea.
The current version is temporarily stored in an SVN branch for another package. It depends on the l3graph
package I'm working on, which is not ready for CTAN yet. The l3graph
package offers a graph datastructure for expl3
with facilities for detecting cycles and working with the transitive closure/reduction and topological order of graphs.
Package Description
The pkgloader
package offers tools for resolving conflicts, and is backed by a database of known resolutions. For the average user, everything would just work. The user interface looks like this:
\documentclass{article}
\usepackage{pkgloader}
% List packages in any order you please
\usepackage{xltxtra}
\usepackage[xetex]{graphicx}
\LoadPackagesNow
\begin{document}
\end{document}
By redefining \usepackage
(and friends), pkgloader
gathers the list of packages (with options) that the user wants to load, then loads them in the right order at the \LoadPackagesNow
command. The package order above (needs XeTeX) would immediately cause an error if not for pkgloader
.
It is able to prevent the problem because I've already included a modest list of package-ordering rules:
\Load {fancyhdr} before {hyperref}
\Load {fncychap} before {hyperref}
\Load {float} before {hyperref}
\Load {hyperref} before {algorithm}
\Load {amssymb} before {xunicode}
\Load {amssymb} before {xltxtra}
\Load {graphicx} before {xltxtra}
\Load {graphicx} before {fontspec}
\Load {caption} before {subfig}
These can also be added manually.
Potential Features
Fixing the package loading order is only the first (and simplest) step. With a bit of extra work we could add features like the following:
- A package ordering rule like:
\Load {cleveref} late
(orearly
) - Facilities for package authors to include their own resolutions in a uniform way
- Automatic detection of cycles within the rules
- Accumulating and combining package options, with specific rules per package
- Adding extra 'glue code' to make two other packages behave (if they're both being loaded)
- Automatically resolving pretty much every conflict listed on Freek's page.
- For conflicts that cannot (yet) be resolved, at least show an error message rather than let things go wrong at a later stage.
Question: What prior work is there?
Specifically:
- Is there already another package that does (something like) this?
- Are there any specific pitfalls I should be aware of?
- Other than Freek's page, is there any kind of comprehensive list of known conflicts and resolutions?
I think a package like this has the potential to be very useful to a lot of people, if I do this right. A package like this will have a very wide scope. I don't want to step on anyone's toes, so please help me do this right.
I'd be happy to collaborate with the community on this - any feedback is welcome, so contact me if you're interested.
scrlfile
package does related stuff\usepackage{amsmath,wasysym}
with\usepackage{wasysym}\let\iint\relax\iiint\relax\usepackage{amsmath}
. The symbols\iint
and\iiint
are different. Also without the\let
assignmentsamsmath
will complain. (AFAIK there is also a package that with situations that packages define the same macro).\newfloat
which should be used after loadingfloat
+hyperref
first. Furthermore LaTeX itself is IMHO the main problem, it's not very modularized. One example: One need to patch\chapter
to adjust the spacing between figures and tables in LoF/LoT, the so-called "chapter's gap". So writing such packages is only scratching on the surface, and IMHO not solving the true problems.pkgloader
will solve all the worlds problems, nor saying that it will stop at loading-order. For better or worse, we're stuck with LaTeX for a while and might as well fix what we can. I do believe that even fixing the loading order alone would solve many problems (thanks for the link, @CountZero).