Last active
October 2, 2020 23:34
-
-
Save aminophen/18f4018a9b4a9e6429e325f98197587c to your computer and use it in GitHub Desktop.
\AtEndOfPackage{\RequirePackage{hoge}} の困ったエラーをなんとかするアレ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%% Code updated (2016-09-16 19:02 GMT+09:00) | |
\begin{filecontents}{test.sty} | |
\DeclareOption{TEST}{\typeout{*** TEST OPTION ***}} | |
\ProcessOptions | |
\AtEndOfPackage{\RequirePackage{xspace}} % some package without \ProcessOptions | |
\end{filecontents} | |
% !!! TeX code BEGIN | |
\makeatletter | |
\def\@process@pti@ns{% | |
\@for\CurrentOption:=\@curroptions\do{% | |
\@ifundefined{ds@\CurrentOption}% | |
{\@use@ption | |
\default@ds}% | |
\@use@ption}% | |
\@for\CurrentOption:=\@declaredoptions\do{% | |
\expandafter\let\csname ds@\CurrentOption\endcsname\relax}% | |
\let\CurrentOption\@empty | |
\let\@fileswith@pti@ns\@@fileswith@pti@ns | |
\AtEndOfPackage{% | |
\expandafter\let\csname @unprocessedoptions-\@currname.\@currext\endcsname % !!! | |
\relax}} | |
\def\RequirePackageWithOptions{% | |
\AtEndOfPackage{% | |
\expandafter\let\csname @unprocessedoptions-\@currname.\@currext\endcsname % !!! | |
\relax}% | |
\@loadwithoptions\@pkgextension\RequirePackage} | |
\def\@onefilewithoptions#1[#2][#3]#4{% | |
\@pushfilename | |
\xdef\@currname{#1}% | |
\global\let\@currext#4% | |
\expandafter\let\csname\@currname.\@currext-h@@k\endcsname\@empty | |
\let\CurrentOption\@empty | |
\@reset@ptions | |
\makeatletter | |
\def\reserved@a{% | |
\@ifl@aded\@currext{#1}% | |
{\@if@ptions\@currext{#1}{#2}{}% | |
{\@latex@error | |
{Option clash for \@cls@pkg\space #1}% | |
{The package #1 has already been loaded | |
with options:\MessageBreak | |
\space\space[\@ptionlist{#1.\@currext}]\MessageBreak | |
There has now been an attempt to load it | |
with options\MessageBreak | |
\space\space[#2]\MessageBreak | |
Adding the global options:\MessageBreak | |
\space\space | |
\@ptionlist{#1.\@currext},#2\MessageBreak | |
to your \noexpand\documentclass declaration may fix this.% | |
\MessageBreak | |
Try typing \space <return> \space to proceed.}}}% | |
{\@pass@ptions\@currext{#2}{#1}% | |
\global\expandafter | |
\let\csname ver@\@currname.\@currext\endcsname\@empty | |
\InputIfFileExists | |
{\@currname.\@currext}% | |
{}% | |
{\@missingfileerror\@currname\@currext}% | |
\expandafter\let\csname @unprocessedoptions-\@currname.\@currext\endcsname % !!! | |
\@@unprocessedoptions | |
\csname\@currname.\@currext-h@@k\endcsname | |
\expandafter\let\csname\@currname.\@currext-h@@k\endcsname | |
\@undefined | |
\ifx\@unprocessedoptions\relax %%% !!! If the package has redefined to \relax | |
\let\@unprocessedoptions\@undefined % !!! then, no error should appear; re-initialization only | |
\else %%% !!! | |
\csname @unprocessedoptions-\@currname.\@currext\endcsname % !!! | |
\fi %%% !!! | |
\expandafter\let\csname @unprocessedoptions-\@currname.\@currext\endcsname % !!! | |
\@undefined} % !!! | |
\@ifl@ter\@currext{#1}{#3}{}% | |
{\@latex@warning@no@line | |
{You have requested,\on@line, | |
version\MessageBreak | |
`#3' of \@cls@pkg\space #1,\MessageBreak | |
but only version\MessageBreak | |
`\csname ver@#1.\@currext\endcsname'\MessageBreak | |
is available}}% | |
\ifx\@currext\@clsextension\let\LoadClass\@twoloadclasserror\fi | |
\@popfilename | |
\@reset@ptions}% | |
\reserved@a} | |
\let\@unprocessedoptions\@undefined %%% !!! Initially \@undefined; kernel won't use it | |
\makeatother | |
% !!! TeX code END | |
\documentclass{article} | |
\usepackage[TEST]{test} | |
\begin{document} | |
success! | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Integrated into LaTeX2e 2020-10-01. Thanks!