[Tex/LaTex] Editing the package

licensingpackage-writingpackages

I didn't find anything about this issue, but if I missed something, please point me to it.

The documentation on the ctan.org site is usually about how to use the packages in a LaTeX document, but what if I want to edit the package itself? Is there documentation available?

And on a related note: is it advisable/OK to edit the package or rather try first tweaking the document and only later edit the package?

Editing the package certainly would affect all documents that use it in the future, so I suppose that it would be better to try changing the document options first, rather than go straight to edit the package.

Best Answer

All or nearly all packages in the TeX world (e.g., those on CTAN) have a license attached to it. Depending on the license you are allowed to modify the package, but the license may pose restrictions upon you on how you do that.

If the license is LPPL (which is the case for many packages in the LaTeX world and beyond) then yes it is allowed to modify the package but the license requires you to obey the following important point (beside others):

ยง6a. If a component of this Derived Work can be a direct replacement for a component of the Work when that component is used with the Base Interpreter, then, wherever this component of the Work identifies itself to the user when used interactively with that Base Interpreter, the replacement component of this Derived Work clearly and unambiguously identifies itself as a modified version of this component to the user when used interactively with that Base Interpreter.

In the good old days the common understanding was (and still is) that "if you change something that is used with TeX then change its file name" because then it can be distinguished from the original and doesn't pose any exchange problems, e.g., if you produce a variant of, say, my array package, call it array-xyz so that a document that uses your package immediately shows this fact as it would contain \usepackage{array-xyz} and not \usepackage{array} which might result in different formatting.

Now if you look at the quote above from the current LPPL this restriction has been softened and the LPPL now only requires that your variant package clearly identifies itself to the user as changed, e.g., which could be done through the \ProvidesPackage argument that could state [with additions by XYZ to fix ABC]. However, the usual practice (for good reason) is to stick to the rule that modification should be provided in a separate file with a new name as that is the easiest and best way to ensure compatibility and processability of documents across different installation (since if the file is not there this is immediately appearent, if it just slightly behaves differently then this may not be noticed until it is too late.

I should say that the above quote is only directly relevant to the situation where one intends to distribute the modification. But distribution can happen faster than one thinks, e.g., if you send the file to somebody else for processing your document you are already distributing even if only in a limited sense.

LPPL lists the following advice here:

It is wise never to modify a component of the Work, even for your own personal use, without also meeting the above conditions for distributing the modified component. While you might intend that such modifications will never be distributed, often this will happen by accident -- you may forget that you have modified that component; or it may not occur to you when allowing others to access the modified version that you are thus distributing it and violating the conditions of this license in ways that could have legal implications and, worse, cause problems for the community. It is therefore usually in your best interest to keep your copy of the Work identical with the public one. Many works provide ways to control the behavior of that work without altering any of its licensed components.

Finally to learn a bit more on the background of licenses in the TeX world and why the LPPL has the clauses it has and limits modification I suggest reading my TUG paper: "Reflections on the history of the LaTeX Project Public License (LPPL) - A software license for LaTeX and more".

Related Question