summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-07-11 19:57:52 +0000
committerKarl Berry <karl@freefriends.org>2024-07-11 19:57:52 +0000
commit9a620ad83fab5020d50f5f5e2912ce0e010d7412 (patch)
tree6343ee26d9a22c832da391ca70dc7a6b3f7f00d5 /Master/texmf-dist
parentcd12fa7b48dd3c5cd65a68c25b3f103385c726a9 (diff)
passopt (11jul24)
git-svn-id: svn://tug.org/texlive/trunk@71775 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/passopt/README.md15
-rw-r--r--Master/texmf-dist/doc/latex/passopt/passopt.pdfbin0 -> 48213 bytes
-rw-r--r--Master/texmf-dist/doc/latex/passopt/passopt.tex94
-rw-r--r--Master/texmf-dist/tex/latex/passopt/passopt.sty60
4 files changed, 169 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/passopt/README.md b/Master/texmf-dist/doc/latex/passopt/README.md
new file mode 100644
index 00000000000..c0b5fa23f19
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/passopt/README.md
@@ -0,0 +1,15 @@
+# The `passopt` package
+Passing options to packages or classes (v1.00a)
+
+## Abstract
+`passopt` allow reset the global options of a loaded macro package or document class, or to change the position of the pre-passed options in the list to the right.
+
+## License
+This work may be distributed and/or modified under the conditions of the CC-BY 4.0 License. The latest version of this license is in https://creativecommons.org/licenses/by/4.0/legalcode
+
+## Website
+| [Gitee](https://gitee.com/texno3/passopt) | [Github](https://github.com/texno3/passopt) | [CTAN](https://ctan.org/pkg/passopt) |
+
+## Maintainer
+QuYi<br/>
+Email: toquyi@163.com \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/passopt/passopt.pdf b/Master/texmf-dist/doc/latex/passopt/passopt.pdf
new file mode 100644
index 00000000000..cdfb11925c8
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/passopt/passopt.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/passopt/passopt.tex b/Master/texmf-dist/doc/latex/passopt/passopt.tex
new file mode 100644
index 00000000000..2b8f694dd68
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/passopt/passopt.tex
@@ -0,0 +1,94 @@
+\documentclass[load-preamble+]{cnltx-doc}
+
+\usepackage{setspace,hologo,changelog,enumitem}
+\usepackage[margin = 1in,marginparwidth = 0.6in,footskip = 0.5in]{geometry}
+\setcnltx
+ {
+ package = passopt,
+ version = v1.00a,
+ date = 2024/07/10,
+ authors = Qu Yi,
+ info = Passing options to packages or classes,
+ email = toquyi@163.com,
+ url = https://github.com/texno3/passopt,
+ abstract =
+ {
+ \pkg*{passopt} allow reset the global options of a loaded macro package or document class, or to change the position of the pre-passed options in the list to the right.
+ },
+ color-scheme = blue,
+ listings-options = {numbers = none,gobble = 2,lineskip = 1pt},
+ pre-output = {\parindent = 0em\setstretch{1.3}},
+ before-skip = \smallskipamount,
+ after-skip = \smallskipamount
+ }
+\makeatletter
+\newcommand{\splitmeta}[2]{\meta{#1}\texttt{,}\meta{#2}}
+\newcommand{\newsplitarg}[4][\splitmeta]
+ {
+ \newcommand{#2}[2]
+ {\code{\textcolor{argument}{#3\textnormal{#1{##1}{##2}}#4}}}
+ }
+\newcommand{\kvsplit}[3]
+ {
+ \item\code{\option{#1}\cnltx@isvalue\splitmarg{#2}{#3}}
+ \cnltx@checkdefault{\hfill\newline}
+ }
+\newsplitarg{\splitoarg}{[}{]}
+\newsplitarg{\splitmarg}{\{}{\}}
+\newsplitarg{\splitdarg}{(}{)}
+\newnote{\newtag}[1]{\textcolor{red}{#1}}
+\renewcommand{\emph}[1]{\textcolor{red}{#1}}
+\renewcommand{\cnltx@write@lastname}{}
+\setlist{nosep,topsep = \smallskipamount}
+\setlist[description,1]{leftmargin = \parindent}
+\setlist[itemize,1]{leftmargin = *}
+\makeatother
+
+\begin{document}
+\section{Preface}
+For a developer, there are some cases where packages and classes may load other packages or classes with options. However, other developers or users may wish to disable the enabled options or enable new ones. To enable new options, \hologo{LaTeXe} provides the \cs{PassOptionsToPackage} and \cs{PassOptionsToClass} commands to pass the options before the package or class is loaded, but the passed options are located on the \textcolor{red}{left} side of the final options list.
+\begin{sourcecode}
+ \PassOptionsToPackage{opt1,opt2=A}{mypackage}
+
+ \documentclass{book}
+ \usepackage[opt3]{mypackage}
+
+ \begin{document}
+ \end{document}
+\end{sourcecode}
+
+In the example above, the list of options that the \pkg*{mypackage} macro package ends up executing is \fbox{\code{opt1,opt2=A,opt3}}. If you wish to \textcolor{red}{disable} the pre-enabled options or place the newly enabled options to the \textcolor{red}{right} of the list (last executed), then you need to modify the code of the load command in the package or class file, but this is not recommended for public sharing. Therefore, this macro package provides commands to reset the options and change the order of the new options.
+
+\section{User commands}
+\begin{commands}
+ \command{SetOptionsToPackage}[\sarg\marg{options list}\marg{package}]
+ Passes options to the macro package, the location of the passed options is to the right of the options used when loading the macro package. If an asterisk parameter is used, only the passed options were ultimately retained.
+ \command{SetOptionsToClass}[\sarg\marg{options list}\marg{class}]
+ Similar to the previous command, but passing options for the document class.
+ \begin{sourcecode}
+ \RequirePackage{passopt}
+ \SetOptionsToPackage{opt1,opt2=A}{mypackage}
+
+ \documentclass{book}
+ \usepackage[opt3]{mypackage}
+
+ \begin{document}
+ \end{sourcecode}
+
+ In the example above, the list of options that the \pkg*{mypackage} macro package ends up executing is \fbox{\code{opt3,opt1,opt2=A}}. If the asterisk parameter is used, the list is \fbox{\code{opt1,opt2=A}}.
+
+ Note that since macro packages or document classes can only be loaded effectively once (using the \cs{usepackage} and \cs{RequirePackage} commands), only options passed before the first loading of a macro package or document class are effective, and it is recommended for users to use commands that pass options before \cs{documentclass}.
+ \command{ClearPackageOptions}[\marg{package}]
+ Clears the options that will be loaded into the macro package. The following commands has the same effect as \cs*{SetOptionsToPackage}\code{*}.
+ \begin{sourcecode}
+ \ClearPackageOptions{mypackage}
+ \SetOptionsToPackage{opt1,opt2=A}{mypackage}
+ \end{sourcecode}
+ \command{ClearClassOptions}[\marg{class}]
+ Similar to the previous command, but passing options for the document class.
+\end{commands}
+
+\appendix
+\nocite{*}
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/passopt/passopt.sty b/Master/texmf-dist/tex/latex/passopt/passopt.sty
new file mode 100644
index 00000000000..6149c974043
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/passopt/passopt.sty
@@ -0,0 +1,60 @@
+%
+% ***************** THE PASSOPT PACKAGE *****************
+%
+% Copyright (C) 2024 by Qu Yi <toquyi@163.com>
+%
+% This work may be distributed and/or modified under the
+% conditions of the CC-BY 4.0 License.
+% The latest version of this license is in
+% https://creativecommons.org/licenses/by/4.0/legalcode
+\NeedsTeXFormat{LaTeX2e}[2021/11/15]
+\ProvidesExplPackage{passopt}{2024/07/10}{1.00a}
+ {Passing options to packages or classes}
+
+\cs_generate_variant:Nn \tl_if_blank:nF { v }
+\cs_new:Npn \po_save_option_list:n #1 { #1 }
+\cs_new:Npn \po_add_before_hook:nnn #1#2
+ { \AddToHook{#1/#2/before}[passopt] }
+\NewDocumentCommand{\SetOptionsToPackage}{smm}
+ {
+ \po_add_before_hook:nnn { package } {#3}
+ {
+ \cs_gset:cpx { @raw@opt@#3.sty }
+ {
+ \IfBooleanF{#1}
+ {
+ \tl_if_blank:vF { opt@#3.sty }
+ { \use:c { opt@#3.sty }, }
+ }
+ \po_save_option_list:n {#2}
+ }
+ }
+ }
+\NewDocumentCommand{\SetOptionsToClass}{smm}
+ {
+ \po_add_before_hook:nnn { class } {#3}
+ {
+ \cs_gset:cpx { @raw@opt@#3.cls }
+ {
+ \IfBooleanF{#1}
+ {
+ \tl_if_blank:vF { opt@#3.cls }
+ { \use:c { opt@#3.cls }, }
+ }
+ \po_save_option_list:n {#2}
+ }
+ }
+ }
+\cs_new_protected:Npn \ClearPackageOptions #1
+ {
+ \po_add_before_hook:nnn { package } {#1}
+ { \tl_clear:c { opt@#1.sty } }
+ }
+\cs_new_protected:Npn \ClearClassOptions #1
+ {
+ \po_add_before_hook:nnn { class } {#1}
+ { \tl_clear:c { opt@#1.cls } }
+ }
+\endinput
+%
+% End of file `passopt.sty'. \ No newline at end of file