From d852feb864bd3edda9a7023a00a1415a8bbcee0d Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 3 Feb 2014 23:52:26 +0000 Subject: pkgloader (3feb14) git-svn-id: svn://tug.org/texlive/trunk@32864 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/pkgloader/README | 51 +++ .../doc/latex/pkgloader/pkgloader-packagedoc.cls | 390 +++++++++++++++++++++ .../texmf-dist/doc/latex/pkgloader/pkgloader.pdf | Bin 0 -> 427828 bytes .../texmf-dist/doc/latex/pkgloader/pkgloader.tex | 331 +++++++++++++++++ Master/texmf-dist/doc/latex/pkgloader/test1.sty | 3 + Master/texmf-dist/doc/latex/pkgloader/test2.sty | 3 + Master/texmf-dist/doc/latex/pkgloader/test3.sty | 3 + 7 files changed, 781 insertions(+) create mode 100644 Master/texmf-dist/doc/latex/pkgloader/README create mode 100644 Master/texmf-dist/doc/latex/pkgloader/pkgloader-packagedoc.cls create mode 100644 Master/texmf-dist/doc/latex/pkgloader/pkgloader.pdf create mode 100644 Master/texmf-dist/doc/latex/pkgloader/pkgloader.tex create mode 100644 Master/texmf-dist/doc/latex/pkgloader/test1.sty create mode 100644 Master/texmf-dist/doc/latex/pkgloader/test2.sty create mode 100644 Master/texmf-dist/doc/latex/pkgloader/test3.sty (limited to 'Master/texmf-dist/doc/latex/pkgloader') diff --git a/Master/texmf-dist/doc/latex/pkgloader/README b/Master/texmf-dist/doc/latex/pkgloader/README new file mode 100644 index 00000000000..0fccd0a2173 --- /dev/null +++ b/Master/texmf-dist/doc/latex/pkgloader/README @@ -0,0 +1,51 @@ +latex-pkgloader +=============== + +LaTeX Package : latex-pkgloader 0.1.0 + +Last Modified : 2014-01-29 + +Author : Michiel Helvensteijn (www.mhelvens.net) + + +Summary +------- + +A LaTeX package for managing the options and loading order of other packages + + +Prerequisites +------------- + +To use this package, you need the following packages: + +* `lt3graph` + +To generate the documentation some additional packages are needed. + + +Installation +------------- + +`pkgloader.sty` is provided directly in the package archive. Put +it in a place where your LaTeX distribution can find it. +(`pkgloader.sty` is not generated, but manually maintained; you + may use docstrip to remove the documentation, but you don't + have to; it will just work the way it is) + + +Documentation +------------- + +`pkgloader.pdf` is provided directly in the package archive. To +generate the documentation yourself, run LaTeX on pkgloader.tex. +(`pkgloader.tex` does not contain the package code itself; it inputs + `pkgloader.sty` directly to document the implementation) + + +License +------- + +This material is subject to the LaTeX Project Public License. See +http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +for the details of that license. \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/pkgloader/pkgloader-packagedoc.cls b/Master/texmf-dist/doc/latex/pkgloader/pkgloader-packagedoc.cls new file mode 100644 index 00000000000..25cc215c359 --- /dev/null +++ b/Master/texmf-dist/doc/latex/pkgloader/pkgloader-packagedoc.cls @@ -0,0 +1,390 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% Copyright (c) 2013 - Michiel Helvensteijn - www.mhelvens.net % +% % +% https://github.com/mhelvens/latex-lt3graph % +% % +% This work may be distributed and/or modified under the conditions % +% of the LaTeX Project Public License, either version 1.3 of this % +% license or (at your option) any later version. The latest version % +% of this license is in http://www.latex-project.org/lppl.txt % +% and version 1.3 or later is part of all distributions of LaTeX % +% version 2005/12/01 or later. % +% % +% This work has the LPPL maintenance status 'maintained'. % +% % +% The Current Maintainer of this work is Michiel Helvensteijn. % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\let\packagename\jobname + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Document Class % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\LoadClassWithOptions{l3doc} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Importing The Main Package % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\RequirePackage{pkgloader} + \RequirePackage{array} + \RequirePackage{etoolbox} + \RequirePackage[table]{xcolor} + \RequirePackage[xcolor]{mdframed} + \RequirePackage{marginnote} + \RequirePackage{listings} + \RequirePackage{textcomp} + \RequirePackage{hyperref} + \RequirePackage{needspace} + \RequirePackage{noindentafter} + \RequirePackage{pkgloader-dry} +\LoadPackagesNow + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Documentation Options % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\def\verbatimchar{"} % because the macro \& is being indexed + +\EnableCrossrefs +\CodelineIndex +\RecordChanges + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% File Info % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\def\extratitlenote{} + +\GetFileInfo{\packagename.sty} + +\title{ + The \textsf{\packagename} package\thanks{% + This document corresponds to + \textsf{\packagename}~\fileversion, + dated \filedate. + } + \ifdefempty{\extratitlenote}{}{\thanks{\extratitlenote}} +} + +\author{ + Michiel Helvensteijn\\ + \href{mailto:mhelvens+latex@gmail.com}{mhelvens+latex@gmail.com} +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Development Info % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newmdenv[ + leftline = false, + rightline = false +]{bannerframe} + +\apptocmd{\maketitle}{ + \begin{bannerframe} + \small + \begin{center} + Development of this package is organized at + \href{https://github.com/mhelvens/latex-\packagename} + {github.com/mhelvens/latex-\packagename}.\\ + I am happy to receive feedback there! + \end{center} + \end{bannerframe} +}{}{} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Example Environment Setup % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\renewcommand{\ttdefault}{pcr} + +\lstdefinelanguage{latex}{ + language=[LaTeX]tex, + alsoletter={_,:}, + morekeywords={before,after,late,early,if, + error,always,because,loaded}, + moretexcs={RequirePackage,RequirePackageWithOptions,Load,LoadPackagesNow}, + mathescape, + texcsstyle=*\bfseries +} + +\lstset{ + language=latex, + escapechar=|, + basicstyle=\ttfamily\upshape, + keywordstyle=\ttfamily\upshape\bfseries, + keywordstyle=[2]\color{green!40!black}, + keywordstyle=[3]\itshape, + commentstyle=\color{gray}, + numbers=left, + numberstyle=\footnotesize, + frame=none, + columns=fixed, + literate={[} {\bfseries[} 1 + {]} {\bfseries]} 1 + {\{} {\bfseries\{} 1 + {\}} {\bfseries\}} 1 + {(} {\bfseries(} 1 + {)} {\bfseries)} 1 + {\&\&} {\bfseries\&\&} 2 + {||} {\bfseries||} 2 + {!} {\bfseries!} 1 + {,} {\bfseries,} 1 +} + +%%% Environments + +\lstnewenvironment{latex}[1][]{ + \lstset{language=latex, #1} +}{} +\NoIndentAfterEnv{latex} + +%%% File Input Command + +\NewDocumentCommand\inputlatexcode{ O{} m }{% + \lstinputlisting[% + language=latex, + literate={[} {\bfseries[} 1 + {]} {\bfseries]} 1 + {\{} {\bfseries\{} 1 + {\}} {\bfseries\}} 1 + {(} {\bfseries(} 1 + {)} {\bfseries)} 1 + {\&\&} {\bfseries\&\&} 2 + {||} {\bfseries||} 2 + {!} {\bfseries!} 1 + {,} {\bfseries,} 1, #1 + ]{#2}% + \NoIndentAfterThis% +} + + +%%% Code formatting + +\lstdefinestyle{examplecode}{% + language=latex,% + basicstyle=\ttfamily\small,% + texcsstyle=*\bfseries,% + keywordstyle=\bfseries% +} + +%%% Setting up example code block + +\definecolor{examplecodelinecolor}{rgb}{0,0,0} +\definecolor{examplecodebackgroundcolor}{rgb}{.9,.9,.9} +\newmdenv[ + linecolor = examplecodelinecolor, + backgroundcolor = examplecodebackgroundcolor, + skipabove = 0bp, + skipbelow = 0bp, + innertopmargin = -3bp, + innerrightmargin = 4bp, + innerbottommargin = -3bp, + innerleftmargin = 4bp +]{examplecodeframe} + +%%% Defining example output block + +\definecolor{exampleoutputbackgroundcolor}{rgb}{1,1,1} +\newmdenv[ + linecolor = examplecodelinecolor, + backgroundcolor = exampleoutputbackgroundcolor, + skipabove = 0bp, + skipbelow = 0bp, + innertopmargin = 4bp, + innerrightmargin = 4bp, + innerbottommargin = 4bp, + innerleftmargin = 4bp +]{exampleoutputframe} + +%%% Macros for counting lines in file, adapted from +%%% http://andreas.scherbaum.la/blog/archives/ +%%% 670-Read-number-lines-in-a-file-in-LaTeX.html +% +\RequirePackage{ifthen} +\newboolean{packagedoc@restfile} +\newcommand*{\packagedoc@fileline}{} +\newread\packagedoc@file +\newcommand*{\packagedoc@readnextline}[1]{% + \ifthenelse{\boolean{packagedoc@restfile}}{% + \read#1 to \packagedoc@fileline% + \ifeof#1\setboolean{packagedoc@restfile}{false}% + \else\fi% + }{}% +} +\newcommand*{\countlinesinfile}[2]{% + \setboolean{packagedoc@restfile}{true}% + \setcounter{packagedoc@linecount}{0}% + \openin\packagedoc@file=#1% + \whiledo{\boolean{packagedoc@restfile}}{% + \packagedoc@readnextline{\packagedoc@file}% + \ifthenelse{\boolean{packagedoc@restfile}}{% + \stepcounter{packagedoc@linecount}% + }{}% + }% + \closein\packagedoc@file% + \edef#2{\thepackagedoc@linecount}% +} + +\newcounter{packagedoc@linecount} +\newlength{\packagedoc@spacetoreserve} + +%%% DRYer without output +% +\NewDRYer{latex-example}{% + \addvspace{4bp}% + {% + \ttfamily\small% + \countlinesinfile{#1}{\countedlines}% + \setlength{\packagedoc@spacetoreserve}{\countedlines\baselineskip}% + \setlength{\packagedoc@spacetoreserve}{1.7\packagedoc@spacetoreserve}% + \addtolength{\packagedoc@spacetoreserve}{-4bp}% + \needspace{\packagedoc@spacetoreserve}% + }% + \begin{examplecodeframe}% + \renewcommand{\ttdefault}{pcr}% + \lstinputlisting[style=examplecode]{#1}% + \end{examplecodeframe}% + #2% + \addvspace{4bp}% +} +\NoIndentAfterEnv{latex-example} + +%%% DRYer WITH output but WITHOUT side-effects +% +\NewDRYer{latex-example-show}{% + \addvspace{4bp}% + {% + \ttfamily\small% + \countlinesinfile{#1}{\countedlines}% + \setlength{\packagedoc@spacetoreserve}{\countedlines\baselineskip}% + \setlength{\packagedoc@spacetoreserve}{1.7\packagedoc@spacetoreserve}% + \addtolength{\packagedoc@spacetoreserve}{\baselineskip}% + \needspace{\packagedoc@spacetoreserve}% + }% + \begin{examplecodeframe}% + \renewcommand{\ttdefault}{pcr}% + \lstinputlisting[style=examplecode]{#1}% + \end{examplecodeframe}\vspace{-4bp}% + \begin{exampleoutputframe}% + #2% + \end{exampleoutputframe}% + \addvspace{4bp}% +} +\NoIndentAfterEnv{latex-example-show} + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Implementation Code Box Setup % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%% Saving old implementation code block font +% +\AtBeginDocument{\let\old@macro@font\macro@font} + +%%% Setup for 'interesting' implementation code blocks +% +\definecolor{interestingcodebackgroundcolor}{rgb}{.9,.9,.9} +\definecolor{interestingcodelinecolor}{rgb}{0,0,0} +\mdfdefinestyle{interestingcode}{ + linecolor = interestingcodelinecolor, + backgroundcolor = interestingcodebackgroundcolor +} +\newcommand*{\interesting}{% + \def\codestyle{interestingcode}% + \let\macro@font\old@macro@font% +} + +%%% Setup for 'UNinteresting' implementation code blocks +% +\definecolor{uninterestingcodebackgroundcolor}{rgb}{.97,.97,.97} +\definecolor{uninterestingcodelinecolor}{rgb}{.5,.5,.5} +\definecolor{uninterestingcodecolor}{rgb}{.4,.4,.4} +\mdfdefinestyle{uninterestingcode}{ + linecolor = uninterestingcodelinecolor, + backgroundcolor = uninterestingcodebackgroundcolor, +} +\newcommand*{\uninteresting}{% + \def\codestyle{uninterestingcode}% + \def\macro@font{\color{uninterestingcodecolor}\old@macro@font}% + \vskip-\belowdisplayskip% + \vskip-1.05\abovedisplayskip% +} + +\BeforeBeginEnvironment{macrocode}{\vskip.2\abovedisplayskip} + +%%% Actually surround 'macrocode' with the frame +% +\surroundwithmdframed[ + style = \codestyle, + skipabove = 0bp, + skipbelow = 0bp, + splitbottomskip = 4bp, + innertopmargin =-3bp, + innerrightmargin = 1bp, + innerbottommargin = 4bp, + innerleftmargin = 1bp +]{macrocode} + +%%% Start out with 'interesting' code status and +%%% always go back to it after one code block +% +\interesting +\AfterEndEnvironment{macrocode}{\vskip\belowdisplayskip\interesting\NoIndentAfterThis} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Argument Specifiers and such % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newcommand*{\movarg}[1]{[ \texttt{#1} ]} +\newcommand*{\momarg}[1]{[ \meta{#1} ]} + +\newcommand{\describemacro}[2]{% + \needspace{3\baselineskip}% + \noindent\\\DescribeMacro{#1} #2\\\NoIndentAfterThis% +} + +\newcommand{\describeanymacro}[2]{% + \needspace{3\baselineskip}% + \noindent\\\marginnote{#1} #2\\\NoIndentAfterThis% +} + +\newcommand{\describemetamacro}[2]{% + \describeanymacro{\meta{#1}}{#2}% +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Other Stuff % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\NoIndentAfterEnv{description} +\NoIndentAfterEnv{itemize} +\NoIndentAfterEnv{enumerate} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Automatic Implementation Docs % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\AtEndDocument{ + \pagebreak + + \renewcommand{\ttdefault}{cmtt} + + \section{Implementation} \label{sec:implementation} + + \StopEventually {\PrintChanges} + + We now show and explain the entire implementation from \texttt{\packagename.sty}. + + \DocInput{\packagename.sty} + + \Finale + + \PrintIndex +} diff --git a/Master/texmf-dist/doc/latex/pkgloader/pkgloader.pdf b/Master/texmf-dist/doc/latex/pkgloader/pkgloader.pdf new file mode 100644 index 00000000000..0d788800559 Binary files /dev/null and b/Master/texmf-dist/doc/latex/pkgloader/pkgloader.pdf differ diff --git a/Master/texmf-dist/doc/latex/pkgloader/pkgloader.tex b/Master/texmf-dist/doc/latex/pkgloader/pkgloader.tex new file mode 100644 index 00000000000..1e186cf1ce1 --- /dev/null +++ b/Master/texmf-dist/doc/latex/pkgloader/pkgloader.tex @@ -0,0 +1,331 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \iffalse %%%% +% % +% Copyright (c) 2014 - Michiel Helvensteijn (www.mhelvens.net) % +% % +% https://github.com/mhelvens/latex-pkgloader % +% % +% This work may be distributed and/or modified under the conditions % +% of the LaTeX Project Public License, either version 1.3 of this % +% license or (at your option) any later version. The latest version % +% of this license is in http://www.latex-project.org/lppl.txt % +% and version 1.3 or later is part of all distributions of LaTeX % +% version 2005/12/01 or later. % +% % +% This work has the LPPL maintenance status `maintained'. % +% % +% The Current Maintainer of this work is Michiel Helvensteijn. % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \fi %%%% + +\documentclass[a4paper]{pkgloader-packagedoc} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Setup % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\def\nt#1{\ensuremath{\hbox{\footnotesize$\langle$}\mathit{#1}\hbox{\footnotesize$\rangle$}}} +\def\|{\ \mid\ } + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Global Changes % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\changes{0.1.0}{2014/01/29} + {initial version} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{document} % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\maketitle + +\section {Introduction} % % % % % % % % % % % % % % % % % % % % % % % % % % % % + +\LaTeX\ can be extended by loading packages +using a \lstinline+\usepackage+, \lstinline+\RequirePackage+ or \lstinline+\RequirePackageWithOptions+ command. +Packages can add definitions, change existing ones, or otherwise extend functionality of the language. + +While the Turing-complete power of the \TeX\ family is quite useful at times, it does +make it all too easy for independent package authors to step on each others +toes. CTAN is full of conceptually independent packages that cannot be +loaded together, or break if they are not loaded in a specific order. + +Yet, until now, there has been no automated package management to speak of. +Document authors are usually told to avoid certain package combinations, +or to load packages in some specific order. +Occasionally, package authors patch their code to be aware of specific +other packages, circumventing known conflicts. +But this makes maintenance more difficult, because these package authors +are `mixing concerns'; they put code related to other packages into their +own package. And it is all done in an ad-hoc fashion. + +Enter \lstinline+pkgloader+. + + + +\subsection {Package Description} % % % % % % % % % % % % % % % % % % % % % % + +Here is an example of main file for a \LaTeX\ document +which uses \lstinline+pkgloader+: + +\begin{latex} +\documentclass{article} + +\RequirePackage{pkgloader} + \usepackage{xltxtra} + \usepackage[xetex]{graphicx} + $\smash{\raisebox{-1pt}{\small\vdots}}$ +\LoadPackagesNow + +\begin{document} $\ldots$ \end{document} +\end{latex} + +The idea is to load \lstinline+pkgloader+ before loading any other package. +It can then intercept all package loading requests, analyze them +and load them properly, taking this burden off the shoulders of +the average document author. + +Between the second and sixth lines, the loading of all packages +is postponed. The \lstinline+\LoadPackagesNow+ command then +loads the packages in some valid order. During this process, +`conflict resolving' code may also be run, meant specifically to make +other packages work together properly. If the above code were +compiled without \lstinline+pkgloader+ (using the \XeTeX\ engine, as of this writing), +the given order between \lstinline+xltxtra+ and \lstinline+graphicx+ would +cause an error. +%% +The main advantage to this approach is that the complexity of dealing +with package conflicts is moved to the \lstinline+pkgloader+ package and handled +in a systematic manner. + +If you are a document author, this may be all you need to know to use +\lstinline+pkgloader+. If you are interested in more advanced functionality, +read on! + + +\subsection {The \texttt{pkgloader} Area} % % % % % % % % + +\describeanymacro + {\ttfamily\bfseries\textbackslash RequirePackage\!\!\!\!\!} + {{\ttfamily{\bfseries\{}pkgloader{\bfseries\}}\quad\ldots\quad{\bfseries\textbackslash LoadPackagesNow}}} + +The \lstinline+pkgloader+ area is the area between +\lstinline+\RequirePackage{pkgloader}+ and +\lstinline+\LoadPackagesNow+. +Within it, the three traditional package-loading commands +are `hijacked', recording information rather than loading +packages directly. Also, a \lstinline+\Load+ command is +available, which offers more flexibility in regulating +package loading behavior. + +|pkgloader| accepts sets of rules coming from outside +packages, though support is still somewhat limited. +Any |pkgloader-|\nt{something}|.sty| file can be loaded +within the |pkgloader| area by passing \nt{something} +as a package option. The file |pkgloader-recommended.sty| +is loaded this way by default. You can overwrite this by +passing |recommended=false| as an option. For example: + +\begin{latex} +\RequirePackage[recommended=false, my-better-rules]{pkgloader} + $\smash{\raisebox{-1pt}{\small\vdots}}$ +\LoadPackagesNow +\end{latex} + +This area does not play by the recommended package loading +rules, but uses the rules in |pkgloader-my-better-rules.sty| +instead. + + + +\subsection {Package Loading Requests} % % % % % % % % + + +\marginnote{\ttfamily\bfseries\textbackslash usepackage\\ + \textbackslash RequirePackage\\ + \textbackslash RequirePackageW{\ldots}s}\noindent +For requesting specific packages inside the |pkgloader| area, +just use the three commands always used +for this purpose: \lstinline+\usepackage+, \lstinline+\RequirePackage+ and +\lstinline+\RequirePackageWithOptions+. Their syntax and effective semantics +are the same as they have always been. Their effects are just delayed, +reordered and perhaps modified by the active rules. + + + +\subsection {Package Loading Rules} % % % % % % % % + +\marginnote{\ttfamily\bfseries\textbackslash Load}\noindent +Each invocation if the \lstinline+\Load+ command sets up a rule about +a package or packages, which are not necessarily ever loaded. +These rules can come from any number of different sources. +A central registry will be maintained together with \lstinline+pkgloader+ itself +in the form of |pkgloader-recommended.sty|, +specifying well-known conflicts and resolutions. +Individual package authors, however, can supply their own rules, +as can document authors. Though ideally, for the +average document author, things should `just work'. + +The \lstinline+\Load+ command expects the following syntax: + +\vskip\abovedisplayskip +\begingroup +\centering +\begin{tabular}{r@{\ \ \ \ }r@{\ \ \ \ }l} + \nt{load} &$::=$& \lstinline+\Load+$\ \nt{package}\ \ \nt{clause}_1\ \ldots\ \nt{clause}_i$ \\ + &$ \|$& \lstinline+\Load error+ $\ \ \ \,\nt{clause}_1\ \ldots\ \nt{clause}_i$ \\[2mm] + + \nt{package} &$::=$& \lstinline+[+$\;\nt{options}\;$\lstinline+] {+$\;\nt{pkg}\;$\lstinline+} [+$\;\nt{version}\;$\lstinline+]+ \\[2mm] + + \nt{clause} &$::=$& $\nt{order}\ \ \|\ \ \nt{condition}\ \ \|\ \ \nt{reason}$ \\[2mm] + + \nt{order} &$::=$& \lstinline+before {+ $\nt{pkg}_1\,$\lstinline+, +$\ldots\,$\lstinline+, +$\nt{pkg}_j$ \lstinline+}+ \\ + &$ \|$& \lstinline+after {+ $\nt{pkg}_1\,$\lstinline+, +$\ldots\,$\lstinline+, +$\nt{pkg}_j$ \lstinline+}+ \\ + &$ \|$& \lstinline+early+ \\ + &$ \|$& \lstinline+late+ \\[2mm] + + \nt{condition} &$::=$& \lstinline+always+ $\ \ \|\ \ $ + \lstinline+if loaded+ $\ \ \|\ \ $ + \lstinline+if {+ $\nt{\phi}$ \lstinline+}+ \\[2mm] + + \nt{\phi} &$::=$& $\nt{pkg}$ $\ \ \|\ \ $ + $\nt{\phi}\ $\lstinline+&&+$\ \nt{\phi}$ $\ \ \|\ \ $ + $\nt{\phi}\ $\lstinline+||+$\ \nt{\phi}$ $\ \ \|\ \ $ + \lstinline+!+$\;\nt{\phi}$ $\ \ \|\ \ $ + \lstinline+(+$\;\nt{\phi}\;$\lstinline+)+ \\[2mm] + + \nt{reason} &$::=$& \lstinline+because {+ $\nt{token{-}list}$ \lstinline+}+ +\end{tabular} +\endgroup +\vskip\belowdisplayskip + +\noindent +\nt{pkg} represents a package name. +\nt{token{-}list} should expand to a human-readable text without formatting. + +\marginnote{\ttfamily\bfseries if}\noindent +The \( \nt{condition} \) clause determines under which package loading +conditions any and all parts of a rule are invoked. +Here is an example of the use of the \( \nt{condition} \) clause: +\begin{latex} +\Load {res-ie-lst} if {inputenc && listings} +\Load {fixltx2e} always +\end{latex} + +\lstinline+res-ie-lst+ (a fictional package built specifically to resolve the +conflict between \lstinline+inputenc+ and \lstinline+listings+) will be loaded if requested +specifically, or if both \lstinline+inputenc+ and \lstinline+listings+ are loaded. The \lstinline+fixltx2e+ package is +always loaded, as it was created to smooth over some mistakes in the +\LaTeXe\ core. + +\marginnote{\ttfamily\bfseries always\\ if loaded} +The \lstinline+always+ keyword makes a rule unconditional. The \lstinline+if loaded+ +directive makes a rule conditional on its package already being loaded anyway. +This can be used to order two packages only when they are being loaded by other +means, and is actually the default behavior (in other words, \lstinline+if loaded+ +really does nothing). + +\marginnote{\ttfamily\bfseries before\\ after} +The \lstinline+before+ and \lstinline+after+ keywords should be pretty straightforward. They +can be used for things like: +\begin{latex} +\Load {xltxtra} after {graphicx} +\end{latex} +which fixes the loading order between these two packages when they are both loaded. + +\marginnote{\ttfamily\bfseries early\\ late} +But the set of \LaTeX\ packages is constantly growing, and it appears that +some big packages should almost always be loaded early in the process, +and others should almost always be loaded late. Therefore the \lstinline+early+ +and \lstinline+late+ stages are provided as a fallback mechanism. If two packages +are not related by an explicit application order, their loading order +may still be decided by their relative stages: \lstinline+early+ before `normal' before \lstinline+late+. +That way, conflicts may be avoided in a majority of cases. +This is implemented with |pkgloader-early| and |pkgloader-late| stubs in +the loading order graph. + +The following example uses the \( \nt{order} \) clause +in addition to the \( \nt{condition} \) clause: +\begin{latex} +\Load {res-ie-lst} if {inputenc && listings} + after {inputenc , listings} +\Load {fixltx2e} always early +\end{latex} +An important observation about the loading order is that it +might form a cycle when contradictory ordering rules are specified: +\begin{latex} +\Load {pkg1} after {pkg2} +\Load {pkg2} after {pkg1} +\end{latex} +In practice this could happen if the authors of \lstinline+pkg1+ and \lstinline+pkg2+ +independently discover a conflict, and both try to solve it by patching +their code and having their own package be loaded last. \lstinline+pkgloader+ +can provide a clear error message when this happens, allowing the +two package authors to seek contact and collaborate on a solution. + +\marginnote{\ttfamily\bfseries error} +Now, about the \lstinline+error+ keyword. +Initially all package combinations are valid. But if two packages +are irredeemably incompatible, their combination can be made to trigger +an error message by a command such as the following: +\begin{latex} +\Load error if {algorithms && pseudocode} +\end{latex} +These two packages provide almost identical functionality and conflict +on many command-names. It was generally agreed upon that they should +never be loaded together. Document authors should simply choose one +or the other. + +\marginnote{\ttfamily\bfseries because} +Finally, the \( \nt{reason} \) clause can be used to supply a +human-readable explanation of a rule. +We finish the above examples by providing reasons: +\begin{latex}[basewidth=.598em] +\Load {res-ie-lst} if {inputenc && listings} + after {inputenc , listings} + because {it allows the use of 1 byte unicode + characters in code listings} + +\Load {fixltx2e} always early + because {it fixes some imperfections in LaTeX2e} + +\Load error when {algorithms && pseudocode} + because {they provide almost identical functionality + and conflict on many command names} +\end{latex} +In the future, reasons will be extracted automatically to +generate documentation. For now, they are displayed with error +messages related to the rule in question. + + +\subsection {Status} % % % % % % % % + +So far, \lstinline+pkgloader+ seems to work as expected, but has not +yet been tested as extensively as it should be. Therefore, bug-reports +on the |pkgloader| issue tracker on Github would be most welcome. +Also, lots more recommended package loading rules are needed. + +I nonetheless decided to publish the package now, because I've been +promising to do so for a while now: + +\begin{center} + \url{http://tex.stackexchange.com/questions/123174} +\end{center} + +\noindent +I hope that, with feedback and community collaboration, +use of this package will become widespread and package +authors will be able to work in a more modular fashion. + +\emph{Future versions} of |pkgloader| will be able to deal with +document classes, to intelligently merge package options +and to track packages loaded by other packages in order +to better inform the user --- perhaps even fix problems +by carrying information into the next run through auxiliary files. +But most of this will depend on feedback. + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\end{document} % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Master/texmf-dist/doc/latex/pkgloader/test1.sty b/Master/texmf-dist/doc/latex/pkgloader/test1.sty new file mode 100644 index 00000000000..2a01c6236e4 --- /dev/null +++ b/Master/texmf-dist/doc/latex/pkgloader/test1.sty @@ -0,0 +1,3 @@ +\xdef\PackageOrderLog{\PackageOrderLog\quad test1[\csname opt@test1.sty\endcsname]} +\DeclareOption*{} +\ProcessOptions\relax diff --git a/Master/texmf-dist/doc/latex/pkgloader/test2.sty b/Master/texmf-dist/doc/latex/pkgloader/test2.sty new file mode 100644 index 00000000000..b817cf49be9 --- /dev/null +++ b/Master/texmf-dist/doc/latex/pkgloader/test2.sty @@ -0,0 +1,3 @@ +\xdef\PackageOrderLog{\PackageOrderLog\quad test2[\csname opt@test2.sty\endcsname]} +\DeclareOption*{} +\ProcessOptions\relax diff --git a/Master/texmf-dist/doc/latex/pkgloader/test3.sty b/Master/texmf-dist/doc/latex/pkgloader/test3.sty new file mode 100644 index 00000000000..933106879fe --- /dev/null +++ b/Master/texmf-dist/doc/latex/pkgloader/test3.sty @@ -0,0 +1,3 @@ +\xdef\PackageOrderLog{\PackageOrderLog\quad test3[\csname opt@test3.sty\endcsname]} +\DeclareOption*{} +\ProcessOptions\relax -- cgit v1.2.3