From c628b1aa9cf528de739c1de45acf3739561619ed Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Fri, 5 Nov 2021 03:01:04 +0000
Subject: CTAN sync 202111050301

---
 language/japanese/jlreq/jlreq.cls | 284 +++++++++++++++++++++++---------------
 1 file changed, 174 insertions(+), 110 deletions(-)

(limited to 'language/japanese/jlreq/jlreq.cls')

diff --git a/language/japanese/jlreq/jlreq.cls b/language/japanese/jlreq/jlreq.cls
index bd208994b0..a06ad633fc 100644
--- a/language/japanese/jlreq/jlreq.cls
+++ b/language/japanese/jlreq/jlreq.cls
@@ -5,9 +5,9 @@
 %%
 % (based on JLReq 20200811 https://www.w3.org/TR/2020/NOTE-jlreq-20200811/)
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesClass{jlreq}[2021/10/09 jlreq]
+\ProvidesClass{jlreq}[2021/11/05 jlreq]
 \RequirePackage{l3keys2e}
-\RequirePackage{ifthen}
+\RequirePackage{etoolbox}
 \RequirePackage{jlreq-helpers}
 
 \ExplSyntaxOn
@@ -105,7 +105,10 @@
     \tl_gput_right:Nn \g__jlreq_papersizelist_tl { { ##1 } { \setlength{\paperwidth}{#3} \setlength{\paperheight}{#4} } }
   }
   \clist_map_inline:nn {#2} {
-    \keys_define:nn { jlreq } { ##1 .code:n = { \setlength{\paperwidth}{#3} \setlength{\paperheight}{#4} } }
+    \keys_define:nn { jlreq } {
+      ##1 .code:n = { \setlength{\paperwidth}{#3} \setlength{\paperheight}{#4} },
+      ##1 .value_forbidden:n = true
+    }
   }
 }
 \keys_define:nn { jlreq } {
@@ -123,50 +126,142 @@
   }
 }
 
+\cs_set:Nn \__jlreq_addpapersize_withwarning:nnnn {
+  \exp_args:Nnnv \__jlreq_addpapersize_withwarning_aux:nnnn {#1}{#2}{jlreq@helper@papersizelist@#3}{#4}
+}
+\cs_set:Nn \__jlreq_addpapersize_withwarning_aux:nnnn {
+  \__jlreq_addpapersize_withwarning_auxi:nnnnn {#1}{#2}#3{#4}
+}
+\cs_set:Nn \__jlreq_addpapersize_withwarning_auxi:nnnnn {
+  \cs_set:Nn \l__jlreq_tmpa:n {
+    \ClassWarningNoLine{jlreq}{#5}
+  }
+  \clist_map_inline:nn {#1} {
+    \tl_gput_right:Nx \g__jlreq_papersizelist_tl { { ##1 } {
+      \exp_not:o { \l__jlreq_tmpa:n {##1} }
+      \exp_not:n { \setlength{\paperwidth}{#3} \setlength{\paperheight}{#4} }
+    } }
+  }
+  \clist_map_inline:nn {#2} {
+    \cs_set:Nx \l__jlreq_do: {
+      \exp_not:N \keys_define:nn { jlreq } {
+         ##1 .code:n = {
+          \exp_not:o { \l__jlreq_tmpa:n {##1} }
+          \exp_not:n { \setlength{\paperwidth}{#3} \setlength{\paperheight}{#4} }
+        },
+        ##1 .value_forbidden:n = true
+      }
+    }
+    \l__jlreq_do:
+  }
+}
+
+\tl_set:Nn \g__jlreq_papersizechangeddate_tl{2021-11-05}
+\cs_set:Nn \__jlreq_addpapersize_withjisBwarning:nnnn {
+  \__jlreq_addpapersize_withwarning:nnnn {#1} {#2} {#3} {The~option~`##1'~means~the~papersize~in~the~ISO~B-series,~not~in~the~JIS~B-series.~This~behavior~was~changed~from~jlreq~version~\g__jlreq_papersizechangeddate_tl.~Use~`paper=#4'~for~the~JIS-B-series.}
+}
+
 \__jlreq_aftercls_addtodeletecs:N \__jlreq_addpapersize:nnn
 \__jlreq_aftercls_addtodeletecs:N \__jlreq_addpapersize_aux:nnn
 \__jlreq_aftercls_addtodeletecs:N \__jlreq_addpapersize_auxi:nnnn
+\__jlreq_aftercls_addtodeletecs:N \__jlreq_addpapersize_withwarning:nnnn
+\__jlreq_aftercls_addtodeletecs:N \__jlreq_addpapersize_withwarning_aux:nnnn
+\__jlreq_aftercls_addtodeletecs:N \__jlreq_addpapersize_withwarning_auxi:nnnnn
+\__jlreq_aftercls_addtodeletecs:N \__jlreq_addpapersize_withjisBwarning:nnnn
 \__jlreq_aftercls_addtodeletecs:N \g__jlreq_papersizelist_tl
 
 % 紙サイズ一覧．b*はJIS B．
-\__jlreq_addpapersize:nnn{a0,A0}{}{a0}
-\__jlreq_addpapersize:nnn{a1,A1}{}{a1}
-\__jlreq_addpapersize:nnn{a2,A2}{}{a2}
-\__jlreq_addpapersize:nnn{a3,A3}{a3paper}{a3}
-\__jlreq_addpapersize:nnn{a4,A4}{a4paper}{a4}
-\__jlreq_addpapersize:nnn{a5,A5}{a5paper}{a5}
-\__jlreq_addpapersize:nnn{a6,A6}{a6paper}{a6}
-\__jlreq_addpapersize:nnn{a7,A7}{}{a7}
-\__jlreq_addpapersize:nnn{a8,A8}{}{a8}
-\__jlreq_addpapersize:nnn{a9,A9}{}{a9}
-\__jlreq_addpapersize:nnn{a10,A10}{}{a10}
-
-\__jlreq_addpapersize:nnn{b0,B0}{}{b0}
-\__jlreq_addpapersize:nnn{b1,B1}{}{b1}
-\__jlreq_addpapersize:nnn{b2,B2}{}{b2}
-\__jlreq_addpapersize:nnn{b3,B3}{}{b3}
-\__jlreq_addpapersize:nnn{b4,B4}{b4paper}{b4}
-\__jlreq_addpapersize:nnn{b5,B5}{b5paper}{b5}
-\__jlreq_addpapersize:nnn{b6,B6}{b6paper}{b6}
-\__jlreq_addpapersize:nnn{b7,B7}{}{b7}
-\__jlreq_addpapersize:nnn{b8,B8}{}{b8}
-\__jlreq_addpapersize:nnn{b9,B9}{}{b9}
-\__jlreq_addpapersize:nnn{b10,B10}{}{b10}
-
-\__jlreq_addpapersize:nnn{c2,C2}{}{c2}
-\__jlreq_addpapersize:nnn{c3,C3}{}{c3}
-\__jlreq_addpapersize:nnn{c4,C4}{}{c4}
-\__jlreq_addpapersize:nnn{c5,C5}{}{c5}
-\__jlreq_addpapersize:nnn{c6,C6}{}{c6}
-\__jlreq_addpapersize:nnn{c7,C7}{}{c7}
-\__jlreq_addpapersize:nnn{c8,C8}{}{c8}
+\__jlreq_addpapersize:nnn{a0paper}{}{a0paper}
+\__jlreq_addpapersize:nnn{a1paper}{}{a1paper}
+\__jlreq_addpapersize:nnn{a2paper}{}{a2paper}
+\__jlreq_addpapersize:nnn{a3paper}{a3paper}{a3paper}
+\__jlreq_addpapersize:nnn{a4paper}{a4paper}{a4paper}
+\__jlreq_addpapersize:nnn{a5paper}{a5paper}{a5paper}
+\__jlreq_addpapersize:nnn{a6paper}{a6paper}{a6paper}
+\__jlreq_addpapersize:nnn{a7paper}{}{a7paper}
+\__jlreq_addpapersize:nnn{a8paper}{}{a8paper}
+\__jlreq_addpapersize:nnn{a9paper}{}{a9paper}
+\__jlreq_addpapersize:nnn{a10paper}{}{a10paper}
+
+\__jlreq_addpapersize:nnn{a0,A0}{}{a0paper}
+\__jlreq_addpapersize:nnn{a1,A1}{}{a1paper}
+\__jlreq_addpapersize:nnn{a2,A2}{}{a2paper}
+\__jlreq_addpapersize:nnn{a3,A3}{}{a3paper}
+\__jlreq_addpapersize:nnn{a4,A4}{}{a4paper}
+\__jlreq_addpapersize:nnn{a5,A5}{}{a5paper}
+\__jlreq_addpapersize:nnn{a6,A6}{}{a6paper}
+\__jlreq_addpapersize:nnn{a7,A7}{}{a7paper}
+\__jlreq_addpapersize:nnn{a8,A8}{}{a8paper}
+\__jlreq_addpapersize:nnn{a9,A9}{}{a9paper}
+\__jlreq_addpapersize:nnn{a10,A10}{}{a10paper}
+
+\__jlreq_addpapersize:nnn{b0paper}{}{b0paper}
+\__jlreq_addpapersize:nnn{b1paper}{}{b1paper}
+\__jlreq_addpapersize:nnn{b2paper}{}{b2paper}
+\__jlreq_addpapersize:nnn{b3paper}{}{b3paper}
+\__jlreq_addpapersize:nnn{b4paper}{}{b4paper}
+\__jlreq_addpapersize:nnn{b5paper}{}{b5paper}
+\__jlreq_addpapersize:nnn{b6paper}{}{b6paper}
+\__jlreq_addpapersize:nnn{b7paper}{}{b7paper}
+\__jlreq_addpapersize:nnn{b8paper}{}{b8paper}
+\__jlreq_addpapersize:nnn{b9paper}{}{b9paper}
+\__jlreq_addpapersize:nnn{b10paper}{}{b10paper}
+
+\__jlreq_addpapersize:nnn{c2paper}{}{c2paper}
+\__jlreq_addpapersize:nnn{c3paper}{}{c3paper}
+\__jlreq_addpapersize:nnn{c4paper}{}{c4paper}
+\__jlreq_addpapersize:nnn{c5paper}{}{c5paper}
+\__jlreq_addpapersize:nnn{c6paper}{}{c6paper}
+\__jlreq_addpapersize:nnn{c7paper}{}{c7paper}
+\__jlreq_addpapersize:nnn{c8paper}{}{c8paper}
+
+\__jlreq_addpapersize:nnn{c2,C2}{}{c2paper}
+\__jlreq_addpapersize:nnn{c3,C3}{}{c3paper}
+\__jlreq_addpapersize:nnn{c4,C4}{}{c4paper}
+\__jlreq_addpapersize:nnn{c5,C5}{}{c5paper}
+\__jlreq_addpapersize:nnn{c6,C6}{}{c6paper}
+\__jlreq_addpapersize:nnn{c7,C7}{}{c7paper}
+\__jlreq_addpapersize:nnn{c8,C8}{}{c8paper}
+
+\__jlreq_addpapersize_withjisBwarning:nnnn{b0,B0}{}{b0paper}{b0j}
+\__jlreq_addpapersize_withjisBwarning:nnnn{b1,B1}{}{b1paper}{b1j}
+\__jlreq_addpapersize_withjisBwarning:nnnn{b2,B2}{}{b2paper}{b2j}
+\__jlreq_addpapersize_withjisBwarning:nnnn{b3,B3}{}{b3paper}{b3j}
+\__jlreq_addpapersize_withjisBwarning:nnnn{b4,B4}{}{b4paper}{b4j}
+\__jlreq_addpapersize_withjisBwarning:nnnn{b5,B5}{}{b5paper}{b5j}
+\__jlreq_addpapersize_withjisBwarning:nnnn{b6,B6}{}{b6paper}{b6j}
+\__jlreq_addpapersize_withjisBwarning:nnnn{b7,B7}{}{b7paper}{b7j}
+\__jlreq_addpapersize_withjisBwarning:nnnn{b8,B8}{}{b8paper}{b8j}
+\__jlreq_addpapersize_withjisBwarning:nnnn{b9,B9}{}{b9paper}{b9j}
+\__jlreq_addpapersize_withjisBwarning:nnnn{b10,B10}{}{b10paper}{b10j}
+
+\__jlreq_addpapersize_withjisBwarning:nnnn{}{b4paper}{b4paper}{b4j}
+\__jlreq_addpapersize_withjisBwarning:nnnn{}{b5paper}{b5paper}{b5j}
+\__jlreq_addpapersize_withjisBwarning:nnnn{}{b6paper}{b6paper}{b6j}
+
+\__jlreq_addpapersize:nnn{b0j}{}{b0j}
+\__jlreq_addpapersize:nnn{b1j}{}{b1j}
+\__jlreq_addpapersize:nnn{b2j}{}{b2j}
+\__jlreq_addpapersize:nnn{b3j}{}{b3j}
+\__jlreq_addpapersize:nnn{b4j}{}{b4j}
+\__jlreq_addpapersize:nnn{b5j}{}{b5j}
+\__jlreq_addpapersize:nnn{b6j}{}{b6j}
+\__jlreq_addpapersize:nnn{b7j}{}{b7j}
+\__jlreq_addpapersize:nnn{b8j}{}{b8j}
+\__jlreq_addpapersize:nnn{b9j}{}{b9j}
+\__jlreq_addpapersize:nnn{b10j}{}{b10j}
 
 \__jlreq_addpapersize:nnn{a4var}{}{a4var}
 \__jlreq_addpapersize:nnn{b5var}{}{b5var}
 
-\__jlreq_addpapersize:nnn{letter}{letterpaper}{letter}
-\__jlreq_addpapersize:nnn{legal}{legalpaper}{legal}
-\__jlreq_addpapersize:nnn{executive}{executivepaper}{executive}
+\__jlreq_addpapersize:nnn{letter,letterpaper}{letterpaper}{letterpaper}
+\__jlreq_addpapersize:nnn{legal,legalpaper}{legalpaper}{legalpaper}
+\__jlreq_addpapersize:nnn{executive,executivepaper}{executivepaper}{executivepaper}
+\__jlreq_addpapersize:nnn{ansiapaper}{}{ansiapaper}
+\__jlreq_addpapersize:nnn{ansibpaper}{}{ansibpaper}
+\__jlreq_addpapersize:nnn{ansicpaper}{}{ansicpaper}
+\__jlreq_addpapersize:nnn{ansidpaper}{}{ansidpaper}
+\__jlreq_addpapersize:nnn{ansiepaper}{}{ansiepaper}
 \__jlreq_addpapersize:nnn{hagaki}{}{hagaki}
 
 
@@ -978,35 +1073,6 @@
 \__jlreq_setprebreakpenalty:Vn \jlreq@charlist@inseparablecharacters {10000}
 % ￥100とか70％とか……
 
-%.. 文字範囲
-\ifx u\jlreq@engine
-  % \kcatcodeの設定
-  \cs_set:Nn \__jlreq_setkcatcode:nn {
-    \clist_map_inline:nn {#1} { \kcatcode"##1=#2\relax }
-  }
-  \__jlreq_aftercls_addtodeletecs:N \__jlreq_setkcatcode:nn
-  % LuaTeX-jaのデフォルトのままに近い設定をする
-  % 範囲1＆8
-  \__jlreq_setkcatcode:nn {80} {15} % Latin-1 Supplement，どうしよう……
-  \__jlreq_setkcatcode:nn {100,180,250,2B0,300,1E00} {15}
-  % 範囲2
-  \__jlreq_setkcatcode:nn {370,400,1F00} {18}
-  % 範囲3
-  \__jlreq_setkcatcode:nn {2000,2070,20A0,20D0,2100,2150,2190,2200,2300,2400,2500,2580,25A0,2600,2700,2900,2980,2B00} {18}
-  % 範囲4
-  \__jlreq_setkcatcode:nn {500,530,590,600,700,750,780,7C0,800,840,8A0,900,980,A00,A80,B00,B80,C00,C80,D00,D80,E00,E80,F00,1000,10A0,1200,1380,13A0,1400,1680,16A0,1700,1720,1740,1760,1780,1800,18B0,1900,1950,1980,19E0,1A00,1A20,1AB0,1B00,1B80,1BC0,1C00,1C50,1C80,1CC0,1CD0,1D00,1D80,1DC0,2400,2440,27C0,27F0,2800,2A00,2C00,4DC0,A4D0,A500,A640,A6A0,A700,A720,A800,A840,A880,A8E0,A900,A930,A960,A980,A9E0,AA00,AA60,AA80,AAE0,AB00,AB30,AB70,ABC0,FB00,FB50,FE00,FE20,FE70,10000,10080,10100,10140,10190,101D0,10280,102A0,102E0,10300,10330,10350,10380,103A0,10400,10450,10480,104B0,10500,10530,10600,10800,10840,10860,10880,108E0,10900,10920,10980,109A0,10A00,10A60,10A80,10AC0,10B00,10B40,10B60,10B80,10C00,10C80,10E60,11000,11080,110D0,11100,11150,11180,111E0,11200,11280,112B0,11300,11400,11480,11580,11600,11660,11680,11700,118A0,11AC0,11C00,11C70,12000,12400,12480,13000,14400,16800,16A40,16AD0,16B00,16F00,16FE0,17000,18800,1B000,1BC00,1BCA0,1D000,1D100,1D200,1D300,1D360,1D400,1D800,1E000,1E800,1E900,1EE00,1F000,1F030,1F0A0,1F100,1F200,1F300,1F600,1F650,1F680,1F700,1F780,1F800,1F900,E000} {15}
-  % 範囲5（Variation Selectors SupplementはLuaTeX-jaではE01F0--E01EFまで範囲5，他は範囲6）
-  \__jlreq_setkcatcode:nn {D800,DB80,DC00,E0000,F0000,100000} {15}
-  % 範囲6
-  \__jlreq_setkcatcode:nn {3040,30A0,31F0} {17} % Hiragana,Katakana,Katakana Phonetic Extensions
-  \__jlreq_setkcatcode:nn {2460,3000,3200,3300,FE10,FE30,FE50,E0100} {18} % Enclosed Alphanumerics,CJK Symbols and Punctuation,Enclosed CJK Letters and Months,CJK Compatibility,Vertical Forms,CJK Compatibility Forms,Small Form Variants,Variation Selectors Supplement
-  \__jlreq_setkcatcode:nn {2E80,3190,3400,4E00,F900,20000} {16}
-  % 範囲7
-  \__jlreq_setkcatcode:nn {A000,A490} {18} % Yi Syllables,Yi Radicals
-  \__jlreq_setkcatcode:nn {1100,3130,AC00,D7B0} {19} % Hangul Jamo,Hangul Compatibility Jamo,Hangul Syllables,Hangul Jamo Extended-B
-  \__jlreq_setkcatcode:nn {2F00,2FF0,3100,31A0,31C0,A830} {16}
-\fi
-
 %.. フォント
 \RequirePackage{lmodern}
 
@@ -1151,11 +1217,18 @@
 
 \emergencystretch 3\jlreq@gol
 \setlength{\parindent}{1\zw}
-\hook_gput_code:nnn { cmd/set@fontsize/after } {.} {
+\newcommand{\jlreqparindent}{1\zw}
+\apptocmd\set@fontsize {
   \expandafter\def\expandafter\size@update\expandafter{\size@update\g__jlreq_setfontsizehook_tl}
+}{}{
+  \ClassWarningNoLine { jlreq } { `\string\apptocmd`~to~`\string\size@update`~failed,~maybe~a~bug}
 }
 \tl_new:N \g__jlreq_setfontsizehook_tl
-\tl_set:Nn \g__jlreq_setfontsizehook_tl { \dim_compare:nT { \parindent>0pt } { \setlength{\parindent}{1\jlreq@zw} } }
+\tl_set:Nn \g__jlreq_setfontsizehook_tl { 
+  \tl_if_empty:VF \jlreqparindent {
+    \dim_compare:nT { \parindent>0pt } { \setlength{\parindent}{\jlreqparindent} }
+  }
+}
 \ifx l\jlreq@engine
   \@tempskipa=\ltjgetparameter{kanjiskip}
   \ifdim\@tempskipa=\maxdimen\else
@@ -1613,7 +1686,7 @@
 % デフォルトでは\<命令名>markと\addcontentslineが必要ならば呼ばれる．
 
 % 見出しの直前に実行される
-\NewHook{./heading/before}
+\cs_new:Nn \g__jlreq_hook_beforeheading:n {}
 % 見出し名一覧を格納する
 \seq_new:N \l__jlreq_heading_allheadings_seq
 % 目次を出力する命令\l@<命令名>を作る命令を作る．{1 = 命令名}{2 = レベル}{3 = ラベルのフォーマット}
@@ -1668,7 +1741,6 @@
 %.. 中/半扉見出し
 % addcontentslineに渡すやつ：番号出すのと出さないの
 \NewDocumentCommand{\DeclareTobiraHeading}{ m m +m } {
-  \ProvideHook{jlreq/heading/before/#1}
   \seq_put_right:Nn \l__jlreq_heading_allheadings_seq {#1}
   \seq_remove_duplicates:N \l__jlreq_heading_allheadings_seq
   \expandafter\def\csname jlreq@heading@level@#1\endcsname{#2}%
@@ -1747,8 +1819,7 @@
         \ifx\jlreq@pagestyle\@empty\else\noexpand\thispagestyle{\exp_not:o {\jlreq@pagestyle}}\fi
         \noexpand\secdef{\exp_not:c {jlreq@TobiraHeading@start@#1}}{\exp_not:c {jlreq@TobiraHeading@start@s@#1}}}%
       \noexpand\def\exp_not:c {#1}{%
-        \noexpand\UseHook{jlreq/heading/before}%
-        \noexpand\UseHook{jlreq/heading/before/#1}%
+        \exp_not:N \g__jlreq_hook_beforeheading:n {#1}
         \exp_not:c {jlreq@headingcs@#1}%
       }%
     }%
@@ -2125,12 +2196,18 @@
   \jlreq@ifgluezero\jlreq@tempskipb{}{\vskip\jlreq@tempskipb}%
   \edef\jlreq@do{%
     \dim_compare:nF { \parskip=0pt } {
-      \noexpand\AddToHookNext{para/before}{\noexpand\parskip=\the\parskip\noexpand\relax}%
+      \exp_not:N \cs_set:Nn \exp_not:N \g__jlreq_gyodori_hook_par: {
+        \noexpand\parskip=\the\parskip\noexpand\relax
+        \exp_not:n { \cs_set:Nn \g__jlreq_gyodori_hook_par: {} }
+      }
       \noexpand\parskip=0pt
     }
   }%
   \expandafter}\jlreq@do
 }
+\cs_set:Nn \g__jlreq_gyodori_hook_par: {}
+\PushPostHook{par}{\g__jlreq_gyodori_hook_par:}
+
 
 % 行取り情報をゲットだぜ
 % \jlreq@resultに{1 = 前空き}{2 = 後ろ空き}{3 = トータル行数}を入れる
@@ -2184,7 +2261,6 @@
 % \DeclareBlockHeading{命令名}{レベル}{設定}
 \seq_new:N \l__jlreq_BlockHeading_allheadings_seq
 \NewDocumentCommand {\DeclareBlockHeading} { m m +m } {
-  \ProvideHook{jlreq/heading/before/#1}
   \def\jlreq@do{\@removeelement{#1}}%
   \seq_put_right:Nn \l__jlreq_heading_allheadings_seq {#1}
   \seq_remove_duplicates:N \l__jlreq_heading_allheadings_seq
@@ -2416,8 +2492,7 @@
     \edef\jlreq@do{%
       \exp_not:o {\jlreq@do}%
       \noexpand\edef\exp_not:c {jlreq@headingcs@#1}{\noexpand\unexpanded{%
-        \noexpand\UseHook{jlreq/heading/before}%
-        \noexpand\UseHook{jlreq/heading/before/#1}%
+        \exp_not:N \g__jlreq_hook_beforeheading:n {#1}
         \exp_not:o {\jlreq@pagebreak}%
         \tl_if_empty:NF \l__jlreq_pagestyle_tl { \exp_not:N \thispagestyle {\exp_not:o { \l__jlreq_pagestyle_tl } } }
         \unexpanded{\jlreq@BlockHeading@start{#1}{#2}}%
@@ -2802,7 +2877,6 @@
   \__jlreq_declare_runin_heading:nnn {#1} {#2} {#3}
 }
 \cs_set:Nn \__jlreq_declare_runin_heading:nnn {
-  \hook_provide:n { jlreq/heading/before/#1 }
   \def\jlreq@do{\@removeelement{#1}}%
   \seq_put_right:Nn \l__jlreq_heading_allheadings_seq {#1}
   \seq_remove_duplicates:N \l__jlreq_heading_allheadings_seq
@@ -2861,8 +2935,7 @@
       % パラメータトークンを含むので，\edefして\unexpandedで包む
       \noexpand\edef\exp_not:c {#1}{%
         \noexpand\unexpanded{%
-          \exp_not:N \UseHook{jlreq/heading/before}%
-          \exp_not:N \UseHook{jlreq/heading/before/#1}
+          \exp_not:N \g__jlreq_hook_beforeheading:n {#1}
           \exp_not:n {\jlreq@RuninHeading@start{#1}{#2}}
             {\bool_if:NF \l__jlreq_number_bool {-}}
             {\exp_not:o {\l__jlreq_label_format_tl}}
@@ -2960,7 +3033,6 @@
 }
 
 \NewDocumentCommand{\DeclareCutinHeading}{ m m +m }{
-  \hook_provide:n { jlreq/heading/before/#1 }
   \expandafter\def\csname jlreq@heading@level@#1\endcsname{#2}
   \expandafter\def\csname jlreq@heading@setting@#1\endcsname{#3}
   \expandafter\def\csname jlreq@heading@type@#1\endcsname{\RenewCutinHeading}
@@ -2985,8 +3057,7 @@
     }{}%
     \cs_set:Nx \l__jlreq_do: {
       \exp_not:N \DeclareDocumentCommand \exp_not:c {#1} {m} {
-        \exp_not:N \UseHook{jlreq/heading/before}%
-        \exp_not:N \UseHook{jlreq/heading/before/#1}%
+        \exp_not:N \g__jlreq_hook_beforeheading:n {#1}
         \exp_not:N \__jlreq_CutinHeading_start:nnnnnnn{#1}{\exp_not:o \l__jlreq_fontcommand_tl}{\exp_not:o \l__jlreq_indent_tl}{\exp_not:o \l__jlreq_after_space_tl}{\exp_not:o \l__jlreq_onelinemax_tl}{\exp_not:o \l__jlreq_twolinemax_tl}{####1}
       }
     }
@@ -3411,23 +3482,15 @@
 \def\jlreq@endnote@texts{}
 \long\def\jlreq@endnote@addtext#1#2{\tl_gput_right:Nx \jlreq@endnote@texts { \exp_not:n {{{#1}{#2}}} } }
 % \endnote自身は後で定義する
-\NewHook{cmd/endnote/before}
-\NewHook{cmd/endnote/after}
-\NewHook{cmd/endnotemark/before}
-\NewHook{cmd/endnotemark/after}
 \NewDocumentCommand { \endnotemark }{ O{} } {
   \jlreq@hook@prenote
-  \UseHook{cmd/endnote/before}
   \jlreq@endnotemark{#1}
-  \UseHook{cmd/endnote/after}
   \jlreq@hook@postnote
 }
 \NewDocumentCommand { \endnotetext } { O{} +m } { \jlreq@endnotetext{#1}{#2} }
 \long\def\jlreq@endnote#1#2{
   \jlreq@hook@prenote
-  \UseHook{ cmd/endnote/before }
   \jlreq@endnotemark{#1}\@endnotetext{#2}
-  \UseHook{ cmd/endnote/after }
   \jlreq@hook@postnote
 }
 \def\jlreq@endnotemark#1{%
@@ -3517,11 +3580,13 @@
 }
 \let\@makeendmark=\@makefnmark
 
+\cs_new:Nn \g__jlreq_endnote_hook_beforeheading:n {}
+\apptocmd \g__jlreq_hook_beforeheading:n { \g__jlreq_endnote_hook_beforeheading:n {#1} }{}{
+  \ClassWarningNoLine { jlreq } { `\string\apptocmd`~to~`\string\g__jlreq_hook_beforeheading:n`~failed,~maybe~a~bug}
+}
 % \theendnoteの出力を仕込む
 \keys_define:nn { jlreqsetup } {
   endnote_position .code:n = {
-    \AddToHook{jlreq/heading/before}[jlreq/endnote]{}
-    \RemoveFromHook{jlreq/heading/before}[jlreq/endnote]
     \jlreq@tempafalse % headingsが指定された
     \jlreq@tempbfalse % paragraphが指定された
     % \jlreq@tempcにセクション名たちを入れていく
@@ -3545,7 +3610,7 @@
     
     \ifjlreq@tempb
       \DeclareDocumentCommand { \endnote } { O{} +m } {
-        \AddToHookNext { para/after } { \theendnotes }
+        \def\par{\@restorepar\theendnotes\par}
         \jlreq@endnote{##1}{##2}
       }
     \else
@@ -3555,15 +3620,17 @@
     \fi
 
     \ifjlreq@tempa
-      \AddToHook{jlreq/heading/before}[jlreq/endnote]{\theendnotes}
+      \cs_set:Nn \g__jlreq_endnote_hook_beforeheading:n {\theendnotes}
     \else
-      \seq_map_variable:NNn \l_jlreq_tmpa_seq \@tempa {
-        \tl_if_empty:VF \@tempa {
-          \AddToHook{jlreq/heading/before/\@tempa}[jlreq/endnote]{}
-          \RemoveFromHook{jlreq/heading/before/\@tempa}[jlreq/endnote]
-          \AddToHook{jlreq/heading/before/\@tempa}[jlreq/endnote]{\theendnotes}
+      \tl_set:Nn \l__jlreq_tmpa_tl {}
+      \seq_map_inline:Nn \l_jlreq_tmpa_seq {
+        \tl_if_empty:nF {##1} {
+          \tl_put_right:Nn \l__jlreq_tmpa_tl { {##1} {\theendnotes} }
         }
       }
+      \cs_set:Nx \g__jlreq_endnote_hook_beforeheading:n {
+        \exp_not:N \str_case:nn { ##1 } { \exp_not:o { \l__jlreq_tmpa_tl } }
+      }
     \fi
   }
 }
@@ -3579,10 +3646,6 @@
 % (2) では\sidenote{見出し}{注中身}を定義
 % sidenote_length>0ptの時のみ定義する
 \dim_compare:nT { \jlreq@sidenote@length > 0pt } {
-  \ProvideHook{ cmd/sidenote/before }
-  \ProvideHook{ cmd/sidenote/after }
-  \ProvideHook{ cmd/sidenotemark/before }
-  \ProvideHook{ cmd/sidenotemark/after }
   \def\jlreq@sidenotemarkname{@thefnmark}% 合印用番号を一時的に入れるマクロ名
   \long\def\@sidenotetext#1{%
     \marginpar{\reset@font\footnotesize
@@ -3600,14 +3663,14 @@
   \__jlreq_jlreqsetup_addtofinally:n {
     \str_if_eq:VnT \jlreq@sidenote@type { number } {
       \DeclareDocumentCommand { \sidenote } { O{} +m } {
-        \jlreq@hook@prenote\UseHook{cmd/sidenote/before}
+        \jlreq@hook@prenote
         \jlreq@sidenote{#1}{#2}
-        \UseHook{cmd/sidenote/after}\jlreq@hook@postnote
+        \jlreq@hook@postnote
       }
       \DeclareDocumentCommand { \sidenotemark } { O{}   } {
-        \jlreq@hook@prenote\UseHook{cmd/sidenotemark/before}
+        \jlreq@hook@prenote
         \jlreq@sidenotemark{#1}
-        \UseHook{cmd/sidenotemark/after}\jlreq@hook@postnote
+        \jlreq@hook@postnote
       }
       \DeclareDocumentCommand { \sidenotetext } { O{} +m } { \jlreq@sidenotetext{#1}{#2} }
       \long\def\jlreq@sidenote#1#2{\jlreq@sidenotemark{#1}\@sidenotetext{#2}}
@@ -3644,8 +3707,8 @@
       \let\@makesidemark=\@makefnmark
     }
     \str_if_eq:VnT \jlreq@sidenote@type { symbol } {% sidenote_type = symbol
-      \DeclareDocumentCommand { \sidenote     } { m +m } { \UseHook{cmd/sidenote/before}\jlreq@sidenote{#1}{#2}\UseHook{cmd/sidenote/after} }
-      \DeclareDocumentCommand { \sidenotemark } { m   } { \UseHook{cmd/sidenotemark/before}\jlreq@sidenotemark{#1}\UseHook{cmd/sidenote/after} }
+      \DeclareDocumentCommand { \sidenote     } { m +m } { \jlreq@sidenote{#1}{#2} }
+      \DeclareDocumentCommand { \sidenotemark } { m    } { \jlreq@sidenotemark{#1} }
       \DeclareDocumentCommand { \sidenotetext } { m +m } { \jlreq@sidenotetext{#1}{#2} }
       \long\def\jlreq@sidenote#1#2{\jlreq@sidenotemark{#1}\jlreq@sidenotetext{#1}{#2}}
       \edef\jlreq@sidenotemark#1{%
@@ -5976,7 +6039,8 @@
   \itemindent=\dimexpr\jlreq@theorem@indent\relax
   \jlreq@theorem@font
   \item[\hskip \labelsep{\reset@font\jlreq@theorem@label@font #1\ #2（#3）}]}
-\AddToHook{package/after/amsthm}{
+\RequirePackage{filehook}
+\AtEndOfPackageFile{amsthm}{
   \jlreq@saveoriginalcs{proof}%
   \jlreq@saveoriginalcs{endproof}%
   \edef\jlreq@do{
-- 
cgit v1.2.3

