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.
Best Answer
The first version of the
pkgloader
package has been released! Based on all of the useful comments above, and my own (re)search, I feel safe to answer my own individual questions as follows:No. The closest that has been suggested is
scrlfile
, and, frankly, it's not all that close. Also, others have since asked for this kind of package, just like I did.The comments above name a couple of important issues that need to be taken into account.
There are probably plenty of other issues. But as for specific pitfalls, I haven't found any that I haven't been able to work around. As always, I'm open to new information (which should go to the Github issue tracker, please).
It doesn't seem so. To equip
pkgloader
with a good set of rules, the following should be done:pkgloader
rules.pkgloader
has been thoroughly tested and is trusted by the community, new conflicts (and resolutions) posted to tex.SE should be reported to thepkgloader
issue tracker.Eventually, the
pkgloader
developers (for now, just me) will need to maintain a comprehensive list.As mentioned in the release-notes, I wouldn't yet trust the package blindly to handle my package loading needs, although I haven't yet found any bugs. A suite of unit-tests needs to be written, additional features need to be implemented and a useful set of rules needs to be defined.
Please feel free to contribute! Just use the Github issue tracker, or contact me personally.