\ProvidesClass{review-base}[2020/01/02]
\RequirePackage{ifthen}
\@ifundefined{Hy@Info}{% for jsbook.cls
  \RequirePackage[dvipdfmx,bookmarks=true,bookmarksnumbered=true]{hyperref}
  \RequirePackage[dvipdfmx]{pxjahyper}
  \newif\if@reclscover \@reclscovertrue
  \newcommand{\includefullpagegraphics}[2][]{%
    \thispagestyle{empty}%
    \begin{center}%
      \includegraphics[#1]{#2}%
    \end{center}}
  \def\review@coverimageoption{width=\textwidth,height=\textheight,keepaspectratio}
}{}
\ifthenelse{\equal{\review@texcompiler}{uplatex}}{%
\RequirePackage[deluxe,uplatex]{otf}%
}{%
\RequirePackage[deluxe]{otf}%
}
\RequirePackage{caption}
\RequirePackage{needspace}
\RequirePackage{suffix}
\RequirePackage[T1]{fontenc}\RequirePackage{textcomp}%T1/TS1
\RequirePackage{lmodern}
\RequirePackage[dvipdfmx]{graphicx}
\RequirePackage[dvipdfmx,table]{xcolor}%requires colortbl, array
\RequirePackage{framed}
\RequirePackage{wrapfig}
\definecolor{shadecolor}{gray}{0.9}
\definecolor{shadecolorb}{gray}{0.1}
\definecolor{reviewgreen}{rgb}{0,0.4,0}
\definecolor{reviewblue}{rgb}{0.2,0.2,0.4}
\definecolor{reviewred}{rgb}{0.7,0,0}
\definecolor{reviewdarkred}{rgb}{0.3,0,0}
\RequirePackage[utf8]{inputenc}
\RequirePackage{ascmac}
\RequirePackage{float}
\RequirePackage{alltt}
\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{amsthm}
\RequirePackage{bm}
\RequirePackage{tabularx}

%% if you use @<u>{} (underline), use jumoline.sty
\IfFileExists{jumoline.sty}{
\RequirePackage{jumoline}
}

\long\def\review@ifempty#1{\expandafter\ifx\expandafter\relax\detokenize{#1}\relax\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}

\newenvironment{shadedb}{%
  \def\FrameCommand{\fboxsep=\FrameSep \colorbox{shadecolorb}}%
  \MakeFramed {\FrameRestore}}%
 {\endMakeFramed}

\newcommand{\parasep}{\vspace*{3zh}}

\newcommand*\PDFDocumentInformation[1]{%
  \AtBeginShipoutFirst{\special{pdf:docinfo <<#1>>}}}
\@onlypreamble\PDFDocumentInformation

\PDFDocumentInformation{
  /Title    (\review@booktitlename)
  /Author   (\review@autnames)
  % /Subject  ()
  % /Keywords (,,)
  /Creator  (Re:VIEW \review@reviewversion, with LaTeX)
}

\RequirePackage{pxrubrica}
\@ifpackagelater{pxrubrica}{2017/04/20}{%
\rubysetup{J}}{%
\rubysetup{g}}

\ifthenelse{\equal{\review@documentclass}{utbook} \OR \equal{\review@documentclass}{tbook}}{%
\newcommand{\headfont}{\gtfamily\sffamily\bfseries}
\RequirePackage{plext}
}{%
}

\ifdefined\review@highlightlatex
  \ifthenelse{\equal{\review@highlightlatex}{listings}}{%
    \ifthenelse{\equal{\review@language}{ja}}{%
      \RequirePackage{listings,plistings}
    }{%
      \RequirePackage{listings}
    }%
  \renewcommand{\lstlistingname}{\review@intn@list}
  \lstset{%
    breaklines=true,%
    breakautoindent=false,%
    breakindent=0pt,%
    fontadjust=true,%
    backgroundcolor=\color{shadecolor},%
    frame=single,%
    framerule=0pt,%
    basicstyle=\ttfamily\scriptsize,%
    commentstyle=\color{reviewgreen},%
    identifierstyle=\color{reviewblue},%
    stringstyle=\color{reviewred},%
    keywordstyle=\bfseries\color{reviewdarkred},%
  }
  \lstnewenvironment{reviewemlistlst}[1][]{\lstset{#1}}{}
  \lstnewenvironment{reviewemlistnumlst}[1][]{\lstset{numbers=left, #1}}{}
  \lstnewenvironment{reviewlistlst}[1][]{\lstset{#1}}{}
  \lstnewenvironment{reviewlistnumlst}[1][]{\lstset{numbers=left, #1}}{}
  \lstnewenvironment{reviewsourcelst}[1][]{\lstset{#1}}{}
  \lstnewenvironment{reviewsourcenumlst}[1][]{\lstset{numbers=left, #1}}{}
  \lstnewenvironment{reviewcmdlst}[1][]{\lstset{backgroundcolor=\color{white}, frameround=tttt, frame=trbl, #1}}{}
  }{%
  }
\fi

\newenvironment{reviewimage}{%
  \begin{figure}
    \begin{center}}{%
    \end{center}
  \end{figure}}

\newenvironment{reviewdummyimage}{%
  \begin{figure}
    \begin{center}\begin{alltt}}{%
    \end{alltt}\end{center}
  \end{figure}}

\DeclareRobustCommand{\reviewincludegraphics}[2][]{%
  \includegraphics[#1]{#2}}

\newcommand{\reviewequationcaption}[1]{%
  \medskip{\small\noindent #1}}
\newenvironment{reviewequationblock}{\needspace{2\Cvs}}{}

\newenvironment{reviewlistblock}{\needspace{2\Cvs}}{}

\newenvironment{reviewemlist}{%
  \medskip\small\begin{shaded}\ifdefined\reviewlistxkanjiskip\xkanjiskip=\reviewlistxkanjiskip\fi\setlength{\baselineskip}{1.3zw}\begin{alltt}}{%
  \end{alltt}\end{shaded}}

\newenvironment{reviewlist}{%
  \begin{shaded}\small\ifdefined\reviewlistxkanjiskip\xkanjiskip=\reviewlistxkanjiskip\fi\setlength{\baselineskip}{1.3zw}\begin{alltt}}{%
  \end{alltt}\end{shaded}\par\vspace*{0.5zw}}

\newenvironment{reviewsource}{%
  \begin{shaded}\small\ifdefined\reviewlistxkanjiskip\xkanjiskip=\reviewlistxkanjiskip\fi\setlength{\baselineskip}{1.3zw}\begin{alltt}}{%
  \end{alltt}\end{shaded}\par\vspace*{0.5zw}}

\newenvironment{reviewcmd}{%
  \color{white}\medskip\small\ifdefined\reviewlistxkanjiskip\xkanjiskip=\reviewlistxkanjiskip\fi\begin{shadedb}\setlength{\baselineskip}{1.3zw}\begin{alltt}}{%
  \end{alltt}\end{shadedb}}

\newenvironment{reviewbox}{%
  \medskip\small\begin{framed}\ifdefined\reviewlistxkanjiskip\xkanjiskip=\reviewlistxkanjiskip\fi\setlength{\baselineskip}{1.3zw}\begin{alltt}}{%
  \end{alltt}\end{framed}}

\newenvironment{reviewtable}[1]{%
  \begin{center}\small\setlength{\baselineskip}{1.2zw}
    \begin{tabular}{#1}}{%
    \end{tabular}
  \end{center}}

\newenvironment{reviewcolumn}[1][]{%
     \begin{framed}
     \reviewcolumnhead{}{#1}
  }{%
     \end{framed}
  \vspace{2zw}}

\newcommand{\reviewcolumnhead}[2]{%
{\noindent\large \review@intn@columnhead{}: #2}}

\newcommand{\reviewtablecaption}[1]{%
  \caption{#1}}

\WithSuffix\newcommand\reviewtablecaption*[1]{%
  \caption*{#1}}

\newcommand\reviewimagecaption[1]{%
  \caption{#1}}

\newcommand{\reviewimgtablecaption}[1]{%
  \caption{#1}\vspace{-3mm}}

\newcommand{\reviewbackslash}[0]{%
  \textbackslash{}}

\newcommand{\reviewlistcaption}[1]{%
  \medskip{\small\noindent #1}\vspace*{-1.3zw}}

\newcommand{\reviewemlistcaption}[1]{%
  \medskip{\small\noindent #1}\vspace*{-1.3zw}}

\newcommand{\reviewsourcecaption}[1]{%
  \medskip{\small\noindent #1}\vspace*{-1.3zw}}

\newcommand{\reviewcmdcaption}[1]{%
  \medskip{\small\noindent #1}\vspace*{-1.3zw}}

\newcommand{\reviewindepimagecaption}[1]{%
  \begin{center}#1\end{center}}

\newcommand{\reviewboxcaption}[1]{%
  \medskip{\small\noindent #1}\vspace*{-1.3zw}}

\newcommand{\reviewimageref}[2]{\review@intn@image #1}
\newcommand{\reviewtableref}[2]{\review@intn@table #1}
\newcommand{\reviewlistref}[1]{\review@intn@list #1}
\newcommand{\reviewequationref}[1]{\review@intn@equation #1}
\newcommand{\reviewbibref}[2]{#1}
\newcommand{\reviewcolumnref}[2]{#1}
\newcommand{\reviewsecref}[2]{#1}

\newenvironment{reviewpart}{%
\setcounter{section}{0}%
\renewcommand{\thesection}{\thepart.\@arabic\c@section}%
}{}

\newcommand{\reviewminicolumntitle}[1]{%
\review@ifempty{#1}{}{%
  {\large \review@intn@memohead{}: #1}\\}}

\renewcommand{\contentsname}{\review@toctitle}

\newenvironment{reviewminicolumn}{%
  \vspace{1.5zw}\begin{screen}}{%
  \end{screen}\vspace{2zw}}

\newenvironment{reviewnote}[1][]{%
  \begin{reviewminicolumn}
\review@ifempty{#1}{}{\reviewminicolumntitle{#1}}
}{\end{reviewminicolumn}}
\newenvironment{reviewmemo}[1][]{%
  \begin{reviewminicolumn}
  \reviewminicolumntitle{#1}
}{\end{reviewminicolumn}}
\newenvironment{reviewtip}[1][]{%
  \begin{reviewminicolumn}
  \reviewminicolumntitle{#1}
}{\end{reviewminicolumn}}
\newenvironment{reviewinfo}[1][]{%
  \begin{reviewminicolumn}
  \reviewminicolumntitle{#1}
}{\end{reviewminicolumn}}
\newenvironment{reviewwarning}[1][]{%
  \begin{reviewminicolumn}
  \reviewminicolumntitle{#1}
}{\end{reviewminicolumn}}
\newenvironment{reviewimportant}[1][]{%
  \begin{reviewminicolumn}
  \reviewminicolumntitle{#1}
}{\end{reviewminicolumn}}
\newenvironment{reviewcaution}[1][]{%
  \begin{reviewminicolumn}
  \reviewminicolumntitle{#1}
}{\end{reviewminicolumn}}
\newenvironment{reviewnotice}[1][]{%
  \begin{reviewminicolumn}
  \reviewminicolumntitle{#1}
}{\end{reviewminicolumn}}

\DeclareRobustCommand{\reviewkw}[1]{\textbf{\textgt{#1}}}
\DeclareRobustCommand{\reviewami}[1]{\mask{#1}{A}}
\DeclareRobustCommand{\reviewem}[1]{\textbf{#1}}
\DeclareRobustCommand{\reviewstrong}[1]{\textbf{#1}}
\DeclareRobustCommand{\reviewballoon}[1]{←{#1}}
\DeclareRobustCommand{\reviewunderline}[1]{\Underline{#1}}
\DeclareRobustCommand{\reviewit}[1]{\textit{#1}}
\DeclareRobustCommand{\reviewbold}[1]{\textbf{#1}}

% allow break line in tt
% contributed by @zr_tex8r
\g@addto@macro\pdfstringdefPreHook{% for PDF bookmarks
  \def\reviewami#1{#1}
  \def\reviewbreakall#1{#1}
  \def\reviewballoon#1{#1}
  \def\reviewbou#1{#1}
  \def\reviewkw#1{#1}
  \def\reviewstrike#1{#1}
  \def\reviewunderline#1{#1}
}
\newif\ifreview@ba@break
\def\review@ba@end{\review@ba@end@}
\DeclareRobustCommand{\reviewbreakall}[1]{%
  \begingroup
    \review@ba@breakfalse
    \review@break@all@a#1\review@ba@end
  \endgroup
}
\def\review@break@all@a{%
  \futurelet\review@ba@tok\review@break@all@b
}
\def\review@break@all@b{%
  \ifx\review@ba@tok\review@ba@end
    \let\next\@gobble
  \else\ifx\review@ba@tok\@sptoken
    \let\next\review@break@all@c
  \else\ifx\review@ba@tok~%
    \let\next\review@break@all@d
  \else\ifx\review@ba@tok\bgroup
    \let\next\review@break@all@e
  \else
    \let\next\review@break@all@f
  \fi\fi\fi\fi
  \next
}
\expandafter\def\expandafter\review@break@all@c\space{%
  \space
  \review@ba@breakfalse
  \review@break@all@a
}
\def\review@break@all@d#1{%
  \review@break@all@f{\mbox{\space}}%
}
\def\review@break@all@e#1{%
  \review@break@all@f{{#1}}%
}
\def\review@break@all@f#1{%
  \ifreview@ba@break
    \hskip0pt plus 0.02em\relax
  \fi
  #1%
  \review@ba@breaktrue
  \review@break@all@a
}
\DeclareRobustCommand{\reviewtt}[1]{{\ttfamily\reviewbreakall{#1}}}
\DeclareRobustCommand{\reviewcode}[1]{{\ttfamily\reviewbreakall{#1}}}
\DeclareRobustCommand{\reviewtti}[1]{{\ttfamily\itshape\reviewbreakall{#1}}}
\DeclareRobustCommand{\reviewttb}[1]{{\ttfamily\bfseries\reviewbreakall{#1}}}

\DeclareRobustCommand{\reviewbou}[1]{\kenten{#1}}

%% @<del> is ignored in LaTeX with default style
\DeclareRobustCommand{\reviewstrike}[1]{#1}

%%%% for ulem.sty:
%%\renewcommand{\reviewstrike}[1]{\sout{#1}}
%%
%%%% for jumoline.sty:
%%\renewcommand{\reviewstrike}[1]{\Middleline{#1}}

\newcommand{\reviewth}[1]{\textgt{#1}}
\newcommand{\reviewtitlefont}[0]{\usefont{T1}{phv}{b}{n}\gtfamily}
\newcommand{\reviewmainfont}[0]{}
\newcommand{\reviewcolophon}[0]{\clearpage}
\newcommand{\reviewappendix}[0]{\appendix}

\newcommand{\reviewprepartname}{\review@prepartname}
\newcommand{\reviewpostpartname}{\review@postpartname}
\newcommand{\reviewprechaptername}{\review@prechaptername}
\newcommand{\reviewpostchaptername}{\review@postchaptername}
\newcommand{\reviewfigurename}{\review@figurename}
\newcommand{\reviewtablename}{\review@tablename}
\newcommand{\reviewappendixname}{\review@appendixname}

\ifdefined\prepartname
  \renewcommand{\prepartname}{\reviewprepartname}
\fi
\ifdefined\postpartname
  \renewcommand{\postpartname}{\reviewpostpartname}
\fi
\ifdefined\prechaptername
  \renewcommand{\prechaptername}{\reviewprechaptername}
\fi
\ifdefined\postchaptername
  \renewcommand{\postchaptername}{\reviewpostchaptername}
\fi
\ifdefined\figurename
  \renewcommand{\figurename}{\reviewfigurename}
\fi
\ifdefined\tablename
  \renewcommand{\tablename}{\reviewtablename}
\fi
\ifdefined\appendixname
  \renewcommand{\appendixname}{\reviewappendixname}
\fi

%% maxwidth is the original width if it is less than linewidth
%% otherwise use linewidth (to make sure the graphics do not exceed the margin)
\def\maxwidth{%
  \ifdim\Gin@nat@width>\linewidth
    \linewidth
  \else
    \Gin@nat@width
  \fi
}

% hooks
\def\reviewbegindocumenthook{}

\def\reviewenddocumenthook{}

\def\reviewfrontmatterhook{%
  \renewcommand{\chaptermark}[1]{{}}
  \frontmatter
}

\def\reviewmainmatterhook{%
  \renewcommand{\chaptermark}[1]{\markboth{\prechaptername\thechapter\postchaptername~##1}{}}
  \mainmatter
}

\def\reviewappendixhook{%
  \renewcommand{\chaptermark}[1]{\markboth{\appendixname\thechapter~##1}{}}
  \reviewappendix
}

\def\reviewbackmatterhook{%
  \backmatter
}

% cover
\newcommand*\covermatter{%
  \ifdefined\review@usecovernombre%
    \pagenumbering{coverpagezero}
    \setcounter{page}{0}% force to even page, to avoid empty page
  \fi
}

\if@reclscover
  \ifdefined\review@coverimage
    \def\reviewcoverpagecont{%
      \expandafter\includefullpagegraphics\expandafter[\review@coverimageoption]{\review@coverimage}
      \cleardoublepage
    }
  \fi
  \ifdefined\review@coverfile
    \def\reviewcoverpagecont{\review@coverfile}
  \fi
\fi

% titlepage
\ifdefined\review@titlepage
  \ifthenelse{\isundefined{\review@titlefile}}{%
    \def\reviewtitlepagecont{%
       \begin{titlepage}
       \thispagestyle{empty}
       \begin{center}%
       \mbox{} \vskip5zw
       \reviewtitlefont%
       {\Huge\review@booktitlename\par}%
       \ifdefined\review@subtitlename
         \vskip 1em%
         {\Large\review@subtitlename\par}%
       \fi
       \vskip 15em%
       {\huge
       \lineskip .75em
       \begin{tabular}[t]{p{\textwidth}}%
       \centering\review@titlepageauthors
       \end{tabular}\par}%
       \vfill
       {\large\review@date \review@intn@edition\hspace{2zw}\review@intn@publishedby\par}%
       \vskip4zw\mbox{}
       \end{center}%
       \end{titlepage}\clearpage
    }
  }{%
    \def\reviewtitlepagecont{\review@titlefile}
  }
\fi

% toc
\ifdefined\review@toc
  \def\reviewtableofcontents{%
\setcounter{tocdepth}{\review@tocdepth}
\tableofcontents
}
\fi

% index
\ifdefined\review@makeindex
  \RequirePackage{makeidx}
  \makeindex
\fi

\ifdefined\review@makeindex
  \def\reviewprintindex{%
\printindex
}
\fi

% colophon
\ifdefined\review@colophon
  \ifthenelse{\isundefined{\review@colophonfile}}{%
    \def\reviewcolophonpagecont{%
\reviewcolophon
\thispagestyle{empty}
\vspace*{\fill}
{\noindent\reviewtitlefont\Large\review@booktitlename}\\
\ifdefined\review@subtitlename
{\noindent\reviewtitlefont\large\review@subtitlename} \\
\fi
\rule[8pt]{\textwidth}{1pt} \\
{\noindent\review@pubhistories}

\begin{tabularx}{\dimexpr\textwidth-0.5em}{lX}
\review@colophonnames
\end{tabularx}
　\\
\rule[0pt]{\textwidth}{1pt} \\
\ifdefined\review@rights
\review@rights
\fi
    }%
  }{%
    \def\reviewcolophonpagecont{\review@colophonfile}
  }
\fi

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
