From 1eca258393711ac5b590d4b47e3f1b3af566b4af Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Thu, 3 May 2018 16:47:05 +0000
Subject: jlreq (11apr18)

git-svn-id: svn://tug.org/texlive/trunk@47589 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/jlreq/jlreq.cls | 476 ++++++++++++++++------------
 1 file changed, 267 insertions(+), 209 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/jlreq/jlreq.cls')

diff --git a/Master/texmf-dist/tex/latex/jlreq/jlreq.cls b/Master/texmf-dist/tex/latex/jlreq/jlreq.cls
index 1ffce720f14..d84993e69ce 100644
--- a/Master/texmf-dist/tex/latex/jlreq/jlreq.cls
+++ b/Master/texmf-dist/tex/latex/jlreq/jlreq.cls
@@ -5,7 +5,7 @@
 %%
 % (based on JLReq 20120403 https://www.w3.org/TR/2012/NOTE-jlreq-20120403/ja/)
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesClass{jlreq}[2018/02/01 jlreq]
+\ProvidesClass{jlreq}[2018/04/11 jlreq]
 \RequirePackage{xkeyval,everyhook,filehook,etoolbox,ifthen}
 
 %. helper1
@@ -29,9 +29,10 @@
 \newskip\jlreq@resultskip
 \newbox\jlreq@resultbox
 \newif\ifjlreq@result
+\newcount\jlreq@resultcnt
 
 \newcommand*{\jlreq@undefcs}[1]{%
-  \ifundef{#1}{\ClassError{jlreq}{Trying to delete \string#1\space even though it is not defined, may be a bug}{\@ehc}}{\undef{#1}}%
+  \ifundef{#1}{\ClassError{jlreq}{Trying to delete \string#1 even though it is not defined, may be a bug}{\@ehc}}{\undef{#1}}%
 }
 
 % クラスファイル内でしか使わないマクロをクラスファイル終了時に未定義にする
@@ -151,28 +152,26 @@
 }
 
 % @removeelementの括弧があっても動くかもしれない版
-% 次の変数を使う：\jlreq@tempa：消したいやつ，\jlreq@tempb：消していない分を放り込んでいく
 % #2から#1を消して#3に入れる
 \def\jlreq@helper@removeelement#1#2#3{%
   \begingroup
-    \def\jlreq@tempb{}%
-    \def\jlreq@tempa{#1}%
-    \jlreq@helper@removeelement@{#2}%
+    \edef\jlreq@tempa{\unexpanded{#1}}% 消したいやつ
+    \def\jlreq@tempb{}% 消していない分を放り込んでいく
+    \jlreq@tempatrue% 最初の\jlreq@tempbへの追加か．
+    \jlreq@helper@removeelement@#2,\jlreq@endmark,%
     \edef\jlreq@do{\unexpanded{\def#3}{\expandonce{\jlreq@tempb}}}%
   \expandafter\endgroup
   \jlreq@do
 }
-\def\jlreq@helper@removeelement@#1{%
-  \jlreq@helper@dividebycomma{#1}%
-  \ifx\jlreq@resulta\jlreq@tempa\else
-    \ifx\jlreq@tempb\@empty
-      \edef\jlreq@tempb{\expandonce{\jlreq@resulta}}%
-    \else
-      \eappto\jlreq@tempb{,\expandonce{\jlreq@resulta}}%
-    \fi
-  \fi
-  \ifjlreq@result\expandafter\@firstofone\else\expandafter\@gobble\fi
-    {\expandafter\jlreq@helper@removeelement@\expandafter{\jlreq@resultb}}%
+\def\jlreq@helper@removeelement@#1,{%
+  \jlreq@ifendmark{#1}{}{%
+    \edef\@tempa{\unexpanded{#1}}%
+    \ifx\jlreq@tempa\@tempa\expandafter\@gobble\else\expandafter\@firstofone\fi{%
+      \eappto\jlreq@tempb{\ifjlreq@tempa\else,\fi\unexpanded{#1}}%
+      \jlreq@tempafalse
+    }%
+    \jlreq@helper@removeelement@
+  }%
 }
 
 % 空白を無視しない\@ifnextchar
@@ -211,12 +210,6 @@
   \fi
 }
 
-% vbox #1の最初を\jlreq@resultboxに入れる
-% #1は消える
-\newcommand*{\jlreq@getfirstbox}[1]{%
-  \loop\ifdim\dimexpr\dp#1+\ht#1=0pt\relax\else\jlreq@getlastbox{#1}\repeat
-}
-
 % 簡易なkeyvalのパース．
 % \jlreq@parsekeyval*[family=jlreq@key]{ % *ありは\setkeys*を使う
 %  {key}{\def\val{#1}}
@@ -297,6 +290,7 @@
 %   {default} % ここは#1を受け付けない（パラメータトークンを受け付けたい場合のため）．
 %} -> abcd
 % 文字列比較→\edefして比較する
+% 第一引数は\jlreq@tempaに入れておく．
 \long\def\jlreq@helper@switch@executeoption#1[#2]{%
   \begingroup
     \def\jlreq@do##1{#2}%
@@ -307,32 +301,30 @@
 \long\def\jlreq@switch#1#2{%
   \begingroup
     \let\jlreq@do\@undefined
-    \edef\jlreq@tempa{#1}%
-    \expandafter\jlreq@helper@switch@\expandafter{\jlreq@tempa}#2\jlreq@endmark
+    \edef\jlreq@tempa{#1}% ループ中ずっと保存する
+    \jlreq@helper@switch@#2\jlreq@endmark
     \ifx\jlreq@do\@undefined
       \def\jlreq@do{\@ifnextchar[{\jlreq@helper@switch@executeoption{#1}}{}}%
     \else
-      \edef\jlreq@do{\expandonce{\jlreq@do}\unexpanded{\@ifnextchar[{\jlreq@helper@removeoption}{}}}%
+      \appto\jlreq@do{\@ifnextchar[{\jlreq@helper@removeoption}{}}%
     \fi
   \expandafter\endgroup
   \jlreq@do
 }
-\long\def\jlreq@helper@switch@#1#2{%
-  \jlreq@ifendmark{#2}{}{\jlreq@helper@switch@@{#1}{#2}}%
+\long\def\jlreq@helper@switch@#1{%
+  \jlreq@ifendmark{#1}{}{\jlreq@helper@switch@@{#1}}%
 }
 
-\long\def\jlreq@helper@switch@@#1#2#3{%
-  \jlreq@ifendmark{#3}{%
-    \edef\jlreq@do{\unexpanded{#2}}%
+\long\def\jlreq@helper@switch@@#1#2{%
+  \jlreq@ifendmark{#2}{%
+    \edef\jlreq@do{\unexpanded{#1}}%
   }{%
-    \def\jlreq@tempa{#1}% 最初に\edefで展開済み
-    \edef\jlreq@tempb{#2}%
-    \ifx\jlreq@tempa\jlreq@tempb\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
-    {%
-      \edef\jlreq@do{\unexpanded{#3}}%
+    \edef\jlreq@tempb{#1}%
+    \ifx\jlreq@tempa\jlreq@tempb\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi{%
+      \edef\jlreq@do{\unexpanded{#2}}%
       \jlreq@deleteuntileendmark
     }{%
-      \jlreq@helper@switch@{#1}%
+      \jlreq@helper@switch@
     }%
   }%
 }
@@ -356,24 +348,14 @@
   \global\jlreq@currentpage=\zref@extractdefault{jlreq@currentpage.\the\jlreq@zref@reference@count}{jlreq@page}{\c@page}\relax
 }
 
-% 現在の段組位置を得る
-\zref@newprop*{jlreq@firstcolumn}[1]{\if@firstcolumn 1\else 0\fi}
-\zref@addprop{main}{jlreq@firstcolumn}
-\newif\ifjlreq@firstcolumn
-\newcommand*{\jlreq@setcurrentcolumn}{%
-  \global\advance\jlreq@zref@reference@count by 1
-  \zref@labelbyprops{jlreq@currentcolumn.\the\jlreq@zref@reference@count}{jlreq@firstcolumn}%
-  \ifnum\zref@extractdefault{jlreq@currentcolumn.\the\jlreq@zref@reference@count}{jlreq@firstcolumn}{1}=1 \global\jlreq@firstcolumntrue\else \global\jlreq@firstcolumnfalse\fi
-}
-
 \def\jlreq@saveoriginalcs#1{%
-  \@ifundefined{#1}{%
-    \ClassError{jlreq}{Trying to save \expandafter\string\csname #1\endcsname\space but it's not defined, may be a bug}{\@ehc}%
-  }{}%
-  \@ifundefined{jlreq@original@#1}{}{%
-    \ClassError{jlreq}{Trying to save \expandafter\string\csname #1\endcsname\space twice, may be a bug}{\@ehc}%
-  }%
-  \expandafter\expandafter\expandafter\let\expandafter\expandafter\csname jlreq@original@#1\endcsname\csname #1\endcsname
+  \ifx#1\relax
+    \ClassError{jlreq}{Trying to save \string#1 but it's not defined, may be a bug}{\@ehc}%
+  \fi
+  \expandafter\ifx\csname jlreq@original@\expandafter\@gobble\string#1\endcsname\relax\else
+    \ClassError{jlreq}{Trying to save \string#1 twice, may be a bug}{\@ehc}%
+  \fi
+  \expandafter\let\csname jlreq@original@\expandafter\@gobble\string#1\endcsname=#1
 }
 \def\jlreq@useoriginalcs#1{%
   \ifcsname jlreq@original@\expandafter\@gobble\string#1\endcsname\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
@@ -552,7 +534,7 @@
 %.. 段間
 \newcommand*{\jlreq@option@column@gap}{2zw}
 \jlreq@aftercls@addtodeletecs{\jlreq@option@column@gap}
-\DeclareOptionX{column_gap}{\renewcommand*{\jlreq@option@column@gap{#1}}}
+\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}
@@ -576,18 +558,18 @@
 \DeclareOptionX{sidenote_length}{\renewcommand*{\jlreq@option@sidenote@length}{#1}}
 
 %.. もろもろ
-\newif\if@restonecol \@restonecolfalse
-\newif\if@titlepage \@titlepagefalse
+\newif\if@restonecol\@restonecolfalse
+\newif\if@titlepage\@titlepagefalse
 \newif\ifjlreq@option@titlepage \jlreq@option@titlepagefalse % titlepageかnotitlepageかが指定された
-\newif\if@landscape \@landscapefalse
+\newif\if@landscape\@landscapefalse
 \newif\if@tate \@tatefalse
 \jlreq@DeclareOption{landscape}{\@landscapetrue}
 \jlreq@DeclareOption{tombo}{%
-  \tombowtrue \tombowdatefalse
+  \tombowtrue\tombowdatefalse
   \setlength{\@tombowwidth}{.1\p@}%
   \maketombowbox}
 \jlreq@DeclareOption{mentuke}{%
-  \tombowtrue \tombowdatefalse
+  \tombowtrue\tombowdatefalse
   \setlength{\@tombowwidth}{\z@}%
   \maketombowbox}
 \jlreq@DeclareOption{tate}{\@tatetrue}
@@ -615,11 +597,11 @@
 
 \ExecuteOptionsX{article_type=article,paper=a4,open_bracket_pos=zenkaku_tentsuki,onecolumn,final}
 % \@removeelementを一旦置き換えてから\ProcessOptionsXを実行する
-\let\jlreq@original@@removeelement=\@removeelement
+\let\jlreq@temporary@original@@removeelement=\@removeelement
 \let\@removeelement=\jlreq@helper@removeelement
 \ProcessOptionsX\relax
-\let\@removeelement=\jlreq@original@@removeelement
-\let\jlreq@original@@removeelement=\@undefined
+\let\@removeelement=\jlreq@temporary@original@@removeelement
+\let\jlreq@temporary@original@@removeelement=\@undefined
 
 \ifjlreq@option@titlepage\else
   \ifthenelse{\equal{\jlreq@article@type}{article}}{\@titlepagefalse}{\@titlepagetrue}
@@ -669,8 +651,10 @@
 % \jlreq@ifprimitive#1#2#3: #1がprimitiveならば#2を，そうでなければ#3を実行する
 % （\if(pdf)primitiveを避けるようにしている．）
 \def\jlreq@ifprimitive#1{%
-  \edef\@tempa{\string#1}%
-  \edef\@tempb{\meaning#1}%
+  \begingroup
+    \edef\@tempa{\string#1}%
+    \edef\@tempb{\meaning#1}%
+  \expandafter\endgroup
   \ifx\@tempa\@tempb\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
 }
 % エンジンの設定
@@ -693,10 +677,6 @@
   \directlua{jlreq = {}}
 \fi
 
-\if@tate
-  \RequirePackage{atbegshi}
-\fi
-
 % (u)pLaTeXの場合ここで初めて\epTeXinputencodingが発行されるので，
 % これ以前には和文は使えない．
 \ifx l\jlreq@engine\else
@@ -709,8 +689,6 @@
   \AtBeginDocument{\tate\message{《縦組モード》}\adjustbaseline}
 \fi
 
-
-
 % \jlreq@gol(Gyo Okuri Length), \jlreq@mol (Moji Okuri Length)を定義
 \let\jlreq@gol=\zh
 \let\jlreq@mol=\zw
@@ -877,10 +855,12 @@
 % \jlreq@fixjfm<次の文字>の形で使う．
 % jlreq@lastnodecharに入っている値と次のトークン（\futureletで得る）の間に入るJFMグルー等を挿入する
 \newcommand*{\jlreq@fixjfm}{%
-  \ifnum\jlreq@lastnodechar>-1
-    \def\@tempa{\futurelet\jlreq@nextchar\jlreq@insertjfm}%
-  \else\def\@tempa{}\fi
-  \@tempa
+  \begingroup
+    \ifnum\jlreq@lastnodechar>-1
+      \def\jlreq@do{\futurelet\jlreq@nextchar\jlreq@insertjfm}%
+    \else\def\jlreq@do{}\fi
+  \expandafter\endgroup
+  \jlreq@do
 }
 % \jlreq@nextcharと\jlreq@lastnodecharの間のJFMグルーを挿入
 \def\jlreq@insertjfm{%
@@ -908,7 +888,7 @@
 \else
   \newcommand*{\jlreq@divide}[2]{%
     \begingroup
-      \@tempdima=#1\relax\@tempdimb=#2\relax
+      \@tempdima=\dimexpr#1\relax\@tempdimb=\dimexpr#2\relax
       % 分母を正にする
       \ifdim\@tempdimb<0pt \@tempdima=-\@tempdima\@tempdimb=-\@tempdimb\fi
       % \jlreq@tempdima*\@tempdimb <= \@tempdima < (\jlreq@tempdima + 1)*\@tempdimb
@@ -1222,8 +1202,8 @@
   \directlua{jlreq.open_bracket_pos = [[\jlreq@open@bracket@pos]]}
   \ifjlreq@burasage\directlua{jlreq.burasage = true}\else\directlua{jlreq.burasage = false}\fi
   % \item後の行頭括弧のために仕込み．
-  \jlreq@saveoriginalcs{list}
-  \jlreq@saveoriginalcs{endlist}
+  \jlreq@saveoriginalcs{\list}
+  \jlreq@saveoriginalcs{\endlist}
   \pretocmd{\list}{\jlreq@pushhook@postpar{\ltjfakeparbegin}}{}{}
   \apptocmd{\endlist}{\jlreq@pophook@postpar}{}{}
 \else
@@ -1254,14 +1234,18 @@
 % スタックに積まれたものは\jlreq@pophook@postparで復帰できる
 \def\jlreq@pushhook@postpar#1{%
   \advance\jlreq@count@listnest by 1
-  \def\@tempa{\SavePostHook{par}}%
-  \expandafter\@tempa\csname jlreq@save@posthook@par \the\jlreq@count@listnest\endcsname
+  \begingroup
+    \edef\jlreq@do{\unexpanded{\SavePostHook{par}}{\expandonce{\csname jlreq@save@posthook@par@\the\jlreq@count@listnest\endcsname}}}%
+  \expandafter\endgroup
+  \jlreq@do
   \PushPostHook{par}{#1}%
 }
 \def\jlreq@pophook@postpar{%
-  \def\@tempa{\RestorePostHook{par}}%
-  \expandafter\@tempa\csname jlreq@save@posthook@par \the\jlreq@count@listnest\endcsname
-  \expandafter\let\csname jlreq@save@posthook@par \the\jlreq@count@listnest\endcsname=\@undefined
+  \begingroup
+    \edef\jlreq@do{\unexpanded{\RestorePostHook{par}}{\expandonce{\csname jlreq@save@posthook@par@\the\jlreq@count@listnest\endcsname}}}%
+  \expandafter\endgroup
+  \jlreq@do
+  \expandafter\let\csname jlreq@save@posthook@par@\the\jlreq@count@listnest\endcsname=\@undefined
   \advance\jlreq@count@listnest by -1
 }
 
@@ -1380,9 +1364,9 @@
   \ifcsname jlreq@jaspace@#1\endcsname\csname jlreq@jaspace@#1\endcsname
   \else\ClassError{jlreq}{unknown jaspace: #1}{\@ehc}\fi
 }
-\def\jlreq@jaspace@zenkaku{\hskip \glueexpr 1\zw\relax}
-\def\jlreq@jaspace@nibu{\hskip \glueexpr .5\zw\relax}
-\def\jlreq@jaspace@shibu{\hskip \glueexpr .25\zw\relax}
+\def\jlreq@jaspace@zenkaku{\hskip\glueexpr 1\zw\relax}
+\def\jlreq@jaspace@nibu{\hskip\glueexpr .5\zw\relax}
+\def\jlreq@jaspace@shibu{\hskip\glueexpr .25\zw\relax}
 
 % 区切り約物．\？ みたいな命令を作る．直後の空きが自動で入る．
 % \？*とすると文中の？として扱われる．
@@ -1431,7 +1415,7 @@
 
 %.. 文字サイズ変更
 \def\jlreq@setfontsizehook{}
-\jlreq@saveoriginalcs{set@fontsize}
+\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\zw}\fi}
 \ifx l\jlreq@engine
@@ -1456,21 +1440,25 @@
 \fi
 
 % \jafontsize
-\def\@tempa#1{
-  \newcommand*{\jafontsize}[2]{%
-    \begingroup
-      \jlreq@iffloat{##1}{%
-        \edef\jlreq@do{\noexpand\fontsize{\strip@pt\dimexpr#1\dimexpr##1pt\relax\relax}}%
-      }{%
-        \edef\jlreq@do{\noexpand\fontsize{\the\dimexpr#1\dimexpr##1\relax\relax}}%
-      }%
-    \expandafter\endgroup
-    \jlreq@do{##2}%
+\ifdim\jlreq@fontsize=\jlreq@jafontsize
+  \let\jafontsize=\fontsize
+\else
+  \def\@tempa#1{
+    \DeclareRobustCommand*{\jafontsize}[2]{%
+      \begingroup
+        \jlreq@iffloat{##1}{%
+          \edef\jlreq@do{\noexpand\fontsize{\strip@pt\dimexpr#1\dimexpr##1pt\relax\relax}}%
+        }{%
+          \edef\jlreq@do{\noexpand\fontsize{\the\dimexpr#1\dimexpr##1\relax\relax}}%
+        }%
+      \expandafter\endgroup
+      \jlreq@do{##2}%
+    }
   }
-}
-\jlreq@divide{\jlreq@fontsize}{\jlreq@jafontsize}
-\edef\jlreq@do{\noexpand\@tempa{\strip@pt\jlreq@resultdimen}}
-\jlreq@do
+  \jlreq@divide{\jlreq@fontsize}{\jlreq@jafontsize}
+  \edef\jlreq@do{\noexpand\@tempa{\strip@pt\jlreq@resultdimen}}
+  \jlreq@do
+\fi
 
 \renewcommand{\normalsize}{%
   \@setfontsize\normalsize{\jlreq@fontsize}{\jlreq@baselineskip}%
@@ -1673,12 +1661,12 @@
   \divide\textheight\baselineskip \multiply\textheight\baselineskip
   \addtolength{\textheight}{\topskip}
 \else
-  \setlength{\textheight}{\dimexpr\jlreq@option@number@of@lines\baselineskip - \baselineskip + \topskip\relax}
+  \setlength{\textheight}{\dimexpr\numexpr\jlreq@option@number@of@lines\relax\baselineskip - \baselineskip + \topskip\relax}
 \fi
 
 \ifx\jlreq@option@headfoot@verticalpos\@empty
   \if@tate\def\jlreq@option@headfoot@verticalpos{1zw}
-  \else\def\jlreq@option@headfoot@verticalpos{2zh}\fi
+  \else\def\jlreq@option@headfoot@verticalpos{2zw}\fi
 \fi
 \setlength{\headsep}{\jlreq@speciallength{\jlreq@option@headfoot@verticalpos}}
 \ifdim\headsep<1\zw\relax\jlreq@note{基本版面との上下方向の最低の空き量を，基本版面の文字サイズの全角アキとする (26.1.a)．}\fi
@@ -1777,6 +1765,24 @@
 \setlength{\maxdepth}{\dimexpr1.5\zw - \topskip\relax}
 
 %. 見出し関係 (4.1)
+% \clear***page
+\newcommand*{\cleartooddpage}{%
+  \clearpage
+  \ifodd\c@page\else
+    \hbox{}%
+    \newpage
+    \if@twocolumn\hbox{}\newpage\fi
+  \fi
+}
+\newcommand*{\cleartoevenpage}{%
+  \clearpage
+  \ifodd\c@page
+    \hbox{}%
+    \newpage
+    \if@twocolumn\hbox{}\newpage\fi
+  \fi
+}
+
 % 同行見出し以外では，jlreq@heading@maketoc@<命令名>が\tableofcontents用の出力をするために呼び出される．
 % #1=*または空（見出し命令に*がついていたかで分岐），#2=ラベル，#3=running head
 % デフォルトでは\<命令名>markと\addcontentslineが必要ならば呼ばれる．
@@ -1836,7 +1842,7 @@
     \let\jlreq@contents@label@format=\@undefined
     \let\jlreq@format=\@undefined
     \edef\jlreq@label@format{\expandonce{\csname the#1\endcsname}}%
-    \def\jlreq@heading@clearpage{\cleardoublepage}%
+    \def\jlreq@heading@clearpage{\clearpage\hbox{}\clearpage}%
     \def\jlreq@pagestyle{empty}%
     \jlreq@parsekeyval[DeclareTobiraHeading:#1]{
       {label_format}{\def\jlreq@label@format{##1}}
@@ -1845,7 +1851,7 @@
       {type}[han,naka]{%
         \jlreq@switch{##1}{
           {han}{\def\jlreq@heading@clearpage{\clearpage}}
-          {naka}{\def\jlreq@heading@clearpage{\cleardoublepage}}
+          {naka}{\def\jlreq@heading@clearpage{\clearpage\hbox{}\clearpage}}
         }%
       }
     }{#3}%
@@ -1880,7 +1886,8 @@
         \unexpanded{\if@restonecol\twocolumn\fi}%
       }%
       \noexpand\def\expandonce{\csname #1\endcsname}{%
-        \unexpanded{\if@twocolumn\onecolumn\@restonecoltrue\else\@restonecolfalse\fi\cleardoublepage}%
+        % 改丁．これでよいのかな．
+        \unexpanded{\if@twocolumn\onecolumn\@restonecoltrue\else\@restonecolfalse\fi\cleartooddpage}%
         \ifx\jlreq@pagestyle\@empty\else\noexpand\thispagestyle{\expandonce{\jlreq@pagestyle}}\fi
         \noexpand\secdef{\expandonce{\csname jlreq@TobiraHeading@start@#1\endcsname}}{\expandonce{\csname jlreq@TobiraHeading@start@s@#1\endcsname}}}%
     }%
@@ -1969,7 +1976,7 @@
 \expandafter\def\expandafter\jlreq@BlockHeading@start@afterheading@@\space{\jlreq@BlockHeading@start@afterheading}
 \def\jlreq@BlockHeading@start@afterheading@@@{%
   \def\jlreq@do{\jlreq@BlockHeading@spaces@output}%
-  \expandafter\@for\expandafter\@tempa\expandafter:\expandafter=\jlreq@BlockHeading@allheadings\do{%
+  \@for\@tempa:=\jlreq@BlockHeading@allheadings\do{%
     \expandafter\ifx\csname\@tempa\endcsname\jlreq@nextchar\def\jlreq@do{}\fi
   }%
   % \jlreq@BlockHeading@HeadingSpaces@ignoretokens内のものは特別扱いする
@@ -2181,7 +2188,7 @@
       {before_space}{\def\jlreq@before@space{##1}}
       {after_space}{\def\jlreq@after@space{##1}}
       {before_lines}{%
-        \jlreq@iffirsttoken{##1}{*}%
+        \jlreq@iffirsttoken@ignorespaces{##1}{*}%
           {\edef\jlreq@before@lines{s:\expandonce{\@gobble ##1}}}%
           {\def\jlreq@before@lines{a:##1}}%
       }
@@ -2236,6 +2243,7 @@
     \newif\ifjlreq@subtitle@break\jlreq@subtitle@breaktrue
     \def\jlreq@subtitle@indent{1\zw}%
     \def\jlreq@column@spanning{false}%
+    \newif\ifjlreq@column@spanning@possible\jlreq@column@spanning@possiblefalse
     % a,bみたいなのをaとbにわける．カンマがなければbは空．引数を{a}{b}として##2を呼び出す．
     \def\jlreq@parsecomma##1##2{%
       \def\jlreq@tempa####1####2{##2}%
@@ -2298,12 +2306,14 @@
           {false}{\def\jlreq@allowbreak@evenpage{*}}
         }%
       }
-      {pagebreak}[clearpage,cleardoublepage,clearcolumn,nariyuki]{%
+      {pagebreak}[clearpage,cleardoublepage,clearcolumn,nariyuki,begin_with_odd_page,begin_with_even_page]{%
         \jlreq@switch{##1}{
-          {clearpage}{\def\jlreq@pagebreak{\clearpage}}
-          {cleardoublepage}{\def\jlreq@pagebreak{\cleardoublepage}}
-          {clearcolumn}{\if@twocolumn\def\jlreq@pagebreak{\newpage}\else\def\jlreq@pagebreak{}\fi}
-          {nariyuki}{\def\jlreq@pagebreak{}}
+          {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}\jlreq@column@spanning@possibletrue}
+          {begin_with_odd_page}{\def\jlreq@pagebreak{\cleartooddpage}\jlreq@column@spanning@possibletrue}
+          {nariyuki}{\def\jlreq@pagebreak{}\jlreq@column@spanning@possiblefalse}
         }%
       }
       % 後々数字を受け付けるようになったりするかもしれないので……
@@ -2326,10 +2336,10 @@
     \def\jlreq@do{}% 初期化．これに最終処理を入れていく．
     % 入力チェック
     \ifthenelse{\equal{\jlreq@column@spanning}{true}}{%
-      \expandafter\ifx\jlreq@pagebreak\clearpage\relax\else\expandafter\ifx\jlreq@pagebreak\cleardoublepage\relax\else
-        \ClassWarningNoLine{jlreq}{column_spanning can be used only with pagebreak=clearpage or pagebreak=cleardoublepage (in BlockHeading #1)}%
+      \ifjlreq@column@spanning@possible\else
+        \ClassWarningNoLine{jlreq}{column_spanning can be used only with `pagebreak=nariyuki' or `pagebreak=clearcolumn' (in BlockHeading #1)}%
         \def\jlreq@column@spanning{false}%
-      \fi\fi
+      \fi
     }{}%
     \edef\jlreq@format{\expandonce{\jlreq@font}\expandonce{\jlreq@format}}%
     % 空き量などの調整を含んだラベル
@@ -2461,7 +2471,7 @@
 \newcommand{\SetBlockHeadingSpaces}[1]{%
   \begingroup
     % 現段階の情報をクリアする
-    \expandafter\@for\expandafter\jlreq@tempa\expandafter:\expandafter=\jlreq@BlockHeading@spaces@headingslist\do{%
+    \@for\jlreq@tempa:=\jlreq@BlockHeading@spaces@headingslist\do{%
       \expandafter\let\csname jlreq@BlockHeading@spaces@setlist@\jlreq@tempa\endcsname=\@undefined
     }%
     \def\jlreq@BlockHeading@spaces@headingslist{}%
@@ -2485,7 +2495,7 @@
   \jlreq@ifendmark{#2}{}{%
     \def\jlreq@headings{}% 見出し名リスト
     \jlreq@BlockHeading@gyodori@parsekeyval[BlockHeadingSpaces]{#1}{}{}{}%
-    \edef\jlreq@totalset{\expandonce{\jlreq@result}}% 上の#1に対応する設定
+    \let\jlreq@totalset=\jlreq@result% 上の#1に対応する設定
     \def\jlreq@set{}% 個々の設定
     \def\jlreq@lastdimen{}% 最後の寸法
     \def\jlreq@do##1##2##3{%
@@ -2522,6 +2532,7 @@
       \expandafter\jlreq@SetBlockHeadingSpaces@@@@\@tempa{\jlreq@endmark}%
     }{%
       \ifjlreq@tempa
+        % 最初が寸法なので，全体の設定（\jlreq@totalset）に組み込む．
         \def\jlreq@do##1##2##3{%
           \edef\jlreq@totalset{{r:\expandonce{\@tempa}}{\unexpanded{##2}}{\unexpanded{##3}}}%
         }%
@@ -2540,7 +2551,7 @@
   }{}%
   \jlreq@ifendswith{#1}{*}{{%
     \def\@tempa_##1*{\def\@tempa{##1}}%
-    \@tempa#1
+    \@tempa#1%
     \ClassWarning{jlreq}{The heading name `\@gobble #1' ends with `*'. Do you mean `\@tempa{*}'? (in SetBlockHeadingSpaces)}%
   }}{}%
   \appto\jlreq@headings{#1}%
@@ -2655,12 +2666,11 @@
       }\unexpanded{{#8}{#9}}%
     }}%
   }%
-  \edef\jlreq@do{\unexpanded{\appto\jlreq@result}{%
+  \eappto\jlreq@result{%
     \csexpandonce{jlreq@BlockHeading@spaces@current@before@\the\jlreq@tempcnta}%
     \jlreq@tempb
     \csexpandonce{jlreq@BlockHeading@spaces@current@after@\the\jlreq@tempcnta}%
-  }}%
-  \jlreq@do
+  }%
 }
 
 % 連続見出しスペース調整用のデータをすべてクリアする
@@ -2695,23 +2705,26 @@
 }
 % {1 = 命令名}{2 = レベル}{3 = *}{4 = running head}{5 = 見出し}{6 = ラベルフォーマット}{7 = ラベルありフォーマット}{8 = ラベルなしフォーマット}
 \long\def\jlreq@RuninHeading@start@@#1#2#3#4#5#6#7#8{%
-  \ifnum0\jlreq@ifempty{#3}{}{1}\ifnum #2>\c@secnumdepth 1\fi>0
-    \def\jlreq@tempa##1{#8}%
-  \else
-    \refstepcounter{#1}%
-    \def\jlreq@tempa##1{#7}%
-  \fi
-  \par
-  \edef\jlreq@do{%
-    \noexpand\everypar{%
-      \unexpanded{\everypar{}}%
-      \unexpanded{{\setbox\jlreq@tempboxa\lastbox}}%
-      \noexpand\begingroup
-        \expandonce{\jlreq@tempa{#5}}%
-        \expandonce{\csname jlreq@heading@maketoc@#1\endcsname{#3}{#6}{#4}}%
-      \noexpand\endgroup
+  \begingroup
+    \def\jlreq@do{}%
+    \ifnum0\jlreq@ifempty{#3}{}{1}\ifnum #2>\c@secnumdepth 1\fi>0
+      \def\jlreq@tempa##1{#8}%
+    \else
+      \appto\jlreq@do{\refstepcounter{#1}}%
+      \def\jlreq@tempa##1{#7}%
+    \fi
+    \par
+    \eappto\jlreq@do{%
+      \noexpand\everypar{%
+        \unexpanded{\everypar{}}%
+        \unexpanded{{\setbox\jlreq@tempboxa\lastbox}}%
+        \noexpand\begingroup
+          \expandonce{\jlreq@tempa{#5}}%
+          \expandonce{\csname jlreq@heading@maketoc@#1\endcsname{#3}{#6}{#4}}%
+        \noexpand\endgroup
+      }%
     }%
-  }%
+  \expandafter\endgroup
   \jlreq@do
   \ignorespaces
 }
@@ -2773,10 +2786,11 @@
     \jlreq@heading@make@l@{#1}{#2}{\jlreq@label@format}%
     \edef\jlreq@do{%
       \expandonce{\jlreq@result}%
+      % パラメータトークンを含むので，\edefして\unexpandedで包む
       \noexpand\edef\expandonce{\csname #1\endcsname}{%
         \noexpand\unexpanded{%
           \unexpanded{\jlreq@hook@beforeheadings{#1}}%
-          \noexpand\jlreq@RuninHeading@start{#1}{#2}{\expandonce{\jlreq@label@format}}{\expandonce{\jlreq@format@wlabel}}{\expandonce{\jlreq@format@wolabel}}%
+          \unexpanded{\jlreq@RuninHeading@start{#1}{#2}}{\expandonce{\jlreq@label@format}}{\expandonce{\jlreq@format@wlabel}}{\expandonce{\jlreq@format@wolabel}}%
         }%
       }%
     }%
@@ -3021,11 +3035,6 @@
       subtitle_font={\jlreq@keepbaselineskip{\Large}}}
     \renewcommand{\thechapter}{\arabic{chapter}}
     \renewcommand{\thesection}{\thechapter.\arabic{section}}
-    \ifthenelse{\equal{\jlreq@article@type}{book}}{
-      \ModifyHeading{chapter}{pagebreak=cleardoublepage}
-    }{
-      \ModifyHeading{chapter}{pagebreak=clearpage}
-    }
   }
   \NewBlockHeading{section}{1}{font={\jlreq@keepbaselineskip{\Large\sffamily\bfseries}},lines=3,after_label_space=1\zw,second_heading_text_indent={-1\zw,1\zw},subtitle_font={\jlreq@keepbaselineskip{\normalsize}}}
   \NewBlockHeading{subsection}{2}{font={\jlreq@keepbaselineskip{\large\sffamily\bfseries}},lines=2,after_label_space=1\zw,second_heading_text_indent={-1\zw,1\zw},subtitle_font={\jlreq@keepbaselineskip{\small}}}
@@ -3037,7 +3046,11 @@
 \ifthenelse{\equal{\jlreq@article@type}{article}}{}{% book, report
   \if@openright
     \ModifyHeading{part}{type=naka}
-    \ModifyHeading{chapter}{pagebreak=cleardoublepage}
+    \if@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}
@@ -3178,8 +3191,8 @@
 \fi
 
 % \footnoteと\footnotemarkの前後に\jlreq@hook@prenote/\jlreq@hook@postnoteを入れる
-\jlreq@saveoriginalcs{footnote}
-\jlreq@saveoriginalcs{footnotemark}
+\jlreq@saveoriginalcs{\footnote}
+\jlreq@saveoriginalcs{\footnotemark}
 \def\footnote{%
   \jlreq@hook@prenote
   \@ifnextchar[{\jlreq@footnote@impl@woption}{\jlreq@footnote@impl@wooption}%
@@ -3189,47 +3202,84 @@
   \@ifnextchar[{\jlreq@footnotemark@impl@woption}{\jlreq@footnotemark@impl@wooption}%
 }
 \if@tate
-  % 縦組の傍注は，その見開き内に付いている合印に対応する注を，奇数ページの左端にそろえて配置する（4.2.6.a）．
-  % TODO: 多段組では最下段の左端にそろえて配置する．
+  % 縦組の傍注は，その見開き内に付いている合印に対応する注を，奇数ページの左端にそろえて配置する．多段組では最下段の左端にそろえて配置する．（4.2.6.a）
+  % 必要ならば\footnoteを\footnotemarkと\footnotetextにわけ，\footnotetextをアウトプット時まで遅延することで実現する．
   \def\jlreq@footnote@delayfootnoteslist{}
-  \preto\@outputpage{%
+  \preto\@opcol{%
     \expandafter\gdef\expandafter\jlreq@footnote@delayfootnoteslist\expandafter{\expandafter}%
     \jlreq@footnote@delayfootnoteslist
   }
-  \def\jlreq@footnote@delayfootnote@delay#1#2#3{%
-    \ifnum#1<1
-      \footnotetext[#2]{#3}%
+  % \jlreq@footnote@delayfootnote@delay#1#2#3：#1ページ目に\footnotetext[#2]{#3}を出す
+  % \jlreq@footnote@delayfootnote@page：何ページ目に\footnotetextを入れるかを\jlreq@resultcntに入れる．その場での場合は-1．
+  \if@twocolumn
+    \def\jlreq@footnote@delayfootnote@page{%
+      \jlreq@setcurrentpage
+      \jlreq@resultcnt=\numexpr\jlreq@currentpage\ifodd\jlreq@currentpage\else + 1\fi\relax
+      % このページに表示＆上の段処理済みだと\output内では間に合わない
+      \ifnum\jlreq@resultcnt=\value{page}\if@firstcolumn\else\jlreq@resultcnt=-1 \fi\fi
+    }
+    \long\def\jlreq@footnote@delayfootnote@delay#1#2#3{%
+      % 二段組みの場合は上段を組んだ直後に\footnotetextを挿入（そのページの下段に入る）
+      \ifnum 0\if@firstcolumn\else 1\fi\ifnum#1>\value{page}1\fi>0
+        \xappto\jlreq@footnote@delayfootnoteslist{\unexpanded{\jlreq@footnote@delayfootnote{#1}{#2}{#3}}}%
+      \else
+        \footnotetext[#2]{#3}%
+      \fi
+    }
+  \else
+    \def\jlreq@footnote@delayfootnote@page{%
+      \jlreq@setcurrentpage
+      \ifodd\jlreq@currentpage
+        \jlreq@resultcnt=-1
+      \else
+        \jlreq@resultcnt=\numexpr\jlreq@currentpage+1\relax
+      \fi
+    }
+    \long\def\jlreq@footnote@delayfootnote@delay#1#2#3{%
+      % 一段組の場合はその前のページを組んだ直後に\footnotetextを挿入．
+      \ifnum\numexpr#1 - 1\relax>\value{page}%
+        \xappto\jlreq@footnote@delayfootnoteslist{\unexpanded{\jlreq@footnote@delayfootnote{#1}{#2}{#3}}}%
+      \else
+        \footnotetext[#2]{#3}%
+      \fi
+    }
+  \fi
+  \def\jlreq@footnote@delayfootnote@immediate#1#2#3{%
+    \ifnum #1<\jlreq@currentpage
+      \xappto\jlreq@footnote@delayfootnoteslist{\unexpanded{\jlreq@footnote@delayfootnote{#1}{#2}{#3}}}%
     \else
-      \xappto\jlreq@footnote@delayfootnoteslist{\noexpand\jlreq@footnote@delayfootnote{\the\numexpr#1 - 1\relax}{\unexpanded{#2}}{\unexpanded{#3}}}%
+      \footnotetext[#2]{#3}%
     \fi
   }
-  \def\jlreq@footnote@delayfootnote@immediate#1#2#3{\footnotetext[#2]{#3}}%
   \let\jlreq@footnote@delayfootnote=\jlreq@footnote@delayfootnote@delay
   \def\jlreq@footnote@flushdelayfootnoteslist{%
-    \let\jlreq@footnote@delayfootnote=\jlreq@footnote@delayfootnote@immediate
-    \jlreq@footnote@delayfootnoteslist
-    \gdef\jlreq@footnote@delayfootnoteslist{}%
-    \let\jlreq@footnote@delayfootnote=\jlreq@footnote@delayfootnote@delay
+    \ifx\jlreq@footnote@delayfootnoteslist\@empty\else
+      \let\jlreq@footnote@delayfootnote=\jlreq@footnote@delayfootnote@immediate
+      \jlreq@setcurrentpage
+      \expandafter\gdef\expandafter\jlreq@footnote@delayfootnoteslist\expandafter{\expandafter}%
+      \jlreq@footnote@delayfootnoteslist
+      \let\jlreq@footnote@delayfootnote=\jlreq@footnote@delayfootnote@delay
+    \fi
   }
   \AtEndDocument{\jlreq@footnote@flushdelayfootnoteslist}
   \preto\newpage{\jlreq@footnote@flushdelayfootnoteslist}
   \long\def\jlreq@footnote@impl@woption[#1]#2{%
-    \jlreq@setcurrentpage
-    \ifodd\jlreq@currentpage
+    \jlreq@footnote@delayfootnote@page
+    \ifnum\jlreq@resultcnt=-1
       \jlreq@useoriginalcs{\footnote}[#1]{#2}%
     \else
       \jlreq@useoriginalcs{\footnotemark}[#1]%
-      \xappto\jlreq@footnote@delayfootnoteslist{\noexpand\jlreq@footnote@delayfootnote{\the\numexpr\jlreq@currentpage - \value{page}\relax}{\unexpanded{#1}}{\unexpanded{#2}}}%
+      \xappto\jlreq@footnote@delayfootnoteslist{\noexpand\jlreq@footnote@delayfootnote{\the\jlreq@resultcnt}{\unexpanded{#1}}{\unexpanded{#2}}}%
     \fi
     \jlreq@hook@postnote
   }
   \long\def\jlreq@footnote@impl@wooption#1{%
-    \jlreq@setcurrentpage
-    \ifodd\jlreq@currentpage
+    \jlreq@footnote@delayfootnote@page
+    \ifnum\jlreq@resultcnt=-1
       \jlreq@useoriginalcs{\footnote}{#1}%
     \else
       \jlreq@useoriginalcs{\footnotemark}%
-      \xappto\jlreq@footnote@delayfootnoteslist{\noexpand\jlreq@footnote@delayfootnote{\the\numexpr\jlreq@currentpage - \value{page}\relax}{\the\value{footnote}}{\unexpanded{#1}}}%
+      \xappto\jlreq@footnote@delayfootnoteslist{\noexpand\jlreq@footnote@delayfootnote{\the\jlreq@resultcnt}{\the\value{footnote}}{\unexpanded{#1}}}%
     \fi
     \jlreq@hook@postnote
   }
@@ -3362,10 +3412,11 @@
     \par
   \fi
 }
+% 4.2.4.b
 \jlreq@endnote@indent=2\jlreq@mol
-% 二行目以降を全角分下げる
+% 二行目以降を全角分下げる（4.2.4.d：TODO: 選択できるべき）
 \newcommand{\@makeendtext}[1]{\parindent 1\jlreq@mol
-    \hskip-1\jlreq@mol\csname\jlreq@endnotemarkname\endcsname\hskip 1\jlreq@mol#1}% 見出し出力と一文字分の空き
+    \hskip-1\jlreq@mol\csname\jlreq@endnotemarkname\endcsname\hskip 1\jlreq@mol#1}% 見出し出力と一文字分の空き（4.2.4.c）
 \def\@makeendmark{\@makefnmark}
 
 % \theendnoteの出力を仕込む
@@ -3419,7 +3470,6 @@
 \jlreqsetup{endnote_position=headings}
 \AtEndDocument{\theendnotes}
 
-\def\jlreq@sidenotemarkname{@thefnmark}% 合印用番号を一時的に入れるマクロ名
 
 % (1) \footnoteとかと同じ形式 sidenote_type=number
 % (2) 文中にマークを入れて，傍注には見出しが入る sidenote_type=symbol
@@ -3431,6 +3481,7 @@
 % \marginparwidth>0ptの時のみ定義する
 \ifdim\marginparwidth>0pt \expandafter\@firstofone\else\expandafter\@gobble\fi
 {
+  \def\jlreq@sidenotemarkname{@thefnmark}% 合印用番号を一時的に入れるマクロ名
   \long\def\@sidenotetext#1{%
     \marginpar{\reset@font\footnotesize
       \color@begingroup
@@ -3799,7 +3850,7 @@
 
 % レベル#1より低いレベルの見出しの**markを\markboth{}{}にする
 \def\jlreq@pagestyle@setclearmark#1{%
-  \expandafter\@for\expandafter\@tempa\expandafter:\expandafter=\jlreq@heading@allheadings\do{%
+  \@for\@tempa:=\jlreq@heading@allheadings\do{%
     \@ifundefined{\@tempa}{}{%
       \ifnum\csname jlreq@heading@level@\@tempa\endcsname<#1\relax\expandafter\def\csname\@tempa mark\endcsname##1{\markboth{}{}}\fi
     }%
@@ -3810,7 +3861,10 @@
 % 要するに\ps@***に\sectionmarkを定義するように仕込む．
 % 常にodd=rightmark，even=leftmarkになる．
 % 場所指定は奇数ページの方．偶数ページは反対になる．
-% mark_format={_chapter={第\thechapter 章\quad #1}}のような形．odd=とかeven=とかも仕込めるようにしたけど
+% mark_format={_chapter={第\thechapter 章\quad #1}}のような形．
+% このとき\ps@***で\def\chaptermark#1{\markboth{第\thechapter 章\quad #1}{}}とか定義される．
+% \markbothか\markrightかはoddかevenかに依存．
+% odd=とかeven=とかも仕込めるようにしたけど
 % あまり意味がない気がしてきた．oddやevenが優先される．
 \newcommand*{\DeclarePageStyle}[2]{%
   \expandafter\edef\csname jlreq@pagestyle@setting@#1\endcsname{\unexpanded{#2}}%
@@ -3839,19 +3893,20 @@
       {mark_format}{\edef\jlreq@mark@format{\unexpanded{##1}}}
       {command}{\edef\jlreq@command{\unexpanded{##1}}}
       {gap}{\def\jlreq@gap{##1}}
+      % trueにすると，\ps@***実行時にまず\***markを全て\@gobbleにする．
       {clear_markcommand}[true,false]{\csname jlreq@clearmarkcommand##1\endcsname}
     }{#2}%
-    % 見出しを出す場合：evenに章などの高いレベルの見出しを出す（2.6.3.a）
     \def\jlreq@markdefinition{}%
-    \def\jlreq@even@running@head@level{}%
-    \def\jlreq@markdefinition{}%
-    % _***な指定な時に，
+    % \jlreq@makemark{odd/even}running_headの中身\jlreq@endmark\jlreq@endmark
+    % として使う．running_headの中身が_から始まる時に，次を実行する．
     % * \jlreq@[even/odd]@running@headを\leftmarkや\rightmarkに書き換える
     % * \jlreq@markdefinitionに\***markを定義するマクロを入れる．
-    % また\jlreq@[even/odd]@running@head@levelに見出しのレベルを入れる．
-    % \jlreq@makemark{odd/even}running_headの中身\jlreq@endmark\jlreq@endmark
+    % * \jlreq@[even/odd]@running@head@levelに見出しのレベルを入れる．
     \def\jlreq@makemark##1##2##3\jlreq@endmark{%
       \ifx_##2%
+        \@ifundefined{##2}{%
+          \ClassError{jlreq}{Unknown Heading `##2' (in PageStyle #1)}{\@ehc}%
+        }{}%
         \ifthenelse{\equal{##1}{even}}{%
           \def\jlreq@even@running@head{\leftmark}%
         }{%
@@ -3863,16 +3918,13 @@
         % mark_formatを調べる
         \def\jlreq@tempa####1{%
           \jlreq@tempafalse
-          \let\jlreq@result=\@undefined
+          \edef\jlreq@result{\expandonce{\csname the##3\endcsname}\noexpand\quad\unexpanded{########1}}%
           \jlreq@parsekeyval*{
             {##1}{\edef\jlreq@result{\unexpanded{########1}}\jlreq@tempatrue}
             {##2##3}{\ifjlreq@tempa\else\edef\jlreq@result{\unexpanded{########1}}\fi}
           }{####1}%
         }%
         \expandafter\jlreq@tempa\expandafter{\jlreq@mark@format}%
-        \ifx\jlreq@result\@undefined
-          \edef\jlreq@result{\expandonce{\csname the##3\endcsname}\noexpand\quad\unexpanded{####1}}%
-        \fi
         \ifthenelse{\equal{##1}{even}}{%
           \def\jlreq@markcommand{\markboth}%
           \def\jlreq@markcommandafter{{}}%
@@ -3887,6 +3939,7 @@
       \fi
       \jlreq@ifendmark{##2}{}{\@gobble}%
     }%
+    \def\jlreq@even@running@head@level{}%
     \def\@tempb{\jlreq@makemark{even}}%
     \expandafter\@tempb\jlreq@even@running@head\jlreq@endmark\jlreq@endmark
     \def\jlreq@odd@running@head@level{}%
@@ -3894,6 +3947,7 @@
     \expandafter\@tempb\jlreq@odd@running@head\jlreq@endmark\jlreq@endmark
     \ifx\jlreq@odd@running@head@level\@empty\else\ifx\jlreq@even@running@head@level\@empty\else
       \ifnum\jlreq@odd@running@head@level<\jlreq@even@running@head@level
+        % 見出しを出す場合：evenに章などの高いレベルの見出しを出す（2.6.3.a）
         \jlreq@note{偶数ページには奇数ページよりアウトラインレベルの高い見出しを入れる (ページスタイル #1内，2.6.3.a)．}%
       \fi
     \fi\fi
@@ -3944,7 +3998,7 @@
           \fi
         }%
       }%
-      % 左に配置するヘッダ．#1は柱の中身．（一回展開で正しくでてくる．）
+      % 左に配置するヘッダ．##1は柱の中身を入れたマクロ．（一回展開で正しくでてくる．）
       \def\jlreq@make@lefthead##1{%
         \jlreq@make@tatebox{##1}%
         \edef\jlreq@lefthead{%
@@ -4564,13 +4618,13 @@
     \def\jlreq@do{}%
     \def\jlreq@keyvallist{}%
     \@for\@tempa:=#1\do{%
-      \expandafter\jlreq@ifcontains\expandafter{\@tempa}{=}%
-        {\expandafter\appto\expandafter\jlreq@keyvallist\expandafter{\@tempa,}}%
-        {%
-          \@for\@tempb:=i,ii,iii,iv,v,vi\do{%
-            \eappto\jlreq@do{\noexpand\def\expandonce{\csname jlreq@itemization@beforeafter@space@\@tempb\endcsname}{\expandonce{\@tempa}}}%
-          }%
+      \expandafter\jlreq@ifcontains\expandafter{\@tempa}{=}{%
+        \expandafter\appto\expandafter\jlreq@keyvallist\expandafter{\@tempa,}%
+      }{%
+        \@for\@tempb:=i,ii,iii,iv,v,vi\do{%
+          \eappto\jlreq@do{\noexpand\def\expandonce{\csname jlreq@itemization@beforeafter@space@\@tempb\endcsname}{\expandonce{\@tempa}}}%
         }%
+      }%
     }%
     \def\jlreq@tempa{%
       \jlreq@parsekeyval{%
@@ -4590,16 +4644,16 @@
 \jlreqsetup{itemization_beforeafter_space={0pt,i=.5\baselineskip},itemization_itemsep=0pt}
 % enumerate, itemize用初期化
 \def\jlreq@init@list{%
-  \setlength{\labelwidth}{2\jlreq@mol}%
+  \setlength{\labelwidth}{2\zw}%
   \setlength{\partopsep}{0pt}%
   \setlength{\itemsep}{\dimexpr\jlreq@itemization@itemsep\relax}%
   \setlength{\parsep}{0pt}%
   \setlength{\listparindent}{\parindent}%
 % itemizeは直後ベタ，enumerateは直後全角空き．
   \ifthenelse{\equal{\@currenvir}{itemize}}{%
-    \setlength{\labelsep}{0\jlreq@mol}%
+    \setlength{\labelsep}{0\zw}%
   }{%
-    \setlength{\labelsep}{1\jlreq@mol}%
+    \setlength{\labelsep}{1\zw}%
   }%
   % \labelsepだけあけるのは一つ目（ラベルの直後）のみ
   \setlength{\itemindent}{\labelsep}%
@@ -4642,11 +4696,20 @@
   \renewcommand{\theenumii}{\jlreq@rensuji{\@arabic\c@enumii}}
   \renewcommand{\theenumiii}{\jlreq@rensuji{\@arabic\c@enumiii}}
   \renewcommand{\theenumiv}{\jlreq@rensuji{\@arabic\c@enumiv}}
+  \newcommand{\labelenumi}{\theenumi}
+  \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}
+  \renewcommand{\theenumiv}{\@Alph\c@enumiv}
+  \newcommand{\labelenumi}{\theenumi.}
+  \newcommand{\labelenumii}{(\theenumii)}
+  \newcommand{\labelenumiii}{\theenumiii.}
+  \newcommand{\labelenumiv}{\theenumiv.}
 \fi
-\newcommand{\labelenumi}{\theenumi}
-\newcommand{\labelenumii}{\theenumii}
-\newcommand{\labelenumiii}{\theenumiii}
-\newcommand{\labelenumiv}{\theenumiv}
 \renewcommand{\p@enumii}{\theenumi}
 \renewcommand{\p@enumiii}{\theenumi(\theenumii)}
 \renewcommand{\p@enumiv}{\p@enumiii\theenumiii}
@@ -4721,8 +4784,8 @@
 
 %. 表関係 4.4
 % 表内の行間を0にする（4.4.3.f）
-\jlreq@saveoriginalcs{tabular}
-\jlreq@saveoriginalcs{endtabular}
+\jlreq@saveoriginalcs{\tabular}
+\jlreq@saveoriginalcs{\endtabular}
 \preto\tabular{\begingroup\appto\@arrayparboxrestore{\baselineskip=0pt\lineskip=0pt}}
 \appto\endtabular{\endgroup}
 % 4.4.3.e
@@ -4829,14 +4892,14 @@
 
 % listoffigures
 \newcommand{\listoffigures}{%
-  \jlreq@top@contents=0
+  \jlreq@top@contents=-100
   \section*{\listfigurename}%
   \@mkboth{\listfigurename}{\listfigurename}%
   \@starttoc{lof}%
 }
 \newcommand*{\l@figure}{\@dottedtocline{1}{0\jlreq@gol}{2\jlreq@gol}}
 \newcommand{\listoftables}{%
-  \jlreq@top@contents=0
+  \jlreq@top@contents=-100
   \section*{\listtablename}%
   \@mkboth{\listtablename}{\listtablename}%
   \@starttoc{lot}%
@@ -4905,11 +4968,7 @@
   \newif\if@mainmatter
   \@mainmattertrue
   \newcommand*{\frontmatter}{%
-    \if@openright
-      \cleardoublepage
-    \else
-      \clearpage
-    \fi
+    \cleardoublepage
     \@mainmatterfalse
     \let\jlreq@pagestyle@atmain\jlreq@current@pagestyle
     \SaveHeading{chapter}{\jlreq@heading@chapter@atmain}%
@@ -4946,7 +5005,6 @@
 \ifthenelse{\equal{\jlreq@article@type}{article}}{
   \appto\appendix{%
     \setcounter{subsection}{0}%
-    \gdef\thesection{\@Alph\c@section}%
     \if@tate
       \def\thesection{\jlreq@rensuji{\Alph{section}}}%
     \else
@@ -5055,8 +5113,8 @@
   \jlreqsetup{year_style=seireki}
 \fi
 %.. 定理環境
-\jlreq@saveoriginalcs{@begintheorem}
-\jlreq@saveoriginalcs{@opargbegintheorem}
+\jlreq@saveoriginalcs{\@begintheorem}
+\jlreq@saveoriginalcs{\@opargbegintheorem}
 \def\@begintheorem#1#2{\topsep=\dimexpr\jlreq@theorem@beforeafter@space\relax
   \trivlist\labelsep=1\zw
   \itemindent=\dimexpr\jlreq@theorem@indent\relax
@@ -5066,11 +5124,11 @@
   \itemindent=\dimexpr\jlreq@theorem@indent\relax
   \item[\hskip \labelsep{\sffamily\bfseries #1\ #2（#3）}]}
 \AtEndOfPackageFile*{amsthm}{%
-  \jlreq@saveoriginalcs{proof}%
-  \jlreq@saveoriginalcs{endproof}%
+  \jlreq@saveoriginalcs{\proof}%
+  \jlreq@saveoriginalcs{\endproof}%
   \edef\jlreq@do{
     \unexpanded{\def\jlreq@proof[#1]}{%
-      \labelsep=1\zw
+      \unexpanded{\labelsep=1\zw}%
       \expandonce{\proof[{\reset@font\sffamily\bfseries #1\inhibitglue}\nopunct]}%
     }
   }
-- 
cgit v1.2.3

