From 9e46b83b2d49ad6f5d4285266a81c9af1dd3d74e Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Fri, 23 Jul 2021 03:00:51 +0000
Subject: CTAN sync 202107230300

---
 language/japanese/jlreq/jlreq.cls | 2304 +++++++++++++++++++------------------
 1 file changed, 1160 insertions(+), 1144 deletions(-)

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

diff --git a/language/japanese/jlreq/jlreq.cls b/language/japanese/jlreq/jlreq.cls
index 477a34af98..434cd4f5b8 100644
--- a/language/japanese/jlreq/jlreq.cls
+++ b/language/japanese/jlreq/jlreq.cls
@@ -5,11 +5,10 @@
 %%
 % (based on JLReq 20200811 https://www.w3.org/TR/2020/NOTE-jlreq-20200811/)
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesClass{jlreq}[2021/05/28 jlreq]
-\RequirePackage{xkeyval,everyhook,etoolbox,ifthen}
+\ProvidesClass{jlreq}[2021/07/22 jlreq]
+\RequirePackage{l3keys2e,etoolbox}
 \RequirePackage{jlreq-helpers}
 
-
 \ExplSyntaxOn
 \tl_new:N \l_jlreq_tmpa_tl
 \cs_new:Nn \l_jlreq_do: {}
@@ -18,14 +17,18 @@
 \str_new:N \l_jlreq_tmpc_str
 \bool_new:N \l_jlreq_tmpa_bool
 \clist_new:N \l_jlreq_tmpa_clist
-\ExplSyntaxOff
+\dim_new:N \l_jlreq_tmpa_dim
+\skip_new:N \l_jlreq_tmpa_skip
+\box_new:N \l_jlreq_tmpa_box
+\box_new:N \l_jlreq_tmpb_box
+\box_new:N \l_jlreq_tmpc_box
 
-\newcommand*{\jlreq@undeferr}[1]{\ClassError{jlreq}{Trying to delete \string#1 even though it is not defined, may be a bug}{\@ehc}}
+\def\jlreq@undeferr#1{\ClassError{jlreq}{Trying~to~delete~\string#1~even~though~it~is~not~defined,~may~be~a~bug}{\@ehc}}
 % クラスファイル内でしか使わないマクロをクラスファイル終了時に未定義にする
-\newcommand*{\jlreq@aftercls@addtodeletecs}[1]{%
+\def\jlreq@aftercls@addtodeletecs#1{%
   \appto\jlreq@aftercls@deletecslist{\jlreq@helper@undefcs{#1}{\jlreq@undeferr}}%
 }
-\newcommand*{\jlreq@aftercls@addtodeleteif}[1]{%
+\def\jlreq@aftercls@addtodeleteif#1{%
   \appto\jlreq@aftercls@deletecslist{\jlreq@helper@undefif{#1}{\jlreq@undeferr}}%
 }
 \jlreq@aftercls@addtodeletecs{\jlreq@aftercls@addtodeletecs}
@@ -43,10 +46,10 @@
 
 \def\jlreq@saveoriginalcs#1{%
   \@ifundefined{#1}{
-    \ClassError{jlreq}{Trying to save #1 but it's not defined, may be a bug}{\@ehc}%
+    \ClassError{jlreq}{Trying~to~save~#1~but~it's~not~defined,~may~be~a~bug}{\@ehc}%
   }{}
   \@ifundefined{jlreq@original@#1}{}{
-    \ClassError{jlreq}{Trying to save #1 twice, may be a bug}{\@ehc}%
+    \ClassError{jlreq}{Trying~to~save~#1~twice,~may~be~a~bug}{\@ehc}%
   }
   \begingroup
     \edef\jlreq@do{\noexpand\let\expandonce{\csname jlreq@original@#1\endcsname}=\expandonce{\csname #1\endcsname}}
@@ -67,25 +70,16 @@
 % オプション処理の際にしか使わない変数（後でそれを元に別の変数を調整する）
 % ものは\jlreq@option@<key>に格納する．
 % _とかは@に変換する．
-% 引数無しの\DeclareOptionX
-\newcommand*{\jlreq@DeclareOption}[2]{%
-  \DeclareOptionX{#1}{%
-    \jlreq@ifempty{##1}{}{\ClassError{jlreq}{The option #1 should have no value}{\@ehc}}%
-    #2%
-  }
-}
-\jlreq@aftercls@addtodeletecs{\jlreq@DeclareOption}
 % エンジン類
-\jlreq@DeclareOption{uplatex}{\let\jlreq@engine=u}
-\jlreq@DeclareOption{platex}{\let\jlreq@engine=p}
-\jlreq@DeclareOption{lualatex}{\let\jlreq@engine=l}
+\keys_define:nn { jlreq } { uplatex .code:n = { \let\jlreq@engine=u }, uplatex .value_forbidden:n = true }
+\keys_define:nn { jlreq } { platex .code:n = { \let\jlreq@engine=p }, platex .value_forbidden:n = true }
+\keys_define:nn { jlreq } { lualatex .code:n = { \let\jlreq@engine=l }, lualatex .value_forbidden:n = true }
 
 % 文書のタイプ
-\newcommand*{\jlreq@article@type}{article}
-\define@choicekey{jlreq.cls}{article_type}{article,report,book}{\renewcommand*{\jlreq@article@type}{#1}}
-\jlreq@DeclareOption{article}{\renewcommand*{\jlreq@article@type}{article}}
-\jlreq@DeclareOption{report}{\renewcommand*{\jlreq@article@type}{report}}
-\jlreq@DeclareOption{book}{\renewcommand*{\jlreq@article@type}{book}}
+\keys_define:nn { jlreq } { article_type .choices:nn = {article,report,book}{\def\jlreq@article@type{#1}} }
+\keys_define:nn { jlreq } { article .code:n = { \def\jlreq@article@type{article} }, article .value_forbidden:n = true }
+\keys_define:nn { jlreq } { report .code:n = { \def\jlreq@article@type{report} }, report .value_forbidden:n = true }
+\keys_define:nn { jlreq } { book .code:n = { \def\jlreq@article@type{book} }, book .value_forbidden:n = true }
 
 %.. 基本版面．まずは紙サイズ．
 \def\jlreq@switchpapersize{}
@@ -99,31 +93,36 @@
   \edef\@tempa{\unexpanded{\jlreq@addpapersize@@{#1}{#2}}\csexpandonce{jlreq@helper@papersizelist@#3}}%
   \@tempa
 }
-\newcommand*{\jlreq@addpapersize@@}[4]{%
-  \@for\@tempa:=#1\do{%
+\def\jlreq@addpapersize@@#1#2#3#4{%
+  \clist_map_variable:nNn {#1} \@tempa {
     \eappto\jlreq@switchpapersize{{\expandonce{\@tempa}}{\unexpanded{\setlength{\paperwidth}{#3}\setlength{\paperheight}{#4}}}}%
   }%
-  \@for\@tempa:=#2\do{%
-    \expandafter\jlreq@DeclareOption\expandafter{\@tempa}{\setlength{\paperwidth}{#3}\setlength{\paperheight}{#4}}%
-  }%
+  \clist_map_inline:nn {#2}  {
+    \keys_define:nn { jlreq } {
+      ##1 .code:n = { \setlength{\paperwidth}{#3}\setlength{\paperheight}{#4} },
+      ##1 .value_forbidden:n = true
+    }
+  }
 }
 \jlreq@aftercls@addtodeletecs{\jlreq@addpapersize}
 \jlreq@aftercls@addtodeletecs{\jlreq@addpapersize@}
 \jlreq@aftercls@addtodeletecs{\jlreq@addpapersize@@}
-\DeclareOptionX{paper}{
-  \edef\jlreq@do{%
-    \unexpanded{\jlreq@switch{#1}}{\expandonce{\jlreq@switchpapersize}}%
-    [\unexpanded{%
-      \jlreq@helper@dividebycomma{#1}%
-      \ifjlreq@result
-        \setlength{\paperwidth}{\dimexpr\jlreq@resulta\relax}%
-        \setlength{\paperheight}{\dimexpr\jlreq@resultb\relax}%
-      \else
-        \ClassError{jlreq}{The paper #1 is unknown}{\@ehc}%
-      \fi
-    }]%
-  }%
-  \jlreq@do
+\keys_define:nn { jlreq } {
+  paper .code:n = {
+    \edef\jlreq@do{%
+      \unexpanded{\jlreq@switch{#1}}{\expandonce{\jlreq@switchpapersize}}%
+      [\unexpanded{%
+        \jlreq@helper@dividebycomma{#1}%
+        \ifjlreq@result
+          \setlength{\paperwidth}{\dimexpr\jlreq@resulta\relax}%
+          \setlength{\paperheight}{\dimexpr\jlreq@resultb\relax}%
+        \else
+          \ClassError{jlreq}{The~paper~#1~is~unknown}{\@ehc}%
+        \fi
+      }]%
+    }%
+    \jlreq@do
+  }
 }
 % 紙サイズ一覧．b*はJIS B．
 \jlreq@addpapersize{a0,A0}{}[a0]
@@ -168,91 +167,81 @@
 
 
 %.. フォントサイズ，行長，1ページあたりの行数で基本版面のサイズを決める（2.4.1.a）
-\newcommand*{\jlreq@option@fontsize}{}
 \jlreq@aftercls@addtodeletecs{\jlreq@option@fontsize}
-\DeclareOptionX{fontsize}{\renewcommand*{\jlreq@option@fontsize}{#1}}
-\jlreq@DeclareOption{10pt}{\renewcommand*{\jlreq@option@fontsize}{10pt}}
-\jlreq@DeclareOption{11pt}{\renewcommand*{\jlreq@option@fontsize}{11pt}}
-\jlreq@DeclareOption{12pt}{\renewcommand*{\jlreq@option@fontsize}{12pt}}
-\newcommand*{\jlreq@option@jafontsize}{}
+\keys_define:nn { jlreq } { fontsize .tl_set:N = \jlreq@option@fontsize }
+\keys_define:nn { jlreq } {
+  10pt .code:n = {\def\jlreq@option@fontsize{10pt}}, 10pt .value_forbidden:n = true,
+  11pt .code:n = {\def\jlreq@option@fontsize{11pt}}, 11pt .value_forbidden:n = true,
+  12pt .code:n = {\def\jlreq@option@fontsize{12pt}}, 12pt .value_forbidden:n = true,
+}
+\keys_define:nn { jlreq } { jafontsize .tl_set:N = \jlreq@option@jafontsize}
+\keys_define:nn { jlreq } { jafontscale .tl_set:N = \jlreq@option@jafontscale}
 \jlreq@aftercls@addtodeletecs{\jlreq@option@jafontsize}
-\DeclareOptionX{jafontsize}{\renewcommand*{\jlreq@option@jafontsize}{#1}}
-\newcommand*{\jlreq@option@jafontscale}{1}
-\DeclareOptionX{jafontscale}{\renewcommand*{\jlreq@option@jafontscale}{#1}}
 \jlreq@aftercls@addtodeletecs{\jlreq@option@jafontscale}
 %.. 行の長さ
-\newcommand*{\jlreq@option@line@length}{}
+\keys_define:nn { jlreq } { line_length .tl_set:N = \jlreq@option@line@length}
 \jlreq@aftercls@addtodeletecs{\jlreq@option@line@length}
-\DeclareOptionX{line_length}{\renewcommand*{\jlreq@option@line@length}{#1}}
 %.. 1ページあたりの行数
-\newcommand*{\jlreq@option@number@of@lines}{}
+\keys_define:nn { jlreq } { number_of_lines .tl_set:N = \jlreq@option@number@of@lines}
 \jlreq@aftercls@addtodeletecs{\jlreq@option@number@of@lines}
-\DeclareOptionX{number_of_lines}{\renewcommand*{\jlreq@option@number@of@lines}{#1}}
 
 % 地の空き量，のどの空き量で配置位置を決める（2.4.1.b）省略されたら中央配置．
 %.. 天
-\newcommand*{\jlreq@option@head@space}{}
+\keys_define:nn { jlreq } { head_space .tl_set:N = \jlreq@option@head@space}
 \jlreq@aftercls@addtodeletecs{\jlreq@option@head@space}
-\DeclareOptionX{head_space}{\renewcommand*{\jlreq@option@head@space}{#1}}
-
 %.. 地
-\newcommand*{\jlreq@option@foot@space}{}
+\keys_define:nn { jlreq } { foot_space .tl_set:N = \jlreq@option@foot@space}
 \jlreq@aftercls@addtodeletecs{\jlreq@option@foot@space}
-\DeclareOptionX{foot_space}{\renewcommand*{\jlreq@option@foot@space}{#1}}
 %.. のど
-\newcommand*{\jlreq@option@gutter}{}
+\keys_define:nn { jlreq } { gutter .tl_set:N = \jlreq@option@gutter}
 \jlreq@aftercls@addtodeletecs{\jlreq@option@gutter}
-\DeclareOptionX{gutter}{\renewcommand*{\jlreq@option@gutter}{#1}}
 %.. 小口
-\newcommand*{\jlreq@option@fore@edge}{}
 \jlreq@aftercls@addtodeletecs{\jlreq@option@fore@edge}
-\DeclareOptionX{fore_edge}{\renewcommand*{\jlreq@option@fore@edge}{#1}}% 昔にこっちにしていたので残している
-\DeclareOptionX{fore-edge}{\renewcommand*{\jlreq@option@fore@edge}{#1}}
+\keys_define:nn { jlreq } {
+  fore_edge .tl_set:N = \jlreq@option@fore@edge,
+  fore-edge .tl_set:N = \jlreq@option@fore@edge
+}
 
 %.. 柱とノンブル
-\newcommand*{\jlreq@option@headfoot@verticalpos}{}
-\jlreq@aftercls@addtodeletecs{\jlreq@option@headfoot@verticalpos}
 % 本文とヘッダ/フッタの間の空き
-\DeclareOptionX{headfoot_verticalposition}{\renewcommand*{\jlreq@option@headfoot@verticalpos}{#1}}
+\keys_define:nn { jlreq } { headfoot_verticalposition .tl_set:N = \jlreq@option@headfoot@verticalpos}
+\jlreq@aftercls@addtodeletecs{\jlreq@option@headfoot@verticalpos}
 % 柱やノンブルの左右の空き
-\newcommand*{\jlreq@headfoot@sidemargin}{0pt}
-\DeclareOptionX{headfoot_sidemargin}{\renewcommand*{\jlreq@headfoot@sidemargin}{#1}}
+\keys_define:nn { jlreq } { headfoot_sidemargin .tl_set:N = \jlreq@headfoot@sidemargin}
 
 %.. 段間
-\newcommand*{\jlreq@option@column@gap}{2zw}
+\keys_define:nn { jlreq } { column_gap .tl_set:N = \jlreq@option@column@gap}
 \jlreq@aftercls@addtodeletecs{\jlreq@option@column@gap}
-\DeclareOptionX{column_gap}{\renewcommand*{\jlreq@option@column@gap}{#1}}
 
 %.. 行送り，指定無しの場合は文字サイズの1.7倍とする．（1.5から2倍が好ましい：2.4.2.d 注3）
-\newcommand*{\jlreq@option@baselineskip}{17zw/10}
+\keys_define:nn { jlreq } {
+  baselineskip .tl_set:N = \jlreq@option@baselineskip,
+  linegap .code:n = { \def\jlreq@option@baselineskip{1zw + #1} }
+}
 \jlreq@aftercls@addtodeletecs{\jlreq@option@baselineskip}
-\DeclareOptionX{baselineskip}{\def\jlreq@option@baselineskip{#1}}
-\DeclareOptionX{linegap}{\def\jlreq@option@baselineskip{1zw + #1}}
 
 %.. 組み方系
 % 行頭に括弧が来たときの配置：3.1.5
 % 段落頭指定_折り返し行頭指定 で与える．
-\newcommand*{\jlreq@open@bracket@pos}{zenkaku_tentsuki}
-\define@choicekey{jlreq.cls}{open_bracket_pos}{zenkaku_tentsuki,zenkakunibu_nibu,nibu_tentsuki}{\renewcommand*{\jlreq@open@bracket@pos}{#1}}
+\keys_define:nn { jlreq } { open_bracket_pos .choices:nn = {zenkaku_tentsuki,zenkakunibu_nibu,nibu_tentsuki}{\def\jlreq@open@bracket@pos{#1}} }
 % ぶら下げ組みをするか：3.8.2 注1
 \newif\ifjlreq@burasage\jlreq@burasagefalse
-\jlreq@DeclareOption{hanging_punctuation}{\jlreq@burasagetrue}
+\keys_define:nn { jlreq } { hanging_punctuation .code:n = {\jlreq@burasagetrue}, hanging_punctuation .value_forbidden:n = true}
 % jsarticleと同じkanjiskipを使う
 \newif\ifjlreq@narrow@kanjiskip\jlreq@narrow@kanjiskipfalse
-\jlreq@DeclareOption{narrow_kanjiskip}{\jlreq@narrow@kanjiskiptrue}
+\keys_define:nn { jlreq } { narrow_kanjiskip .code:n = {\jlreq@narrow@kanjiskiptrue}, narrow_kanjiskip .value_forbidden:n = true}
 \jlreq@aftercls@addtodeleteif{\ifjlreq@narrow@kanjiskip}
 
 %.. 注
 % 傍注のタイプ
-\newcommand*{\jlreq@option@sidenote@length}{0pt}
+\keys_define:nn { jlreq } { sidenote_length .tl_set:N = \jlreq@option@sidenote@length }
 \jlreq@aftercls@addtodeletecs{\jlreq@option@sidenote@length}
-\DeclareOptionX{sidenote_length}{\renewcommand*{\jlreq@option@sidenote@length}{#1}}
 
 %.. 逆ノンブル
 \newif\ifjlreq@option@use@reverse@pagination
 \jlreq@aftercls@addtodeleteif{\ifjlreq@option@use@reverse@pagination}
 \jlreq@option@use@reverse@paginationfalse
-\jlreq@DeclareOption{use_reverse_pagination}{\jlreq@option@use@reverse@paginationtrue}
+\keys_define:nn { jlreq } { use_reverse_pagination .code:n = {\jlreq@option@use@reverse@paginationtrue}, use_reverse_pagination .value_forbidden:n = true }
 
 %.. もろもろ
 \newif\if@restonecol\@restonecolfalse
@@ -261,45 +250,48 @@
 \newif\if@tate \@tatefalse
 \newif\ifjlreq@option@titlepage \jlreq@option@titlepagefalse % titlepageかnotitlepageかが指定された
 \jlreq@aftercls@addtodeleteif{\ifjlreq@option@titlepage}
-\jlreq@DeclareOption{landscape}{\@landscapetrue}
-\jlreq@DeclareOption{tombo}{\ClassWarningNoLine{jlreq}{The option `tombo' is not supported by jlreq class. Please use the jlreq-trimmarks package}}
-\jlreq@DeclareOption{tombow}{\ClassWarningNoLine{jlreq}{The option `tombow' is not supported by jlreq class. Please use the jlreq-trimmarks package}}
-\jlreq@DeclareOption{mentuke}{\ClassWarningNoLine{jlreq}{The option `mentuke' is not supported by jlreq class. Please use the jlreq-trimmarks package}}
-\jlreq@DeclareOption{tate}{\@tatetrue}
+\keys_define:nn { jlreq } { landscape .code:n = {\@landscapetrue}, landscape .value_forbidden:n = true }
+\keys_define:nn { jlreq } { tombo .code:n = {\ClassWarningNoLine{jlreq}{The~option~`tombo'~is~not~supported~by~jlreq~class.~Please~use~the~jlreq-trimmarks~package}} }
+\keys_define:nn { jlreq } { tombow .code:n = {\ClassWarningNoLine{jlreq}{The~option~`tombow'~is~not~supported~by~jlreq~class.~Please~use~the~jlreq-trimmarks~package}} }
+\keys_define:nn { jlreq } { mentuke .code:n = {\ClassWarningNoLine{jlreq}{The~option~`mentuke'~is~not~supported~by~jlreq~class.~Please~use~the~jlreq-trimmarks~package}} }
+\keys_define:nn { jlreq } { tate .code:n = { \@tatetrue }, tate .value_forbidden:n = true}
 
 \newif\ifjlreq@option@twoside\jlreq@option@twosidefalse % onesideかtwosideが指定された
 \jlreq@aftercls@addtodeleteif{\ifjlreq@option@twoside}
-\jlreq@DeclareOption{oneside}{\@twosidefalse\@mparswitchfalse\jlreq@option@twosidetrue}
-\jlreq@DeclareOption{twoside}{\@twosidetrue\@mparswitchtrue\jlreq@option@twosidetrue}
-\jlreq@DeclareOption{onecolumn}{\@twocolumnfalse}
-\jlreq@DeclareOption{twocolumn}{\@twocolumntrue}
-\jlreq@DeclareOption{titlepage}{\jlreq@option@titlepagetrue\@titlepagetrue}
-\jlreq@DeclareOption{notitlepage}{\jlreq@option@titlepagetrue\@titlepagefalse}
-\jlreq@DeclareOption{draft}{\setlength\overfullrule{5pt}}
-\jlreq@DeclareOption{final}{\setlength\overfullrule{0pt}}
+\keys_define:nn { jlreq } { oneside .code:n = { \@twosidefalse\@mparswitchfalse\jlreq@option@twosidetrue }, oneside .value_forbidden:n = true }
+\keys_define:nn { jlreq } { twoside .code:n = { \@twosidetrue\@mparswitchtrue\jlreq@option@twosidetrue }, twoside .value_forbidden:n = true }
+\keys_define:nn { jlreq } { onecolumn .code:n = { \@twocolumnfalse }, onecolumn .value_forbidden:n = true }
+\keys_define:nn { jlreq } { twocolumn .code:n = { \@twocolumntrue }, twocolumn .value_forbidden:n = true }
+\keys_define:nn { jlreq } { titlepage .code:n = { \jlreq@option@titlepagetrue\@titlepagetrue }, titlepage .value_forbidden:n = true }
+\keys_define:nn { jlreq } { notitlepage .code:n = { \jlreq@option@titlepagetrue\@titlepagefalse }, notitlepage .value_forbidden:n = true }
+\keys_define:nn { jlreq } { draft .code:n = { \setlength\overfullrule{5pt} }, draft .value_forbidden:n = true }
+\keys_define:nn { jlreq } { final .code:n = { \setlength\overfullrule{0pt} }, final .value_forbidden:n = true }
 \newif\if@openright
 \newif\ifjlreq@option@open \jlreq@option@openfalse % openrightかopenanyが指定された
 \jlreq@aftercls@addtodeleteif{\ifjlreq@option@open}
-\jlreq@DeclareOption{openright}{\@openrighttrue\jlreq@option@opentrue}
-\jlreq@DeclareOption{openany}{\@openrightfalse\jlreq@option@opentrue}
-\jlreq@DeclareOption{leqno}{\input{leqno.clo}}
-\jlreq@DeclareOption{fleqn}{\input{fleqn.clo}}
+\keys_define:nn { jlreq } { openright .code:n = { \@openrighttrue\jlreq@option@opentrue }, openright .value_forbidden:n = true}
+\keys_define:nn { jlreq } { openany .code:n = { \@openrightfalse\jlreq@option@opentrue }, openany .value_forbidden:n = true}
+\keys_define:nn { jlreq } { leqno .code:n = { \input{leqno.clo } }, leqno .value_forbidden:n = true}
+\keys_define:nn { jlreq } { fleqn .code:n = { \input{fleqn.clo } }, fleqn .value_forbidden:n = true}
 \newif\ifjlreq@option@enablejfam \jlreq@option@enablejfamtrue
 \jlreq@aftercls@addtodeleteif{\ifjlreq@option@enablejfam}
-\jlreq@DeclareOption{disablejfam}{\jlreq@option@enablejfamfalse}
-
-\newcommand*{\jlreq@note}[1]{}
-\jlreq@DeclareOption{jlreq_notes}{\renewcommand*{\jlreq@note}[1]{\message{^^JJLReq note: ##1^^J}}}
-
-\ExecuteOptionsX{article_type=article,paper=a4,open_bracket_pos=zenkaku_tentsuki,onecolumn,final}
-% \@removeelementを一旦置き換えてから\ProcessOptionsXを実行する
-\let\jlreq@temporary@original@@removeelement=\@removeelement
-\let\@removeelement=\jlreq@helper@removeelement
-\ProcessOptionsX\relax
-\let\@removeelement=\jlreq@temporary@original@@removeelement
-\let\jlreq@temporary@original@@removeelement=\@undefined
+\keys_define:nn { jlreq } { disablejfam .code:n = { \jlreq@option@enablejfamfalse }, disablejfam .value_forbidden:n = true}
+
+\def\jlreq@note#1{}
+\keys_define:nn { jlreq } { jlreq_notes .code:n = { \def\jlreq@note##1{\message{^^JJLReq note: ##1^^J}}}, jlreq_notes .value_forbidden:n = true}
+
+%\ExecuteOptionsX{article_type=article,paper=a4,open_bracket_pos=zenkaku_tentsuki,onecolumn,final}
+\keys_set:nn { jlreq } {
+  article_type=article,paper=a4,
+  number_of_lines={},line_length = {},
+  head_space={},foot_space={},gutter={},fore_edge={},
+  jafontsize={},jafontscale={1},baselineskip={17zw/10},
+  sidenote_length=0pt,column_gap={2zw},
+  headfoot_verticalposition = {},headfoot_sidemargin={0pt},
+  open_bracket_pos=zenkaku_tentsuki,
+  onecolumn,final}
+\ProcessKeysOptions { jlreq }
 
-\ExplSyntaxOn
 \legacy_if:nF { jlreq@option@titlepage } {
   \str_if_eq:VnTF \jlreq@article@type { article } { \@titlepagefalse } { \@titlepagetrue }
 }
@@ -316,41 +308,22 @@
 \legacy_if:nF { jlreq@option@twoside } {
   \str_if_eq:VnTF \jlreq@article@type { book } { \@twosidetrue } { \@twosidefalse }
 }
-\ExplSyntaxOff
 
-\def\jlreq@jlreqsetup@keyvallist{}
-\def\jlreq@jlreqsetup@finally{}
-\newcommand{\jlreqsetup}[1]{%
-  \begingroup
-    \edef\jlreq@do{\unexpanded{\jlreq@parsekeyval[jlreqsetup]}{\expandonce{\jlreq@jlreqsetup@keyvallist}}}%
-  \expandafter\endgroup
-  \jlreq@do{#1}%
-  \jlreq@jlreqsetup@finally
-}
-% \jlreqsetupの項目に加えるマクロ．\jlreq@jlreqsetup@add{key}{action}とするとkeyに対して定義できる．
-% action内ではvalが#1として取得できる．（従ってaction内でマクロを定義する際には##1を使う必要がある．）
-\newcommand{\jlreq@jlreqsetup@add}[1]{%
-  \@ifnextchar[{\jlreq@jlreqsetup@add@{#1}}{\jlreq@jlreqsetup@add@@{#1}}%
-}
-\long\def\jlreq@jlreqsetup@add@#1[#2]#3{%
-  \eappto\jlreq@jlreqsetup@keyvallist{\unexpanded{{#1}[#2]{#3}}}%
-}
-\long\def\jlreq@jlreqsetup@add@@#1#2{%
-  \eappto\jlreq@jlreqsetup@keyvallist{\unexpanded{{#1}{#2}}}%
+\tl_new:N \g__jlreq_jlreqsetup_finally_tl
+\NewDocumentCommand{\jlreqsetup} { +m } {
+  \keys_set:nn { jlreqsetup } {#1}
+  \tl_use:N \g__jlreq_jlreqsetup_finally_tl
 }
 % \jlreqsetupの最後に必ず実行される処理を入れる．
-\newcommand\jlreq@jlreqsetup@addtofinally[1]{\eappto\jlreq@jlreqsetup@finally{\unexpanded{#1}}}
-\jlreq@aftercls@addtodeletecs{\jlreq@jlreqsetup@add}
-\jlreq@aftercls@addtodeletecs{\jlreq@jlreqsetup@add@}
-\jlreq@aftercls@addtodeletecs{\jlreq@jlreqsetup@add@@}
-\jlreq@aftercls@addtodeletecs{\jlreq@jlreqsetup@addtofinally}
+\cs_set:Nn \__jlreq_jlreqsetup_addtofinally:n { \tl_gput_right:Nx \g__jlreq_jlreqsetup_finally_tl { \exp_not:n {#1} } }
+\jlreq@aftercls@addtodeletecs{\__jlreq_jlreqsetup_addtofinally:n}
 \@onlypreamble\jlreqsetup
 
 % エンジンの設定
 \ifx\jlreq@engine\@undefined
   \jlreq@helper@guessengine
   \let\jlreq@engine=\jlreq@result
-  \message{jlreq guessed engine: 
+  \message{jlreq~guessed~engine:~
     \ifx l\jlreq@engine lualatex\fi
     \ifx p\jlreq@engine platex\fi
     \ifx u\jlreq@engine uplatex\fi
@@ -358,7 +331,6 @@
 \fi
 
 %.. JFMとluatexjaのロード
-\ExplSyntaxOn
 \ifx l\jlreq@engine
   \def\ltj@stdyokojfm{jlreq}
   \def\ltj@stdtatejfm{jlreqv}
@@ -377,6 +349,7 @@
   \ltjsetparameter{stretch_priority={kanjiskip=0,xkanjiskip=10}}
   \ltjsetparameter{shrink_priority={kanjiskip=0,xkanjiskip=-30}}
 \else
+  \RequirePackage{everyhook}
   \def\jlreq@jfmname@prefix{}
   \jlreq@aftercls@addtodeletecs{\jlreq@jfmname@prefix}
   \ifjlreq@burasage\edef\jlreq@jfmname@prefix{b\jlreq@jfmname@prefix}\fi
@@ -389,7 +362,6 @@
   \jlreq@aftercls@addtodeletecs{\jlreq@jfmname}
   \jlreq@aftercls@addtodeletecs{\jlreq@jfmnameg}
 \fi
-\ExplSyntaxOff
 
 % (u)pLaTeXの場合ここで初めて\epTeXinputencodingが発行されるので，
 % これ以前には和文は使えない．
@@ -438,7 +410,7 @@
       \ifcat （\noexpand #11\fi
       \ifcat A\noexpand #11\fi
       \ifcat 1\noexpand #11\fi
-    >0
+    >0~
   \fi}%
 }
 
@@ -446,10 +418,10 @@
 % 組方向を判定
 % \jlreq@if(y|t)(dir|box)を定義する．
 \jlreq@if{\ifx l\jlreq@engine\fi}{
-  \def\jlreq@ifydir{\jlreq@if{\ifnum\ltjgetparameter{direction}=4 \fi}}
-  \def\jlreq@iftdir{\jlreq@if{\ifnum\numexpr\ltjgetparameter{direction}-(\ltjgetparameter{direction}/8)*8\relax=3 \fi}}
-  \def\jlreq@ifybox#1{\jlreq@if{\ifnum\ltjgetparameter{boxdir}{#1}=4 \fi}}
-  \def\jlreq@iftbox#1{\jlreq@if{\ifnum\numexpr\ltjgetparameter{boxdir}{#1}-(\ltjgetparameter{boxdir}{#1}/8)*8\relax=3 \fi}}
+  \def\jlreq@ifydir { \int_compare:nTF { \ltjgetparameter{direction} == 4 } }
+  \def\jlreq@iftdir { \int_compare:nTF { (\ltjgetparameter{direction}-(\ltjgetparameter{direction}/8)*8) == 3 } }
+  \def\jlreq@ifybox#1{ \int_compare:nTF { \ltjgetparameter{boxdir}{#1} == 4 } }
+  \def\jlreq@iftbox#1{ \int_compare:nTF { (\ltjgetparameter{boxdir}{#1}-(\ltjgetparameter{boxdir}{#1}/8)*8) == 3 } }
 }{
   \def\jlreq@ifydir{\jlreq@if{\ifydir\fi}}
   \def\jlreq@iftdir{\jlreq@if{\iftdir\fi}}
@@ -459,7 +431,6 @@
 
 % 左ページであるか
 % #1 : odd or even or ページ数
-\ExplSyntaxOn
 \def\jlreq@ifleftpage#1{%
   \bool_if:nTF { ( \legacy_if_p:n { @tate }  &&
     \bool_lazy_or_p:nn { \str_if_eq_p:ee {#1} { odd  } }
@@ -469,19 +440,18 @@
       { \bool_lazy_and_p:nn { ! \str_if_eq_p:ee {#1} { odd  } } { ! \int_if_odd_p:n {#1} } }
   ) }
 }
-\ExplSyntaxOff
 
 \ifx l\jlreq@engine
-  \newcommand*{\jlreq@getpostbreakpenalty}[1]{\ltjgetparameter{postbreakpenalty}{#1}}
+  \def\jlreq@getpostbreakpenalty#1{\ltjgetparameter{postbreakpenalty}{#1}}
 \else
-  \newcommand*{\jlreq@getpostbreakpenalty}[1]{\postbreakpenalty#1}
+  \def\jlreq@getpostbreakpenalty#1{\postbreakpenalty#1}
 \fi
 
 % 現在行の残りを得る．
 \ifx l\jlreq@engine
   % 以下のコードはLuaTeX-jaのバグ？に依存している
   % https://ja.osdn.net/projects/luatex-ja/ticket/36489
-  \newcommand*{\jlreq@calc@current@linewidth@onecolumn}{%
+  \def\jlreq@calc@current@linewidth@onecolumn{%
     \dimexpr
        \jlreq@reference@ref{jlreq@rest@width.pos.X.\the\jlreq@reference@count}{0} sp - \@totalleftmargin -
       \ifodd\jlreq@currentpage
@@ -501,7 +471,7 @@
   }{
     \def\jlreq@tombow@adjust{\iftombow -1truein \fi}
   }
-  \newcommand*{\jlreq@calc@current@linewidth@onecolumn}{%
+  \def\jlreq@calc@current@linewidth@onecolumn{%
     \dimexpr
       \jlreq@ifydir{%
         \jlreq@reference@ref{jlreq@rest@width.pos.X.\the\jlreq@reference@count}{0} sp - \hoffset
@@ -524,7 +494,7 @@
     \relax
   }
 \fi
-\newcommand*{\jlreq@calc@current@linewidth}{%
+\def\jlreq@calc@current@linewidth{%
   \dimexpr\jlreq@calc@current@linewidth@onecolumn
     \if@twocolumn
       \ifdim\jlreq@calc@current@linewidth@onecolumn<\dimexpr\linewidth+\columnsep\relax\else
@@ -569,26 +539,26 @@
 
 % #1と#2の間に入るjmglue（(x)kanjiskipも）を\jlreq@resultskipに入れる
 \ifx l\jlreq@engine
-  \newcommand*{\jlreq@calc@jfmglue}[2]{%
+  \def\jlreq@calc@jfmglue#1#2{%
     \begingroup
       \setbox\jlreq@tempboxa=\hbox{\inhibitglue #1\inhibitglue\hbox{}\inhibitglue#2\inhibitglue}%
       \setbox\jlreq@tempboxb=\hbox{\inhibitglue #1#2\inhibitglue}%
       \edef\jlreq@do{\noexpand\jlreq@resultskip=\the\dimexpr\wd\jlreq@tempboxb - \wd\jlreq@tempboxa\relax\noexpand\relax}%
       \jlreq@do
       \directlua{
-        local width = 0
-        local stretch = 0
-        local shrink = 0
-        local n = tex.box["jlreq@tempboxb"].head
-        while n do
+        local~width = 0~
+        local~stretch = 0~
+        local~shrink = 0~
+        local~n = tex.box["jlreq@tempboxb"].head~
+        while~n~do~
           % すべてのglueの和を計算する．
-          if n.id == node.id("glue") then
-            width = width + n.width
-            stretch = stretch + n.stretch
-            shrink = shrink + n.shrink
-          end
-          n = n.next
-        end
+          if~n.id == node.id("glue")~then~
+            width = width + n.width~
+            stretch = stretch + n.stretch~
+            shrink = shrink + n.shrink~
+          end~
+          n = n.next~
+        end~
         tex.setglue("jlreq@tempskipa",width,stretch,shrink)
       }%
       % TeXで計測した物と一致していなければTeXでの方を信じる
@@ -599,7 +569,7 @@
     \jlreq@do
   }
 \else
-  \newcommand*{\jlreq@calc@jfmglue}[2]{%
+  \def\jlreq@calc@jfmglue#1#2{%
     \begingroup
       \setbox\jlreq@tempboxa=\hbox{\inhibitglue #1\inhibitglue\hbox{}\inhibitglue#2\inhibitglue}%
       \setbox\jlreq@tempboxb=\hbox{\inhibitglue #1#2\inhibitglue}%
@@ -612,7 +582,7 @@
 \newcount\jlreq@lastnodechar
 % \jlreq@fixjfm<次の文字>の形で使う．
 % jlreq@lastnodecharに入っている値と次のトークン（\futureletで得る）の間に入るJFMグルー等を挿入する
-\newcommand*{\jlreq@fixjfm}{%
+\def\jlreq@fixjfm{%
   \begingroup
     \ifnum\jlreq@lastnodechar>-1
       \def\jlreq@do{\futurelet\jlreq@nextchar\jlreq@insertjfm}%
@@ -639,8 +609,8 @@
 }
 
 \ifx l\jlreq@engine
-  \newcommand*{\jlreq@divide}[2]{%
-    \jlreq@resultdimen=\directlua{tex.print(tostring(\strip@pt\dimexpr #1\relax/\strip@pt\dimexpr #2\relax) .. "pt ")}%
+  \def\jlreq@divide#1#2{%
+    \jlreq@resultdimen=\directlua{tex.print(tostring(\strip@pt\dimexpr #1\relax/\strip@pt\dimexpr #2\relax) .. "pt~")}%
   }
 \else
   \let\jlreq@divide=\jlreq@helper@divide
@@ -651,11 +621,11 @@
 \def\@ptsize{0}
 %.. (x)kanjiskip
 \ifjlreq@narrow@kanjiskip
-  \providecommand*{\jlreqkanjiskip}{0pt plus .1\jlreq@zw minus .01\jlreq@zw}
+  \providecommand*{\jlreqkanjiskip}{0pt~plus~.1\jlreq@zw ~minus~.01\jlreq@zw}
 \else
-  \providecommand*{\jlreqkanjiskip}{0pt plus 0.25\jlreq@zw minus 0pt}
+  \providecommand*{\jlreqkanjiskip}{0pt~plus~0.25\jlreq@zw ~minus~0pt}
 \fi
-\providecommand*{\jlreqxkanjiskip}{0.25\jlreq@zw plus 0.25\jlreq@zw minus 0.125\jlreq@zw}
+\providecommand*{\jlreqxkanjiskip}{0.25\jlreq@zw ~plus~0.25\jlreq@zw ~minus~0.125\jlreq@zw}
 \jlreq@if{\ifx l\jlreq@engine\fi}{
   \AtBeginDocument{%
     \ltjsetparameter{kanjiskip=\jlreqkanjiskip}%
@@ -675,10 +645,10 @@
   % Q,zw,zhが正しく扱われるようになる．\dimexprつきに展開される．
   \def\jlreq@expand@optionfontsize#1{%
     \dimexpr\directlua{
-      local act = string.char(92)
-      local s = [[#1]]
-      s = s:gsub("[QH]",act .. "dimexpr 0.25mm" .. act .. "relax")
-      tex.print(s)
+      local~act = string.char(92)~
+      local~s = [[#1]]~
+      s = s:gsub("[QH]",act .. "dimexpr 0.25mm" .. act .. "relax")~
+      tex.print(s)~
     }\relax
   }%
 \else
@@ -705,13 +675,11 @@
 
 
 % 行頭の括弧は \jlreq@open@bracket@before@space \inhibitglue 「みたいにする．
-\ExplSyntaxOn
 \str_if_eq:VnTF \jlreq@open@bracket@pos { zenkakunibu_nibu } {
   \def\jlreq@open@bracket@before@space{\hskip\glueexpr-.5\jlreq@zw\relax}
 }{
   \def\jlreq@open@bracket@before@space{}
 }
-\ExplSyntaxOff
 
 \ifx p\jlreq@engine
   \def\jlreq@yokokanjiencoding{JY1}
@@ -730,8 +698,7 @@
 \jlreq@aftercls@addtodeletecs{\jlreq@jafontscale}
 \ifx l\jlreq@engine
   \jlreq@saveoriginalcs{DeclareFontShape}
-  \ExplSyntaxOn
-  \def\DeclareFontShape#1#2#3#4#5#6{
+    \def\DeclareFontShape#1#2#3#4#5#6{
     \group_begin:
       \bool_if:nT { \str_if_eq_p:nn {#1} {JY3} || \str_if_eq_p:nn {#1} {JT3} } {
         \tl_set:Nx \l_jlreq_tmpa_tl {#5}
@@ -754,11 +721,10 @@
     \exp_after:wN \group_end: \l_jlreq_do:
     \jlreq@useoriginalcs{DeclareFontShape} {#1} {#2} {#3} {#4} {#5} {#6}
   }
-  \ExplSyntaxOff
-  \DeclareFontShape{JY3}{mc}{m}{n}{<->s*[\jlreq@jafontscale]\ltj@stdmcfont:jfm=jlreq;script=latn;-kern}{}
-  \DeclareFontShape{JY3}{gt}{m}{n}{<->s*[\jlreq@jafontscale]\ltj@stdgtfont:jfm=jlreq;script=latn;-kern}{}
-  \DeclareFontShape{JT3}{mc}{m}{n}{<->s*[\jlreq@jafontscale]\ltj@stdmcfont:jfm=jlreqv;script=latn;-kern}{}
-  \DeclareFontShape{JT3}{gt}{m}{n}{<->s*[\jlreq@jafontscale]\ltj@stdgtfont:jfm=jlreqv;script=latn;-kern}{}
+  \DeclareFontShape{JY3}{mc}{m}{n}{<->s*[\jlreq@jafontscale]\ltj@stdmcfont :jfm=jlreq;script=latn;-kern}{}
+  \DeclareFontShape{JY3}{gt}{m}{n}{<->s*[\jlreq@jafontscale]\ltj@stdgtfont :jfm=jlreq;script=latn;-kern}{}
+  \DeclareFontShape{JT3}{mc}{m}{n}{<->s*[\jlreq@jafontscale]\ltj@stdmcfont :jfm=jlreqv;script=latn;-kern}{}
+  \DeclareFontShape{JT3}{gt}{m}{n}{<->s*[\jlreq@jafontscale]\ltj@stdgtfont :jfm=jlreqv;script=latn;-kern}{}
 \else
   \DeclareFontShape{\jlreq@yokokanjiencoding}{mc}{m}{n}{<->s*[\jlreq@jafontscale]\jlreq@jfmname}{}
   \DeclareFontShape{\jlreq@yokokanjiencoding}{gt}{m}{n}{<->s*[\jlreq@jafontscale]\jlreq@jfmnameg}{}
@@ -770,7 +736,6 @@
   \DeclareFontShape{\jlreq@tatekanjiencoding}{mc}{m}{n-jidori}{<->s*[\jlreq@jafontscale]\jlreq@tempa jlreq-v-jidori}{}
   \DeclareFontShape{\jlreq@tatekanjiencoding}{gt}{m}{n-jidori}{<->s*[\jlreq@jafontscale]\jlreq@tempa jlreqg-v-jidori}{}
 \fi
-\ExplSyntaxOn
 \clist_set:NV  \l_jlreq_tmpa_clist \jlreq@yokokanjiencoding
 \clist_push:NV \l_jlreq_tmpa_clist \jlreq@tatekanjiencoding
 \clist_map_inline:Nn \l_jlreq_tmpa_clist {% #1 = encoding
@@ -790,7 +755,6 @@
     }
   }
 }
-\ExplSyntaxOff
 
 %.. 文字クラスのリスト
 % 開き括弧（文字クラス1）
@@ -823,20 +787,18 @@
 \edef\jlreq@charlist@katakana{アイウエオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモヤユヨラリルレロワヰヱヲンヴ\ifx p\jlreq@engine\else ヷヸヹヺ\fi}% カ゚キ゚ク゚ケ゚コ゚セ゚ツ゚ト゚
 
 %.. 行頭括弧調整
-\AtBeginDocument{\PushPostHook{par}{\jlreq@hook@everypar}}
-\def\jlreq@hook@everypar{}
 \jlreq@saveoriginalcs{item}
-\ExplSyntaxOn
 \ifx l\jlreq@engine
   % \itemの直後は折り返し行頭と同じにする．
+  \cs_set:Nn \__jlreq_hook_everypar: {}
   \def\item{%
-    \def\jlreq@hook@everypar{%
-      \def\jlreq@hook@everypar{}%
-      \inhibitglue
-    }%
     \jlreq@useoriginalcs{item}%
+    \cs_set:Nn \__jlreq_hook_everypar: { \cs_set:Nn \__jlreq_hook_everypar: {} \inhibitglue }
+    \expandafter\everypar\expandafter{\the\everypar\__jlreq_hook_everypar:}
   }
 \else
+  \AtBeginDocument{\PushPostHook{par}{\jlreq@hook@everypar}}
+  \def\jlreq@hook@everypar{}
   % 非LuaTeXの場合はJFMの入れ替えと\everyparでの処理で対処．
   % 行頭括弧に対して\inhibitglueを入れたりする命令を作る
   % \jlreq@charlist@openingbracketsの各括弧に対して，\ifx\jlreq@nextchar 「1\fiみたいなのが並んだのを作る
@@ -845,9 +807,9 @@
   \expandafter\jlreq@do\jlreq@charlist@openingbrackets\jlreq@endmark
   % JFM glueの伸び縮みで行頭括弧が揃わないのを防ぐために常に\inhibitglueを入れる．
   \str_if_eq:VnTF \jlreq@open@bracket@pos { nibu_tentsuki } {
-    \edef\jlreq@openbracket@hook@ii{\noexpand\ifnum0\expandonce{\jlreq@tempa}>0 \unexpanded{\hskip -.5\jlreq@zw\inhibitglue}\noexpand\fi}
+    \edef\jlreq@openbracket@hook@ii{\noexpand\ifnum0\expandonce{\jlreq@tempa}>0~\unexpanded{\hskip -.5\jlreq@zw\inhibitglue}\noexpand\fi}
   }{% zenkakunibu_nibu,zenkaku_tentsuki
-    \edef\jlreq@openbracket@hook@ii{\noexpand\ifnum0\expandonce{\jlreq@tempa}>0 \unexpanded{\inhibitglue}\noexpand\fi}
+    \edef\jlreq@openbracket@hook@ii{\noexpand\ifnum0\expandonce{\jlreq@tempa}>0~\unexpanded{\inhibitglue}\noexpand\fi}
   }
   % source special対策
   \def\jlreq@openbracket@hook@i{\ifx\jlreq@nextchar\special\expandafter\jlreq@openbracket@hook@iii\else\expandafter\jlreq@openbracket@hook@ii\fi}
@@ -862,13 +824,12 @@
     \jlreq@useoriginalcs{item}%
   }
 \fi
-\ExplSyntaxOff
 
 %.. 禁則処理
 \ifx l\jlreq@engine
-  \newcommand*{\jlreq@setpostbreakpenalty@}[2]{\ltjsetparameter{postbreakpenalty={`#1,#2}}}
-  \newcommand*{\jlreq@setprebreakpenalty@}[2]{\ltjsetparameter{prebreakpenalty={`#1,#2}}}
-  \newcommand*{\jlreq@addjaxspmode@}[2]{%
+  \def\jlreq@setpostbreakpenalty@#1#2{\ltjsetparameter{postbreakpenalty={`#1,#2}}}
+  \def\jlreq@setprebreakpenalty@#1#2{\ltjsetparameter{prebreakpenalty={`#1,#2}}}
+  \def\jlreq@addjaxspmode@#1#2{%
     \jlreq@tempcnta=\ltjgetparameter{jaxspmode}{`#1}%
     \jlreq@switch{#2}{
       {pre}{%
@@ -887,7 +848,7 @@
       }
     }%
   }
-  \newcommand*{\jlreq@deljaxspmode@}[2]{%
+  \def\jlreq@deljaxspmode@#1#2{%
     \jlreq@tempcnta=\ltjgetparameter{jaxspmode}{`#1}%
     \jlreq@switch{#2}{
       {pre}{%
@@ -907,9 +868,9 @@
     }%
   }
 \else
-  \newcommand*{\jlreq@setpostbreakpenalty@}[2]{\postbreakpenalty`#1=#2}
-  \newcommand*{\jlreq@setprebreakpenalty@}[2]{\prebreakpenalty`#1=#2}
-  \newcommand*{\jlreq@addjaxspmode@}[2]{%
+  \def\jlreq@setpostbreakpenalty@#1#2{\postbreakpenalty`#1=#2}
+  \def\jlreq@setprebreakpenalty@#1#2{\prebreakpenalty`#1=#2}
+  \def\jlreq@addjaxspmode@#1#2{%
     \jlreq@tempcnta=\inhibitxspcode`#1
     \jlreq@switch{#2}{
       {pre}{%
@@ -928,7 +889,7 @@
       }
     }%
   }
-  \newcommand*{\jlreq@deljaxspmode@}[2]{%
+  \def\jlreq@deljaxspmode@#1#2{%
     \jlreq@tempcnta=\inhibitxspcode`#1
     \jlreq@switch{#2}{
       {pre}{%
@@ -949,84 +910,93 @@
   }
 \fi
 % #1{...}{#3}を...が#2のリストに対して適用．
-\newcommand*\jlreq@iterateapply[3]{%
-  \edef\jlreq@tempa{#2}%
-  \expandafter\@tfor\expandafter\@tempa\expandafter:\expandafter=\jlreq@tempa\do{%
-    \expandafter#1\expandafter{\@tempa}{#3}%
-  }%
+\cs_set:Nn \__jlreq_iterateapply:nnn {
+  \tl_map_inline:nn {#2} {
+    #1{##1}{#3}
+  }
 }
-\def\jlreq@setpostbreakpenalty{\jlreq@iterateapply{\jlreq@setpostbreakpenalty@}}
-\def\jlreq@setprebreakpenalty{\jlreq@iterateapply{\jlreq@setprebreakpenalty@}}
-\def\jlreq@addjaxspmode{\jlreq@iterateapply{\jlreq@addjaxspmode@}}
-\def\jlreq@deljaxspmode{\jlreq@iterateapply{\jlreq@deljaxspmode@}}
-
-\jlreq@aftercls@addtodeletecs{\jlreq@iterateapply}
-\jlreq@aftercls@addtodeletecs{\jlreq@setpostbreakpenalty}
+\cs_set:Nn \__jlreq_setpostbreakpenalty:nn { \__jlreq_iterateapply:nnn {\jlreq@setpostbreakpenalty@} {#1} {#2}}
+\cs_generate_variant:Nn \__jlreq_setpostbreakpenalty:nn { Vn }
+\cs_set:Nn \__jlreq_setprebreakpenalty:nn { \__jlreq_iterateapply:nnn {\jlreq@setprebreakpenalty@} {#1} {#2} }
+\cs_generate_variant:Nn \__jlreq_setprebreakpenalty:nn { Vn }
+\cs_set:Nn \__jlreq_addjaxspmode:nn {\__jlreq_iterateapply:nnn {\jlreq@addjaxspmode@} {#1} {#2} }
+\cs_generate_variant:Nn \__jlreq_addjaxspmode:nn { Vn }
+\cs_set:Nn \__jlreq_deljaxspmode:nn { \__jlreq_iterateapply:nnn{\jlreq@deljaxspmode@} {#1} {#2} }
+\cs_generate_variant:Nn \__jlreq_deljaxspmode:nn { Vn }
+
+\jlreq@aftercls@addtodeletecs{\__jlreq_iterateapply:nnn}
+\jlreq@aftercls@addtodeletecs{\__jlreq_setpostbreakpenalty:nn}
+\jlreq@aftercls@addtodeletecs{\__jlreq_setpostbreakpenalty:Vn}
 \jlreq@aftercls@addtodeletecs{\jlreq@setpostbreakpenalty@}
-\jlreq@aftercls@addtodeletecs{\jlreq@setprebreakpenalty}
+\jlreq@aftercls@addtodeletecs{\__jlreq_setprebreakpenalty:nn}
+\jlreq@aftercls@addtodeletecs{\__jlreq_setprebreakpenalty:Vn}
 \jlreq@aftercls@addtodeletecs{\jlreq@setprebreakpenalty@}
-\jlreq@aftercls@addtodeletecs{\jlreq@addjaxspmode}
+\jlreq@aftercls@addtodeletecs{\__jlreq_addjaxspmode:nn}
+\jlreq@aftercls@addtodeletecs{\__jlreq_addjaxspmode:Vn}
 \jlreq@aftercls@addtodeletecs{\jlreq@addjaxspmode@}
-\jlreq@aftercls@addtodeletecs{\jlreq@deljaxspmode}
+\jlreq@aftercls@addtodeletecs{\__jlreq_deljaxspmode:nn}
+\jlreq@aftercls@addtodeletecs{\__jlreq_deljaxspmode:Vn}
 \jlreq@aftercls@addtodeletecs{\jlreq@deljaxspmode@}
 
 % 行末禁則
-\jlreq@setpostbreakpenalty{\jlreq@charlist@openingbrackets}{10000}
-\jlreq@setpostbreakpenalty{\jlreq@charlist@prefixedabbreviations}{10000}
+\__jlreq_setpostbreakpenalty:Vn \jlreq@charlist@openingbrackets {10000}
+\__jlreq_setpostbreakpenalty:Vn \jlreq@charlist@prefixedabbreviations {10000}
 
 % 行頭禁則
-\jlreq@setprebreakpenalty{\jlreq@charlist@closingbrackets}{10000}
-\jlreq@setprebreakpenalty{\jlreq@charlist@hyphens}{10000}
-\jlreq@setprebreakpenalty{\jlreq@charlist@dividingpunctuationmarks}{10000}
-\jlreq@setprebreakpenalty{\jlreq@charlist@middlenodes}{10000}
-\jlreq@setprebreakpenalty{\jlreq@charlist@fullstops}{10000}
-\jlreq@setprebreakpenalty{\jlreq@charlist@commas}{10000}
-\jlreq@setprebreakpenalty{\jlreq@charlist@iterationmarks}{10000}
-\jlreq@setprebreakpenalty{\jlreq@charlist@prolongedsoundmark}{10000}
-\jlreq@setprebreakpenalty{\jlreq@charlist@smallkana}{10000}
+\__jlreq_setprebreakpenalty:Vn \jlreq@charlist@closingbrackets {10000}
+\__jlreq_setprebreakpenalty:Vn \jlreq@charlist@hyphens {10000}
+\__jlreq_setprebreakpenalty:Vn \jlreq@charlist@dividingpunctuationmarks {10000}
+\__jlreq_setprebreakpenalty:Vn \jlreq@charlist@middlenodes {10000}
+\__jlreq_setprebreakpenalty:Vn \jlreq@charlist@fullstops {10000}
+\__jlreq_setprebreakpenalty:Vn \jlreq@charlist@commas {10000}
+\__jlreq_setprebreakpenalty:Vn \jlreq@charlist@iterationmarks {10000}
+\__jlreq_setprebreakpenalty:Vn \jlreq@charlist@prolongedsoundmark {10000}
+\__jlreq_setprebreakpenalty:Vn \jlreq@charlist@smallkana {10000}
 
 % xkanjiskip
-\jlreq@addjaxspmode{\jlreq@charlist@iterationmarks}{pre}
-\jlreq@addjaxspmode{\jlreq@charlist@iterationmarks}{post}
-\jlreq@addjaxspmode{\jlreq@charlist@prolongedsoundmark}{pre}
-\jlreq@addjaxspmode{\jlreq@charlist@prolongedsoundmark}{post}
-\jlreq@addjaxspmode{\jlreq@charlist@smallkana}{pre}
-\jlreq@addjaxspmode{\jlreq@charlist@smallkana}{post}
-\jlreq@addjaxspmode{\jlreq@charlist@hiragana}{pre}
-\jlreq@addjaxspmode{\jlreq@charlist@hiragana}{post}
-\jlreq@addjaxspmode{\jlreq@charlist@katakana}{pre}
-\jlreq@addjaxspmode{\jlreq@charlist@katakana}{post}
-\jlreq@addjaxspmode{\jlreq@charlist@dividingpunctuationmarks}{post}
+\__jlreq_addjaxspmode:Vn \jlreq@charlist@iterationmarks {pre}
+\__jlreq_addjaxspmode:Vn \jlreq@charlist@iterationmarks {post}
+\__jlreq_addjaxspmode:Vn \jlreq@charlist@prolongedsoundmark {pre}
+\__jlreq_addjaxspmode:Vn \jlreq@charlist@prolongedsoundmark {post}
+\__jlreq_addjaxspmode:Vn \jlreq@charlist@smallkana {pre}
+\__jlreq_addjaxspmode:Vn \jlreq@charlist@smallkana {post}
+\__jlreq_addjaxspmode:Vn \jlreq@charlist@hiragana {pre}
+\__jlreq_addjaxspmode:Vn \jlreq@charlist@hiragana {post}
+\__jlreq_addjaxspmode:Vn \jlreq@charlist@katakana {pre}
+\__jlreq_addjaxspmode:Vn \jlreq@charlist@katakana {post}
+\__jlreq_addjaxspmode:Vn \jlreq@charlist@dividingpunctuationmarks {post}
 
 % 分割禁止（分離禁止文字は特定の並びで分割禁止だが，とりあえず一括で禁止しておく．）
-\jlreq@setprebreakpenalty{\jlreq@charlist@inseparablecharacters}{10000}
+\__jlreq_setprebreakpenalty:Vn \jlreq@charlist@inseparablecharacters {10000}
 % ￥100とか70％とか……
 
 %.. 文字範囲
 \ifx u\jlreq@engine
   % \kcatcodeの設定
-  \def\jlreq@setkcatcode#1#2{\@for\@tempa:=#1\do{\kcatcode"\@tempa=#2\relax}}
-  \jlreq@aftercls@addtodeletecs{\jlreq@setkcatcode}
+  \cs_set:Nn \__jlreq_setkcatcode:nn {
+    \clist_map_inline:nn {#1} { \kcatcode"##1=#2\relax }
+  }
+  \jlreq@aftercls@addtodeletecs{\__jlreq_setkcatcode:nn}
   % LuaTeX-jaのデフォルトのままに近い設定をする
   % 範囲1＆8
-  \jlreq@setkcatcode{80}{15} % Latin-1 Supplement，どうしよう……
-  \jlreq@setkcatcode{100,180,250,2B0,300,1E00}{15}
+  \__jlreq_setkcatcode:nn {80} {15} % Latin-1 Supplement，どうしよう……
+  \__jlreq_setkcatcode:nn {100,180,250,2B0,300,1E00} {15}
   % 範囲2
-  \jlreq@setkcatcode{370,400,1F00}{18}
+  \__jlreq_setkcatcode:nn {370,400,1F00} {18}
   % 範囲3
-  \jlreq@setkcatcode{2000,2070,20A0,20D0,2100,2150,2190,2200,2300,2400,2500,2580,25A0,2600,2700,2900,2980,2B00}{18}
+  \__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{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}
+  \__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{D800,DB80,DC00,E0000,F0000,100000}{15}
+  \__jlreq_setkcatcode:nn {D800,DB80,DC00,E0000,F0000,100000} {15}
   % 範囲6
-  \jlreq@setkcatcode{3040,30A0,31F0}{17} % Hiragana,Katakana,Katakana Phonetic Extensions
-  \jlreq@setkcatcode{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{2E80,3190,3400,4E00,F900,20000}{16}
+  \__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{A000,A490}{18} % Yi Syllables,Yi Radicals
-  \jlreq@setkcatcode{1100,3130,AC00,D7B0}{19} % Hangul Jamo,Hangul Compatibility Jamo,Hangul Syllables,Hangul Jamo Extended-B
-  \jlreq@setkcatcode{2F00,2FF0,3100,31A0,31C0,A830}{16}
+  \__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
 
 %.. フォント
@@ -1042,7 +1012,7 @@
 \DeclareOldFontCommand{\jlreq@oldfontcommand@it}{\normalfont\itshape}{\mathit}
 \DeclareOldFontCommand{\jlreq@oldfontcommand@sl}{\normalfont\slshape}{\@nomath\sl}
 \DeclareOldFontCommand{\jlreq@oldfontcommand@sc}{\normalfont\scshape}{\@nomath\sc}
-\newcommand*{\jlreq@oldfontcommand@enable}{%
+\def\jlreq@oldfontcommand@enable{%
   \let\mc=\jlreq@oldfontcommand@mc
   \let\gt=\jlreq@oldfontcommand@gt
   \let\rm=\jlreq@oldfontcommand@rm
@@ -1053,7 +1023,7 @@
   \let\sl=\jlreq@oldfontcommand@sl
   \let\sc=\jlreq@oldfontcommand@sc
 }
-\newcommand*{\jlreq@oldfontcommand@disable}{%
+\def\jlreq@oldfontcommand@disable{%
   \let\mc=\@undefined
   \let\gt=\@undefined
   \let\rm=\@undefined
@@ -1096,9 +1066,9 @@
 }
 \expandafter\def\expandafter\jlreq@zenkakuspace@ignorespaces@\space{\　}
 \def\jlreq@tempa{}
-\def\jlreq@do#1{\jlreq@ifendmark{#1}{}{\appto\jlreq@tempa{\ifnum\lastnodechar=`#1 1\fi}\jlreq@do}}
+\def\jlreq@do#1{\jlreq@ifendmark{#1}{}{\appto\jlreq@tempa{\ifnum\lastnodechar=`#1~1\fi}\jlreq@do}}
 \expandafter\jlreq@do\jlreq@charlist@dividingpunctuationmarks\jlreq@endmark
-\edef\@tempa{\noexpand\ifnum0\expandonce{\jlreq@tempa}>0 }
+\edef\@tempa{\noexpand\ifnum0\expandonce{\jlreq@tempa}>0~}
 \expandafter\DeclareRobustCommand\expandafter*\expandafter\jlreq@zenkakuspace@main\expandafter{\@tempa
     \hskip 1\jlreq@zw\hbox{}%
     \jlreq@lastnodechar=`　
@@ -1114,9 +1084,9 @@
 \fi
 
 % \jaspace
-\DeclareRobustCommand*{\jaspace}[1]{%
+\NewDocumentCommand{\jaspace}{ m } {
   \ifcsname jlreq@jaspace@#1\endcsname\csname jlreq@jaspace@#1\endcsname
-  \else\ClassError{jlreq}{unknown jaspace: #1}{\@ehc}\fi
+  \else\ClassError{jlreq}{unknown~jaspace:~#1}{\@ehc}\fi
 }
 \def\jlreq@jaspace@zenkaku{\hskip\glueexpr 1\jlreq@zw\relax}
 \def\jlreq@jaspace@nibu{\hskip\glueexpr .5\jlreq@zw\relax}
@@ -1128,7 +1098,7 @@
 \def\jlreq@do#1{\jlreq@ifendmark{#1}{}{\appto\jlreq@tempa{\ifx\jlreq@nextchar #11\fi}\jlreq@do}}
 \expandafter\jlreq@do\jlreq@charlist@closingbrackets\jlreq@endmark
 \edef\jlreq@dividingpunctuationmarkscommand{%
-  \noexpand\ifnum 0\expandonce{\jlreq@tempa}>0 \unexpanded{\expandafter\ignorespaces\else\expandafter\　\fi}%
+  \noexpand\ifnum 0\expandonce{\jlreq@tempa}>0~\unexpanded{\expandafter\ignorespaces\else\expandafter\　\fi}%
 }
 \def\jlreq@do#1{%
   \jlreq@ifendmark{#1}{}{
@@ -1151,30 +1121,28 @@
 \ifx l\jlreq@engine
   \setlength{\jlreq@baselineskip}{%
     \dimexpr\directlua{
-      local act = string.char(92)
-      local s = [[\jlreq@option@baselineskip]]
-      s = s:gsub("[QH]",act .. "dimexpr 0.25mm" .. act .. "relax"):gsub("zh",act .. "zh"):gsub("zw",act .. "zw")
-      tex.print(s)
+      local~act = string.char(92)~
+      local~s = [[\jlreq@option@baselineskip]]~
+      s = s:gsub("[QH]",act .. "dimexpr 0.25mm" .. act .. "relax"):gsub("zh",act .. "zh"):gsub("zw",act .. "zw")~
+      tex.print(s)~
     }\relax
   }%
 \else
   \setlength{\jlreq@baselineskip}{\dimexpr\jlreq@option@baselineskip\relax}
 \fi
 \ifdim\jlreq@fontsize>\jlreq@baselineskip
-  \ClassError{jlreq}{The baselineskip is less than fontsize}{\@ehc}%
+  \ClassError{jlreq}{The~baselineskip~is~less~than~fontsize}{\@ehc}%
 \fi
-\ExplSyntaxOn
 \bool_if:nT { \dim_compare_p:n { \jlreq@baselineskip < 1.5\zw } || \dim_compare_p:n { \jlreq@baselineskip > 2\zw } } {
   \jlreq@note { 行間は二分以上全角以下が望ましい (2.4.2.d~注3)．}
 }
-\ExplSyntaxOff
 
 \emergencystretch 3\jlreq@gol
 \setlength{\parindent}{1\zw}
 \def\jlreq@setfontsizehook{}
 \jlreq@saveoriginalcs{set@fontsize}
 \apptocmd{\set@fontsize}{\expandafter\def\expandafter\size@update\expandafter{\size@update\jlreq@setfontsizehook}}{}{}
-\appto\jlreq@setfontsizehook{\ifdim\parindent>0pt \setlength{\parindent}{1\jlreq@zw}\fi}
+\appto\jlreq@setfontsizehook{ \dim_compare:nT { \parindent>0pt } { \setlength{\parindent}{1\jlreq@zw} } }
 \ifx l\jlreq@engine
   \@tempskipa=\ltjgetparameter{kanjiskip}
   \ifdim\@tempskipa=\maxdimen\else
@@ -1201,7 +1169,7 @@
   \let\jafontsize=\fontsize
 \else
   \def\@tempa#1{
-    \DeclareRobustCommand*{\jafontsize}[2]{%
+    \NewDocumentCommand{\jafontsize}{ m m }{%
       \begingroup
         \jlreq@iffloat{##1}{%
           \edef\jlreq@do{\noexpand\fontsize{\strip@pt\dimexpr#1\dimexpr##1pt\relax\relax}}%
@@ -1270,7 +1238,7 @@
 \setlength{\parskip}{0pt}
 % https://github.com/texjporg/jsclasses/issues/14
 \renewcommand*{\flushbottom}{%
-  \def\@textbottom{\vskip 0pt plus 0.1pt}%
+  \def\@textbottom{\vskip 0pt~plus~0.1pt}%
   \let\@texttop\relax
 }
 \@lowpenalty   51
@@ -1309,10 +1277,10 @@
   \def\jlreq@expand@speciallength#1{%
     % zhやzwを\zhや\zwにする．
     \directlua{
-      local act = string.char(92)
-      local s = [[#1]]
-      s = s:gsub("zw",act .. "zw"):gsub("zh",act .. "zh")
-      tex.print(s)
+      local~act = string.char(92)~
+      local~s = [[#1]]~
+      s = s:gsub("zw",act .. "zw"):gsub("zh",act .. "zh")~
+      tex.print(s)~
     }%
   }
 \else
@@ -1516,7 +1484,7 @@
   \jlreq@setsidemargin@by@gutter{\jlreq@speciallength{\jlreq@option@gutter}}
   \ifx\jlreq@option@fore@edge\@empty\else
     \ifjlreq@determine@kihonhanmen@warning@first
-      \ClassWarningNoLine{jlreq}{fore-edge is ignored}
+      \ClassWarningNoLine{jlreq}{fore-edge~is~ignored}
     \fi
   \fi
 \fi
@@ -1575,12 +1543,12 @@
     \if@tate
       \jlreq@settopmarginbyfoot{\jlreq@speciallength{\jlreq@option@foot@space}}
       \ifx\jlreq@option@line@length\@empty\else
-        \ClassWarningNoLine{jlreq}{head_space is ignored}
+        \ClassWarningNoLine{jlreq}{head_space~is~ignored}
       \fi
     \else
       \jlreq@settopmarginbyhead{\jlreq@speciallength{\jlreq@option@head@space}}
       \ifx\jlreq@option@number@of@lines\@empty\else
-        \ClassWarningNoLine{jlreq}{foot_space is ignored}
+        \ClassWarningNoLine{jlreq}{foot_space~is~ignored}
       \fi
     \fi
   \fi
@@ -1605,7 +1573,7 @@
 
 %. 見出し関係 (4.1)
 % \clear***page
-\newcommand*{\cleartooddpage}[1][]{%
+\NewDocumentCommand{\cleartooddpage}{ O{} }{
   \clearpage
   \ifodd\c@page\else
     \jlreq@ifempty{#1}{}{\thispagestyle{#1}}%
@@ -1614,7 +1582,7 @@
     \if@twocolumn\hbox{}\newpage\fi
   \fi
 }
-\newcommand*{\cleartoevenpage}[1][]{%
+\NewDocumentCommand{\cleartoevenpage}{ O{} }{
   \clearpage
   \ifodd\c@page
     \jlreq@ifempty{#1}{}{\thispagestyle{#1}}%
@@ -1635,7 +1603,7 @@
 % 見出しの直前に実行される
 \NewHook{./heading/before}
 % 見出し名一覧を格納する
-\def\jlreq@heading@allheadings{}
+\seq_new:N \l__jlreq_heading_allheadings_seq
 % 目次を出力する命令\l@<命令名>を作る命令を作る．{1 = 命令名}{2 = レベル}{3 = ラベルのフォーマット}
 % 結果は\jlreq@resultに入る．
 \def\jlreq@heading@make@l@#1#2#3{%
@@ -1687,11 +1655,10 @@
 
 %.. 中/半扉見出し
 % addcontentslineに渡すやつ：番号出すのと出さないの
-\newcommand{\DeclareTobiraHeading}[3]{%
-  \IfHookExistsTF{jlreq/heading/before/#1}{}{\NewHook{./heading/before/#1}}%
-  \def\jlreq@do{\@removeelement{#1}}%
-  \expandafter\jlreq@do\expandafter{\jlreq@heading@allheadings}{\jlreq@heading@allheadings}%
-  \appto{\jlreq@heading@allheadings}{,#1}%
+\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}%
   \expandafter\edef\csname jlreq@heading@setting@#1\endcsname{\unexpanded{#3}}%
   \expandafter\def\csname jlreq@heading@type@#1\endcsname{\RenewTobiraHeading}%
@@ -1702,21 +1669,18 @@
     \let\jlreq@contents@label@format=\@undefined
     \let\jlreq@format=\@undefined
     \edef\jlreq@label@format{\expandonce{\csname the#1\endcsname}}%
-    \def\jlreq@heading@clearpage{\clearpage\hbox{}\clearpage}%
-    \def\jlreq@pagestyle{empty}%
-    \newif\ifjlreq@number \jlreq@numbertrue
-    \jlreq@parsekeyval[DeclareTobiraHeading:#1]{
-      {label_format}{\def\jlreq@label@format{##1}}
-      {format}{\def\jlreq@format####1####2{##1}}
-      {pagestyle}{\def\jlreq@pagestyle{##1}}
-      {type}[han,naka]{%
-        \jlreq@switch{##1}{
-          {han}{\def\jlreq@heading@clearpage{\clearpage}}
-          {naka}{\def\jlreq@heading@clearpage{\clearpage\hbox{}\clearpage}}
-        }%
-      }
-      {number}[true,false]{\csname jlreq@number##1\endcsname}
-    }{#3}%
+    \newif\ifjlreq@number
+    \keys_define:nn { DeclareTobiraHeading:#1 } {
+      label_format .tl_set:N = \jlreq@label@format,
+      format .code:n = {\def\jlreq@format####1####2{##1}},
+      pagestyle .tl_set:N = \jlreq@pagestyle,
+      type .choice:,
+      type / han .code:n = { \def\jlreq@heading@clearpage{\clearpage} },
+      type / naka .code:n = { \def\jlreq@heading@clearpage{\clearpage\hbox{}\thispagestyle{empty}\clearpage} },
+      number .choices:nn = {true,false} { \csname jlreq@number ##1 \endcsname }
+    }
+    \keys_set:nn { DeclareTobiraHeading:#1 } { type = naka, pagestyle = empty, number = true}
+    \keys_set:nn { DeclareTobiraHeading:#1 } {#3}
     \def\jlreq@do{}%
     \ifx\jlreq@format\@undefined
       \def\jlreq@format##1##2{##1##2}%
@@ -1780,13 +1744,13 @@
   \jlreq@do
 }
 
-\newcommand{\NewTobiraHeading}[3]{%
+\NewDocumentCommand{\NewTobiraHeading}{ m m +m }{%
   \expandafter\@ifdefinable\csname #1\endcsname{\DeclareTobiraHeading{#1}{#2}{#3}}%
 }
-\newcommand{\RenewTobiraHeading}[3]{%
+\NewDocumentCommand{\RenewTobiraHeading}{ m m +m }{%
   \@ifundefined{#1}{\@latex@error{\expandafter\string\csname#1\endcsname\space undefined}\@ehc}{\DeclareTobiraHeading{#1}{#2}{#3}}%
 }
-\newcommand{\ProvideTobiraHeading}[3]{%
+\NewDocumentCommand{\ProvideTobiraHeading}{ m m +m }{%
   \@ifundefined{#1}{\DeclareTobiraHeading{#1}{#2}{#3}}{}%
 }
 
@@ -1803,7 +1767,7 @@
 % 見出し全体のフォーマット内では#1=ラベル，#2=見出し文字列，#3=副題，それぞれ各々のフォーマットに基づき整形される．
 % ラベルフォーマットでは#1=カウンタ名，見出し文字列フォーマットでは#1=見出し文字列，副題フォーマットでは#1=副題
 % ラベルのみのフォーマットは目次に使われる．
-\newcommand{\jlreq@BlockHeading@start}[6]{%
+\long\def\jlreq@BlockHeading@start#1#2#3#4#5#6{%
   \if@noskipsec\leavevmode\fi
   % #5と#6は\parを含むかもしれないので引数渡しはしない（後の\@ifstarで詰まる）
   \edef\jlreq@BlockHeading@start@eachformat{\expandonce{\@firstoftwo#5}}%
@@ -1812,7 +1776,7 @@
   \jlreq@BlockHeading@start@{#1}{#2}{#3}{#4}%
 }
 % {1 = 命令}{2 = レベル}{3 = スペース関連}
-\newcommand{\jlreq@BlockHeading@start@}[4]{%
+\long\def\jlreq@BlockHeading@start@#1#2#3#4{%
   \@ifstar{\@dblarg{\jlreq@BlockHeading@start@@{#1}{#2}{#3}{*}}}{\@dblarg{\jlreq@BlockHeading@start@@{#1}{#2}{#3}{#4}}}%
 }
 % {1 = 命令}{2 = レベル}{3 = スペース関連}{4 = *}[5 = running head]{6 = 見出し}
@@ -1889,17 +1853,17 @@
 \expandafter\def\expandafter\jlreq@BlockHeading@start@afterheading@skipspaces\space{\jlreq@BlockHeading@start@afterheading}
 \def\jlreq@BlockHeading@start@afterheading@ii{%
   \def\jlreq@do{\jlreq@BlockHeading@spaces@output}%
-  \@for\@tempa:=\jlreq@BlockHeading@allheadings\do{%
-    \expandafter\ifx\csname\@tempa\endcsname\jlreq@nextchar\def\jlreq@do{}\fi
+  \seq_map_inline:Nn \l__jlreq_BlockHeading_allheadings_seq {
+    \expandafter\ifx\csname##1\endcsname\jlreq@nextchar\def\jlreq@do{}\fi
   }%
   % \jlreq@BlockHeading@HeadingSpaces@ignoretokens(@noargument)内のものは特別扱いする
-  \expandafter\@tfor\expandafter\@tempa\expandafter:\expandafter=\jlreq@BlockHeading@HeadingSpaces@ignoretokens@noargument\do{%
-    \expandafter\ifx\@tempa\jlreq@nextchar
+  \tl_map_inline:Nn \jlreq@BlockHeading@HeadingSpaces@ignoretokens@noargument {
+    \ifx##1\jlreq@nextchar
       \def\jlreq@do{\jlreq@BlockHeading@start@afterheading@saveafter@cs@noargument}%
     \fi
   }%
-  \expandafter\@tfor\expandafter\@tempa\expandafter:\expandafter=\jlreq@BlockHeading@HeadingSpaces@ignoretokens\do{%
-    \expandafter\ifx\@tempa\jlreq@nextchar
+  \tl_map_inline:Nn \jlreq@BlockHeading@HeadingSpaces@ignoretokens {
+    \ifx##1\jlreq@nextchar
       \def\jlreq@do{\jlreq@BlockHeading@start@afterheading@saveafter@cs}%
     \fi
   }%
@@ -2044,12 +2008,16 @@
 \def\jlreq@BlockHeading@start@removecolumn#1:{#1}
 
 % 空き指定を解釈する．a:10pt -> \jlreq@resulta=a，\jlreq@resultb=10pt
-\def\jlreq@BlockHeading@start@analyzespace#1:#2\jlreq@endmark{%
+\cs_set:Nn \__jlreq_BlockHeading_start_analyzespace:n{%
+  \__jlreq_BlockHeading_start_analyzespace_aux#1:\jlreq@endmark
+}
+\cs_generate_variant:Nn \__jlreq_BlockHeading_start_analyzespace:n {V}
+\def\__jlreq_BlockHeading_start_analyzespace_aux#1:#2\jlreq@endmark{
   \jlreq@ifempty{#1}{%
     \def\jlreq@resulta{}%
     \def\jlreq@resultb{}%
   }{%
-    \let\jlreq@resulta=#1%
+    \let\jlreq@resulta=#1
     \edef\jlreq@resultb{\expandonce{\jlreq@BlockHeading@start@removecolumn#2}}%
   }%
 }
@@ -2064,10 +2032,13 @@
   \jlreq@tempskipa=0pt
   \jlreq@tempskipb=0pt
   \jlreq@tempskipc=0pt
-  \jlreq@BlockHeading@start@analyzespace#1:\jlreq@endmark
+  \tl_set_rescan:Nnn \l_jlreq_tmpa_tl {\ExplSyntaxOn}{#1}
+%  \message{[[[\expandafter\getcatcode\l_jlreq_tmpa_tl]]]}
+  \__jlreq_BlockHeading_start_analyzespace:V \l_jlreq_tmpa_tl
   \let\jlreq@maeakitype=\jlreq@resulta
   \let\jlreq@maeaki=\jlreq@resultb
-  \jlreq@BlockHeading@start@analyzespace#2:\jlreq@endmark
+  \tl_set_rescan:Nnn \l_jlreq_tmpa_tl {\ExplSyntaxOn}{#2}
+  \__jlreq_BlockHeading_start_analyzespace:V \l_jlreq_tmpa_tl
   \let\jlreq@ushiroakitype=\jlreq@resulta
   \let\jlreq@ushiroaki=\jlreq@resultb
   \def\jlreq@lines{#3}%
@@ -2130,29 +2101,24 @@
     \dp\jlreq@tempboxa=\dimexpr\dp\jlreq@tempboxa + \ht\jlreq@tempboxa - \jlreq@tempdimb\relax
     \ht\jlreq@tempboxa=\jlreq@tempdimb
     \box\jlreq@tempboxa
-    \ifx r\jlreq@ushiroakitype\prevdepth=-1000pt \else\prevdepth=\jlreq@tempdimc\fi
+    \ifx r\jlreq@ushiroakitype\prevdepth=-1000pt\relax\else\prevdepth=\jlreq@tempdimc\fi
     % \jlreq@tempdimb, \jlreq@tempdimcの利用ここまで
   \else
     \dp\jlreq@tempboxa=\dimexpr\dp\jlreq@tempboxa + \ht\jlreq@tempboxa\relax
     \ht\jlreq@tempboxa=0pt
     \box\jlreq@tempboxa
-    \ifx r\jlreq@ushiroakitype\prevdepth=-1000pt \else\prevdepth=0pt \fi
+    \ifx r\jlreq@ushiroakitype\prevdepth=-1000pt\relax\else\prevdepth=0pt\relax\fi
   \fi
   \nobreak
   \jlreq@ifgluezero\jlreq@tempskipb{}{\vskip\jlreq@tempskipb}%
   \edef\jlreq@do{%
-    \ifdim\parskip=0pt \else
-      \unexpanded{\def\jlreq@parhook@gyodori}{%
-        \noexpand\parskip=\the\parskip
-        \unexpanded{\def\jlreq@parhook@gyodori{}}%
-      }%
-      \unexpanded{\parskip=0pt}%
-    \fi
+    \dim_compare:nF { \parskip=0pt } {
+      \noexpand\AddToHookNext{para/before}{\noexpand\parskip=\the\parskip\noexpand\relax}%
+      \noexpand\parskip=0pt
+    }
   }%
   \expandafter}\jlreq@do
 }
-\PushPostHook{par}{\jlreq@parhook@gyodori}
-\def\jlreq@parhook@gyodori{}
 
 % 行取り情報をゲットだぜ
 % \jlreq@resultに{1 = 前空き}{2 = 後ろ空き}{3 = トータル行数}を入れる
@@ -2165,49 +2131,53 @@
   \@ifnextchar[{\jlreq@BlockHeading@gyodori@parsekeyval@@{#1}}{\jlreq@BlockHeading@gyodori@parsekeyval@@{#1}[jlreq@key]}%
 }
 \long\def\jlreq@BlockHeading@gyodori@parsekeyval@@#1[#2]#3#4#5#6{%
-  \begingroup
-    \def\jlreq@lines{#6}%
-    \def\jlreq@before@space{}%
-    \def\jlreq@before@lines{}%
-    \def\jlreq@after@space{}%
-    \def\jlreq@after@lines{}%
-    \jlreq@parsekeyval#1[#2]{
-      {lines}{\def\jlreq@lines{##1}}
-      {before_space}{\def\jlreq@before@space{##1}}
-      {after_space}{\def\jlreq@after@space{##1}}
-      {before_lines}{%
-        \jlreq@ifempty{##1}{\def\jlreq@before@lines{}}{%
-          \jlreq@iffirsttoken@ignorespaces{##1}{*}%
-            {\edef\jlreq@before@lines{s:\expandonce{\@gobble ##1}}}%
-            {\def\jlreq@before@lines{a:##1}}%
-        }%
-      }
-      {after_lines}{\def\jlreq@after@lines{##1}}
-    }{#3}%
+  \group_begin:
+    \keys_define:nn {#2} {
+      lines .tl_set:N = \l__jlreq_lines_tl,
+      before_space .tl_set:N = \l__jlreq_before_space_tl,
+      after_space .tl_set:N = \l__jlreq_after_space_tl,
+      before_lines .code:n = {
+        \tl_if_empty:nTF {##1}{
+          \tl_set:Nn \l__jlreq_before_lines_tl {}
+        }{
+          \str_if_eq:eeTF { \str_head:n {##1} } {*}
+            {\tl_set:Nx \l__jlreq_before_lines_tl {s:\exp_not:o {\use_none:n ##1}}}
+            {\tl_set:Nx \l__jlreq_before_lines_tl {a:##1}}
+        }
+      },
+      after_lines .tl_set:N = \l__jlreq_after_lines_tl
+    }
+    \tl_if_empty:nF {#1} { \keys_define:nn {#2} { unknown .code:n = {} } }
+    \keys_set:nn {#2} {lines = {#6}, before_space = {}, before_lines = {}, after_space = {}, after_lines = {} }
+    \keys_set:nn {#2} {#3} 
     % before/after_lines優先
-    \ifx\jlreq@before@space\@empty\else\edef\jlreq@before@space{r:\expandonce{\jlreq@before@space}}\fi
-    \ifx\jlreq@before@lines\@empty\else\edef\jlreq@before@space{\expandonce{\jlreq@before@lines}\baselineskip}\fi
-    \ifx\jlreq@before@space\@empty\def\jlreq@before@space{#4}\fi
-    \ifx\jlreq@after@space\@empty\else\edef\jlreq@after@space{r:\expandonce{\jlreq@after@space}}\fi
-    \ifx\jlreq@after@lines\@empty\else\edef\jlreq@after@space{a:\expandonce{\jlreq@after@lines}\baselineskip}\fi
-    \ifx\jlreq@after@space\@empty\def\jlreq@after@space{#5}\fi
-    \edef\jlreq@do{%
-      \unexpanded{\def\jlreq@result}{{\expandonce{\jlreq@before@space}}{\expandonce{\jlreq@after@space}}{\expandonce{\jlreq@lines}}}%
+    \tl_if_empty:NF \l__jlreq_before_space_tl { \tl_put_left:Nn \l__jlreq_before_space_tl {r:} }
+    \tl_if_empty:NF \l__jlreq_before_lines_tl { \tl_set:Nx \l__jlreq_before_space_tl {\exp_not:o {\l__jlreq_before_lines_tl} \baselineskip } }
+    \tl_if_empty:NT \l__jlreq_before_space_tl { \tl_set:Nn \l__jlreq_before_space_tl {#4} }
+    \tl_if_empty:NF \l__jlreq_after_space_tl { \tl_put_left:Nn \l__jlreq_after_space_tl {r:} }
+    \tl_if_empty:NF \l__jlreq_after_lines_tl { \tl_set:Nx \l__jlreq_after_space_tl { a:\exp_not:o {\l__jlreq_after_lines_tl} \baselineskip } }
+    \tl_if_empty:NT \l__jlreq_after_space_tl { \tl_set:Nn \l__jlreq_after_space_tl {#5} }
+    \cs_set:Nx \l__jlreq_do: {
+      \exp_not:n {\def\jlreq@result}{
+        {\exp_not:o {\l__jlreq_before_space_tl } }
+        {\exp_not:o {\l__jlreq_after_space_tl } }
+        {\exp_not:o {\l__jlreq_lines_tl } }
+      }
     }%
-  \expandafter\endgroup
-  \jlreq@do
+  \exp_after:wN \group_end:
+  \l__jlreq_do:
 }
 
 \newbox\jlreq@BlockHeading@start@label@box
 % \DeclareBlockHeading{命令名}{レベル}{設定}
-\def\jlreq@BlockHeading@allheadings{}% 別行見出し一覧
-\newcommand{\DeclareBlockHeading}[3]{%
-  \IfHookExistsTF{jlreq/heading/before/#1}{}{\NewHook{jlreq/heading/before/#1}}%
+\seq_new:N \l__jlreq_BlockHeading_allheadings_seq
+\NewDocumentCommand {\DeclareBlockHeading} { m m +m } {
+  \ProvideHook{jlreq/heading/before/#1}
   \def\jlreq@do{\@removeelement{#1}}%
-  \expandafter\jlreq@do\expandafter{\jlreq@heading@allheadings}{\jlreq@heading@allheadings}%
-  \appto\jlreq@heading@allheadings{,#1}%
-  \expandafter\jlreq@do\expandafter{\jlreq@BlockHeading@allheadings}{\jlreq@BlockHeading@allheadings}%
-  \appto\jlreq@BlockHeading@allheadings{,#1}%
+  \seq_put_right:Nn \l__jlreq_heading_allheadings_seq {#1}
+  \seq_remove_duplicates:N \l__jlreq_heading_allheadings_seq
+  \seq_put_right:Nn \l__jlreq_BlockHeading_allheadings_seq {#1}
+  \seq_remove_duplicates:N \l__jlreq_BlockHeading_allheadings_seq
   \expandafter\def\csname jlreq@heading@level@#1\endcsname{#2}%
   \expandafter\edef\csname jlreq@heading@setting@#1\endcsname{\unexpanded{#3}}%
   \expandafter\def\csname jlreq@heading@type@#1\endcsname{\RenewBlockHeading}%
@@ -2215,29 +2185,12 @@
   \@ifundefined{#1mark}{\expandafter\let\csname #1mark\endcsname\@gobble}{}%
   \jlreq@heading@make@maketoc{#1}{#2}%
   \begingroup
-    \def\jlreq@font{}%
-    \def\jlreq@subtitle@font{}%
-    \def\jlreq@indent{0\jlreq@zw}%
-    \def\jlreq@end@indent{0\jlreq@zw}%
-    \def\jlreq@align{l}%
-    \edef\jlreq@format{\unexpanded{##1##2##3}}%
     \edef\jlreq@heading@text@format{\unexpanded{##1}}%
-    \def\jlreq@pagebreak{}%
-    \def\jlreq@label@format{\@seccntformat{#1}}%
-    \newif\ifjlreq@second@text@indent@withlabel\jlreq@second@text@indent@withlabeltrue
-    \def\jlreq@after@label@space{1\jlreq@zw}%
-    \def\jlreq@second@heading@text@indent@wlabel{0pt}%
-    \def\jlreq@second@heading@text@indent@wolabel{0pt}%
-    \edef\jlreq@subtitle@format{\unexpanded{---##1---}}%
-    \newif\ifjlreq@subtitleindent@withlabel\jlreq@subtitleindent@withlabeltrue
-    \def\jlreq@subtitle@indent{1\jlreq@zw}%
-    \def\jlreq@afterindent{\@afterindenttrue}%
-    \def\jlreq@allowbreak@evenpage{*}% 偶数ページでも改ページを許可するならば空，そうでないなら*
-    \newif\ifjlreq@subtitle@break\jlreq@subtitle@breaktrue
-    \def\jlreq@subtitle@indent{1\jlreq@zw}%
-    \def\jlreq@column@spanning{false}%
-    \newif\ifjlreq@column@spanning@possible\jlreq@column@spanning@possiblefalse
-    \newif\ifjlreq@number \jlreq@numbertrue
+    \newif\ifjlreq@second@text@indent@withlabel
+    \newif\ifjlreq@subtitleindent@withlabel
+    \newif\ifjlreq@subtitle@break
+    \newif\ifjlreq@column@spanning@possible
+    \newif\ifjlreq@number
     % a,bみたいなのをaとbにわける．カンマがなければbは空．引数を{a}{b}として##2を呼び出す．
     \def\jlreq@parsecomma##1##2{%
       \jlreq@helper@dividebycomma{##1}%
@@ -2249,26 +2202,27 @@
       \def\jlreq@tempa####1####2{##2}%
       \jlreq@do
     }%
-    \jlreq@parsekeyval[BlockHeading:#1]{
-      {lines}{}
-      {before_space}{}
-      {after_space}{}
-      {before_lines}{}
-      {after_lines}{}
-      {font}{\def\jlreq@font{##1}}
-      {subtitle_font}{\def\jlreq@subtitle@font{##1}}
-      {indent}{\def\jlreq@indent{##1}}
-      {end_indent}{\def\jlreq@end@indent{##1}}
-      {align}[left,center,right]{%
-        \jlreq@switch{##1}{
-          {left}{\def\jlreq@align{l}}
-          {center}{\def\jlreq@align{c}}
-          {right}{\def\jlreq@align{r}}
-        }%
-      }
-      {format}{\edef\jlreq@format{\unexpanded{##1}}}
-      {after_label_space}{\def\jlreq@after@label@space{##1}}
-      {second_heading_text_indent,heading_text_second_indent}{%
+    \keys_define:nn { BlockHeading:#1 } {
+      lines .code:n = {},
+      before_space .code:n = {},
+      after_space .code:n = {},
+      before_lines .code:n = {},
+      after_lines .code:n = {},
+      font .tl_set:N = \jlreq@font,
+      subtitle_font .tl_set:N = \jlreq@subtitle@font,
+      indent .tl_set:N = \jlreq@indent,
+      end_indent .tl_set:N = \jlreq@end@indent,
+      align .choice:,
+      align / left .code:n = { \def\jlreq@align{l} },
+      align / center .code:n = { \def\jlreq@align{c} },
+      align / right .code:n = { \def\jlreq@align{r} },
+      format .code:n = {\edef\jlreq@format{\unexpanded{##1}}},
+      after_label_space .tl_set:N = \jlreq@after@label@space,
+      heading_text_second_indent .code:n = {
+        \ClassError { jlreq } { `heading_text_second_indent`~was~removed,~use~`second_heading_text_indent`~instead~(in~BlockHeading:~#1) }{\@ehc}
+      },
+%      {second_heading_text_indent,heading_text_second_indent}{%
+      second_heading_text_indent .code:n = {
         \jlreq@parsecomma{##1}{%
           \jlreq@iffirsttoken{####1}{*}{%
             \jlreq@second@text@indent@withlabelfalse
@@ -2283,10 +2237,10 @@
             \def\jlreq@second@heading@text@indent@wolabel{####2}%
           }%
         }%
-      }
-      {label_format}{\edef\jlreq@label@format{\unexpanded{##1}}}
-      {subtitle_format}{\edef\jlreq@subtitle@format{\unexpanded{##1}}}
-      {subtitle_indent}{%
+      },
+      label_format .code:n = {\edef\jlreq@label@format{\unexpanded{##1}}},
+      subtitle_format .code:n = {\edef\jlreq@subtitle@format{\unexpanded{##1}}},
+      subtitle_indent .code:n = {%
         \jlreq@iffirsttoken{##1}{*}{%
           \jlreq@subtitleindent@withlabelfalse
           \edef\jlreq@subtitle@indent{\expandonce{\@gobble ##1}}%
@@ -2294,27 +2248,24 @@
           \jlreq@subtitleindent@withlabeltrue
           \def\jlreq@subtitle@indent{##1}%
         }%
-      }
-      {subtitle_break}[true,false]{\csname jlreq@subtitle@break##1\endcsname}
-      {afterindent}[true,false]{\edef\jlreq@afterindent{\expandonce{\csname @afterindent##1\endcsname}}}
-      {allowbreak_if_evenpage}[true,false]{%
-        \jlreq@switch{##1}{
-          {true}{\def\jlreq@allowbreak@evenpage{}}
-          {false}{\def\jlreq@allowbreak@evenpage{*}}
-        }%
-      }
-      {pagebreak}[clearpage,cleardoublepage,clearcolumn,nariyuki,begin_with_odd_page,begin_with_even_page]{%
-        \jlreq@switch{##1}{
-          {clearpage}{\def\jlreq@pagebreak{\clearpage}\jlreq@column@spanning@possibletrue}
-          {cleardoublepage}{\def\jlreq@pagebreak{\cleardoublepage}\jlreq@column@spanning@possibletrue}
-          {clearcolumn}{\if@twocolumn\def\jlreq@pagebreak{\newpage}\else\def\jlreq@pagebreak{}\fi\jlreq@column@spanning@possiblefalse}
-          {begin_with_even_page}{\def\jlreq@pagebreak{\cleartoevenpage[empty]}\jlreq@column@spanning@possibletrue}
-          {begin_with_odd_page}{\def\jlreq@pagebreak{\cleartooddpage[empty]}\jlreq@column@spanning@possibletrue}
-          {nariyuki}{\def\jlreq@pagebreak{}\jlreq@column@spanning@possiblefalse}
-        }%
-      }
+      },
+      subtitle_break .choices:nn = {true,false}{\csname jlreq@subtitle@break##1\endcsname},
+      afterindent .choices:nn = {true,false}{\edef\jlreq@afterindent{\expandonce{\csname @afterindent##1\endcsname}}},
+      allowbreak_if_evenpage .choices:nn = {true,false}{%
+        \str_if_eq:nnTF {##1} {true}
+          {\def\jlreq@allowbreak@evenpage{}}
+          {\def\jlreq@allowbreak@evenpage{*}}
+      },
+      pagebreak .choice:,
+      pagebreak / clearpage            .code:n = {\def\jlreq@pagebreak{\clearpage}\jlreq@column@spanning@possibletrue},
+      pagebreak / cleardoublepage      .code:n = {\def\jlreq@pagebreak{\cleardoublepage}\jlreq@column@spanning@possibletrue},
+      pagebreak / clearcolumn          .code:n = {\if@twocolumn\def\jlreq@pagebreak{\newpage}\else\def\jlreq@pagebreak{}\fi\jlreq@column@spanning@possiblefalse},
+      pagebreak / begin_with_even_page .code:n = {\def\jlreq@pagebreak{\cleartoevenpage[empty]}\jlreq@column@spanning@possibletrue},
+      pagebreak / begin_with_odd_page  .code:n = {\def\jlreq@pagebreak{\cleartooddpage[empty]}\jlreq@column@spanning@possibletrue},
+      pagebreak / nariyuki             .code:n = {\def\jlreq@pagebreak{}\jlreq@column@spanning@possiblefalse},
+      pagestyle .tl_set:N = \l__jlreq_pagestyle_tl,
       % 後々数字を受け付けるようになったりするかもしれないので……
-      {column_spanning}{%
+      column_spanning .code:n = {%
         \jlreq@tempatrue % validな入力に対してfalse
         \jlreq@ifempty{##1}{}{%
           \jlreq@ifnumber{##1}{% 数字の時はtrueに回す
@@ -2327,18 +2278,27 @@
             }%
           }%
         }%
-        \ifjlreq@tempa\ClassWarningNoLine{jlreq}{Invalid input `##1' for column_spanning in BlockHeading #1}\fi
-      }
-      {number}[true,false]{\csname jlreq@number##1\endcsname}
-    }{#3}%
+        \ifjlreq@tempa\ClassWarningNoLine{jlreq}{Invalid~input~`##1'~for~column_spanning~in~BlockHeading~#1}\fi
+      },
+      number .choices:nn = {true,false}{\csname jlreq@number\l_keys_choice_tl\endcsname},
+    }%
+    \keys_set:nn { BlockHeading:#1 } {
+      font = {}, subtitle_font = {},
+      indent = {0pt}, end_indent = {0pt}, align = {left}, subtitle_indent = {1\jlreq@zw}, afterindent = {true},
+      second_heading_text_indent = {0pt}, after_label_space = {1\jlreq@zw}, 
+      pagebreak = {nariyuki}, allowbreak_if_evenpage = {false}, subtitle_break = {true}, column_spanning = {false}, 
+      format = {##1##2##3}, label_format = {\@seccntformat{#1}}, subtitle_format = {---##1---}, number = {true},
+      pagestyle = {}
+    }
+    \keys_set:nn { BlockHeading:#1 } {#3}
     \def\jlreq@do{}% 初期化．これに最終処理を入れていく．
     % 入力チェック
-    \ifthenelse{\equal{\jlreq@column@spanning}{true}}{%
+    \str_if_eq:VnT \jlreq@column@spanning { true } {
       \jlreq@if{\unless\ifjlreq@column@spanning@possible\fi}{
-        \ClassWarningNoLine{jlreq}{column_spanning can be used only with `pagebreak=nariyuki' or `pagebreak=clearcolumn' (in BlockHeading #1)}%
+        \ClassWarningNoLine{jlreq}{column_spanning~can~be~used~only~with~`pagebreak=nariyuki'~or~`pagebreak=clearcolumn'~(in~BlockHeading~#1)}%
         \def\jlreq@column@spanning{false}%
       }{}%
-    }{}%
+    }%
     % ラベルありフォーマット：前
     \edef\jlreq@pre@format@wlabel{%
       \noexpand\noindent
@@ -2363,12 +2323,12 @@
     \edef\jlreq@label@format@modified{%
       \noexpand\jlreq@BlockHeading@start@outputlabel
       \unexpanded{\inhibitglue\hbox{}}%
-      \ifdim\dimexpr\jlreq@after@label@space\relax=0pt \else
+      \ifdim\dimexpr\jlreq@after@label@space\relax=\dimexpr 0pt\relax\else
         \noexpand\hspace*{\noexpand\dimexpr\expandonce{\jlreq@after@label@space}\noexpand\relax}%
       \fi
     }%
     \edef\jlreq@heading@text@format@wlabel{%
-      \ifnum 0\ifdim\jlreq@second@heading@text@indent@wlabel=0pt \else 1\fi\ifjlreq@second@text@indent@withlabel 1\fi>0
+      \ifnum 0\ifdim\jlreq@second@heading@text@indent@wlabel=\dimexpr 0pt\relax\else 1\fi\ifjlreq@second@text@indent@withlabel 1\fi>0
         \unexpanded{\hangindent=\glueexpr}(\expandonce{\jlreq@second@heading@text@indent@wlabel})%
           \ifjlreq@second@text@indent@withlabel + (\expandonce{\jlreq@after@label@space}) + \unexpanded{\jlreq@BlockHeading@start@labellength}\fi
           \noexpand\relax
@@ -2376,7 +2336,7 @@
       \expandonce{\jlreq@heading@text@format}%
     }%
     \edef\jlreq@heading@text@format@wolabel{%
-      \ifdim\dimexpr\jlreq@second@heading@text@indent@wolabel\relax=0pt \else
+      \ifdim\dimexpr\jlreq@second@heading@text@indent@wolabel\relax=\dimexpr 0pt\relax\else
         \unexpanded{\hangindent=\dimexpr}\expandonce{\jlreq@second@heading@text@indent@wolabel}\noexpand\relax
       \fi
       \expandonce{\jlreq@heading@text@format}%
@@ -2389,7 +2349,7 @@
           ##2%
           \unexpanded{\nobreak\noindent}%
         \else
-          \ifdim\jlreq@subtitle@indent=0pt \else
+          \ifdim\jlreq@subtitle@indent=\dimexpr 0pt\relax\else
             \noexpand\hspace*{\expandonce{\jlreq@subtitle@indent}}%
           \fi
         \fi
@@ -2401,14 +2361,14 @@
         \noexpand\hangafter=0
         \unexpanded{\hangindent=\dimexpr}\noexpand\jlreq@BlockHeading@start@labellength + (\expandonce{\jlreq@after@label@space}) + (\expandonce{\jlreq@subtitle@indent})\noexpand\relax
       \else
-        \ifdim\jlreq@subtitle@indent=0pt \else
+        \ifdim\jlreq@subtitle@indent=\dimexpr 0pt\relax\else
           \noexpand\hangafter=0
           \unexpanded{\hangindent=\dimexpr}\expandonce{\jlreq@subtitle@indent}\noexpand\relax
         \fi
       \fi
     }%
     \jlreq@make@subtitle@format\jlreq@subtitle@format@wolabel{%
-      \ifdim\jlreq@subtitle@indent=0pt \else
+      \ifdim\jlreq@subtitle@indent=\dimexpr 0pt\relax\else
         \noexpand\hangafter=0
         \unexpanded{\hangindent=\dimexpr}\expandonce{\jlreq@subtitle@indent}\noexpand\relax
       \fi
@@ -2420,7 +2380,7 @@
     \edef\jlreq@totalformat{\unexpanded{##1}}%
     \edef\jlreq@totalformat@after{\expandonce{\jlreq@afterindent}\noexpand\@afterheading}%
     \if@twocolumn
-      \ifthenelse{\equal{\jlreq@column@spanning}{true}}{%
+      \str_if_eq:VnT \jlreq@column@spanning { true }{%
         \def\@tempa##1##2##3{%
           % 前開きが常に入ってしまうので，a:の時は除去する
           \jlreq@iffirsttoken{##1}{a}{\def\jlreq@spaceset{{}{##2}{##3}}}{}%
@@ -2439,7 +2399,6 @@
         }%
         \expandafter\@tempa\jlreq@spaceset
         \def\jlreq@totalformat@after{}%
-      }{%
       }%
     \fi
     \edef\jlreq@do{%
@@ -2448,6 +2407,7 @@
         \noexpand\UseHook{jlreq/heading/before}%
         \noexpand\UseHook{jlreq/heading/before/#1}%
         \expandonce{\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}}%
         {{\expandonce{\jlreq@align}}{\expandonce{\jlreq@indent}}{\expandonce{\jlreq@end@indent}}\expandonce{\jlreq@spaceset}{\expandonce{\jlreq@allowbreak@evenpage}}}%
         {\ifjlreq@number\else -\fi}%
@@ -2471,13 +2431,13 @@
   \jlreq@do
 }
 
-\newcommand{\NewBlockHeading}[3]{%
+\NewDocumentCommand{\NewBlockHeading}{ m m +m }{%
   \expandafter\@ifdefinable\csname #1\endcsname{\DeclareBlockHeading{#1}{#2}{#3}}%
 }
-\newcommand{\RenewBlockHeading}[3]{%
+\NewDocumentCommand{\RenewBlockHeading}{ m m +m }{%
   \@ifundefined{#1}{\@latex@error{\expandafter\string\csname#1\endcsname\space undefined}\@ehc}{\DeclareBlockHeading{#1}{#2}{#3}}%
 }
-\newcommand{\ProvideBlockHeading}[3]{%
+\NewDocumentCommand{\ProvideBlockHeading}{ m m +m }{%
   \@ifundefined{#1}{\DeclareBlockHeading{#1}{#2}{#3}}{}%
 }
 
@@ -2513,7 +2473,7 @@
 \def\jlreq@BlockHeading@spaces@current@sequence{}
 \def\jlreq@BlockHeading@spaces@headingslist{}
 
-\newcommand{\SetBlockHeadingSpaces}[1]{%
+\NewDocumentCommand{\SetBlockHeadingSpaces} { m } {
   \begingroup
     % 現段階の情報をクリアする
     \def\jlreq@tempa{}% 見出しリスト
@@ -2521,8 +2481,8 @@
     \jlreq@SetBlockHeadingSpaces#1\jlreq@endmark
     \edef\jlreq@do{%
       \unexpanded{%
-        \@for\@tempa:=\jlreq@BlockHeading@spaces@headingslist\do{%
-          \expandafter\let\csname jlreq@BlockHeading@spaces@setlist@\@tempa\endcsname=\@undefined
+        \clist_map_inline:Nn \jlreq@BlockHeading@spaces@headingslist {
+          \expandafter\let\csname jlreq@BlockHeading@spaces@setlist@####1\endcsname=\@undefined
         }%
       }%
       \unexpanded{\def\jlreq@BlockHeading@spaces@headingslist}{\expandonce{\jlreq@tempa}}%
@@ -2563,7 +2523,7 @@
     \fi
     \eappto\jlreq@tempb{%
       \noexpand\@ifundefined{jlreq@BlockHeading@spaces@setlist@\jlreq@headings}{}{%
-        \noexpand\ClassError{jlreq}{The spaces for \jlreq@headings\space is defined more than once (in SetBlockHeadingSpaces)}{\noexpand\@ehc}%
+        \noexpand\ClassError{jlreq}{The~spaces~for~\jlreq@headings\space is~defined~more~than~once~(in~SetBlockHeadingSpaces)}{\noexpand\@ehc}%
       }%
       \noexpand\def\expandonce{\csname jlreq@BlockHeading@spaces@setlist@\jlreq@headings\endcsname}{{\expandonce{\jlreq@totalset}}\expandonce{\jlreq@set}}%
     }%
@@ -2582,16 +2542,16 @@
     \def\jlreq@tempb{\jlreq@uniqtoken}%
     \ifx\jlreq@tempa\jlreq@tempb\def\jlreq@do{}%
     \else\def\jlreq@do{%
-      \ClassError{jlreq}{Invalid setting ``\unexpanded{#1{#2}}'' is found, You forgot `_'? (in SetBlockHeadingSpaces)}{\@ehc}%
+      \ClassError{jlreq}{Invalid~setting~``\unexpanded{#1{#2}}''~is~found,~you~forgot~`_'?~(in~SetBlockHeadingSpaces)}{\@ehc}%
     }\fi
   \expandafter\endgroup
   \jlreq@do
 }
 
 \def\jlreq@SetBlockHeadingSpaces@iii#1{%
-  \@for\@tempa:=#1\do{%
+  \clist_map_variable:nNn {#1} \@tempa {
     \expandafter\jlreq@helper@trim\expandafter{\@tempa}{\@tempa}%
-    \expandafter\jlreq@iffirsttoken@ignorespaces\expandafter{\@tempa}{_}{%
+    \str_if_eq:eeTF {\str_head:N \@tempa} {_} {
       \ifx\jlreq@lastdimen\@empty\else\eappto\jlreq@set{{\expandonce{\jlreq@lastdimen}}}\fi%
       \def\jlreq@lastdimen{}%
       \expandafter\jlreq@SetBlockHeadingSpaces@iv\@tempa{\jlreq@endmark}\jlreq@endmark
@@ -2611,14 +2571,16 @@
     \jlreq@tempafalse
   }%
 }
+
 \def\jlreq@SetBlockHeadingSpaces@iv#1#{%
-  \expandafter\jlreq@ifcontains\expandafter{\@gobble #1}{_}{%
-    \ClassWarning{jlreq}{Unusual heading name `\@gobble #1' is found. You forgot a comma? (in SetBlockHeadingSpaces)}%
-  }{}%
+  \str_set:Nx \l__jlreq_tmpa_str {\@gobble #1}
+  \str_if_in:NnT \l__jlreq_tmpa_str {_} {
+    \ClassWarning{jlreq}{Unusual~heading~name~`\@gobble #1'~is~found.~You~forgot~a~comma?~(in~SetBlockHeadingSpaces)}%
+  }%
   \jlreq@ifendswith{#1}{*}{{%
     \def\@tempa_##1*{\def\@tempa{##1}}%
     \@tempa#1%
-    \ClassWarning{jlreq}{The heading name `\@gobble #1' ends with `*'. Do you mean `_\@tempa{*}'? (in SetBlockHeadingSpaces)}%
+    \ClassWarning{jlreq}{The~heading~name~`\@gobble #1'~ends~with~`*'.~Do~you^mean~`_\@tempa{*}'?~(in~SetBlockHeadingSpaces)}%
   }}{}%
   \appto\jlreq@headings{#1}%
   \jlreq@SetBlockHeadingSpaces@v
@@ -2646,7 +2608,7 @@
     \def\@tempb##1##{\@temptokena\expandafter{\the\@temptokena##1}\@tempc}%
     \def\@tempc##1{\jlreq@ifendmark{##1}{}{\@temptokena\expandafter{\the\@temptokena{##1}}\@tempb}}%
     \@tempb#1%
-    \ClassWarningNoLine{jlreq}{Extra setting `\the\@temptokena' is found in SetBlockHeadingSpaces, omitted}
+    \ClassWarningNoLine{jlreq}{Extra~setting~`\the\@temptokena'~is~found~in~SetBlockHeadingSpaces,~omitted}
   }}%
 }
 
@@ -2689,13 +2651,12 @@
   \fi
 }
 
-\ExplSyntaxOn
 \def\jlreq@BlockHeading@spaces@output@#1#2\jlreq@endmark{%
   \def\jlreq@result{}%
   \jlreq@tempcnta=0
   \jlreq@BlockHeading@spaces@output@@#2\jlreq@endmark
   \jlreq@tempatrue % 周りの行取り処理が必要か
-  \jlreq@ifempty{#1}{\jlreq@tempafalse}{}%
+  \tl_if_empty:nT {#1} {\jlreq@tempafalse}%
   \tl_if_eq:nnT {#1} {{}{}{}} { \jlreq@tempafalse }
   \edef\jlreq@do{%
     \ifjlreq@tempa
@@ -2709,11 +2670,10 @@
   \jlreq@BlockHeading@spaces@clear
   \jlreq@do
 }
-\ExplSyntaxOff
 % jlreq@resultに出力すべきものを入れていく
 \def\jlreq@BlockHeading@spaces@output@@#1{%
   \jlreq@ifendmark{#1}{}{%
-    \jlreq@iffirsttoken@ignorespaces{#1}{_}{%
+    \str_if_eq:eeTF {\str_head:n {#1}} {_} {
       \advance\jlreq@tempcnta by 1
       \expandafter\jlreq@BlockHeading@spaces@output@@@\expandafter{\@gobble #1}%
     }{%
@@ -2808,13 +2768,11 @@
               \expandonce{\jlreq@tempa{#5}}%
               \expandonce{\csname jlreq@heading@maketoc@#1\endcsname}\unexpanded{{#3}{#6}{#4}}%
             \noexpand\endgroup
-            \unexpanded{\def\jlreq@hook@everypar{\inhibitglue}}%
+            \noexpand\inhibitglue
           \noexpand\else
             \unexpanded{\everypar{}}%
           }%
-            \ifx l\jlreq@engine
-              \unexpanded{\unexpanded{\def\jlreq@hook@everypar{}}}%
-            \else
+            \ifx l\jlreq@engine\else
               \unexpanded{\unexpanded{\let\jlreq@hook@everypar\jlreq@openbracket@hook}}%
             \fi
          \unexpanded{\noexpand\fi}%
@@ -2828,11 +2786,14 @@
 \jlreq@tempa
 
 % \DeclareRuninHeading{命令名}{レベル}{設定}
-\newcommand*{\DeclareRuninHeading}[3]{%
-  \IfHookExistsTF{jlreq/heading/before/#1}{}{\NewHook{jlreq/heading/before/#1}}%
+\NewDocumentCommand { \DeclareRuninHeading } { m m +m } {
+  \__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}}%
-  \expandafter\jlreq@do\expandafter{\jlreq@heading@allheadings}{\jlreq@heading@allheadings}%
-  \appto\jlreq@heading@allheadings{,#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}%
   \expandafter\edef\csname jlreq@heading@setting@#1\endcsname{\unexpanded{#3}}%
   \expandafter\def\csname jlreq@heading@type@#1\endcsname{\RenewRuninHeading}%
@@ -2840,124 +2801,133 @@
   \@ifundefined{#1mark}{\expandafter\let\csname #1mark\endcsname\@gobble}{}%
   \@ifundefined{l@#1}{\expandafter\def\csname l@#1\endcsname{\@dottedtocline{#2}{0\jlreq@zw}{2\jlreq@zw}}}{}%
   \jlreq@heading@make@maketoc{#1}{#2}%
-  \begingroup
-    \def\jlreq@font{\normalfont\normalsize}%
-    \def\jlreq@indent{0pt}%
-    \def\jlreq@after@label@space{1\jlreq@zw}%
+  \group_begin:
     \def\jlreq@label@font{}%
-    \def\jlreq@label@format{\@seccntformat{#1}}%
-    \def\jlreq@after@space{1\jlreq@zw}%
-    \newif\ifjlreq@number \jlreq@numbertrue
-    \jlreq@parsekeyval[RuninHeading:#1]{%
-      {font}{\def\jlreq@font{##1}}
-      {indent}{\def\jlreq@indent{##1}}
-      {label_format}{\def\jlreq@label@format{##1}}
-      {after_label_space}{%
-        \ifdim\dimexpr##1\relax<0pt \ClassWarning{jlreq}{after_label_space in Runin Heading #1 should be not negative}\fi
-        \def\jlreq@after@label@space{##1}%
-      }
-      {after_space}{%
-        \ifdim\dimexpr##1\relax<0pt \ClassWarning{jlreq}{after_space in Runin Heading #1 should be not negative}\fi
-        \def\jlreq@after@space{##1}%
-      }
-      {number}{\csname jlreq@number##1\endcsname}
-    }{#3}%
-    \newif\ifjlreq@indent@zero
-    \jlreq@ifgluezero{\glueexpr\jlreq@indent\relax}{\jlreq@indent@zerotrue}{\jlreq@indent@zerofalse}%
-    \newif\ifjlreq@after@space@zero
-    \jlreq@ifgluezero{\glueexpr\jlreq@after@space\relax}{\jlreq@after@space@zerotrue}{\jlreq@after@space@zerofalse}%
-    \newif\ifjlreq@after@label@space@zero
-    \jlreq@ifgluezero{\glueexpr\jlreq@after@label@space\relax}{\jlreq@after@label@spacefalse}%
-    \edef\jlreq@format@wlabel{{%
-      \ifjlreq@indent@zero\else\unexpanded{\hskip\glueexpr}\expandonce{\jlreq@indent}\noexpand\relax\fi
-      \expandonce{\jlreq@font}%
-      \expandonce{\jlreq@label@format}%
-      \ifjlreq@after@label@space@zero\else\unexpanded{\hskip\glueexpr}\expandonce{\jlreq@after@label@space}\noexpand\relax\fi
+    \keys_define:nn { RuninHeading:#1 } {
+      font .tl_set:N = \l__jlreq_font_tl,
+      indent .tl_set:N = \l__jlreq_indent_tl,
+      label_format .tl_set:N = \l__jlreq_label_format_tl,
+      after_label_space .tl_set:N = \l__jlreq_after_label_space_tl,
+      after_space .tl_set:N = \l__jlreq_after_space_tl,
+      number .bool_set:N = \l__jlreq_number_bool,
+    }
+    \keys_set:nn { RuninHeading:#1 } {
+      font = {\normalfont\normalsize},
+      indent = {0pt},
+      label_format = {\@seccntformat{#1}},
+      after_label_space = {1\jlreq@zw},
+      after_space = {1\jlreq@zw},
+      number = true
+    }
+    \keys_set:nn { RuninHeading:#1 } {#3}
+    \dim_compare:nT { \l__jlreq_after_space_tl < 0pt } {
+      \ClassWarning{jlreq}{after_space~in~Runin~Heading~#1~should~be~not~negative}
+    }
+    \dim_compare:nT { \l__jlreq_after_label_space_tl < 0pt } {
+      \ClassWarning{jlreq}{after_label_space~in~Runin~Heading~#1~should~be~not~negative}
+    }
+    \bool_set:Nn \l__jlreq_indent_zero_bool { \skip_if_eq_p:nn { \l__jlreq_indent_tl } { 0pt } }
+    \bool_set:Nn \l__jlreq_after_space_zero_bool { \skip_if_eq_p:nn { \l__jlreq_after_space_tl } { 0pt } }
+    \bool_set:Nn \l__jlreq_after_label_space_zero_bool { \skip_if_eq_p:nn { \l__jlreq_after_label_space_tl } { 0pt } }
+    \tl_set:Nx \l__jlreq_format_wlabel_tl {{
+      \bool_if:NF \l__jlreq_indent_zero_bool { \exp_not:N \skip_horizontal:n { \exp_not:o {\l__jlreq_indent_tl} } }
+      \exp_not:o { \l__jlreq_font_tl }
+      \exp_not:o { \l__jlreq_label_format_tl }
+      \bool_if:NF \l__jlreq_after_space_zero_bool { \exp_not:N \skip_horizontal:n { \exp_not:o {\l__jlreq_after_label_space_tl} } }
       ####1%
-      \ifjlreq@after@space@zero\else\unexpanded{\hskip\glueexpr}\expandonce{\jlreq@after@space}\noexpand\relax\fi
+      \bool_if:NF \l__jlreq_after_space_zero_bool { \exp_not:N \skip_horizontal:n { \exp_not:o {\l__jlreq_after_space_tl} } }
     }}%
-    \edef\jlreq@format@wolabel{{%
-      \ifjlreq@indent@zero\else\unexpanded{\hskip\glueexpr}\expandonce{\jlreq@indent}\noexpand\relax\fi
-      \expandonce{\jlreq@font}%
+    \tl_set:Nx \l__jlreq_format_wolabel_tl {{
+      \bool_if:NF \l__jlreq_indent_zero_bool { \exp_not:N \skip_horizontal:n { \exp_not:o {\l__jlreq_indent_tl} } }
+      \exp_not:o { \l__jlreq_font_tl }
       ####1%
-      \ifjlreq@after@space@zero\else\unexpanded{\hskip\glueexpr}\expandonce{\jlreq@after@space}\noexpand\relax\fi
+      \bool_if:NF \l__jlreq_after_space_zero_bool { \exp_not:N \skip_horizontal:n {\exp_not:o {\l__jlreq_after_space_tl} } }
     }}%
-    \jlreq@heading@make@l@{#1}{#2}{\jlreq@label@format}%
-    \edef\jlreq@do{%
-      \expandonce{\jlreq@result}%
+    \jlreq@heading@make@l@{#1}{#2}{\l__jlreq_label_format_tl}%
+    \cs_set:Nx \l__jlreq_do: {
+      \exp_not:o { \jlreq@result }
       % パラメータトークンを含むので，\edefして\unexpandedで包む
       \noexpand\edef\expandonce{\csname #1\endcsname}{%
         \noexpand\unexpanded{%
-          \noexpand\UseHook{jlreq/heading/before}%
-          \noexpand\UseHook{jlreq/heading/before/#1}%
-          \unexpanded{\jlreq@RuninHeading@start{#1}{#2}}{\ifjlreq@number\else -\fi}{\expandonce{\jlreq@label@format}}{\expandonce{\jlreq@format@wlabel}}{\expandonce{\jlreq@format@wolabel}}%
+          \exp_not:N \UseHook{jlreq/heading/before}%
+          \exp_not:N \UseHook{jlreq/heading/before/#1}
+          \exp_not:n {\jlreq@RuninHeading@start{#1}{#2}}
+            {\bool_if:NF \l__jlreq_number_bool {-}}
+            {\exp_not:o {\l__jlreq_label_format_tl}}
+            {\exp_not:o {\l__jlreq_format_wlabel_tl}}
+            {\exp_not:o {\l__jlreq_format_wolabel_tl}}
         }%
       }%
     }%
-  \expandafter\endgroup
-  \jlreq@do
+  \exp_after:wN \group_end:
+  \l__jlreq_do:
 }
-\newcommand*{\NewRuninHeading}[3]{%
+
+\NewDocumentCommand{\NewRuninHeading}{ m m +m }{
   \expandafter\@ifdefinable\csname #1\endcsname{\DeclareRuninHeading{#1}{#2}{#3}}%
 }
-\newcommand*{\RenewRuninHeading}[3]{%
+\NewDocumentCommand{\RenewRuninHeading}{ m m +m }{%
   \@ifundefined{#1}{\@latex@error{\expandafter\string\csname#1\endcsname\space undefined}\@ehc}{\DeclareRuninHeading{#1}{#2}{#3}}%
 }
-\newcommand*{\ProvideRuninHeading}[3]{%
+\NewDocumentCommand{\ProvideRuninHeading}{ m m +m }{%
   \@ifundefined{#1}{\DeclareRuninHeading{#1}{#2}{#3}}{}%
 }
 
 %.. 窓見出し
-\def\jlreq@CutinHeading@start#1#2#3#4#5#6#7{%
+\cs_set:Nn \__jlreq_CutinHeading_start:nnnnnnn {
   \if@noskipsec\leavevmode\fi
   \par
-  \jlreq@if{\ifnum\hangafter=1 \fi}{%
-    \jlreq@CutinHeading@start@{#2}{#3}{#4}{#5}{#6}{#7}%
+  \int_compare:nTF { \hangafter=1 } {
+    \__jlreq_CutinHeading_start_aux:nnnnnn{#2}{#3}{#4}{#5}{#6}{#7}%
   }{%
-    \ClassError{jlreq}{Can not use \expandafter\string\csname#1\endcsname\space here}{\@ehc}%
+    \ClassError{jlreq}{Can~not~use~\expandafter\string\csname#1\endcsname\space here}{\@ehc}%
   }%
 }
 % 1 = 書式指定，2 = インデント, 3 = 見出しと本文の間, 4 = これを越えたら二行以上，5 = これを越えたら三行以上，6 = テキスト
-\def\jlreq@CutinHeading@start@#1#2#3#4#5#6{%
+\cs_set:Nn \__jlreq_CutinHeading_start_aux:nnnnnn{%
   % 一行で処理したときの見出し長さを計測
-  \begingroup
-    \setbox\@tempboxa=\hbox{#1#6}%
-    \@tempdima=\wd\@tempboxa
-    % 何行必要かを\jlreq@CutinHeading@linecountに入れる
-    \ifdim\@tempdima>#5\def\jlreq@CutinHeading@linecount{3}%
-    \else\ifdim\@tempdima>#4\def\jlreq@CutinHeading@linecount{2}%
-    \else\def\jlreq@CutinHeading@linecount{1}\fi\fi
-    % \@tempdimaが実際の一行の長さに近い
-    \divide\@tempdima by \jlreq@CutinHeading@linecount
-    % \jlreq@resultboxに見出し部分を，\jlreq@CutinHeading@linecountに見出し自身に何行使うかを入れる
-    \ifnum\jlreq@CutinHeading@linecount=1\relax
-      \setbox\jlreq@resultbox=\vbox{\parindent=0pt\rightskip=0pt\leftskip=0pt\hbox{#1#6}}%
-      \def\jlreq@CutinHeading@linecount{2}%
-    \else
-      \jlreq@inlinenote@determinelength{#6}{#1}{}{\jlreq@CutinHeading@linecount}{\jlreq@CutinHeading@linecount}{\@tempdima}{\linewidth}%
-      \def\jlreq@CutinHeading@linecount{3}%
-    \fi
+  \group_begin:
+    \hbox_set:Nn \l_jlreq_tmpa_box {#1#6}
+    \dim_set:Nn \l_jlreq_tmpa_dim { \box_wd:N \l_jlreq_tmpa_box}
+    % 何行必要かを\l__jlreq_cutinheading_linecount_tlに入れる
+    \dim_compare:nTF { \l_jlreq_tmpa_dim > #5} {
+      \tl_set:Nn \l__jlreq_cutinheading_linecount_tl {3}
+    }{
+      \dim_compare:nTF { \l_jlreq_tmpa_dim > #4 }{
+        \tl_set:Nn \l__jlreq_cutinheading_linecount_tl {2}
+      } { \tl_set:Nn \l__jlreq_cutinheading_linecount_tl {1} } }
+    % \l_jlreq_tmpa_dimが実際の一行の長さに近い
+    \dim_set:Nn \l_jlreq_tmpa_dim { \l_jlreq_tmpa_dim / \l__jlreq_cutinheading_linecount_tl }
+    % \l_jlreq_tmpb_boxに見出し部分を，\l__jlreq_cutinheading_linecount_tlに見出し自身に何行使うかを入れる
+    \int_compare:nTF { \l__jlreq_cutinheading_linecount_tl = 1 }{
+      \vbox_set:Nn \l_jlreq_tmpb_box {\parindent=0pt\rightskip=0pt\leftskip=0pt\hbox_unpack_drop:N \l_jlreq_tmpa_box}
+      \tl_set:Nn \l__jlreq_cutinheading_linecount_tl {2}
+    }{
+      \jlreq@inlinenote@determinelength{#6}{#1}{}{\l__jlreq_cutinheading_linecount_tl}{\l__jlreq_cutinheading_linecount_tl}{\l_jlreq_tmpa_dim}{\linewidth}%
+      \box_set_eq:NN \l_jlreq_tmpb_box \jlreq@resultbox
+      \tl_set:Nn \l__jlreq_cutinheading_linecount_tl {3}
+    }
     % 普通の一行の高さ/深さに合わせて見出しのボックスを作る
-    \setbox\@tempboxa=\vtop to \dimexpr\numexpr\jlreq@CutinHeading@linecount - 1\relax\baselineskip + 1\jlreq@zh\relax{\vskip 0pt plus 1fill minus 1fill \box\jlreq@resultbox\vskip 0pt plus 1fill minus 1fill}%
+    \setbox\l_jlreq_tmpa_box =\vtop to \dimexpr\numexpr\l__jlreq_cutinheading_linecount_tl - 1\relax\baselineskip + 1\jlreq@zh\relax{\skip_vertical:n {0pt~plus~1fill~minus~1fill} \box_use_drop:N \l_jlreq_tmpb_box \skip_vertical:n {0pt~plus~1fill~minus~1fill}}%
     % 高さを通常の一行のそれにする
-    \setbox\jlreq@tempboxa=\hbox{阿}%
-    \dp\@tempboxa=\dimexpr\ht\@tempboxa + \dp\@tempboxa - \ht\jlreq@tempboxa\relax
-    \ht\@tempboxa=\ht\jlreq@tempboxa
+    \hbox_set:Nn \l_jlreq_tmpc_box {阿}
+    \box_set_dp:Nn \l_jlreq_tmpa_box { \box_ht:N \l_jlreq_tmpa_box + \box_dp:N \l_jlreq_tmpa_box - \box_ht:N \l_jlreq_tmpc_box }
+    \box_set_ht:Nn \l_jlreq_tmpa_box { \box_ht:N \l_jlreq_tmpc_box }
     \noindent
     \hspace*{#2}%
-    \copy\@tempboxa
+    \box_use:N \l_jlreq_tmpa_box
     \hspace*{#3}%
     % でかい見出しボックスの分をキャンセルする空きを入れる
-    % \baselineskip - \ht\jlreq@tempboxaはTeXが挿入するスキップの分
-    \edef\jlreq@do{%
-      \noexpand\par
-      \noexpand\vskip -\the\dimexpr\ht\@tempboxa + \dp\@tempboxa + \baselineskip - \ht\jlreq@tempboxa\relax\relax
-      \noexpand\hangindent=\the\dimexpr#2 + \wd\@tempboxa + #3\relax\relax
-      \noexpand\hangafter=-\jlreq@CutinHeading@linecount\relax
+    % \baselineskip - box_ht:N \l_jlreq_tmpc_boxはTeXが挿入するスキップの分
+    \cs_set:Nx \l__jlreq_do:{
+      \exp_not:N \par
+      \exp_not:N \skip_vertical:n {\dim_eval:n {-\box_ht:N \l_jlreq_tmpa_box - \box_dp:N \l_jlreq_tmpa_box - \baselineskip + \box_ht:N \l_jlreq_tmpc_box}}
+      \exp_not:N\hangindent= \dim_eval:n {#2 + \box_wd:N \l_jlreq_tmpa_box + #3} \exp_not:N \relax
+      \exp_not:N\hangafter=-\l__jlreq_cutinheading_linecount_tl\relax
     }%
-  \expandafter\endgroup
-  \jlreq@do
-  \prevdepth=0pt
+  \exp_after:wN \group_end:
+  \l__jlreq_do:
+  \prevdepth=0pt\relax
   % 改段落が起こっても\hang****をキープするように\parを書き換えておく（終わったら元に戻す）．
   \def\par{%
     \ifvmode\jlreq@tempatrue\else\jlreq@tempafalse\fi
@@ -2977,50 +2947,52 @@
   \ignorespaces
 }
 
-\newcommand*{\DeclareCutinHeading}[3]{%
-  \IfHookExistsTF{jlreq/heading/before/#1}{}{\NewHook{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}%
-  \begingroup
-    \def\jlreq@fontcommand{\sffamily\gtfamily\bfseries}%
-    \def\jlreq@onelinemax{6\jlreq@zw}%
-    \def\jlreq@twolinemax{20\jlreq@zw}%
-    \def\jlreq@indent{0pt}%
-    \def\jlreq@after@space{1\jlreq@zw}%
-    \jlreq@parsekeyval[CutinHeading:#1]{
-      {font}{\def\jlreq@fontcommand{##1}}
-      {onelinemax}{\def\jlreq@onelinemax{##1}}
-      {twolinemax}{\def\jlreq@twolinemax{##1}}
-      {indent}{\def\jlreq@indent{##1}}
-      {after_space}{\def\jlreq@after@space{##1}}
-    }{#3}%
-    \ifthenelse{\lengthtest{\jlreq@after@space < 0.99\jlreq@zw} \OR \lengthtest{\jlreq@after@space > 2.01\jlreq@zw}}{%
-      \jlreq@note{窓見出しと本文との空き量は，基本版面の文字サイズの全角以上，2倍未満とする (4.1.10.c)．}%
+\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}
+  \group_begin:
+    \keys_define:nn { CutinHeading:#1 } {
+      font .tl_set:N = \l__jlreq_fontcommand_tl,
+      onelinemax .tl_set:N = \l__jlreq_onelinemax_tl,
+      twolinemax .tl_set:N = \l__jlreq_twolinemax_tl,
+      indent .tl_set:N = \l__jlreq_indent_tl,% 0pt
+      after_space .tl_set:N = \l__jlreq_after_space_tl,
+    }
+    \keys_set:nn { CutinHeading:#1 } {
+      font = { \sffamily\gtfamily\bfseries },
+      onelinemax = { 6\jlreq@zw },
+      twolinemax = { 20\jlreq@zw } ,
+      indent = { 0pt },
+      after_space = { 1\jlreq@zw }
+    }
+    \keys_set:nn { CutinHeading:#1 } {#3}
+    \bool_if:nT { \dim_compare_p:n {\l__jlreq_after_space_tl < 0.99\jlreq@zw} || \dim_compare_p:n { \l__jlreq_after_space_tl > 2.01\jlreq@zw } }{
+      \jlreq@note{窓見出しと本文との空き量は，基本版面の文字サイズの全角以上，2倍未満とする~(4.1.10.c)．}%
     }{}%
-    \edef\jlreq@do{%
-      \noexpand\def\expandonce{\csname #1\endcsname}{%
-        \noexpand\UseHook{jlreq/heading/before}%
-        \noexpand\UseHook{jlreq/heading/before/#1}%
-        \noexpand\jlreq@CutinHeading@start{#1}{\expandonce{\jlreq@fontcommand}}{\expandonce{\jlreq@indent}}{\expandonce{\jlreq@after@space}}{\expandonce{\jlreq@onelinemax}}{\expandonce{\jlreq@twolinemax}}%
-      }%
-    }%
-  \expandafter\endgroup
-  \jlreq@do
+    \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 \__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}
+      }
+    }
+  \exp_after:wN \group_end:
+  \l__jlreq_do:
 }
-\newcommand*{\NewCutinHeading}[3]{%
+\NewDocumentCommand{\NewCutinHeading} { m m +m } {%
   \expandafter\@ifdefinable\csname #1\endcsname{\DeclareCutinHeading{#1}{#2}{#3}}%
 }
-\newcommand*{\RenewCutinHeading}[3]{%
+\NewDocumentCommand{\RenewCutinHeading} { m m +m } {%
   \@ifundefined{#1}{\@latex@error{\expandafter\string\csname#1\endcsname\space undefined}\@ehc}{\DeclareCutinHeading{#1}{#2}{#3}}%
 }
-\newcommand*{\ProvideCutinHeading}[3]{%
+\NewDocumentCommand{\ProvideCutinHeading} { m m +m } {%
   \@ifundefined{#1}{\DeclareCutinHeading{#1}{#2}{#3}}{}%
 }
 
-\ExplSyntaxOn
-\NewDocumentCommand{\ModifyHeading}{m m}{
-  \@ifundefined { jlreq@heading@setting@#1 } { \ClassError{jlreq}{Unknown heading: #1}{\@ehc} } {}
+\NewDocumentCommand{\ModifyHeading}{m +m}{
+  \@ifundefined { jlreq@heading@setting@#1 } { \ClassError{jlreq}{Unknown~heading:~#1}{\@ehc} } {}
   \group_begin:
     \tl_set:Nn \l_jlreq_tmpa_tl {#2}
     \str_set:Nn \l_jlreq_tmpa_str {#2}
@@ -3045,23 +3017,22 @@
   \exp_after:wN \group_end:
   \l_jlreq_do:
 }
-\ExplSyntaxOff
 % 見出し#1をマクロ#2に保存する
-\newcommand{\SaveHeading}[2]{%
-  \@ifundefined{jlreq@heading@setting@#1}{\ClassError{jlreq}{Unknown heading: #1}{\@ehc}}{}%
+\NewDocumentCommand{\SaveHeading}{ m m }{%
+  \@ifundefined{jlreq@heading@setting@#1}{\ClassError{jlreq}{Unknown~heading:~#1}{\@ehc}}{}%
   \edef#2{%
     \csexpandonce{jlreq@heading@type@#1}{\unexpanded{#1}}{\csexpandonce{jlreq@heading@level@#1}}{\csexpandonce{jlreq@heading@setting@#1}}%
   }%
 }
 
-\newcommand*{\jlreq@keepbaselineskip}[1]{%
+\def\jlreq@keepbaselineskip#1{%
   \begingroup
     \edef\jlreq@do{\unexpanded{#1}\noexpand\baselineskip=\the\baselineskip}%
   \expandafter\endgroup
   \jlreq@do
 }
 
-\newcommand*{\jlreq@HeadingType}[1]{%
+\def\jlreq@HeadingType#1{%
   \ifcsname jlreq@heading@type@#1\endcsname
     \jlreq@HeadingType@{#1}{\RenewTobiraHeading}{TobiraHeading}{%
     \jlreq@HeadingType@{#1}{\RenewBlockHeading}{BlockHeading}{%
@@ -3072,31 +3043,15 @@
     UndefinedHeading%
   \fi
 }
-\newcommand*{\jlreq@HeadingType@}[2]{%
+\def\jlreq@HeadingType@#1#2{%
   \jlreq@if{\expandafter\expandafter\expandafter\ifx\csname jlreq@heading@type@#1\endcsname#2\fi}%
 }
 
 % 全ての見出しにマクロ#1を適用する．
 \def\jlreq@heading@execmacro@toallheadings#1{%
-  \begingroup
-    \def\jlreq@do{}%
-    \ifx\jlreq@heading@allheadings\@undefined
-      \jlreq@heading@execmacro@toallheadings@{#1}{chapter,part,section,subsection,subsubsection,paragraph,subparagraph}%
-    \else
-      \def\@tempa{\jlreq@heading@execmacro@toallheadings@{#1}}%
-      \expandafter\@tempa\expandafter{\jlreq@heading@allheadings}%
-    \fi
-  \expandafter\endgroup
-  \jlreq@do
+  \seq_map_inline:Nn \l__jlreq_heading_allheadings_seq { #1{##1} }
 }
 
-\def\jlreq@heading@execmacro@toallheadings@#1#2{
-  \@for\jlreq@tempa:=#2\do{%
-    \@ifundefined{\jlreq@tempa}{}{%
-      \eappto\jlreq@do{\noexpand#1{\expandonce{\jlreq@tempa}}}%
-    }%
-  }%
-}
 \def\jlreq@clearheadingmarks#1{%
   \@ifundefined{#1mark}{}{%
     \expandafter\let\csname#1mark\endcsname=\@gobble
@@ -3120,13 +3075,13 @@
 %. 注
 % 文字サイズは6ポイントくらい（4.2.3.a）とりあえす\scriptsize
 %.. 合印（4.2.3）
-\newcommand*\jlreq@referencemark@format[1]{#1}
+\newcommand*{\jlreq@referencemark@format}[1]{#1}
 \newif\ifjlreqadjustreferencemark
 \jlreqadjustreferencemarktrue
-\ExplSyntaxOn
-\jlreq@jlreqsetup@add{reference_mark}[inline,interlinear]{
-  \def\jlreq@referencemark{#1}
-  \str_if_eq:VnTF \jlreq@referencemark { inline } {
+\keys_define:nn { jlreqsetup } {
+  reference_mark .choice:,
+  reference_mark / inline .code:n = {
+    \def\jlreq@referencemark{#1}
     \def\jlreq@notemark##1{%
       \jlreq@ifydir{%
         \hbox{}\hbox{\@textsuperscript{\normalfont\jlreq@referencemark@format{##1}}}\hbox{}%
@@ -3148,7 +3103,9 @@
       }%
       \noexpand\jlreq@if{\noexpand\ifnum 0\expandonce{\@tempa}>0~\noexpand\fi}{}{\noexpand\inhibitglue}%
     }
-  }{% reference_mark=interlinear
+  },
+  reference_mark / interlinear .code:n = {
+    \def\jlreq@referencemark{#1}
     \def\jlreq@notemark##1{{%
       \setbox\@tempboxa=\hbox{\scriptsize\jlreq@referencemark@format{##1}}%
       \@tempdima=\wd\@tempboxa
@@ -3178,7 +3135,6 @@
     \def\jlreq@hook@postnote{\jlreq@fixjfm}
   }
 }
-\ExplSyntaxOff
 % \@footnotemarkをシンプルなものにする
 \def\jlreq@setdefaultnotemark#1#2{%
   \def#1{%
@@ -3211,51 +3167,51 @@
 \jlreq@do
 
 % インデントの計算：脚注の長さが文字の整数倍になるように字下げする（4.2.5.b）
-\jlreq@jlreqsetup@add{footnote_indent}{%
-  \if@tate\else
-    \ifdim\dimexpr#1\relax=0pt \else\jlreq@note{脚注は，一般にその前に区切りのための罫線を挿入するので，字下げは行わなくてよい（4.2.5.b）．}\fi
-  \fi
-  \begingroup
-    \footnotesize
-    \jlreq@footnoteindent=\dimexpr#1\relax
-    \@tempdima=\dimexpr\textwidth - \jlreq@footnoteindent\relax
-    \@tempdimb=1\jlreq@zw
-    \divide\@tempdima\@tempdimb \multiply\@tempdima\@tempdimb
-    \edef\jlreq@do{\noexpand\jlreq@footnoteindent=\the\dimexpr\textwidth - \@tempdima\relax}%
-  \expandafter\endgroup
-  \jlreq@do
+\keys_define:nn { jlreqsetup } {
+  footnote_indent .code:n = {
+    \bool_if:nT { \legacy_if_p:n { @tate } && \dim_compare_p:n { #1 = 0pt } } {
+      \jlreq@note{脚注は，一般にその前に区切りのための罫線を挿入するので，字下げは行わなくてよい（4.2.5.b）．}
+    }
+    \begingroup
+      \footnotesize
+      \jlreq@footnoteindent=\dimexpr#1\relax
+      \@tempdima=\dimexpr\textwidth - \jlreq@footnoteindent\relax
+      \@tempdimb=1\jlreq@zw
+      \divide\@tempdima\@tempdimb \multiply\@tempdima\@tempdimb
+      \edef\jlreq@do{\noexpand\jlreq@footnoteindent=\the\dimexpr\textwidth - \@tempdima\relax}%
+    \expandafter\endgroup
+    \jlreq@do
+  }
 }
 
 \newcommand{\@makefntext}[1]{\jlreq@makefntext{#1}}
-\ExplSyntaxOn
-\jlreq@jlreqsetup@add{footnote_second_indent}{%
-  \legacy_if:nF { @tate }{
-    \bool_if:nF {
-      ( \dim_compare_p:n {  0.99\jlreq@zw < \dimexpr #1\relax } && \dim_compare_p:n { \dimexpr #1\relax < 1.01\jlreq@zw  } ) ||
-      ( \dim_compare_p:n { -1.01\jlreq@zw < \dimexpr #1\relax } && \dim_compare_p:n { \dimexpr #1\relax < -0.99\jlreq@zw } )
-    }{\jlreq@note{脚注が2行以上となった場合，脚注の2行目以下の字下げを1行目より，脚注の文字サイズの全角アキとするか，逆に，1行目の字下げを2行目より，脚注の文字サイズの全角アキとする (4.2.5.d)．}}
-  }
-  \ifdim\dimexpr #1\relax<0pt
-    \def\jlreq@makefntext{}
-  \else
-    \def\jlreq@makefntext{\addtolength{\leftskip}{\glueexpr #1\relax}}
-  \fi
-  \long\edef\jlreq@makefntext##1{\expandonce{\jlreq@makefntext}%
-    \unexpanded{%
-      \addtolength{\leftskip}{\jlreq@footnoteindent}%
-      \parindent=1\jlreq@zw
-      \noindent
-      \hskip-\glueexpr #1\relax
-      \jlreq@referencemark@format{\@thefnmark}%
-      \hskip\glueexpr 1\jlreq@zw\relax
-    }##1%
+\keys_define:nn { jlreqsetup } {
+  footnote_second_indent .code:n = {
+    \legacy_if:nF { @tate }{
+      \bool_if:nF {
+        ( \dim_compare_p:n {  0.99\jlreq@zw < #1 } && \dim_compare_p:n { #1 < 1.01\jlreq@zw  } ) ||
+        ( \dim_compare_p:n { -1.01\jlreq@zw < #1 } && \dim_compare_p:n { #1 < -0.99\jlreq@zw } )
+      }{\jlreq@note{脚注が2行以上となった場合，脚注の2行目以下の字下げを1行目より，脚注の文字サイズの全角アキとするか，逆に，1行目の字下げを2行目より，脚注の文字サイズの全角アキとする~(4.2.5.d)．}}
+    }
+    \dim_compare:nTF { #1 < 0pt } {
+      \def\jlreq@makefntext{}
+    }{
+      \def\jlreq@makefntext{\addtolength{\leftskip}{\glueexpr #1\relax}}
+    }
+    \long\edef\jlreq@makefntext##1{\expandonce{\jlreq@makefntext}%
+      \unexpanded{%
+        \addtolength{\leftskip}{\jlreq@footnoteindent}%
+        \parindent=1\jlreq@zw
+        \noindent
+        \hskip-\glueexpr #1\relax
+        \jlreq@referencemark@format{\@thefnmark}%
+        \hskip\glueexpr 1\jlreq@zw\relax
+      }##1%
+    }
   }
 }
-\ExplSyntaxOff
 
-\jlreq@jlreqsetup@add{footnotetext_indent}{
-  \ClassWarningNoLine{jlreq}{footnotetext_indent was removed}
-}
+\keys_define:nn { jlreqsetup } { footnotetext_indent .code:n = {\ClassWarningNoLine{jlreq}{footnotetext_indent~was~removed} } }
 
 \ifx l\jlreq@engine
   \fnfixbottomtrue
@@ -3300,7 +3256,6 @@
   \let\footnotetext=\jlreq@temporary@saved@footnotetext
 }
 
-\ExplSyntaxOn
 \bool_if:nTF { \legacy_if_p:n { @tate } && (\legacy_if_p:n { @twoside } || \legacy_if_p:n { @twocolumn }) }{
   % 縦組の傍注は，その見開き内に付いている合印に対応する注を，奇数ページの左端にそろえて配置する．多段組では最下段の左端にそろえて配置する．（4.2.6.a）
   % 必要ならば\footnoteを\footnotemarkと\footnotetextにわけ，\footnotetextをアウトプット時まで遅延することで実現する．
@@ -3324,7 +3279,7 @@
       \def\jlreq@footnote@delayfootnote@page{%
         \jlreq@setcurrentpage
         \jlreq@resultcnt=\numexpr\jlreq@currentpage\relax
-        \ifnum\jlreq@resultcnt=\value{page}\if@firstcolumn\else\jlreq@resultcnt=-1 \fi\fi
+        \ifnum\jlreq@resultcnt=\value{page}\if@firstcolumn\else\jlreq@resultcnt=-1~\fi\fi
       }
     \fi
     \long\def\jlreq@footnote@delayfootnote@delay#1#2{%
@@ -3374,7 +3329,7 @@
         \def\jlreq@result{}#2[#4]\jlreq@result
         \def\jlreq@result{}#3[#4]{#5}%
         \jlreq@restore@jlreq@footnotes}%
-        \jlreq@if{\ifnum\jlreq@resultcnt=-1 \fi}{\noexpand\jlreq@result}{\unexpanded{%
+        \int_compare:nTF { \jlreq@resultcnt=-1 }{\noexpand\jlreq@result}{\unexpanded{%
           \xappto\jlreq@footnote@delayfootnoteslist{%
             \noexpand\jlreq@footnote@delayfootnote{\the\jlreq@resultcnt}{%
               \noexpand\jlreq@restore@original@footnotes
@@ -3421,19 +3376,18 @@
     \jlreq@hook@postnote
   }
 }
-\ExplSyntaxOff
 
 % 合印
 \renewcommand*{\@makefnmark}{%
   \jlreq@ifydir{\jlreq@notemark{\@thefnmark}}{\hbox{\jlreq@notemark{\@thefnmark}}}%
 }
 % 4.2.2注3
-\if@tate
+\legacy_if:nTF { @tate } {
   \renewcommand*{\thefootnote}{\jlreq@open@bracket@before@space\inhibitglue（\tatechuyoko*{\@arabic\c@footnote}）\inhibitglue}
-\else
+}{
   \renewcommand*{\thefootnote}{\arabic{footnote}\hbox{}）\inhibitglue}
-\fi
-\ifthenelse{\equal{\jlreq@article@type}{article}}{}{\@addtoreset{footnote}{chapter}}
+}
+\str_if_eq:VnF \jlreq@article@type { article } { \@addtoreset{footnote}{chapter} }
 
 
 %.. 後注（4.2.4）
@@ -3522,12 +3476,16 @@
 }
 % 4.2.4.b
 \jlreq@endnote@indent=2\jlreq@mol
-\jlreq@jlreqsetup@add{endnote_second_indent}{
-  \def\jlreq@endnote@second@indent{#1}
-  \ifthenelse{
-    \( \lengthtest{0.99\jlreq@zw < #1} \AND \lengthtest{#1 < 1.01\jlreq@zw} \) \OR 
-    \( \lengthtest{1.99\jlreq@zw < #1} \AND \lengthtest{#1 < 2.01\jlreq@zw} \)
-  }{}{\jlreq@note{後注が2行以上となった場合，後注の2行目以下の字下げは，1行目より，後注の文字サイズの2倍又は全角とする (4.2.4.d)．}}
+\keys_define:nn { jlreqsetup } { 
+  endnote_second_indent .code:n = {
+    \def\jlreq@endnote@second@indent{#1}
+    \bool_if:nTF {
+      ( \dim_compare_p:n { 0.99\jlreq@zw < #1 } && \dim_compare_p:n { #1 < 1.01\jlreq@zw } ) ||
+      ( \dim_compare_p:n { 1.99\jlreq@zw < #1 } && \dim_compare_p:n { #1 < 2.01\jlreq@zw } )
+    } {} {
+      \jlreq@note{後注が2行以上となった場合，後注の2行目以下の字下げは，1行目より，後注の文字サイズの2倍又は全角とする (4.2.4.d)．}
+    }
+  }
 }
 \newcommand{\@makeendtext}[1]{%
   \csname\jlreq@endnotemarkname\endcsname
@@ -3537,48 +3495,49 @@
 \let\@makeendmark=\@makefnmark
 
 % \theendnoteの出力を仕込む
-\jlreq@jlreqsetup@add{endnote_position}{
-  \AddToHook{jlreq/heading/before}[jlreq/endnote]{}
-  \RemoveFromHook{jlreq/heading/before}[jlreq/endnote]
-  \jlreq@tempafalse % headingsが指定された
-  \jlreq@tempbfalse % paragraphが指定された
-  % \jlreq@tempcにセクション名たちを入れていく
-  \def\jlreq@tempc{}
-  \@for\jlreq@tempa:=#1\do{
-    \expandafter\jlreq@helper@trim\expandafter{\jlreq@tempa}{\jlreq@tempa}%
-    \jlreq@switch{\jlreq@tempa}{
-      {headings}{\jlreq@tempatrue}
-      {paragraph}{
-        \jlreq@tempatrue% _paragraphの時は_headingsも有効にする
-        \jlreq@tempbtrue
-      }
-      {
-        \expandafter\jlreq@iffirsttoken@ignorespaces\expandafter{\jlreq@tempa}{_}{
-          \edef\jlreq@tempc{\jlreq@tempc,\expandafter\@gobble\jlreq@tempa}
-        }{
-          \ClassError{jlreq}{Invalid value \jlreq@tempa\space in endnote_position}{\@ehc}
+\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にセクション名たちを入れていく
+    \def\jlreq@tempc{}
+    \clist_map_variable:nNn {#1} \jlreq@tempa {
+      \expandafter\jlreq@helper@trim\expandafter{\jlreq@tempa}{\jlreq@tempa}%
+      \jlreq@switch{\jlreq@tempa}{
+        {headings}{\jlreq@tempatrue}
+        {paragraph}{
+          \jlreq@tempatrue% _paragraphの時は_headingsも有効にする
+          \jlreq@tempbtrue
+        }
+        {
+          \str_if_eq:eeTF { \str_head:N \jlreq@tempa } {_} {
+            \edef\jlreq@tempc{\jlreq@tempc,\expandafter\@gobble\jlreq@tempa}
+          }{
+            \ClassError{jlreq}{Invalid~value~\jlreq@tempa\space in~endnote_position}{\@ehc}
+          }
         }
       }
     }
-  }
-  
-  \ifjlreq@tempb
-    \edef\endnote{\unexpanded{\def\par{\@restorepar\theendnotes\par}}\expandonce{\jlreq@endnote@impl}}
-  \else
-    \let\endnote=\jlreq@endnote@impl
-  \fi
+    
+    \ifjlreq@tempb
+      \edef\endnote{\unexpanded{\def\par{\@restorepar\theendnotes\par}}\expandonce{\jlreq@endnote@impl}}
+    \else
+      \let\endnote=\jlreq@endnote@impl
+    \fi
 
-  \ifjlreq@tempa
-    \AddToHook{jlreq/heading/before}[jlreq/endnote]{\theendnotes}
-  \else
-    \@for\@tempa:=\jlreq@tempc\do{
-      \ifx\@tempa\@empty\else
-        \AddToHook{jlreq/heading/before/\@tempa}[jlreq/endnote]{}
-        \RemoveFromHook{jlreq/heading/before/\@tempa}[jlreq/endnote]
-        \AddToHook{jlreq/heading/before/\@tempa}[jlreq/endnote]{\theendnotes}
-      \fi
-    }
-  \fi
+    \ifjlreq@tempa
+      \AddToHook{jlreq/heading/before}[jlreq/endnote]{\theendnotes}
+    \else
+      \clist_map_variable:NNn \jlreq@tempc \@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}
+        }
+      }
+    \fi
+  }
 }
 \AtEndDocument{\theendnotes}
 
@@ -3591,7 +3550,7 @@
 % (1) では\sidenote[]{}を定義
 % (2) では\sidenote{見出し}{注中身}を定義
 % sidenote_length>0ptの時のみ定義する
-\jlreq@if{\ifdim\jlreq@sidenote@length>0pt \fi}
+\jlreq@if{\ifdim\jlreq@sidenote@length>0pt\relax\fi}
 {
   \def\jlreq@sidenotemarkname{@thefnmark}% 合印用番号を一時的に入れるマクロ名
   \long\def\@sidenotetext#1{%
@@ -3603,10 +3562,12 @@
   }
   \jlreq@setdefaultnotemark\@sidenotemark\@makesidemark
   \def\jlreq@sidenotecounter{footnote}% 傍注用のカウンタ名
-  \jlreq@jlreqsetup@add{sidenote_type}[number,symbol]{\def\jlreq@sidenote@type{#1}}
+  \keys_define:nn { jlreqsetup } {
+    sidenote_type .choices:nn = { number, symbol } { \def\jlreq@sidenote@type{#1} }
+  }
   \def\jlreq@sidenote@type{number}
-  \jlreq@jlreqsetup@addtofinally{
-    \ifthenelse{\equal{\jlreq@sidenote@type}{number}}{
+  \__jlreq_jlreqsetup_addtofinally:n {
+    \str_if_eq:VnT \jlreq@sidenote@type { number } {
       \def\sidenote{\jlreq@hook@prenote\@ifnextchar[{\jlreq@sidenote}{\jlreq@sidenote[]}}
       \def\sidenotemark{\jlreq@hook@prenote\@ifnextchar[{\jlreq@sidenotemark}{\jlreq@sidenotemark[]}}
       \def\sidenotetext{\@ifnextchar[{\jlreq@sidenotetext}{\jlreq@sidenotetext[]}}
@@ -3643,7 +3604,8 @@
         \long\def\@makesidetext#1{　\kern-1\jlreq@zw\csname\jlreq@sidenotemarkname\endcsname\hspace{0.5\jlreq@mol}#1}
       \fi
       \let\@makesidemark=\@makefnmark
-    }{% sidenote_type = symbol
+    }
+    \str_if_eq:VnT \jlreq@sidenote@type { symbol } {% sidenote_type = symbol
       \long\def\sidenote#1#2{\jlreq@sidenote{#1}{#2}}
       \def\sidenotemark#1{\jlreq@sidenotemark{#1}}
       \long\def\sidenotetext#1#2{\jlreq@sidenotetext{#1}{#2}}
@@ -3668,20 +3630,20 @@
       \apptocmd{\sidenotemark}{\jlreq@hook@postnote}{}{}
     }
   }
-  \jlreq@jlreqsetup@add{sidenote_symbol}{\def\jlreq@sidenote@defaultmark{#1}}
-  \jlreq@jlreqsetup@add{sidenote_keyword_font}{\def\jlreq@sidenote@keywordfont{#1}}
+  \keys_define:nn { jlreqsetup } { sidenote_symbol .tl_set:N = \jlreq@sidenote@defaultmark }
+  \keys_define:nn { jlreqsetup } { sidenote_keyword_font .tl_set:N = \jlreq@sidenote@keywordfont }
 }{}
 
 %.. 割注（3.4）
 \def\inlinenotesize{.6\jlreq@jafontsize} % 割注の文字サイズ
 \let\jlreq@inlinenote@autolinebreak=\\% 計測時は\linebreakより\\の方が安定する．悩ましい……．
 
-\newcommand{\jlreq@inlinenote@kakkofontsize}{%
+\def\jlreq@inlinenote@kakkofontsize{%
   \fontsize{\dimexpr\inlinenotesize * 2\relax}{\dimexpr \inlinenotesize * 2\relax}%
   \selectfont
 }
 
-\newcommand{\jlreq@inlinenote@fontsize}{%
+\def\jlreq@inlinenote@fontsize{%
   \fontsize{\inlinenotesize}{\inlinenotesize}%
   \selectfont
 }
@@ -3691,16 +3653,20 @@
 % \inlinenote*は自動で改行されない．\\で改行位置を指定する．
 \newif\ifjlreq@in@inlinenote
 \jlreq@in@inlinenotefalse
-\newcommand*{\jlreq@inlinenote@}[1]{%
-  \ifjlreq@in@inlinenote\ClassError{jlreq}{\string#1\space can't be nested}{\@ehc}\fi
+\NewDocumentCommand{\inlinenote}{ s m } {
+  \ifjlreq@in@inlinenote\ClassError{jlreq}{\string\inlinenote\space can't~be~nested}{\@ehc}\fi
+  \jlreq@in@inlinenotetrue
+  \ifvmode\leavevmode\fi
+  \IfBooleanTF {#1} { \jlreq@inlinenote@noauto {#2} } { \jlreq@inlinenote@auto {#2} }
+}
+\NewDocumentCommand{\warichu}{ s m } {
+  \ifjlreq@in@inlinenote\ClassError{jlreq}{\string\warichu\space can't~be~nested}{\@ehc}\fi
   \jlreq@in@inlinenotetrue
   \ifvmode\leavevmode\fi
-  \@ifstar\jlreq@inlinenote@noauto\jlreq@inlinenote@auto
+  \IfBooleanTF {#1} { \jlreq@inlinenote@noauto {#2} } { \jlreq@inlinenote@auto {#2} }
 }
-\DeclareRobustCommand*{\inlinenote}{\jlreq@inlinenote@{\inlinenote}}
-\DeclareRobustCommand*{\warichu}{\jlreq@inlinenote@{\warichu}}
 
-\newcommand*{\jlreq@inlinenote@auto}[1]{%
+\def\jlreq@inlinenote@auto#1{%
   % 割注初め括弧の前の場所を保存
   \jlreq@savepos@for@rest@linewidth
   % \jlreq@tempdimbに，現在行の残り長さを入れる
@@ -3730,10 +3696,10 @@
   \fi
   % \jlreq@parshapeargに\parshapeに指定する書式の最後以外を入れる．
   \ifnum\@tempcntb>2\relax
-    \edef\jlreq@parshapearg{0pt \the\jlreq@tempdimb\space 0pt \the\jlreq@tempdimb}%
+    \edef\jlreq@parshapearg{0pt~\the\jlreq@tempdimb\space 0pt~\the\jlreq@tempdimb}%
     \@tempcnta=4\relax
     \@whilenum\@tempcnta<\@tempcntb\do{%
-      \edef\jlreq@parshapearg{\jlreq@parshapearg\space 0pt \the\linewidth\space 0pt \the\linewidth}%
+      \edef\jlreq@parshapearg{\jlreq@parshapearg\space 0pt~\the\linewidth\space 0pt~\the\linewidth}%
       \advance\@tempcnta by 2\relax
     }%
     \setlength{\jlreq@tempdimc}{\dimexpr\jlreq@tempdimc - \jlreq@tempdimb - \linewidth * \numexpr(\@tempcntb - 4)/2\relax\relax}%
@@ -3755,10 +3721,10 @@
       \@tempcntb=1001\relax
     \fi
     \advance\@tempcntb by 2\relax
-    \edef\jlreq@parshapearg{\jlreq@parshapearg 0pt \the\jlreq@tempdimb 0pt \the\jlreq@tempdimb}%
+    \edef\jlreq@parshapearg{\jlreq@parshapearg~0pt~\the\jlreq@tempdimb~0pt~\the\jlreq@tempdimb}%
   }%
   \ifvoid\jlreq@resultbox
-    \ClassWarning{jlreq}{\string\warichu\space failed, may be a bug}%
+    \ClassWarning{jlreq}{\string\warichu\space failed,~may~be~a~bug}%
   \else
     \@tempcnta=0
     \splittopskip=0pt\relax
@@ -3769,7 +3735,7 @@
     \addtolength{\jlreq@tempdimb}{-\wd\@tempboxa}%
     \setbox\@tempboxa=\box\jlreq@resultbox
     \@whilenum\@tempcnta<\jlreq@inlinenote@lines\do{%
-      \ifnum\@tempcnta>0 \jlreq@inlinenote@autolinebreak\fi
+      \int_compare:nT { \@tempcnta > 0 } { \jlreq@inlinenote@autolinebreak }
       % \jlreq@tempdimaに今の行の長さを入れる
       \ifnum\@tempcnta<\numexpr\jlreq@inlinenote@lines - 2\relax
         \ifnum\@tempcnta=0\jlreq@tempdima=\jlreq@tempdimb
@@ -3804,7 +3770,7 @@
   \jlreq@inlinenote@endnote
 }
 
-\newcommand*{\jlreq@inlinenote@noauto}[1]{%
+\def\jlreq@inlinenote@noauto#1{%
   \setbox\jlreq@tempboxa=\hbox{\jlreq@inlinenote@kakkofontsize\inhibitglue\jlreq@open@bracket@before@space（}%
   \inhibitglue\jlreq@box@putcenter\jlreq@tempboxa
   \jlreq@inlinenote@noauto@#1\\\jlreq@endmark\jlreq@endmark
@@ -3840,7 +3806,7 @@
   \jlreq@box@putcenter\@tempboxa
 }
 
-\newcommand{\jlreq@inlinenote@endnote}{%
+\def\jlreq@inlinenote@endnote{%
   \jlreq@in@inlinenotefalse
   {%
     \setbox\jlreq@tempboxa=\hbox{\jlreq@inlinenote@kakkofontsize）}%
@@ -3856,14 +3822,14 @@
 % * それ以降はX
 % として整形した際に，#5行以内に収まる．
 % \jlreq@resultboxに整形結果を返す（垂直ボックス）．見つからなかったらvoid．\globalに設定する．
-\newcommand{\jlreq@inlinenote@determinelength}[7]{%
+\def\jlreq@inlinenote@determinelength#1#2#3#4#5#6#7{%
   \begingroup
   %  \message{#1 の試行開始，行数 = #5, \the\dimexpr#6\relax から \the\dimexpr#7\relaxまで}%
     \@tempcnta=1\relax
     \def\@tempa{}%
     % 調整に使う行の\parshape指定を\@tempaに入れる．長さは\jlreq@tempdima．
     \@whilenum\@tempcnta<#4\do{%
-      \expandafter\def\expandafter\@tempa\expandafter{\@tempa 0pt \the\jlreq@tempdima}%
+      \expandafter\def\expandafter\@tempa\expandafter{\@tempa 0pt~\the\jlreq@tempdima}%
       \advance\@tempcnta by 1\relax
     }%
     \@tempcnta=0
@@ -3877,7 +3843,7 @@
         \setbox\@tempboxa=\vbox{#2%
           \vbadness=10000\hbadness=10000\vfuzz=\maxdimen\hfuzz=\maxdimen
           \parindent=0pt\leftskip=0pt\rightskip=0pt
-          \parshape #5 #3 \@tempa 0pt \the\maxdimen
+          \parshape #5~#3~\@tempa 0pt~\the\maxdimen
           #1\par\global\@tempcntb=\prevgraf}%
   %      \message{\string\jlreq@tempdima = \the\jlreq@tempdima で試行，行数は\the\@tempcntb , 書式 #5 #3 \@tempa 0pt \the\maxdimen}%
       \fi
@@ -3918,24 +3884,27 @@
 % 2.6.1.cの後半が前半と整合的でないように見える……
 % 柱：両柱と片柱（2.6.3）
 \@tempdima=\jlreq@speciallength{\jlreq@headfoot@sidemargin}
-\ifthenelse{\lengthtest{\@tempdima=0pt} \OR \(\lengthtest{0.99\zw < \@tempdima} \AND \lengthtest{\@tempdima < 1.01\zw}\)}{}{
+\bool_if:nTF {
+  \dim_compare_p:n { \@tempdima = 0pt } ||
+  ( \dim_compare_p:n { 0.99\jlreq@zw < \@tempdima } && \dim_compare_p:n { \@tempdima < 1.01\jlreq@zw} )
+} {} {
   \jlreq@note{ノンブルまたは柱は，基本版面の左右にそろえるか，全角アキだけ寄せた位置に配置する (2.6.1.b)．}
 }
 
 %.. 場所指定解析
 % bottom-leftみたいなのを解釈する．入力の順番はどっちでも良いが，出力は<top/bottom><left/right>の順番
 % #1 = bottom-leftみたいなのを{bottom}{left}に変換し，#2に代入，#3はデフォルト値，出力形式で入れる
-\newcommand*{\jlreq@pagestyle@parse@position}[3]{%
+\def\jlreq@pagestyle@parse@position#1#2#3{%
   \jlreq@ifempty{#1}{\def#2{#3}}%
   {%
     \begingroup
       \jlreq@pagestyle@parse@position@#1-\jlreq@endmark
-      \ifthenelse{\equal{\jlreq@tempa}{fore}}{%
+      \str_if_eq:VnTF \jlreq@tempa { fore } {
         \expandafter\jlreq@pagestyle@parse@position@\jlreq@tempb-\jlreq@endmark
-        \ifthenelse{\equal{\jlreq@tempa}{edge}}{%
+        \str_if_eq:VnTF \jlreq@tempa { edge } {
           \def\jlreq@tempa{fore-edge}%
         }{%
-          \ClassError{jlreq}{Invalid position: fore-\jlreq@tempa}{\@ehc}%
+          \ClassError{jlreq}{Invalid~position:~fore-\jlreq@tempa}{\@ehc}%
         }%
       }{}%
       % \jlreq@tempcに縦方向を，\jlreq@tempdに横方向を入れる
@@ -3953,14 +3922,14 @@
 \def\jlreq@pagestyle@parse@position@#1-#2\jlreq@endmark{%
   \def\jlreq@tempa{#1}\def\jlreq@tempb{#2}%
   \jlreq@ifempty{#2}{%
-    \ifx\jlreq@tempb\@empty\ClassError{jlreq}{Invalid position: #1}{\@ehc}\fi
+    \ifx\jlreq@tempb\@empty\ClassError{jlreq}{Invalid~position:~#1}{\@ehc}\fi
   }{%
     \def\@tempa##1-\jlreq@endmark{\def\jlreq@tempb{##1}}%
     \@tempa#2\jlreq@endmark\relax
   }%
 }
 
-\newcommand*\jlreq@pagestyle@parse@position@@[1]{%
+\def\jlreq@pagestyle@parse@position@@#1{%
   \jlreq@switch{#1}{
     {top}{\def\jlreq@tempc{#1}}
     {bottom}{\def\jlreq@tempc{#1}}
@@ -3970,16 +3939,16 @@
     {gutter}{\if@tate\def\jlreq@tempd{right}\else\def\jlreq@tempd{left}\fi}
     {fore_edge}{\if@tate\def\jlreq@tempd{left}\else\def\jlreq@tempd{right}\fi}
     {fore-edge}{\if@tate\def\jlreq@tempd{left}\else\def\jlreq@tempd{right}\fi}
-    {\ClassError{jlreq}{Invalid position: #1}{\@ehc}}
+    {\ClassError{jlreq}{Invalid~position:~#1}{\@ehc}}
   }%
 }
 
 % レベル#1より低いレベルの見出しの**markを\markboth{}{}にする
 \def\jlreq@pagestyle@setclearmark#1{%
-  \@for\@tempa:=\jlreq@heading@allheadings\do{%
-    \@ifundefined{\@tempa}{}{%
-      \@ifundefined{jlreq@heading@level@\@tempa}{}{%
-        \ifnum\csname jlreq@heading@level@\@tempa\endcsname<#1\relax\expandafter\def\csname\@tempa mark\endcsname##1{\markboth{}{}}\fi
+  \seq_map_inline:Nn \l__jlreq_heading_allheadings_seq {
+    \@ifundefined{##1}{}{%
+      \@ifundefined{jlreq@heading@level@##1}{}{%
+        \ifnum\csname jlreq@heading@level@##1\endcsname<#1\relax\expandafter\def\csname##1 mark\endcsname####1{\markboth{}{}}\fi
       }%
     }%
   }%
@@ -4034,14 +4003,14 @@
 % #1@heading@levelにレベルを入れる
 \def\jlreq@pagestyle@setmark#1#2#3#4#5{%
   \begingroup
-    \expandafter\jlreq@iffirsttoken\expandafter{#1}{_}{%
-      \ifthenelse{\equal{#3}{odd}}{\let\jlreq@leftright=r}{\let\jlreq@leftright=l}%
+    \str_if_eq:eeTF {\str_head:N #1} {_} {
+      \str_if_eq:nnTF {#3} { odd } { \let\jlreq@leftright=r } { \let\jlreq@leftright=l }
       \edef\jlreq@do{%
         \unexpanded{\def#1}{%
           \ifx l\jlreq@leftright
-            \ifnum#2=0 \noexpand\leftmark\else\unexpanded{\jlreq@extraleftmark{#2}}\fi
+            \int_compare:nTF { #2 = 0 } { \exp_not:N \leftmark } { \exp_not:n {\jlreq@extraleftmark{#2}} }
           \else
-            \ifnum#2=0 \noexpand\rightmark\else\unexpanded{\jlreq@extrarightmark{#2}}\fi
+            \int_compare:nTF { #2 = 0 } { \exp_not:N \rightmark } { \exp_not:n {\jlreq@extrarightmark{#2}} }
           \fi
         }%
       }%
@@ -4052,7 +4021,7 @@
       \eappto\jlreq@do{%
         \noexpand\let\expandonce{\csname\expandafter\@gobble\string #1@heading@level\endcsname}=\expandonce{\csname jlreq@heading@level@\jlreq@headingname\endcsname}%
         \unexpanded{\def#5}{\expandonce{#5},\expandonce{\jlreq@headingname}}%
-        \noexpand\appto\expandonce{\csname #4@\jlreq@headingname\endcsname}{{{\ifnum#2=0 #3\fi}{#2}{\ifx r\jlreq@leftright r\else l\fi}}}%
+        \noexpand\appto\expandonce{\csname #4@\jlreq@headingname\endcsname}{{{\int_compare:nT {#2=0} {#3}}{#2}{\ifx r\jlreq@leftright r\else l\fi}}}%
       }%
     }{\def\jlreq@do{}}%
   \expandafter\endgroup
@@ -4065,7 +4034,7 @@
 % #4: {{mark_formatからさらに調べるやつ (odd|even)}{マークの何番目か．extraでない場合は0}{l or r(leftかrightか)}}の並び
 \def\jlreq@pagestyle@make@headingmark#1#2#3#4{%
   \begingroup
-    \@for\jlreq@i:=0,1,2\do{%
+    \clist_map_variable:nNn {0,1,2} \jlreq@i {
       \expandafter\def\csname jlreq@leftmark@\jlreq@i\endcsname{}%
       \expandafter\def\csname jlreq@rightmark@\jlreq@i\endcsname{}%
     }%
@@ -4079,7 +4048,7 @@
     \else
       \eappto\jlreq@do{\jlreq@ifempty{#1}{\noexpand\markboth}{\noexpand\jlreq@markboth}{\csexpandonce{jlreq@leftmark@0}}{\csexpandonce{jlreq@rightmark@0}}}%
     \fi
-    \@for\jlreq@i:=1,2\do{%
+    \clist_map_variable:nNn {1,2} \jlreq@i {
       \expandafter\ifx\csname jlreq@leftmark@\jlreq@i\endcsname\@empty
         \expandafter\ifx\csname jlreq@rightmark@\jlreq@i\endcsname\@empty\else
           \eappto\jlreq@do{\noexpand\jlreq@setextrarightmark{\jlreq@i}{\csexpandonce{jlreq@rightmark@\jlreq@i}}}%
@@ -4115,8 +4084,8 @@
     \unexpanded{##1}%
   }%
   \jlreq@parsekeyval@nokey{%
-    \jlreq@ifempty{##1}{}{\ifthenelse{\equal{##1}{#3}}{\edef\jlreq@tempb{\unexpanded{##2}}}{}}%
-    \ifthenelse{\equal{##1}{_#1}}{\edef\jlreq@tempb{\unexpanded{##2}}}{}%
+    \tl_if_empty:nF {##1} {\str_if_eq:nnT {##1} {#3} {\edef\jlreq@tempb{\unexpanded{##2}}}}
+    \str_if_eq:nnT {##1} {_#1} {\edef\jlreq@tempb{\unexpanded{##2}}}%
   }{#2}%
   \ifx l#5%
     \expandafter\edef\csname jlreq@leftmark@#4\endcsname{\expandonce{\jlreq@tempb}}%
@@ -4136,8 +4105,7 @@
 
 % \edef内だと，#1 != 0ptならば\hskip \dimexpr#1\relaxになる
 \def\jlreq@pagestyle@hskip#1{%
-  \ifdim\dimexpr#1\relax=0pt \expandafter\@gobble\else\expandafter\@firstofone\fi
-    {\noexpand\hskip\noexpand\dimexpr#1\noexpand\relax}%
+  \dim_compare:nF { #1 = 0pt }{\noexpand\hskip\noexpand\dimexpr#1\noexpand\relax}%
 }
 \def\jlreq@pagestyle@setheadfoot@#1#2#3#4{%
   \begingroup
@@ -4202,7 +4170,7 @@
   }%
 }
 \def\jlreq@pagestyle@make@runninghead@#1#2#3#4#5{%
-  \jlreq@if{\ifnum\numexpr\jlreq@ifendmark{#5}{1}{0}*\ifjlreq@tempa 1\else 0\fi\relax=1 \fi}{%
+  \jlreq@if{\ifnum\numexpr\jlreq@ifendmark{#5}{1}{0}*\ifjlreq@tempa 1\else 0\fi\relax=1~\fi}{%
     % 項目が一つしか無い
     \jlreq@ifempty{#2}{\csappto}{\cspreto}{#1}{#4}%
   }{%
@@ -4259,89 +4227,79 @@
 
 %.. \DeclarePageStyle
 \newbox\jlreq@PageStyle@box
-\newcommand{\DeclarePageStyle}[2]{%
+\NewDocumentCommand{\DeclarePageStyle} { m +m } {%
   \expandafter\edef\csname jlreq@pagestyle@setting@#1\endcsname{\unexpanded{#2}}%
   \begingroup
-    \def\jlreq@nombre@i@position{}%
-    \def\jlreq@nombre@i{\thepage}%
-    \def\jlreq@running@head@i@position{}%
-    \def\jlreq@odd@running@head@i{}%
-    \def\jlreq@even@running@head@i{}%
-    \def\jlreq@command{}%
-    \def\jlreq@mark@format{}%
-    \def\jlreq@font{}%
-    \def\jlreq@nombre@font{}%
-    \def\jlreq@running@head@font{}%
     % フォーマットを空という可能性もあるかもしれないので，デフォルト値は\relaxで表す．
     \let\jlreq@oddheadformat\relax
     \let\jlreq@evenheadformat\relax
     \let\jlreq@oddfootformat\relax
     \let\jlreq@evenfootformat\relax
     % 柱とノンブルの間
-    \def\jlreq@gap{1.5\jlreq@zw}%
-    \def\jlreq@nombre@gap{}%
-    \def\jlreq@running@head@gap{}%
-    \newif\ifjlreq@clearmarkcommand\jlreq@clearmarkcommandtrue
-    \newif\ifjlreq@pstate\jlreq@pstatefalse % PageStyleTATE
-    \@for\jlreq@i:=ii,iii\do{%
-      \expandafter\def\csname jlreq@nombre@\jlreq@i @position\endcsname{}%
-      \expandafter\def\csname jlreq@running@head@\jlreq@i @position\endcsname{}%
-      \expandafter\def\csname jlreq@nombre@\jlreq@i\endcsname{}%
-      \expandafter\def\csname jlreq@odd@running@head@\jlreq@i\endcsname{}%
-      \expandafter\def\csname jlreq@even@running@head@\jlreq@i\endcsname{}%
-      \expandafter\def\csname jlreq@nombre@\jlreq@i @font\endcsname{}%
-      \expandafter\def\csname jlreq@running@head@\jlreq@i @font\endcsname{}%
-    }%
-    \jlreq@parsekeyval[PageStyle:#1]{
-      *{tate}{\jlreq@pstatetrue}
-      *{yoko}{\jlreq@pstatefalse}
-      {nombre}{\def\jlreq@nombre@i{##1}}
-      {nombre_position}{\def\jlreq@nombre@i@position{##1}}
-      {running_head_position}{\def\jlreq@running@head@i@position{##1}}
-      {odd_running_head}{\def\jlreq@odd@running@head@i{##1}}
-      {even_running_head}{\def\jlreq@even@running@head@i{##1}}
-      {font}{%
+    \newif\ifjlreq@clearmarkcommand
+    \newif\ifjlreq@pstate % PageStyleTATE
+    \keys_define:nn { PageStyle:#1 } {
+      tate .code:n = {\jlreq@pstatetrue},
+      yoko .code:n = {\jlreq@pstatefalse},
+      nombre .tl_set:N = \jlreq@nombre@i,
+      nombre_position .tl_set:N = \jlreq@nombre@i@position,
+      running_head_position .tl_set:N = \jlreq@running@head@i@position,
+      odd_running_head .tl_set:N = \jlreq@odd@running@head@i,
+      even_running_head .tl_set:N = \jlreq@even@running@head@i,
+      font .code:n = {
         \def\jlreq@nombre@font{##1}%
         \def\jlreq@running@head@font{##1}%
-      }
-      {nombre_font}{\def\jlreq@nombre@font{##1}}
-      {running_head_font}{\def\jlreq@running@head@font{##1}}
-      {mark_format}{\edef\jlreq@mark@format{\unexpanded{##1}}}
-      {command}{\edef\jlreq@command{\unexpanded{##1}}}
-      {gap}{\def\jlreq@gap{##1}}
-      {nombre_gap}{\def\jlreq@nombre@gap{##1}}
-      {running_head_gap}{\def\jlreq@running@head@gap{##1}}
+      },
+      nombre_font .tl_set:N = \jlreq@nombre@font,
+      running_head_font .tl_set:N = \jlreq@running@head@font,
+      mark_format .code:n = {\edef\jlreq@mark@format{\unexpanded{##1}}},
+      command .code:n = {\edef\jlreq@command{\unexpanded{##1}}},
+      gap .tl_set:N = \jlreq@gap,
+      nombre_gap .tl_set:N = \jlreq@nombre@gap,
+      running_head_gap .tl_set:N = \jlreq@running@head@gap,
       % trueにすると，\ps@***実行時にまず\***markを全て\@gobbleにする．
-      {clear_markcommand}[true,false]{\csname jlreq@clearmarkcommand##1\endcsname}
-      {odd_head_format}{\edef\jlreq@oddheadformat{\unexpanded{##1}}}
-      {even_head_format}{\edef\jlreq@evenheadformat{\unexpanded{##1}}}
-      {odd_foot_format}{\edef\jlreq@oddfootformat{\unexpanded{##1}}}
-      {even_foot_format}{\edef\jlreq@evenfootformat{\unexpanded{##1}}}
+      clear_markcommand .choices:nn = {true,false}{\csname jlreq@clearmarkcommand##1\endcsname},
+      odd_head_format .code:n = {\edef\jlreq@oddheadformat{\unexpanded{##1}}},
+      even_head_format .code:n = {\edef\jlreq@evenheadformat{\unexpanded{##1}}},
+      odd_foot_format .code:n = {\edef\jlreq@oddfootformat{\unexpanded{##1}}},
+      even_foot_format .code:n = {\edef\jlreq@evenfootformat{\unexpanded{##1}}},
       % 二つ目
-      {nombre_ii}{\def\jlreq@nombre@ii{##1}}
-      {nombre_ii_position}{\def\jlreq@nombre@ii@position{##1}}
-      {running_head_ii_position}{\def\jlreq@running@head@ii@position{##1}}
-      {odd_running_head_ii}{\def\jlreq@odd@running@head@ii{##1}}
-      {even_running_head_ii}{\def\jlreq@even@running@head@ii{##1}}
-      {nombre_ii_font}{\def\jlreq@nombre@ii@font{##1}}
-      {running_head_ii_font}{\def\jlreq@running@head@ii@font{##1}}
+      nombre_ii .tl_set:N = \jlreq@nombre@ii,
+      nombre_ii_position .tl_set:N = \jlreq@nombre@ii@position,
+      running_head_ii_position .tl_set:N = \jlreq@running@head@ii@position,
+      odd_running_head_ii .tl_set:N = \jlreq@odd@running@head@ii,
+      even_running_head_ii .tl_set:N = \jlreq@even@running@head@ii,
+      nombre_ii_font .tl_set:N = \jlreq@nombre@ii@font,
+      running_head_ii_font .tl_set:N = \jlreq@running@head@ii@font,
       % 三つ目
-      {nombre_iii}{\def\jlreq@nombre@iii{##1}}
-      {nombre_iii_position}{\def\jlreq@nombre@iii@position{##1}}
-      {running_head_iii_position}{\def\jlreq@running@head@iii@position{##1}}
-      {odd_running_head_iii}{\def\jlreq@odd@running@head@iii{##1}}
-      {even_running_head_iii}{\def\jlreq@even@running@head@iii{##1}}
-      {nombre_iii_font}{\def\jlreq@nombre@iii@font{##1}}
-      {running_head_iii_font}{\def\jlreq@running@head@iii@font{##1}}
-    }{#2}%
+      nombre_iii .tl_set:N = \jlreq@nombre@iii,
+      nombre_iii_position .tl_set:N = \jlreq@nombre@iii@position,
+      running_head_iii_position .tl_set:N = \jlreq@running@head@iii@position,
+      odd_running_head_iii .tl_set:N = \jlreq@odd@running@head@iii,
+      even_running_head_iii .tl_set:N = \jlreq@even@running@head@iii,
+      nombre_iii_font .tl_set:N = \jlreq@nombre@iii@font,
+      running_head_iii_font .tl_set:N = \jlreq@running@head@iii@font
+    }
+    \keys_set:nn { PageStyle:#1 } {
+      yoko,
+      nombre_font = {}, nombre_position = {}, nombre = {\thepage},
+      nombre_ii_font = {}, nombre_ii_position = {}, nombre_ii = {},
+      nombre_iii_font = {}, nombre_iii_position = {}, nombre_iii = {},
+      running_head_font = {}, running_head_position = {}, odd_running_head = {}, even_running_head = {}, 
+      running_head_ii_font = {}, running_head_ii_position = {}, odd_running_head_ii = {}, even_running_head_ii = {}, 
+      running_head_iii_font = {}, running_head_iii_position = {}, odd_running_head_iii = {}, even_running_head_iii = {}, 
+      command = {}, mark_format = {}, gap = {1.5\jlreq@zw}, nombre_gap = {}, running_head_gap = {},
+      clear_markcommand = {true}, 
+    }
+    \keys_set:nn { PageStyle:#1 } {#2}
     % ノンブル同士の間や柱同士の間のデフォルトはノンブルと柱の間の空き量
     \ifx\jlreq@nombre@gap\@empty\let\jlreq@nombre@gap=\jlreq@gap\fi
     \ifx\jlreq@running@head@gap\@empty\let\jlreq@running@head@gap=\jlreq@gap\fi
     % _iiが存在するか調べて\ifjlreq@headii@existに入れる
     \newif\ifjlreq@headii@exist
     \jlreq@headii@existfalse
-    \jlreq@for@noexpand\jlreq@tempa:=\jlreq@odd@running@head@ii,\jlreq@odd@running@head@ii\do{%
-      \expandafter\ifx\jlreq@tempa\@empty\else\jlreq@headii@existtrue\fi
+    \clist_map_inline:nn { \jlreq@odd@running@head@ii, \jlreq@odd@running@head@ii } {
+      \tl_if_empty:VF ##1 { \jlreq@headii@existtrue }
     }%
     % markの処理
     % (odd|even)_running_head(_ii)が_<見出し命令>で与えられている場合，次のようにする．
@@ -4356,8 +4314,8 @@
     % * \jlreq@(odd|even)@running@head(@ii)@heading@levelに<見出し命令>のレベルを入れる．レベルが不明な時は\relaxになる．
     % また，\jlreq@headingmarklistに<見出し命令>の一覧を入れる．
     \def\jlreq@headingmarklist{}%
-    \@for\jlreq@parity:=odd,even\do{%
-      \@for\jlreq@i:=0,1,2\do{%
+    \clist_map_variable:nNn { odd, even } \jlreq@parity {
+      \clist_map_variable:nNn { 0, 1, 2 } \jlreq@i {
         % \jlreq@pagestyle@setmarkが上の処理を行う．
         \edef\jlreq@next{\noexpand\jlreq@pagestyle@setmark{\expandonce{\csname jlreq@\jlreq@parity @running@head@\@roman\numexpr\jlreq@i + 1\relax\endcsname}}{\expandonce{\jlreq@i}}{\expandonce{\jlreq@parity}}{jlreq@markdata}{\noexpand\jlreq@headingmarklist}}%
         \jlreq@next
@@ -4366,7 +4324,7 @@
     % \jlreq@minimumlevelに見出しの最低（数値が小さいという意味）レベルを入れる．
     \let\jlreq@minimumlevel=\@undefined
     \def\jlreq@markdefinecommand{}%
-    \@for\jlreq@heading:=\jlreq@headingmarklist\do{%
+    \exp_args:No \clist_map_variable:nNn \jlreq@headingmarklist \jlreq@heading {
       \ifx\jlreq@heading\@empty\else
         \expandafter\let\expandafter\jlreq@level\csname jlreq@heading@level@\jlreq@heading\endcsname
         \ifx\jlreq@level\relax\else
@@ -4389,8 +4347,8 @@
       \fi
     }}%
     % 二番目以降にフォント設定を追加
-    \@for\jlreq@i:=ii,iii\do{%
-      \@for\jlreq@parity:=odd,even\do{%
+    \clist_map_variable:nNn { ii, iii } \jlreq@i {
+      \clist_map_variable:nNn { odd, even } \jlreq@parity {
         \jlreq@pagestyle@addfont@tocs{jlreq@\jlreq@parity @running@head@\jlreq@i}{jlreq@running@head@\jlreq@i @font}%
       }%
       \jlreq@pagestyle@addfont@tocs{jlreq@nombre@\jlreq@i}{jlreq@nombre@\jlreq@i @font}%
@@ -4410,7 +4368,7 @@
       \jlreq@pagestyle@addifempty{\jlreq@running@head@iii@position}{\jlreq@even@running@head@ii}{\jlreq@gapcs}{\jlreq@even@running@head@iii}%
       \jlreq@pagestyle@addifempty{\jlreq@running@head@ii@position}{\jlreq@even@running@head@i}{\jlreq@gapcs}{\jlreq@even@running@head@ii}%
       \def\jlreq@nombre@contents{}% ノンブルを入れる（下の方に出力）
-      \@for\jlreq@i:=i,ii,iii\do{%
+      \clist_map_variable:nNn { i, ii, iii } \jlreq@i {
         \expandafter\let\expandafter\jlreq@position\csname jlreq@nombre@\jlreq@i @position\endcsname
         \expandafter\ifx\csname jlreq@nombre@\jlreq@i\endcsname\@empty\else
           \jlreq@ifgluezero{\glueexpr\jlreq@position\relax}{\def\jlreq@position{}}{}%
@@ -4425,9 +4383,9 @@
         \fi
       }%
       % \jlreq@(odd|even)@contentsに柱を入れる（上の方に出力）
-      \@for\jlreq@parity:=odd,even\do{%
+      \clist_map_variable:nNn { odd, even } \jlreq@parity {
         \expandafter\def\csname jlreq@\jlreq@parity @contents\endcsname{}%
-        \@for\jlreq@i:=i,ii,iii\do{%
+        \clist_map_variable:nNn { i, ii, iii } \jlreq@i {
           \expandafter\let\expandafter\jlreq@position\csname jlreq@running@head@\jlreq@i @position\endcsname
           \expandafter\ifx\csname jlreq@\jlreq@parity @running@head@\jlreq@i\endcsname\@empty\else
             \jlreq@ifgluezero{\glueexpr\jlreq@position\relax}{\def\jlreq@position{}}{}%
@@ -4489,41 +4447,50 @@
       \def\jlreq@nombre@i@position@default{{bottom}{center}}%
       \def\jlreq@running@head@i@position@default{{top}{center}}%
       % ii以降の位置は指定されていない場合はiのそれに合わせる
-      \@for\jlreq@tempa:=jlreq@nombre,jlreq@running@head\do{%
-        \@for\jlreq@i:=ii,iii\do{%
+      \clist_map_variable:nNn { jlreq@nombre, jlreq@running@head } \jlreq@tempa {
+        \clist_map_variable:nNn { ii, iii } \jlreq@i {
           \expandafter\ifx\csname\jlreq@tempa @\jlreq@i @position\endcsname\@empty
             \expandafter\let\csname\jlreq@tempa @\jlreq@i @position\expandafter\endcsname\csname\jlreq@tempa @i@position\endcsname
           \fi
           \expandafter\edef\csname\jlreq@tempa @\jlreq@i @position@default\endcsname{\csname\jlreq@tempa @i@position@default\endcsname}%
         }%
       }%
-      \@for\jlreq@tempa:=jlreq@nombre@i@position,jlreq@nombre@ii@position,jlreq@nombre@iii@position,jlreq@running@head@i@position,jlreq@running@head@ii@position,jlreq@running@head@iii@position\do{%
+      \clist_map_variable:nNn {
+        jlreq@nombre@i@position, jlreq@nombre@ii@position, jlreq@nombre@iii@position, jlreq@running@head@i@position, jlreq@running@head@ii@position, jlreq@running@head@iii@position
+      } \jlreq@tempa {
         \edef\jlreq@next{\noexpand\jlreq@pagestyle@parse@position{\csexpandonce{\jlreq@tempa}}{\expandonce{\csname\jlreq@tempa\endcsname}}{\csexpandonce{\jlreq@tempa @default}}}%
         \jlreq@next
       }%
-      \ifthenelse{\(
-        \boolean{@tate} \AND \(
-          \equal{\expandafter\@secondoftwo\jlreq@nombre@i@position}{right} \OR
-          \equal{\expandafter\@secondoftwo\jlreq@running@head@i@position}{right}
-      \)\) \OR \(
-        \(\NOT \boolean{@tate}\) \AND \(
-          \equal{\expandafter\@secondoftwo\jlreq@nombre@i@position}{left} \OR
-          \equal{\expandafter\@secondoftwo\jlreq@running@head@i@position}{left}
-        \)
-      \)}{%
+      \bool_if:nT { (
+        \legacy_if_p:n { @tate } && (
+          \str_if_eq_p:ee { \expandafter\@secondoftwo\jlreq@nombre@i@position } { right } ||
+          \str_if_eq_p:ee { \expandafter\@secondoftwo\jlreq@running@head@i@position }{ right }
+          ))}{
+      )) || (
+        (! \legacy_if_p:n { @tate } ) && (
+          \str_if_eq_p:ee { \expandafter\@secondoftwo\jlreq@nombre@i@position }{ left } ||
+          \str_if_eq_p:ee { \expandafter\@secondoftwo\jlreq@running@head@i@position }{ left }
+        )
+      )}{
         \if@twoside
           \jlreq@note{柱やノンブルは，左ページでは，基本版面の左端の延長線にノンブル又は柱の先頭をそろえて配置するか，基本版面の左端の延長線から基本版面の文字サイズの全角アキだけ右に寄せた位置に配置する (ページスタイル #1 内，2.6.1.b)．}%
         \fi
-      }{}%
+      }%
       % フォント変更命令に文字出力命令が入っているとエラーになるのを回避するために\setboxでごまかす．
       \setbox\jlreq@tempboxa=\hbox{\jlreq@running@head@font
-        \ifthenelse{\lengthtest{\jlreq@gap < 1.49\jlreq@zw} \OR \( \lengthtest{\jlreq@gap > 1.51\jlreq@zw} \AND \lengthtest{\jlreq@gap < 1.99\jlreq@zw} \) \OR \lengthtest{\jlreq@gap > 2.01\jlreq@zw}}{\jlreq@note{ノンブルと柱との空き量は柱に使用する文字サイズの2倍又は1.5倍とする (ページスタイル #1 内，2.6.1.c)．}}{}%
+        \bool_if:nT {
+          \dim_compare_p:n { \jlreq@gap < 1.49\jlreq@zw } ||
+          ( \dim_compare_p:n { \jlreq@gap > 1.51\jlreq@zw } && \dim_compare_p:n { \jlreq@gap < 1.99\jlreq@zw } ) ||
+          \dim_compare_p:n { \jlreq@gap > 2.01\jlreq@zw }
+        }{
+          \jlreq@note{ノンブルと柱との空き量は柱に使用する文字サイズの2倍又は1.5倍とする (ページスタイル #1 内，2.6.1.c)．}
+        }
       }%
       % 初期化
-      \@for\jlreq@parity:=odd,even\do{%
-        \@for\jlreq@vert:=top,bottom\do{%
-          \@for\jlreq@hor:=left,center,right\do{%
-            \@for\jlreq@type:=nombre,running@head\do{%
+      \clist_map_variable:nNn { odd, even } \jlreq@parity {
+        \clist_map_variable:nNn { top, bottom } \jlreq@vert {
+          \clist_map_variable:nNn { left, center, right } \jlreq@hor {
+            \clist_map_variable:nNn { nombre, running@head } \jlreq@type {
               \expandafter\def\csname jlreq@\jlreq@type @\jlreq@parity @\jlreq@vert @\jlreq@hor\endcsname{}%
             }%
           }%
@@ -4532,13 +4499,13 @@
         \jlreq@ifleftpage{\jlreq@parity}{\def\jlreq@pagehor{left}}{\def\jlreq@pagehor{right}}%
         % \jlreq@(running@head|nombre)@(odd|even)@(top|bottom)@(left|center|right)に入れていく
         % 左ページではノンブルが左（2.6.1.c），i,ii,...はiが左になるようにする．
-        \@for\jlreq@i:=i,ii,iii\do{%
+        \clist_map_variable:nNn { i, ii, iii } \jlreq@i {
           % nombre
           \expandafter\ifx\csname jlreq@nombre@\jlreq@i\endcsname\@empty\else
             \edef\jlreq@position{\csname jlreq@nombre@\jlreq@i @position\endcsname}%
             \edef\jlreq@vert{\expandafter\@firstoftwo\jlreq@position}%
             \edef\jlreq@hor{\expandafter\@secondoftwo\jlreq@position}%
-            \ifthenelse{\equal{\jlreq@parity}{even}}{\jlreq@reverse@leftright{\jlreq@hor}}{}%
+            \str_if_eq:VnT \jlreq@parity { even } {\jlreq@reverse@leftright{\jlreq@hor}}
             \jlreq@ifleftpage{\jlreq@parity}{\let\jlreq@addtocs=\cseappto}{\let\jlreq@addtocs\csepreto}%
             \edef\jlreq@csname{jlreq@nombre@\jlreq@parity @\jlreq@vert @\jlreq@hor}%
             \expandafter\ifx\csname\jlreq@csname\endcsname\@empty\else\jlreq@addtocs{\jlreq@csname}{\unexpanded{\hskip\glueexpr}\expandonce{\jlreq@nombre@gap}\noexpand\relax}\fi
@@ -4550,23 +4517,23 @@
             \edef\jlreq@position{\csname jlreq@running@head@\jlreq@i @position\endcsname}%
             \edef\jlreq@vert{\expandafter\@firstoftwo\jlreq@position}%
             \edef\jlreq@hor{\expandafter\@secondoftwo\jlreq@position}%
-            \ifthenelse{\equal{\jlreq@parity}{even}}{\jlreq@reverse@leftright{\jlreq@hor}}{}%
-            \ifthenelse{\equal{\jlreq@hor}{\jlreq@pagehor}}{\let\jlreq@addtocs=\cseappto}{\let\jlreq@addtocs=\csepreto}%
+            \str_if_eq:VnT \jlreq@parity { even } {\jlreq@reverse@leftright{\jlreq@hor}}
+            \str_if_eq:VVTF \jlreq@hor \jlreq@pagehor {\let\jlreq@addtocs=\cseappto}{\let\jlreq@addtocs=\csepreto}%
             \edef\jlreq@csname{jlreq@running@head@\jlreq@parity @\jlreq@vert @\jlreq@hor}%
             \jlreq@addtocs{\jlreq@csname}{{\csexpandonce{jlreq@\jlreq@parity @running@head@\jlreq@i}}}%
           \fi
         }%
         % {A}{B}{C}の順だった柱を結合する．本体は\jlreq@pagestyle@make@runninghead．
-        \@for\jlreq@vert:=top,bottom\do{%
-          \@for\jlreq@hor:=left,center,right\do{%
-            \ifthenelse{\equal{\jlreq@hor}{right}}{\def\jlreq@tempa{*}}{\def\jlreq@tempa{}}%
+        \clist_map_variable:nNn { top, bottom } \jlreq@vert {
+          \clist_map_variable:nNn { left, center, right } \jlreq@hor {
+            \str_if_eq:VnTF \jlreq@hor { right } { \def\jlreq@tempa{*} } { \def\jlreq@tempa{} }
             \edef\jlreq@do{\noexpand\jlreq@pagestyle@make@runninghead{jlreq@running@head@\jlreq@parity @\jlreq@vert @\jlreq@hor}{\expandonce{\jlreq@tempa}}{\expandonce{\jlreq@running@head@gap}}}%
             \jlreq@do
           }%
         }%
         % ノンブルと柱を結合し，必要ならばフォント設定をする．
-        \@for\jlreq@vert:=top,bottom\do{%
-          \@for\jlreq@hor:=left,center,right\do{%
+        \clist_map_variable:nNn { top, bottom } \jlreq@vert {%
+          \clist_map_variable:nNn { left, center, right } \jlreq@hor {%
             \edef\jlreq@csname{jlreq@\jlreq@parity @\jlreq@vert @\jlreq@hor}%
             \edef\jlreq@runheadcsname{jlreq@running@head@\jlreq@parity @\jlreq@vert @\jlreq@hor}%
             \edef\jlreq@nombrecsname{jlreq@nombre@\jlreq@parity @\jlreq@vert @\jlreq@hor}%
@@ -4587,10 +4554,10 @@
               }{%
 %                % 両方ある場合：左ページではノンブルが左，右ページではノンブルが右．
                 \jlreq@ifleftpage{\jlreq@parity}{%
-                  \ifthenelse{\equal{\jlreq@hor}{right}}{%
+                  \str_if_eq:VnTF \jlreq@hor { right } {
                     % <ノンブル><空き><柱>，右寄せ
                     % 柱が空出ないときに限り<空き>を入れる．
-                    \jlreq@pagestyle@addfont@totokens{\unexpanded{\ifdim\wd\jlreq@PageStyle@box=0pt \else\hskip}\expandonce{\jlreq@gap}\unexpanded{\relax\fi}}{jlreq@running@head@font}{jlreq@tempa}%
+                    \jlreq@pagestyle@addfont@totokens{\exp_not:N \dim_compare:nF { \exp_not:n { \wd\jlreq@PageStyle@box=0pt } } { \exp_not:N \hskip\expandonce{\jlreq@gap}\exp_no:N \relax } }{jlreq@running@head@font}{jlreq@tempa}%
                     \expandafter\edef\csname\jlreq@csname\endcsname{%
                       \unexpanded{\setbox\jlreq@PageStyle@box=\hbox}{\expandonce{\jlreq@running@head@font}\csexpandonce{\jlreq@runheadcsname}}%
                       \csexpandonce{\jlreq@nombrecsname}\expandonce{\jlreq@tempa}\unexpanded{\box\jlreq@PageStyle@box}%
@@ -4602,11 +4569,14 @@
                     \expandafter\edef\csname\jlreq@csname\endcsname{\csexpandonce{\jlreq@nombrecsname}\expandonce{\jlreq@tempa}}%
                   }%
                 }{%
-                  \ifthenelse{\equal{\jlreq@hor}{left}}{%
+                  \str_if_eq:VnTF \jlreq@hor { left } {
                     % <柱><空き><ノンブル>，左寄せ
                     \jlreq@pagestyle@addfont@totokens{%
                       \unexpanded{\setbox\jlreq@PageStyle@box=\hbox}{\csexpandonce{\jlreq@runheadcsname}}%
-                      \unexpanded{\copy\jlreq@PageStyle@box\ifdim\wd\jlreq@PageStyle@box=0pt \else\hskip\glueexpr}\expandonce{\jlreq@gap}\unexpanded{\relax\fi}%
+                      \unexpanded{\copy\jlreq@PageStyle@box}
+                      \exp_not:N \dim_compare:nF { \exp_not:n { \wd\jlreq@PageStyle@box=0pt } } {
+                        \exp_not:n { \hskip\glueexpr } \exp_not:o {\jlreq@gap} \exp_not:N \relax
+                      }
                     }{jlreq@running@head@font}{jlreq@tempa}%
                     \expandafter\edef\csname\jlreq@csname\endcsname{\expandonce{\jlreq@tempa}\csexpandonce{\jlreq@nombrecsname}}%
                   }{%
@@ -4625,7 +4595,7 @@
       \jlreq@pagestyle@setheadfoot{\jlreq@oddfoot}{jlreq@odd@bottom@left}{jlreq@odd@bottom@center}{jlreq@odd@bottom@right}%
       \jlreq@pagestyle@setheadfoot{\jlreq@evenhead}{jlreq@even@top@left}{jlreq@even@top@center}{jlreq@even@top@right}%
       \jlreq@pagestyle@setheadfoot{\jlreq@evenfoot}{jlreq@even@bottom@left}{jlreq@even@bottom@center}{jlreq@even@bottom@right}%
-      \ifthenelse{\lengthtest{\jlreq@sidenote@length >0pt} \AND \(\NOT\boolean{@tate}\)}{%
+      \bool_if:nTF { \dim_compare_p:n { \jlreq@sidenote@length > 0pt } && (! \legacy_if_p:n { @tate } ) }{
         \def\jlreq@defaultformat{\hss\hbox to \jlreqyokoheadlength{####1}\hss}%
       }{%
         \def\jlreq@defaultformat{####1}%
@@ -4689,18 +4659,18 @@
 \fi
 \edef\jlreqtateheadlength{\unexpanded{\dimexpr\headsep + \headheight + \textheight}\if@tate\else\unexpanded{- \topskip + 1\jlreq@zh}\fi\noexpand\relax}
 
-\newcommand*{\NewPageStyle}[2]{%
+\NewDocumentCommand{\NewPageStyle} { m +m } {%
   \expandafter\@ifdefinable\csname ps@#1\endcsname{\DeclarePageStyle{#1}{#2}}%
 }
-\newcommand*{\RenewPageStyle}[2]{%
+\NewDocumentCommand{\RenewPageStyle} { m +m } {%
   \@ifundefined{ps@#1}{\@latex@error{\expandafter\string\csname#1\endcsname\space undefined}\@ehc}{\DeclarePageStyle{#1}{#2}}%
 }
-\newcommand*{\ProvidePageStyle}[2]{%
+\NewDocumentCommand{\ProvidePageStyle} { m +m } {%
   \@ifundefined{ps@#1}{\DeclarePageStyle{#1}{#2}}{}%
 }
-\newcommand*{\ModifyPageStyle}[2]{%
+\NewDocumentCommand{\ModifyPageStyle} { m +m } {%
   \begingroup
-    \@ifundefined{jlreq@pagestyle@setting@#1}{\ClassError{jlreq}{Unknown pagestyle: #1}{\@ehc}}{}%
+    \@ifundefined{jlreq@pagestyle@setting@#1}{\ClassError{jlreq}{Unknown~pagestyle:~#1}{\@ehc}}{}%
     \expandafter\let\expandafter\setting\expandafter=\csname jlreq@pagestyle@setting@#1\endcsname
     \edef\jlreq@do{\noexpand\RenewPageStyle{#1}{\expandonce{\setting},\unexpanded{#2}}}%
   \expandafter\endgroup
@@ -4731,7 +4701,7 @@
           \noexpand\edef\expandonce{\csname #2\endcsname}{\unexpanded{\unexpanded{##1}}}
           \noexpand\def\expandonce{\csname #1\endcsname}{}%
         }%
-        \expandafter\@for\expandafter\jlreq@tempa\expandafter:\expandafter=\csname #1\endcsname\do{%
+        \clist_map_variable:cNn {#1} \jlreq@tempa {
           \epreto\jlreq@do{\noexpand\let\expandonce{\csname #2@\jlreq@tempa\endcsname}\noexpand\@undefined}%
         }%
       }{%
@@ -4793,12 +4763,11 @@
   \vskip\belowcaptionskip
 }}
 
-\jlreq@jlreqsetup@add{caption_font}{\jlreq@jlreqsetup@withenv{jlreq@@makecaption@font@envlist}{jlreq@@makecaption@font@setting}{#1}}
-\jlreq@jlreqsetup@add{caption_label_font}{\jlreq@jlreqsetup@withenv{jlreq@@makecaption@label@font@envlist}{jlreq@@makecaption@label@font@setting}{#1}}
-\jlreq@jlreqsetup@add{caption_label_format}{\jlreq@jlreqsetup@withenv{jlreq@@makecaption@label@format@envlist}{jlreq@@makecaption@label@format@setting}{#1}}
-\jlreq@jlreqsetup@add{caption_after_label_space}{\jlreq@jlreqsetup@withenv{jlreq@@makecaption@after@label@space@envlist}{jlreq@@makecaption@after@label@space@setting}{#1}}
+\keys_define:nn { jlreqsetup } {caption_font .code:n = {\jlreq@jlreqsetup@withenv{jlreq@@makecaption@font@envlist}{jlreq@@makecaption@font@setting}{#1}}}
+\keys_define:nn { jlreqsetup } {caption_label_font .code:n = {\jlreq@jlreqsetup@withenv{jlreq@@makecaption@label@font@envlist}{jlreq@@makecaption@label@font@setting}{#1}}}
+\keys_define:nn { jlreqsetup } {caption_label_format .code:n = {\jlreq@jlreqsetup@withenv{jlreq@@makecaption@label@format@envlist}{jlreq@@makecaption@label@format@setting}{#1}}}
+\keys_define:nn { jlreqsetup } {caption_after_label_space .code:n = {\jlreq@jlreqsetup@withenv{jlreq@@makecaption@after@label@space@envlist}{jlreq@@makecaption@after@label@space@setting}{#1}}}
 
-\ExplSyntaxOn
 %% 
 %% \jlreq@@makecaption@align@setting@small(@env)に小さい時のalign，jlreq@@makecaption@align@setting@large(@env)に大きいときのalignを入れる．
 %% \l_jlreq_tmpb_tlに各環境の設定クリア
@@ -4879,21 +4848,22 @@
   }
 }
 
-\jlreq@jlreqsetup@add{caption_align}{%
-  \group_begin:
-    \tl_clear:N \l_jlreq_tmpb_tl
-    \tl_clear:N \l_jlreq_tmpc_tl
-    \tl_clear:N \l_jlreq_tmpd_tl
-    \keys_set:nn { __jlreqsetup_caption_align } {#1}
-    \cs_set:Nx \l_jlreq_do:{
-      \exp_not:o \l_jlreq_tmpb_tl
-      \exp_not:o \l_jlreq_tmpc_tl
-      \exp_not:o \l_jlreq_tmpd_tl
-    }
-  \exp_after:wN \group_end:
-  \l_jlreq_do:
+\keys_define:nn { jlreqsetup } {
+  caption_align .code:n = {
+    \group_begin:
+      \tl_clear:N \l_jlreq_tmpb_tl
+      \tl_clear:N \l_jlreq_tmpc_tl
+      \tl_clear:N \l_jlreq_tmpd_tl
+      \keys_set:nn { __jlreqsetup_caption_align } {#1}
+      \cs_set:Nx \l_jlreq_do:{
+        \exp_not:o \l_jlreq_tmpb_tl
+        \exp_not:o \l_jlreq_tmpc_tl
+        \exp_not:o \l_jlreq_tmpd_tl
+      }
+    \exp_after:wN \group_end:
+    \l_jlreq_do:
+  }
 }
-\ExplSyntaxOff
 
 % 特に根拠のない値
 \setlength\abovecaptionskip{.5\jlreq@gol}
@@ -4901,7 +4871,6 @@
 
 %.. figure環境
 \newcounter{figure}
-\ExplSyntaxOn
 \str_if_eq:VnTF \jlreq@article@type { article } {
   \renewcommand{\thefigure}{\@arabic\c@figure}
 }{%
@@ -4929,7 +4898,6 @@
 \newcommand*{\fnum@table}{\tablename\thetable}
 \newenvironment{table}{\@float{table}}{\end@float}
 \newenvironment{table*}{\@dblfloat{table}}{\end@dblfloat}
-\ExplSyntaxOff
 
 %. タイトル周り
 \newenvironment{titlepage}{%
@@ -4947,7 +4915,6 @@
   \fi
 }
 
-\ExplSyntaxOn
 \if@titlepage
   \newcommand{\maketitle}{%
     % jarticleとかからあまり変更していない
@@ -5011,7 +4978,6 @@
     \jlreq@endofmaketitle
   }
 \fi
-\ExplSyntaxOff
 % いろいろクリアする．
 \def\jlreq@endofmaketitle{%
   \setcounter{footnote}{0}%
@@ -5058,7 +5024,6 @@
 
 %.. abstract
 \def\jlreq@parhook@abstract{}
-\ExplSyntaxOn
 \str_if_eq:VnF \jlreq@article@type { book } {
   \newbox\jlreq@abstractbox
   \newcommand*{\abstractname}{概要}
@@ -5145,7 +5110,6 @@
     }
   \fi
 }
-\ExplSyntaxOff
 %. 箇条書き． cf. JISX4051 8.4
 % 用語定義型
 \newenvironment{description}{\list{}{%
@@ -5173,8 +5137,8 @@
       \ifjlreq@parsekeyval@nokey@novalue{%
         % 生の値．環境に対するものをクリアし，全ての<i-iv>に同じ値を設定
         % 環境一覧リストもクリア．
-        \@for\jlreq@tempa:=i,ii,iii,iv,v,vi\do{%
-          \expandafter\@for\expandafter\jlreq@tempb\expandafter:\expandafter=\csname #1\endcsname\do{%
+        \clist_map_variable:nNn {i,ii,iii,iv,v,vi} \jlreq@tempa{
+          \clist_map_variable:cNn {#1} \jlreq@tempb {
             \ifx\jlreq@tempb\@empty\else
               \eappto\jlreq@generalset{\noexpand\let\expandonce{\csname #2@\jlreq@tempa @\jlreq@tempb\endcsname}\noexpand\@undefined}%
             \fi
@@ -5185,10 +5149,9 @@
         }%
         \appto\jlreq@generalset{\expandafter\def\csname #1\endcsname{}}%
       }{%
-%        \bool_if:nTF{ \str_if_eq_p:nn {##1} {i} || \str_if_eq_p:nn {##1} {ii} || \str_if_eq_p:nn {##1} {iii} || \str_if_eq_p:nn {##1} {iv} || \str_if_eq_p:nn {##1} {v} || \str_if_eq_p:nn {##1} {vi} }{
-        \ifthenelse{\equal{##1}{i} \OR \equal{##1}{ii} \OR \equal{##1}{iii} \OR \equal{##1}{iv} \OR \equal{##1}{v} \OR \equal{##1}{vi}}{%
+        \bool_if:nTF{ \str_if_eq_p:nn {##1} {i} || \str_if_eq_p:nn {##1} {ii} || \str_if_eq_p:nn {##1} {iii} || \str_if_eq_p:nn {##1} {iv} || \str_if_eq_p:nn {##1} {v} || \str_if_eq_p:nn {##1} {vi} }{
           % i=とかの時，環境に対応するものをクリアし，\#2@##1に値を入れる
-          \expandafter\@for\expandafter\jlreq@tempa\expandafter:\expandafter=\csname #1\endcsname\do{
+          \clist_map_variable:cNn {#1} \jlreq@tempa {
             \ifx\jlreq@tempa\@empty\else
               \epreto\jlreq@envset{\noexpand\let\expandonce{\csname #2@##1@\jlreq@tempa\endcsname}\noexpand\@undefined}%
             \fi
@@ -5199,7 +5162,7 @@
           \jlreq@parsekeyval@nokey{%
             \ifjlreq@parsekeyval@nokey@novalue{%
               % i - viまでに全てセットする．
-              \@for\jlreq@tempa:=i,ii,iii,iv,v,vi\do{%
+              \clist_map_variable:nNn {i,ii,iii,iv,v,vi} \jlreq@tempa{
                 \epreto\jlreq@envset{\noexpand\edef\expandonce{\csname #2@\jlreq@tempa @##1\endcsname}{\unexpanded{\unexpanded{####1}}}}%
               }%
             }{%
@@ -5222,10 +5185,10 @@
 
 
 \def\jlreq@itemization@beforeafter@space@envlist{}
-\jlreq@jlreqsetup@add{itemization_beforeafter_space}{\jlreq@jlreqsetup@itemization{jlreq@itemization@beforeafter@space@envlist}{jlreq@itemization@beforeafter@space@setting}{#1}}
-\jlreq@jlreqsetup@add{itemization_itemsep}{\jlreq@jlreqsetup@withenv{jlreq@itemization@itemsep@envlist}{jlreq@itemization@itemsep@setting}{#1}}
-\jlreq@jlreqsetup@add{itemization_labelsep}{\jlreq@jlreqsetup@withenv{jlreq@itemization@labelsep@envlist}{jlreq@itemization@labelsep@setting}{#1}}
-\jlreq@jlreqsetup@add{itemization_label_length}{\jlreq@jlreqsetup@itemization{jlreq@itemization@label@length@envlist}{jlreq@itemization@label@length@setting}{#1}}
+\keys_define:nn { jlreqsetup } {itemization_beforeafter_space .code:n = {\jlreq@jlreqsetup@itemization{jlreq@itemization@beforeafter@space@envlist}{jlreq@itemization@beforeafter@space@setting}{#1}}}
+\keys_define:nn { jlreqsetup } {itemization_itemsep .code:n = {\jlreq@jlreqsetup@withenv{jlreq@itemization@itemsep@envlist}{jlreq@itemization@itemsep@setting}{#1}}}
+\keys_define:nn { jlreqsetup } {itemization_labelsep .code:n = {\jlreq@jlreqsetup@withenv{jlreq@itemization@labelsep@envlist}{jlreq@itemization@labelsep@setting}{#1}}}
+\keys_define:nn { jlreqsetup } {itemization_label_length .code:n = {\jlreq@jlreqsetup@itemization{jlreq@itemization@label@length@envlist}{jlreq@itemization@label@length@setting}{#1}}}
 % enumerate, itemize用初期化，#1 = i,ii,...
 \def\jlreq@init@list#1{%
   \setlength{\partopsep}{0pt}%
@@ -5248,10 +5211,14 @@
 \def\@listvi{\jlreq@init@list{vi}}
 
 % 引用系．3.5.2の例．
-\jlreq@jlreqsetup@add{quote_indent}{\def\jlreq@quote@indent{#1}}
-\jlreq@jlreqsetup@add{quote_end_indent}{\def\jlreq@quote@end@indent{#1}}
-\jlreq@jlreqsetup@add{quote_fontsize}[normalsize,small,footnotesize,scriptsize,tiny,]{\jlreq@ifempty{#1}{\def\jlreq@quote@fontsize{}}{\edef\jlreq@quote@fontsize{\expandonce{\csname #1\endcsname}}}}
-\jlreq@jlreqsetup@add{quote_beforeafter_space}{\def\jlreq@quote@beforeafter@space{#1}}
+\keys_define:nn { jlreqsetup } { quote_indent .tl_set:N = \jlreq@quote@indent }
+\keys_define:nn { jlreqsetup } { quote_end_indent .tl_set:N = \jlreq@quote@end@indent }
+\keys_define:nn { jlreqsetup }{
+  quote_fontsize .choices:nn = {normalsize,small,footnotesize,scriptsize,tiny,{}}{
+    \jlreq@ifempty{#1}{\def\jlreq@quote@fontsize{}}{\edef\jlreq@quote@fontsize{\expandonce{\csname #1\endcsname}}}
+  }
+}
+\keys_define:nn { jlreqsetup } { quote_beforeafter_space .tl_set:N = \jlreq@quote@beforeafter@space }
 
 \newenvironment{verse}
   {\let\\\@centercr
@@ -5329,14 +5296,12 @@
 \setlength\fboxsep{.3\zw}
 \setlength\fboxrule{\jlreq@omotekeiwidth} % 根拠はない
 % 後で
-\ExplSyntaxOn
 \str_if_eq:VnTF \jlreq@article@type { article } {
   \renewcommand{\theequation}{\@arabic\c@equation}
 }{%
   \@addtoreset{equation}{chapter}
   \renewcommand{\theequation}{\ifnum\c@chapter>\z@\thechapter.\fi \@arabic\c@equation}
 }
-\ExplSyntaxOff
 
 %. 目次
 \setcounter{tocdepth}{3}
@@ -5361,12 +5326,11 @@
 
 \newcount\jlreq@top@contents % トップ見出しを入れる．レベルと同じ値．
 \jlreq@top@contents=-100
-\newcommand*{\jlreq@set@top@contents}[1]{%
+\def\jlreq@set@top@contents#1{%
   \ifnum\jlreq@top@contents=-100
     \jlreq@top@contents=#1\relax
   \fi
 }
-\ExplSyntaxOn
 \str_if_eq:VnTF \jlreq@article@type { article } {
   \newcommand{\tableofcontents}{%
     \jlreq@top@contents=-100\relax
@@ -5394,7 +5358,6 @@
     \if@restonecol\twocolumn\fi
   }
 }
-\ExplSyntaxOff
 
 % JIS X 4051自身の目次に近づけようかと……なりきれてないけど．
 % 文字の大きさは全て同じ（\normalsize）にする．
@@ -5496,21 +5459,22 @@
 \newcommand{\subsubitem}{\@idxitem \hspace*{3\jlreq@mol}}
 \newcommand{\indexspace}{\par \vskip 1\jlreq@gol \@plus .5\jlreq@gol \@minus .3\jlreq@gol\relax}
 \def\jlreq@theindex@pagestyle{}
-\jlreq@jlreqsetup@add{theindex_pagestyle}{
-  \def\jlreq@tempa{}% ページスタイル名
-  \def\jlreq@theindex@pagestyle{}%
-  \jlreq@tempafalse % restore
-  \jlreq@parsekeyval@nokey{%
-    \ifjlreq@parsekeyval@nokey@novalue{\def\jlreq@tempa{##1}}{%
-      \jlreq@switch{##1}{%
-        {restore}{\csname jlreq@tempa##2\endcsname}%
+\keys_define:nn { jlreqsetup } {theindex_pagestyle .code:n = {
+    \def\jlreq@tempa{}% ページスタイル名
+    \def\jlreq@theindex@pagestyle{}%
+    \jlreq@tempafalse % restore
+    \jlreq@parsekeyval@nokey{%
+      \ifjlreq@parsekeyval@nokey@novalue{\def\jlreq@tempa{##1}}{%
+        \jlreq@switch{##1}{%
+          {restore}{\csname jlreq@tempa##2\endcsname}%
+        }%
       }%
-    }%
-  }{#1}%
-  \eappto\jlreq@theindex@pagestyle{\unexpanded{\let\jlreq@theindex@savedpagestyle}\ifjlreq@tempa\noexpand\jlreq@current@pagestyle\else\noexpand\@undefined\fi}%
-  \ifx\jlreq@tempa\@empty\else
-    \eappto\jlreq@theindex@pagestyle{\noexpand\pagestyle{\expandonce{\jlreq@tempa}}}%
-  \fi
+    }{#1}%
+    \eappto\jlreq@theindex@pagestyle{\unexpanded{\let\jlreq@theindex@savedpagestyle}\ifjlreq@tempa\noexpand\jlreq@current@pagestyle\else\noexpand\@undefined\fi}%
+    \ifx\jlreq@tempa\@empty\else
+      \eappto\jlreq@theindex@pagestyle{\noexpand\pagestyle{\expandonce{\jlreq@tempa}}}%
+    \fi
+  }
 }
 
 %. 前付，後付，付録
@@ -5540,13 +5504,13 @@
                 {runin}{\def\jlreq@declaretype{RenewRunin}}
                 {cutin}{\def\jlreq@declaretype{RenewCutin}}
                 {modify}{\def\jlreq@declaretype{Modify}}
-                {\ClassError{jlreq}{Unknown heading type `####2'}{\@ehc}}
+                {\ClassError{jlreq}{Unknown~heading~type~`####2'}{\@ehc}}
               }%
             }
             {heading_level}{\def\jlreq@level{####2}}
             {%
-              \jlreq@ifempty{#1}{\@firstofone}{%
-                \ifthenelse{\equal{####1}{restore}}{%
+              \tl_if_empty:nTF {#1} { \@firstofone }{%
+                \str_if_eq:nnTF {####1} { restore } {
                   \csname jlreq@tempa####2\endcsname\@gobble
                 }{\@firstofone}%
               }%
@@ -5563,7 +5527,7 @@
       }%
       % \jlreq@declareに\ModifyHeadingか\Renew***Headingを入れる
       \edef\jlreq@declare{\expandonce{\csname\jlreq@declaretype Heading\endcsname}{##1}}%
-      \ifthenelse{\NOT \equal{\jlreq@declaretype}{Modify}}{%
+      \str_if_eq:VnF \jlreq@declaretype { Modify } {
         \ifx\jlreq@level\@empty
           % \frontmatter時でのレベルを引用する．
           \edef\jlreq@declare{%
@@ -5589,77 +5553,82 @@
 \def\jlreq@matter@counter@norestore#1#2{%
   \def#1{}%
   \jlreq@parsekeyval@nokey{%
-    \jlreq@parsekeyval*{
-      {value}{\appto#1{\setcounter{##1}{####1}}}
-      {the}{\eappto#1{\noexpand\def\expandonce{\csname the##1\endcsname}{\unexpanded{####1}}}}
-    }{##2}%
+    \keys_define:nn { __jlreq_keyval } {
+      value .code:n = \appto#1{\setcounter{##1}{####1}},
+      the .code:n = {\eappto#1{\noexpand\def\expandonce{\csname the##1\endcsname}{\unexpanded{####1}}}}
+    }
+    \keys_set:nn { __jlreq_keyval } {##2}
   }{#2}%
 }
 
-\ifthenelse{\equal{\jlreq@article@type}{book}}{
+\str_if_eq:VnT \jlreq@article@type { book } {
   \newif\if@mainmatter
   \@mainmattertrue
-  \jlreq@jlreqsetup@add{frontmatter_pagebreak}{%
+  \keys_define:nn { jlreqsetup } {frontmatter_pagebreak .code:n = {%
     \edef\jlreq@frontmatter@pagebreak{\jlreq@ifempty{#1}{}{\expandonce{\csname #1\endcsname}}}%
+  }}
+  \keys_define:nn { jlreqsetup } {frontmatter_counter .code:n = {%
+      \def\jlreq@frontmatter@counter{}%
+      \def\jlreq@tempa{}% 復帰させるカウンタ名リスト
+      \jlreq@parsekeyval@nokey{%
+        \def\jlreq@tempb{}% 中身
+        \jlreq@tempatrue % restore
+        \keys_define:nn { frontmatter_counter } {
+          value .code:n = {\appto\jlreq@tempb{\setcounter{##1}{####1}}},
+          restore .code:n = {\csname jlreq@tempa####1\endcsname},
+          the .code:n = {\eappto\jlreq@tempb{\noexpand\def\expandonce{\csname the##1\endcsname}{\unexpanded{####1}}}}
+        }
+        \keys_set:nn { frontmatter_counter } {##2}
+        \ifjlreq@tempa
+          \epreto\jlreq@tempb{%
+            \noexpand\let\expandonce{\csname jlreq@frontmatter@savedcounter@the@##1\endcsname}\expandonce{\csname the##1\endcsname}%
+            \noexpand\edef\expandonce{\csname jlreq@frontmatter@savedcounter@value@##1\endcsname}{\unexpanded{\the\value{##1}}}%
+          }%
+          \eappto\jlreq@tempa{\ifx\jlreq@tempa\@empty\else ,\fi\unexpanded{##1}}%
+        \fi
+        \eappto\jlreq@frontmatter@counter{\expandonce{\jlreq@tempb}}%
+      }{#1}%
+      \eappto\jlreq@frontmatter@counter{\unexpanded{\def\jlreq@frontmatter@restorecounters}{\expandonce{\jlreq@tempa}}}%
+    }
   }
-  \jlreq@jlreqsetup@add{frontmatter_counter}{%
-    \def\jlreq@frontmatter@counter{}%
-    \def\jlreq@tempa{}% 復帰させるカウンタ名リスト
-    \jlreq@parsekeyval@nokey{%
-      \def\jlreq@tempb{}% 中身
+  \keys_define:nn { jlreqsetup } {frontmatter_heading .code:n = {\jlreq@matter@heading[\jlreq@frontmatter@restoreheadings]{jlreq@frontmatter@savedheading}{\jlreq@frontmatter@heading}{#1}}}
+  \keys_define:nn { jlreqsetup } {frontmatter_pagestyle .code:n = {%
+      \def\jlreq@tempa{}% ページスタイル名
+      \def\jlreq@frontmatter@pagestyle{}%
       \jlreq@tempatrue % restore
-      \jlreq@parsekeyval{
-        {value}{\appto\jlreq@tempb{\setcounter{##1}{####1}}}
-        {restore}{\csname jlreq@tempa####1\endcsname}
-        {the}{\eappto\jlreq@tempb{\noexpand\def\expandonce{\csname the##1\endcsname}{\unexpanded{####1}}}}
-      }{##2}%
-      \ifjlreq@tempa
-        \epreto\jlreq@tempb{%
-          \noexpand\let\expandonce{\csname jlreq@frontmatter@savedcounter@the@##1\endcsname}\expandonce{\csname the##1\endcsname}%
-          \noexpand\edef\expandonce{\csname jlreq@frontmatter@savedcounter@value@##1\endcsname}{\unexpanded{\the\value{##1}}}%
+      \jlreq@parsekeyval@nokey{%
+        \ifjlreq@parsekeyval@nokey@novalue{\def\jlreq@tempa{##1}}{%
+          \jlreq@switch{##1}{%
+            {restore}{\csname jlreq@tempa##2\endcsname}%
+          }%
         }%
-        \eappto\jlreq@tempa{\ifx\jlreq@tempa\@empty\else ,\fi\unexpanded{##1}}%
+      }{#1}%
+      \ifjlreq@tempa
+        \appto\jlreq@frontmatter@pagestyle{\let\jlreq@frontmatter@savedpagestyle\jlreq@current@pagestyle}%
       \fi
-      \eappto\jlreq@frontmatter@counter{\expandonce{\jlreq@tempb}}%
-    }{#1}%
-    \eappto\jlreq@frontmatter@counter{\unexpanded{\def\jlreq@frontmatter@restorecounters}{\expandonce{\jlreq@tempa}}}%
+      \ifx\jlreq@tempa\@empty\else
+        \eappto\jlreq@frontmatter@pagestyle{\noexpand\pagestyle{\expandonce{\jlreq@tempa}}}%
+      \fi
+    }
   }
-  \jlreq@jlreqsetup@add{frontmatter_heading}{\jlreq@matter@heading[\jlreq@frontmatter@restoreheadings]{jlreq@frontmatter@savedheading}{\jlreq@frontmatter@heading}{#1}}
-  \jlreq@jlreqsetup@add{frontmatter_pagestyle}{%
-    \def\jlreq@tempa{}% ページスタイル名
-    \def\jlreq@frontmatter@pagestyle{}%
-    \jlreq@tempatrue % restore
-    \jlreq@parsekeyval@nokey{%
-      \ifjlreq@parsekeyval@nokey@novalue{\def\jlreq@tempa{##1}}{%
-        \jlreq@switch{##1}{%
-          {restore}{\csname jlreq@tempa##2\endcsname}%
+  \keys_define:nn { jlreqsetup } {frontmatter_precode .code:n = {\edef\jlreq@frontmatter@precode{\unexpanded{#1}}}}
+  \keys_define:nn { jlreqsetup } {frontmatter_postcode .code:n = {\edef\jlreq@frontmatter@postcode{\unexpanded{#1}}}}
+  \keys_define:nn { jlreqsetup } {frontmatter_pagination .code:n = {%
+      \def\jlreq@pagination@frontmatterstyle{arabic}%
+      \let\jlreq@pagination@mainmatterpagecommand=\pagenumbering
+      \clist_map_variable:nNn {#1} \jlreq@tempa {
+        \expandafter\jlreq@helper@trim\expandafter{\jlreq@tempa}{\jlreq@tempa}%
+        \jlreq@switch{\jlreq@tempa}{
+          {continuous}{%
+            \def\jlreq@pagination@mainmatterpagecommand##1{\gdef\thepage{\csname @##1\endcsname\c@page}}%
+          }
+          {independent}{\let\jlreq@pagination@mainmatterpagecommand=\pagenumbering}
+          {\edef\jlreq@pagination@frontmatterstyle{\jlreq@tempa}}
         }%
       }%
-    }{#1}%
-    \ifjlreq@tempa
-      \appto\jlreq@frontmatter@pagestyle{\let\jlreq@frontmatter@savedpagestyle\jlreq@current@pagestyle}%
-    \fi
-    \ifx\jlreq@tempa\@empty\else
-      \eappto\jlreq@frontmatter@pagestyle{\noexpand\pagestyle{\expandonce{\jlreq@tempa}}}%
-    \fi
-  }
-  \jlreq@jlreqsetup@add{frontmatter_precode}{\edef\jlreq@frontmatter@precode{\unexpanded{#1}}}
-  \jlreq@jlreqsetup@add{frontmatter_postcode}{\edef\jlreq@frontmatter@postcode{\unexpanded{#1}}}
-  \jlreq@jlreqsetup@add{frontmatter_pagination}{%
-    \def\jlreq@pagination@frontmatterstyle{arabic}%
-    \let\jlreq@pagination@mainmatterpagecommand=\pagenumbering
-    \@for\jlreq@tempa:=#1\do{%
-      \expandafter\jlreq@helper@trim\expandafter{\jlreq@tempa}{\jlreq@tempa}%
-      \jlreq@switch{\jlreq@tempa}{
-        {continuous}{%
-          \def\jlreq@pagination@mainmatterpagecommand##1{\gdef\thepage{\csname @##1\endcsname\c@page}}%
-        }
-        {independent}{\let\jlreq@pagination@mainmatterpagecommand=\pagenumbering}
-        {\edef\jlreq@pagination@frontmatterstyle{\jlreq@tempa}}
-      }%
-    }%
+    }
   }
-  \newcommand*{\frontmatter}{%
+  \NewDocumentCommand{\frontmatter}{}{%
     \jlreq@frontmatter@precode
     \jlreq@frontmatter@pagebreak
     \@mainmatterfalse
@@ -5673,20 +5642,18 @@
   \def\jlreq@frontmatter@restorecounters{}
   \def\jlreq@frontmatter@restoreheadings{}
   \def\jlreq@frontmatter@restorecommands{}
-  \jlreq@jlreqsetup@add{mainmatter_pagebreak}{%
+  \keys_define:nn { jlreqsetup } {mainmatter_pagebreak .code:n = {%
     \edef\jlreq@mainmatter@pagebreak{\jlreq@ifempty{#1}{}{\expandonce{\csname #1\endcsname}}}%
-  }
-  \jlreq@jlreqsetup@add{mainmatter_pagestyle}{%
+  }}
+  \keys_define:nn { jlreqsetup } {mainmatter_pagestyle .code:n = {%
     \edef\jlreq@mainmatter@pagestyle{\jlreq@ifempty{#1}{}{\unexpanded{\pagestyle{#1}}}}%
-  }
-  \jlreq@jlreqsetup@add{mainmatter_counter}{\jlreq@matter@counter@norestore{\jlreq@mainmatter@counter}{#1}}%
-  \jlreq@jlreqsetup@add{mainmatter_heading}{\jlreq@matter@heading{\jlreq@mainmatter@heading}{#1}}%
-  \jlreq@jlreqsetup@add{mainmatter_precode}{\edef\jlreq@mainmatter@precode{\unexpanded{#1}}}%
-  \jlreq@jlreqsetup@add{mainmatter_postcode}{\edef\jlreq@mainmatter@postcode{\unexpanded{#1}}}%
-  \jlreq@jlreqsetup@add{mainmatter_pagination}{%
-    \def\jlreq@pagination@mainmatterstyle{#1}%
-  }
-  \newcommand*{\mainmatter}{%
+  }}
+  \keys_define:nn { jlreqsetup } {mainmatter_counter .code:n = {\jlreq@matter@counter@norestore{\jlreq@mainmatter@counter}{#1}}}
+  \keys_define:nn { jlreqsetup } {mainmatter_heading .code:n = {\jlreq@matter@heading{\jlreq@mainmatter@heading}{#1}}}
+  \keys_define:nn { jlreqsetup } {mainmatter_precode .code:n = {\edef\jlreq@mainmatter@precode{\unexpanded{#1}}}}
+  \keys_define:nn { jlreqsetup } {mainmatter_postcode .code:n = {\edef\jlreq@mainmatter@postcode{\unexpanded{#1}}}}
+  \keys_define:nn { jlreqsetup } {mainmatter_pagination .tl_set:N = \jlreq@pagination@mainmatterstyle}
+  \NewDocumentCommand{\mainmatter}{}{%
     \jlreq@mainmatter@precode
     \jlreq@mainmatter@pagebreak
     \@mainmattertrue
@@ -5695,44 +5662,45 @@
     }{%
       \expandafter\pagestyle\expandafter{\jlreq@frontmatter@savedpagestyle}%
     }%
-    \@for\jlreq@tempa:=\jlreq@frontmatter@restorecounters\do{%
+    \clist_map_variable:NNn \jlreq@frontmatter@restorecounters \jlreq@tempa {
       \setcounter{\jlreq@tempa}{\csname jlreq@frontmatter@savedcounter@value@\jlreq@tempa\endcsname}%
       \expandafter\let\csname the\jlreq@tempa\expandafter\endcsname\csname jlreq@frontmatter@savedcounter@the@\jlreq@tempa\endcsname
     }%
     \jlreq@mainmatter@counter
-    \@for\jlreq@tempa:=\jlreq@frontmatter@restoreheadings\do{\csname jlreq@frontmatter@savedheading@\jlreq@tempa\endcsname}
+    \clist_map_variable:NNn \jlreq@frontmatter@restoreheadings \jlreq@tempa { \csname jlreq@frontmatter@savedheading@\jlreq@tempa\endcsname }
     \jlreq@mainmatter@heading
-    \@for\jlreq@tempa:=\jlreq@frontmatter@restorecommands\do{%
+    \clist_map_variable:NNn \jlreq@frontmatter@restorecommands \jlreq@tempa {
       \expandafter\let\csname \jlreq@tempa\expandafter\endcsname\csname jlreq@frontmatter@savedcommand@\jlreq@tempa\endcsname
     }%
     \expandafter\jlreq@pagination@mainmatterpagecommand\expandafter{\jlreq@pagination@mainmatterstyle}%
     \jlreq@mainmatter@postcode
   }
-  \jlreq@jlreqsetup@add{backmatter_pagebreak}{%
+  \keys_define:nn { jlreqsetup } {backmatter_pagebreak .code:n = {%
     \edef\jlreq@backmatter@pagebreak{\jlreq@ifempty{#1}{}{\expandonce{\csname #1\endcsname}}}%
-  }
-  \jlreq@jlreqsetup@add{backmatter_pagestyle}{%
+  }}
+  \keys_define:nn { jlreqsetup } {backmatter_pagestyle .code:n = {%
     \edef\jlreq@backmatter@pagestyle{\jlreq@ifempty{#1}{}{\unexpanded{\pagestyle{#1}}}}%
-  }
-  \jlreq@jlreqsetup@add{backmatter_counter}{\jlreq@matter@counter@norestore{\jlreq@backmatter@counter}{#1}}%
-  \jlreq@jlreqsetup@add{backmatter_heading}{\jlreq@matter@heading{\jlreq@backmatter@heading}{#1}}
-  \jlreq@jlreqsetup@add{backmatter_precode}{\edef\jlreq@backmatter@precode{\unexpanded{#1}}}
-  \jlreq@jlreqsetup@add{backmatter_postcode}{\edef\jlreq@backmatter@postcode{\unexpanded{#1}}}
-  \jlreq@jlreqsetup@add{backmatter_pagination}{
-    \let\jlreq@pagination@backmatterpagecommand=\pagenumbering
-    \def\jlreq@pagination@backmatterstyle{arabic}%
-    \@for\jlreq@tempa:=#1\do{%
-      \expandafter\jlreq@helper@trim\expandafter{\jlreq@tempa}{\jlreq@tempa}%
-      \jlreq@switch{\jlreq@tempa}{
-        {continuous}{%
-          \def\jlreq@pagination@backmatterpagecommand##1{\gdef\thepage{\csname @##1\endcsname\c@page}}%
-        }
-        {independent}{\let\jlreq@pagination@backmatterpagecommand=\pagenumbering}
-        {\edef\jlreq@pagination@backmatterstyle{\jlreq@tempa}}
+  }}
+  \keys_define:nn { jlreqsetup } {backmatter_counter .code:n = {\jlreq@matter@counter@norestore{\jlreq@backmatter@counter}{#1}}}
+  \keys_define:nn { jlreqsetup } {backmatter_heading .code:n = {\jlreq@matter@heading{\jlreq@backmatter@heading}{#1}}}
+  \keys_define:nn { jlreqsetup } {backmatter_precode .code:n = {\edef\jlreq@backmatter@precode{\unexpanded{#1}}}}
+  \keys_define:nn { jlreqsetup } {backmatter_postcode .code:n = {\edef\jlreq@backmatter@postcode{\unexpanded{#1}}}}
+  \keys_define:nn { jlreqsetup } {backmatter_pagination .code:n = {
+      \let\jlreq@pagination@backmatterpagecommand=\pagenumbering
+      \def\jlreq@pagination@backmatterstyle{arabic}%
+      \clist_map_variable:nNn {#1} \jlreq@tempa {
+        \expandafter\jlreq@helper@trim\expandafter{\jlreq@tempa}{\jlreq@tempa}%
+        \jlreq@switch{\jlreq@tempa}{
+          {continuous}{%
+            \def\jlreq@pagination@backmatterpagecommand##1{\gdef\thepage{\csname @##1\endcsname\c@page}}%
+          }
+          {independent}{\let\jlreq@pagination@backmatterpagecommand=\pagenumbering}
+          {\edef\jlreq@pagination@backmatterstyle{\jlreq@tempa}}
+        }%
       }%
-    }%
+    }
   }
-  \newcommand*{\backmatter}{%
+  \NewDocumentCommand{\backmatter}{}{%
     \jlreq@backmatter@precode
     \jlreq@backmatter@pagebreak
     \jlreq@backmatter@pagestyle
@@ -5742,13 +5710,13 @@
     \expandafter\jlreq@pagination@backmatterpagecommand\expandafter{\jlreq@pagination@backmatterstyle}%
     \jlreq@backmatter@postcode
   }
-}{}
+}
 
-\jlreq@jlreqsetup@add{appendix_counter}{\jlreq@matter@counter@norestore{\jlreq@appendix@counter}{#1}}
-\jlreq@jlreqsetup@add{appendix_heading}{\jlreq@matter@heading{\jlreq@appendix@heading}{#1}}
-\jlreq@jlreqsetup@add{appendix_precode}{\edef\jlreq@appendix@precode{\unexpanded{#1}}}
-\jlreq@jlreqsetup@add{appendix_postcode}{\edef\jlreq@appendix@postcode{\unexpanded{#1}}}
-\newcommand*{\appendix}{%
+\keys_define:nn { jlreqsetup } {appendix_counter .code:n = {\jlreq@matter@counter@norestore{\jlreq@appendix@counter}{#1}}}
+\keys_define:nn { jlreqsetup } {appendix_heading .code:n = {\jlreq@matter@heading{\jlreq@appendix@heading}{#1}}}
+\keys_define:nn { jlreqsetup } {appendix_precode .code:n = {\edef\jlreq@appendix@precode{\unexpanded{#1}}}}
+\keys_define:nn { jlreqsetup } {appendix_postcode .code:n = {\edef\jlreq@appendix@postcode{\unexpanded{#1}}}}
+\NewDocumentCommand{\appendix}{}{%
   \par
   \jlreq@appendix@precode
   \jlreq@appendix@counter
@@ -5761,7 +5729,7 @@
 \protected\def\tatechuyoko{\@ifstar
   {\jlreq@tatechuyoko@i}%
   {%
-    \jlreq@iftdir{}{\ClassError{jlreq}{\string\tatechuyoko\space is not allowed in yoko mode}{\@ehc}}%
+    \jlreq@iftdir{}{\ClassError{jlreq}{\string\tatechuyoko\space is~not~allowed~in~yoko~mode}{\@ehc}}%
     \jlreq@tatechuyoko@ii
   }%
 }
@@ -5771,9 +5739,9 @@
   \unexpanded{\ifvmode\leavevmode\fi}%
   \ifx l\jlreq@engine\unexpanded{%
     \jlreq@lastnodechar=\lastnodechar\relax
-    \ifnum\jlreq@lastnodechar>-1 \inhibitglue\fi
+    \int_compare:nT { \jlreq@lastnodechar>-1 } { \inhibitglue }
   }\else\unexpanded{%
-    \ifnum\lastnodechar>-1 \inhibitglue\fi
+    \int_compare:nT { \jlreq@lastnodechar>-1 } { \inhibitglue }
     \jlreq@lastnodechar=\lastnodechar\relax
   }\fi
 }
@@ -5788,7 +5756,7 @@
   \hbox{\yoko
     \begingroup
       \setbox\jlreq@tempboxa=\hbox{阿}%
-      \vrule width 0pt height \ht\jlreq@tempboxa depth \dp\jlreq@tempboxa
+      \vrule width~0pt~height~\ht\jlreq@tempboxa depth~\dp\jlreq@tempboxa
     \endgroup
     #1}%
   \futurelet\jlreq@nextchar\jlreq@tatechuyoko@iii
@@ -5808,18 +5776,57 @@
   \jlreq@do
 }
 
-\ExplSyntaxOn
 \jlreq@saveoriginalcs{kanjishape}
+\ifx l\jlreq@engine
+  \cs_new:Nn \__jlreq_setkanjiskip:nn {
+    \group_begin:
+      \ltj@setpar@global
+      \cs_set:Nn \l_jlreq_do: {}
+      \tl_if_empty:nF {#1} {
+        \skip_set:Nn \l_jlreq_tmpa_skip { #1 }
+        \cs_set:Nx \l_jlreq_do: { \exp_not:o \l_jlreq_do:
+          \exp_not:N \cs_set:Npn \exp_not:N \jlreqkanjiskip { \skip_use:N \l_jlreq_tmpa_skip }
+          \exp_not:N \ltjsetkanjiskip \skip_use:N \l_jlreq_tmpa_skip
+        }
+      }
+      \tl_if_empty:nF {#2} {
+        \skip_set:Nn \l_jlreq_tmpa_skip { #2 }
+        \cs_set:Nx \l_jlreq_do: { \exp_not:o \l_jlreq_do:
+          \exp_not:N \cs_set:Npn \exp_not:N \jlreqxkanjiskip { \skip_use:N \l_jlreq_tmpa_skip }
+          \exp_not:N \ltjsetxkanjiskip \skip_use:N \l_jlreq_tmpa_skip
+        }
+      }
+    \exp_after:wN \group_end:
+    \l_jlreq_do:
+  }
+\else
+  \cs_new:Nn \__jlreq_setkanjiskip:nn {
+    \group_begin:
+      \cs_set:Nn \l_jlreq_do: {}
+      \tl_if_empty:nF {#1} {
+        \skip_set:Nn \l_jlreq_tmpa_skip { #1 }
+        \cs_set:Nx \l_jlreq_do: { \exp_not:o \l_jlreq_do:
+          \exp_not:N \cs_set:Npx \exp_not:N \jlreqkanjiskip { \skip_use:N \l_jlreq_tmpa_skip }
+          \exp_not:N \skip_set:Nn \exp_not:N \kanjiskip { \skip_use:N \l_jlreq_tmpa_skip }
+        }
+      }
+      \tl_if_empty:nF {#2} {
+        \skip_set:Nn \l_jlreq_tmpa_skip { #2 }
+        \cs_set:Nx \l_jlreq_do: { \exp_not:o \l_jlreq_do:
+          \exp_not:N \cs_set:Npx \exp_not:N \jlreqxkanjiskip { \skip_use:N \l_jlreq_tmpa_skip }
+          \exp_not:N \skip_set:Nn \exp_not:N \xkanjiskip { \skip_use:N \l_jlreq_tmpa_skip }
+        }
+      }
+    \exp_after:wN \group_end:
+    \l_jlreq_do:
+  }
+\fi
 \ifx l\jlreq@engine
   \cs_set:Nn \l_jlreq_tmpa:n {
     \NewDocumentCommand { \jidori } { m m } {
       \mode_if_vertical:TF { \leavevmode } {}
       \group_begin:
-        \ltj@setpar@global
-        \ltjsetkanjiskip 0pt~plus~1fil~minus~0pt
-        \ltjsetxkanjiskip 0pt~plus~1fil~minus~0pt
-        \renewcommand*{ \jlreqkanjiskip  }  { 0pt~plus~1fil~minus~0pt }
-        \renewcommand*{ \jlreqxkanjiskip } { 0pt~plus~1fil~minus~0pt }
+        \__jlreq_setkanjiskip:nn { 0pt~plus~1fil~minus~0pt } { 0pt~plus~1fil~minus~0pt }
         \hbox_to_wd:nn {##1} {
           \def#1 {　}
           \kanjishape{n-jidori}\selectfont
@@ -5837,10 +5844,7 @@
   \NewDocumentCommand { \jidori } { m m } {
     \mode_if_vertical:TF { \leavevmode } {}
     \group_begin:
-      \setlength { \kanjiskip  } { 0pt~plus~15zw~minus~0pt }
-      \setlength { \xkanjiskip } { 0pt~plus~15zw~minus~0pt }
-      \renewcommand* { \jlreqkanjiskip  } { 0pt~plus~15zw~minus~0pt }
-      \renewcommand* { \jlreqxkanjiskip } { 0pt~plus~15zw~minus~0pt }
+      \__jlreq_setkanjiskip:nn { 0pt~plus~15zw~minus~0pt } { 0pt~plus~15zw~minus~0pt }
       \hbox_to_wd:nn {#1} {
         \kanjishape{n-jidori}\selectfont
         \inhibitglue #2
@@ -5849,7 +5853,13 @@
     \group_end:
   }
 \fi
-\ExplSyntaxOff
+\NewDocumentCommand { \akigumi } { m m } {
+  \mode_if_vertical:TF { \leavevmode } {}
+  \group_begin:
+    \__jlreq_setkanjiskip:nn { \jlreqkanjiskip + #1 } { }
+    \hbox:n {#2}
+  \group_end:
+}
 
 % 日にち
 \newif\if西暦
@@ -5857,21 +5867,26 @@
 \def\和暦{\西暦false}
 % #1年#2月#3日 #4は\numberとか\kansujiとか
 \def\jlreq@wareki#1#2#3#4{%
-  \jlreq@warekiyear{#1}{#2}{#3}{#4}%
+  \__jlreq_warekiyear:nnnn{#1}{#2}{#3}{#4}%
   #4#2月#4#3日%
 }
-\def\jlreq@warekiyear#1#2#3#4{%
+\cs_set:Nn \__jlreq_warekiyear:nnnn {
   % 昭和：1989年1月7日まで
-  \ifnum0\ifnum#1<1989 1\fi\ifnum#1=1989 \ifnum#2=1 \ifnum#3<8 1\fi\fi\fi>0
-    昭和\jlreq@warekiyear@{#1}{1926}{#4}%
-  % 平成：2019年4月末日まで
-  \else\ifnum0\ifnum#1<2019 1\fi\ifnum#1=2019 \ifnum#2<5 1\fi\fi>0
-    平成\jlreq@warekiyear@{#1}{1989}{#4}%
-  \else
-    令和\jlreq@warekiyear@{#1}{2019}{#4}%
-  \fi\fi
+  \bool_if:nTF { \int_compare_p:n { #1 < 1989 } || 
+    ( \int_compare_p:n { #1 == 1989 } && \int_compare_p:n { #2 == 1 } && \int_compare_p:n { #3 < 8 } ) }{
+    昭和\__jlreq_warekiyear_aux:nnn{#1}{1926}{#4}%
+  }{
+    % 平成：2019年4月末日まで
+    \bool_if:nTF { \int_compare_p:n { #1 < 2019 } || ( \int_compare_p:n { #1 == 2019 } && \int_compare_p:n { #2 < 5 } ) } {
+      平成\__jlreq_warekiyear_aux:nnn{#1}{1989}{#4}%
+    }{
+      令和\__jlreq_warekiyear_aux:nnn{#1}{2019}{#4}%
+    }
+  }
+}
+\cs_set:Nn \__jlreq_warekiyear_aux:nnn {
+  \int_compare:nTF { #1 = #2 } {元年} { \int_eval:n { #1 - #2 + 1 } 年 }
 }
-\def\jlreq@warekiyear@#1#2#3{\ifnum#1=#2 元年\else #3\numexpr#1-#2+1\relax 年\fi}
 \def\today{%
   \if西暦
     \jlreq@iftdir{%
@@ -5891,11 +5906,11 @@
     }%
   \fi
 }
-\jlreq@jlreqsetup@add{year_style}[seireki,wareki]{%
-  \jlreq@switch{#1}{%
-    {seireki}{\西暦true}
-    {wareki}{\西暦false}
-  }
+
+\keys_define:nn { jlreqsetup } {
+  year_style .choice:,
+  year_style / seireki .code:n = {\西暦true},
+  year_style / wareki .code:n = {\西暦false}
 }
 
 % 時刻
@@ -5933,40 +5948,42 @@
 \def\jlreq@setupamsthm{
   \newtheoremstyle{jlreq}{\dimexpr\jlreq@theorem@beforeafter@space\relax}{\dimexpr\jlreq@theorem@beforeafter@space\relax}{\jlreq@theorem@font}{\dimexpr\jlreq@theorem@indent\relax}{\jlreq@theorem@label@font}{}{1\jlreq@zw}{\thmname{##1}\thmnumber{\ ##2}\thmnote{（##3）}}
 }
-\jlreq@jlreqsetup@add{theorem_beforeafter_space}{
-  \def\jlreq@theorem@beforeafter@space{#1}
-  \begingroup\jlreq@tempdima=\dimexpr\jlreq@theorem@beforeafter@space\relax\endgroup
-  \@ifpackageloaded{amsthm}{\jlreq@setupamsthm}{}
-}
-\jlreq@jlreqsetup@add{theorem_indent}{
-  \def\jlreq@theorem@indent{#1}
-  \begingroup\jlreq@tempdima=\dimexpr\jlreq@theorem@indent\relax\endgroup
-  \@ifpackageloaded{amsthm}{\jlreq@setupamsthm}{}
+\keys_define:nn { jlreqsetup } {theorem_beforeafter_space .code:n = {
+    \def\jlreq@theorem@beforeafter@space{#1}
+    \begingroup\jlreq@tempdima=\dimexpr\jlreq@theorem@beforeafter@space\relax\endgroup
+    \@ifpackageloaded{amsthm}{\jlreq@setupamsthm}{}
+  }
 }
-\jlreq@jlreqsetup@add{theorem_font}{
-  \def\jlreq@theorem@font{#1}
-  \@ifpackageloaded{amsthm}{\jlreq@setupamsthm}{}
+\keys_define:nn { jlreqsetup } {theorem_indent .code:n = {
+    \def\jlreq@theorem@indent{#1}
+    \begingroup\jlreq@tempdima=\dimexpr\jlreq@theorem@indent\relax\endgroup
+    \@ifpackageloaded{amsthm}{\jlreq@setupamsthm}{}
+  }
 }
-\jlreq@jlreqsetup@add{theorem_label_font}{
-  \def\jlreq@theorem@label@font{#1}
-  \@ifpackageloaded{amsthm}{\jlreq@setupamsthm}{}
+\keys_define:nn { jlreqsetup } {theorem_font .code:n = {
+    \def\jlreq@theorem@font{#1}
+    \@ifpackageloaded{amsthm}{\jlreq@setupamsthm}{}
+  }
 }
-\jlreq@jlreqsetup@add{proof_label_font}{
-  \def\jlreq@proof@label@font{#1}
+\keys_define:nn { jlreqsetup } {theorem_label_font .code:n = {
+    \def\jlreq@theorem@label@font{#1}
+    \@ifpackageloaded{amsthm}{\jlreq@setupamsthm}{}
+  }
 }
+\keys_define:nn { jlreqsetup } {proof_label_font .tl_set:N = \jlreq@proof@label@font}
 
 %. デフォルト設定
 %.. 見出し
 \if@tate
   \renewcommand{\thepart}{\jlreq@Kanji{part}}
-  \ifthenelse{\equal{\jlreq@article@type}{article}}{}{\renewcommand{\thechapter}{\jlreq@Kanji{chapter}}}
+  \str_if_eq:VnF \jlreq@article@type { article }{\renewcommand{\thechapter}{\jlreq@Kanji{chapter}}}
   \renewcommand{\thesection}{\tatechuyoko*{\@arabic\c@section}}
   \renewcommand{\thesubsection}{\tatechuyoko*{\@alph\c@subsection}}
   \renewcommand{\thesubsubsection}{\tatechuyoko*{\@arabic\c@subsubsection}}
   \renewcommand{\theparagraph}{(\tatechuyoko*{\@arabic\c@paragraph})}
   \renewcommand{\thesubparagraph}{(\tatechuyoko*{\@arabic\c@subparagraph})}
 
-  \ifthenelse{\equal{\jlreq@article@type}{article}}{
+  \str_if_eq:VnTF \jlreq@article@type { article } {
     \NewBlockHeading{part}{0}{font={\jlreq@keepbaselineskip{\LARGE}},indent=4\jlreq@zw,lines=4,after_label_space=1\jlreq@zw,second_heading_text_indent={-1\jlreq@zw,1\jlreq@zw},subtitle_font={\jlreq@keepbaselineskip{\large}}}
     \if@twoside\ModifyHeading{part}{allowbreak_if_evenpage=true}\fi
   }
@@ -5990,11 +6007,10 @@
   \renewcommand{\thesubsubsection}{\thesubsection .\arabic{subsubsection}}
   \renewcommand{\theparagraph}{\thesubsubsection .\arabic{paragraph}}
   \renewcommand{\thesubparagraph}{\theparagraph .\arabic{subparagraph}}
-  \ifthenelse{\equal{\jlreq@article@type}{article}}{
+  \str_if_eq:VnTF \jlreq@article@type { article } {
     \NewBlockHeading{part}{0}{font={\jlreq@keepbaselineskip{\LARGE\sffamily\gtfamily\bfseries}},label_format={第\thepart 部},lines=4,after_label_space=1\jlreq@zw,second_heading_text_indent={-1\jlreq@zw,1\jlreq@zw},subtitle_font={\jlreq@keepbaselineskip{\large}}}
     \renewcommand{\thesection}{\arabic{section}}
-  }
-  {% book, report
+  }{% book, report
     \NewTobiraHeading{part}{-1}{label_format={第\thepart 部\hspace*{1\jlreq@gol}},format={\null\vfil {\Huge\sffamily\gtfamily\bfseries #1#2}\vfil}}
     \NewBlockHeading{chapter}{0}{%
       font={\jlreq@keepbaselineskip{\huge\sffamily\gtfamily\bfseries}},
@@ -6011,71 +6027,71 @@
   \NewRuninHeading{subparagraph}{5}{font={\jlreq@keepbaselineskip{\normalsize\sffamily\gtfamily\bfseries}},indent=2\jlreq@zw}
 \fi
 
-\ifthenelse{\equal{\jlreq@article@type}{article}}{}{% book, report
-  \if@openright
+\str_if_eq:VnF \jlreq@article@type { article } {
+  \legacy_if:nTF { @openright } {
     \ModifyHeading{part}{type=naka}
-    \if@tate
+    \legacy_if:nTF { @tate } {
       \ModifyHeading{chapter}{pagebreak=begin_with_even_page}
-    \else
+    }{
       \ModifyHeading{chapter}{pagebreak=begin_with_odd_page}
-    \fi
-  \else
+    }
+  }{
     \ModifyHeading{part}{type=han}
     \ModifyHeading{chapter}{pagebreak=clearpage}
-  \fi
+  }
 }
 
 %.. ページスタイル
 \RenewPageStyle{empty}{nombre={},odd_running_head={},even_running_head={}}
-\ifthenelse{\equal{\jlreq@article@type}{article}}{
-  \if@twoside
+\str_if_eq:VnTF \jlreq@article@type { article } {
+  \legacy_if:nTF { @twoside } {
     \NewPageStyle{headings}{odd_running_head={_subsection},even_running_head={_section}}
-  \else
+  }{
     \NewPageStyle{headings}{odd_running_head={_section},even_running_head={}}
-  \fi
+  }
 }{% book, article
-  \if@twoside
+  \legacy_if:nTF { @twoside } {
     \NewPageStyle{headings}{odd_running_head={_section},even_running_head={_chapter}}
-  \else
+  }{
     \NewPageStyle{headings}{odd_running_head={_chapter},even_running_head={}}
-  \fi
+  }
   \ModifyPageStyle{headings}{mark_format={_chapter={第\thechapter 章\quad #1}}}
 }
-\if@tate
+\legacy_if:nTF { @tate } {
   \RenewPageStyle{plain}{nombre=\thepage,odd_running_head={},even_running_head={},clear_markcommand=false}
   \NewPageStyle{myheadings}{nombre=\thepage,odd_running_head=\rightmark,even_running_head=\leftmark,clear_markcommand=false}
-  \if@twoside
+  \legacy_if:nTF { @twoside } {
     \ModifyPageStyle{plain}{nombre_position={top-left}}
     \ModifyPageStyle{headings}{nombre=\thepage,nombre_position=bottom-left,running_head_position=top-left}
     \ModifyPageStyle{myheadings}{nombre_position=bottom-left,running_head_position=top-left}
-  \else
+  }{
     \ModifyPageStyle{plain}{nombre_position={top-center}}
     \ModifyPageStyle{headings}{nombre=\thepage,nombre_position=bottom-center,running_head_position=top-center}
     \ModifyPageStyle{myheadings}{nombre_position=bottom-center,running_head_position=top-center}
-  \fi
-\else% yoko
+  }
+}{% yoko
   \RenewPageStyle{plain}{nombre=\thepage,odd_running_head={},even_running_head={},nombre_position={bottom-center},clear_markcommand=false}
   \ModifyPageStyle{headings}{nombre=\thepage,nombre_position=bottom-center,running_head_position=top-center}
   \NewPageStyle{myheadings}{nombre=\thepage,nombre_position=bottom-center,running_head_position=top-center,odd_running_head=\rightmark,even_running_head=\leftmark,clear_markcommand=false}
-\fi
+}
 \ModifyPageStyle{plain}{font=\small}
 \ModifyPageStyle{headings}{font=\small}
 \ModifyPageStyle{myheadings}{font=\small}
 
 %.. 注
 \jlreqsetup{reference_mark=inline}
-\if@tate
+\legacy_if:nTF { @tate } {
   \jlreqsetup{footnote_indent=1\jlreq@zw}% 根拠なし
-\else
+}{
   \jlreqsetup{footnote_indent=0pt}% （4.2.5.b）
-\fi
+}
 \jlreqsetup{footnote_second_indent=1\jlreq@zw}
 \jlreqsetup{endnote_second_indent=2\jlreq@zw}
 \jlreqsetup{endnote_position=headings}
-\ifdim\jlreq@sidenote@length>0pt
+\dim_compare:nT { \jlreq@sidenote@length>0pt } {
   \jlreqsetup{sidenote_type=number}
   \jlreqsetup{sidenote_symbol=＊,sidenote_keyword_font={}}
-\fi
+}
 
 %.. キャプション
 \jlreqsetup{
@@ -6087,7 +6103,7 @@
 }
 
 %.. 箇条書き
-\if@tate
+\legacy_if:nTF { @tate } {
   \renewcommand{\theenumi}{\jlreq@Kanji{enumi}}
   \renewcommand{\theenumii}{\tatechuyoko*{\@arabic\c@enumii}}
   \renewcommand{\theenumiii}{\tatechuyoko*{\@arabic\c@enumiii}}
@@ -6096,7 +6112,7 @@
   \newcommand{\labelenumii}{\theenumii}
   \newcommand{\labelenumiii}{\theenumiii}
   \newcommand{\labelenumiv}{\theenumiv}
-\else
+}{
   \renewcommand{\theenumi}{\@arabic\c@enumi}
   \renewcommand{\theenumii}{\@alph\c@enumii}
   \renewcommand{\theenumiii}{\@roman\c@enumiii}
@@ -6105,20 +6121,20 @@
   \newcommand{\labelenumii}{(\theenumii)\hspace{.5\jlreq@zw}}
   \newcommand{\labelenumiii}{\theenumiii.\hspace{.5\jlreq@zw}}
   \newcommand{\labelenumiv}{\theenumiv.\hspace{.5\jlreq@zw}}
-\fi
+}
 \renewcommand{\p@enumii}{\theenumi}
 \renewcommand{\p@enumiii}{\theenumi(\theenumii)}
 \renewcommand{\p@enumiv}{\p@enumiii\theenumiii}
 
 \newcommand{\labelitemi}{\hbox to 1\jlreq@zw{\hss\textbullet\hss}}
 %\newcommand{\labelitemi}{•}
-\if@tate
+\legacy_if:nTF { @tate } {
   \newcommand{\labelitemii}{○}
   \newcommand{\labelitemiii}{＊}
-\else
+}{
   \newcommand{\labelitemii}{\hbox to 1\jlreq@zw{\hss\textendash\hss}}
   \newcommand{\labelitemiii}{\hbox to 1\jlreq@zw{\hss\textasteriskcentered\hss}}
-\fi
+}
 \newcommand{\labelitemiv}{\hbox to 1\jlreq@zw{\hss ・\hss}}
 
 % 見出しが一つ上のレベルからどのくらいずれているかを入れる．
@@ -6139,7 +6155,6 @@
 }
 
 %.. 引用
-\ExplSyntaxOn
 \jlreqsetup{
   quote_indent=2\jlreq@zw,
   quote_end_indent=0pt,
@@ -6170,11 +6185,11 @@
     mainmatter_precode = {},
     mainmatter_postcode = {},
   }
-  \if@openright
+  \legacy_if:nTF { @openright } {
     \jlreqsetup{backmatter_pagebreak=cleardoublepage}
-  \else
+  }{
     \jlreqsetup{backmatter_pagebreak=clearpage}
-  \fi
+  }
   \jlreqsetup{
     backmatter_pagestyle = plain,
     backmatter_counter = {
@@ -6193,50 +6208,49 @@
   }
 }
 \str_if_eq:VnTF \jlreq@article@type { article } {
-  \if@tate
+  \legacy_if:nTF { @tate } {
     \jlreqsetup{
       appendix_counter = {
         section = {value = 0, the = {\tatechuyoko*{\Alph{section}}}},
         subsection = {value = 0},
       }
     }
-  \else
+  }{
     \jlreqsetup{
       appendix_counter = {
         section = {value = 0, the = {\Alph{section}}},
         subsection = {value = 0},
       }
     }
-  \fi
+  }
  \jlreqsetup{appendix_heading = {},appendix_precode = {},appendix_postcode = {}}
 }{%book, report
-  \if@tate
+  \legacy_if:nTF { @tate } {
     \jlreqsetup{
       appendix_counter = {
         chapter = {value = 0, the = {\tatechuyoko*{\Alph{chapter}}}},
       }
     }
- \else
+  }{
     \jlreqsetup{
       appendix_counter = {
         chapter = {value = 0, the = {\Alph{chapter}}},
       }
     }
- \fi
- \jlreqsetup{
-   appendix_heading = {
-     chapter = {label_format = {付録\thechapter}}
-   },
-   appendix_postcode = {%
-     \str_if_eq:VnT \jlreq@current@pagestyle { headings } {
-       \def\chaptermark#1{\markboth{付録\thechapter\quad #1}{}}%
-       \ModifyPageStyle{headings}{mark_format={_chapter={付録\thechapter\quad #1}}}%
-     }{}%
-   },
-   appendix_precode = {}
- }
+  }
+  \jlreqsetup{
+    appendix_heading = {
+      chapter = {label_format = {付録\thechapter}}
+    },
+    appendix_postcode = {%
+      \str_if_eq:VnT \jlreq@current@pagestyle { headings } {
+        \def\chaptermark#1{\markboth{付録\thechapter\quad #1}{}}%
+        \ModifyPageStyle{headings}{mark_format={_chapter={付録\thechapter\quad #1}}}%
+      }{}%
+    },
+    appendix_precode = {}
+  }
 }
-\ExplSyntaxOff
 \jlreqsetup{theindex_pagestyle=plain}
 \jlreqsetup{year_style=seireki}
 \jlreqsetup{
@@ -6267,6 +6281,8 @@
   \onecolumn
   \raggedbottom
 \fi
+
+\ExplSyntaxOff
 \endinput
 
 
-- 
cgit v1.2.3

