From bf57698567e2b9ca1ac8f73a59416e089aad371b Mon Sep 17 00:00:00 2001 From: Kenshi Muto Date: Sun, 11 Aug 2019 11:30:02 +0900 Subject: [PATCH] introduce reviewbreakall. Closes: #1348 --- templates/latex/review-jlreq/review-base.sty | 56 +++++++++++++++++-- templates/latex/review-jsbook/review-base.sty | 56 +++++++++++++++++-- 2 files changed, 104 insertions(+), 8 deletions(-) diff --git a/templates/latex/review-jlreq/review-base.sty b/templates/latex/review-jlreq/review-base.sty index d314bd21d..3cfec0714 100644 --- a/templates/latex/review-jlreq/review-base.sty +++ b/templates/latex/review-jlreq/review-base.sty @@ -167,10 +167,58 @@ \DeclareRobustCommand{\reviewunderline}[1]{\underline{#1}}% ulemかjumolineで上書き。デフォルトはulemにしている \DeclareRobustCommand{\reviewit}[1]{\textit{#1}} \DeclareRobustCommand{\reviewbold}[1]{\textbf{#1}} -\DeclareRobustCommand{\reviewcode}[1]{\texttt{#1}} -\DeclareRobustCommand{\reviewtt}[1]{\texttt{#1}} -\DeclareRobustCommand{\reviewtti}[1]{\texttt{\textit{#1}}} -\DeclareRobustCommand{\reviewttb}[1]{\texttt{\textbf{#1}}} + +% allow break line in tt +% contributed by @zr_tex8r +\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}} %% @ is ignored in LaTeX with default style diff --git a/templates/latex/review-jsbook/review-base.sty b/templates/latex/review-jsbook/review-base.sty index db545dc2d..a4945f274 100644 --- a/templates/latex/review-jsbook/review-base.sty +++ b/templates/latex/review-jsbook/review-base.sty @@ -264,10 +264,58 @@ \DeclareRobustCommand{\reviewunderline}[1]{\Underline{#1}} \DeclareRobustCommand{\reviewit}[1]{\textit{#1}} \DeclareRobustCommand{\reviewbold}[1]{\textbf{#1}} -\DeclareRobustCommand{\reviewcode}[1]{\texttt{#1}} -\DeclareRobustCommand{\reviewtt}[1]{\texttt{#1}} -\DeclareRobustCommand{\reviewtti}[1]{\texttt{\textit{#1}}} -\DeclareRobustCommand{\reviewttb}[1]{\texttt{\textbf{#1}}} + +% allow break line in tt +% contributed by @zr_tex8r +\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}} %% @ is ignored in LaTeX with default style