%% -*- coding: iso-2022-jp; mode: yatex; -*-
%%
%% $B$V$i2<$2AH$_(B
%%
%% $Id: hanging.sty,v 1.5 2007/05/06 05:13:27 isao Exp $
%%
\ProvidesFile{hanging.sty}
\ProvidesPackage{hanging}[2007/04/29 \space Ver. 1.0 %
  hanging punctuation, isao yasuda]
% option
\DeclareOption{jpnoglue}{\let\@jpglue\inhibitglue}%
\ProcessOptions%
\ifx\@jpglue\@undefined\def\@jpglue{\relax}\fi%
%% latin
%% TeXbook p.534.
\newdimen\commahang\setbox0=\hbox{,}\commahang=\wd0%
\newdimen\periodhang\setbox0=\hbox{.}\periodhang=\wd0%
\newdimen\scolonhang\setbox0=\hbox{;}\scolonhang=\wd0%
\newdimen\colonhang\setbox0=\hbox{:}\colonhang=\wd0%
\newdimen\quotehang\setbox0=\hbox{`}\quotehang=\wd0%
\newdimen\qquotehang\setbox0=\hbox{``}\qquotehang=\wd0%
\newskip\zzz%
\def\allowhyphens{\nobreak\hskip\zzz}%
\def\lqq{``}%
\def\rqq{''}%
\def\pnt{.}%
\def\comma{,\kern-\commahang\kern\commahang}%
\def\period{.\kern-\periodhang\kern\periodhang}%
\def\scolon{;\kern-\scolonhang\kern\scolonhang}%
\def\ncolon{:\kern-\colonhang\kern\colonhang}%
\def\rquote{'\kern-\quotehang\kern\quotehang}%
\def\lquote{\ifhmode\kern\quotehang\vadjust{}\else\leavevmode\fi%
 \kern-\quotehang`\allowhyphens}%
\begingroup%
\catcode44=\active% ,
\catcode46=\active% .
\catcode59=\active% ;
\catcode58=\active% :
\catcode39=\active% '
\catcode96=\active% `
%% \activehanging
%% $BH>3Q$N(B ,.;:'` $B$N$V$i2<$2AH$_$rM-8z$K$9$k!%(B
\gdef\activehanging{%
  \catcode44=\active\let,=\comma%
  \catcode46=\active\let.=\period%
  \catcode59=\active\let;=\scolon%
  \catcode58=\active\let:=\ncolon%
  \catcode39=\active\def'{\futurelet\next\rqtest}%
  \catcode96=\active\def`{\futurelet\next\lqtest}%
  \def\rqtest{\ifx\next'\let\next=\rquotes\else\let\next=\rquote\fi\next}%
  \def\lqtest{\ifx\next`\let\next=\lquotes\else\let\next=\lquote\fi\next}%
  \def\rquotes'{\rqq\kern-\qquotehang\kern\qquotehang}%
  \def\lquotes`{\ifhmode\kern\qquotehang\vadjust{}\else\leavevmode\fi%
    \kern-\qquotehang\lqq\allowhyphens}%
}%
\catcode44=12% ,
\catcode46=12% .
\catcode59=12% ;
\catcode58=12% :
\catcode39=12% '
\catcode96=12% `
%% \disablehanging
%% $BH>3Q$N(B ,.;:'` $B$N$V$i2<$2AH$_$rL58z$K$9$k!%(B
\gdef\disablehanging{%
  \catcode44=12%
  \catcode46=12%
  \catcode59=12%
  \catcode58=12%
  \catcode39=12%
  \catcode96=12%
}%
\endgroup%

%% $BOBJ8(B
\ifx\pfmtname\@undefined% if latex no operation.
\else% it is platex
%% $BK\$E$/$j$NH,39(B, p.69 $B%3%s%H%m!<%k%7!<%1%s%9$N$_(B
%%% kanji $B6gFIE@(B
\newdimen\jten@hang \setbox0=\hbox{$B!%(B} \jten@hang=\wd0%
\newdimen\jten@hangspace%
\jten@hangspace=1zw \advance\jten@hangspace-\jten@hang%
\def\$B!%(B{%
  \@jpglue\penalty10000%
  \hbox{$B!%(B}\kern-\jten@hang\kern\jten@hang\hskip\jten@hangspace}%
\def\$B!$(B{%
  \@jpglue\penalty10000%
  \hbox{$B!$(B}\kern-\jten@hang\kern\jten@hang\hskip\jten@hangspace}%
\def\$B!#(B{%
  \@jpglue\penalty10000%
  \hbox{$B!#(B}\kern-\jten@hang\kern\jten@hang\hskip\jten@hangspace}%
\def\$B!"(B{%
  \@jpglue\penalty10000%
  \hbox{$B!"(B}\kern-\jten@hang\kern\jten@hang\hskip\jten@hangspace}%
%% $B1&$+$C$3(B
%%% right parenthesis
\newdimen\rparen@hang%
\setbox0=\hbox{)}%
\rparen@hang=\wd0%
\def\rparen{\penalty10000\hbox{)}\kern-\rparen@hang\kern\rparen@hang}%
%%% kanji right parenthesis
\newdimen\jrparen@hang%
\setbox0=\hbox{$B!K(B}%
\jrparen@hang=\wd0%
\def\$B!K(B{\@jpglue\penalty10000\hbox{$B!K(B}\kern-\jrparen@hang\kern\jrparen@hang}%
%
\fi%

\endinput
% end of style

hanging.sty $B;H$$J}(B

\usepackage{hanging}$B$r;XDj$9$k!%%*%W%7%g%s$K(B jpnoglue $B$r;XDj$9$k$H!$OBJ8$N(B
$B6gFIE@$N%0%k!<$NA^F~$r6X;_$9$k!J(B\inhibitglue$B$rIU2C$9$k!K!%(B

$B$V$i$5$2AH$_$N;XDj(B

- $B2$J8$N>l9g(B
  $BH>3QJ8;z(B .,;:`' $B$K$D$$$F$V$i2<$2AH$_$H$7$?$$>l9g!$(B\activehanging$B$rH/9T$9$k!%(B
  \activehanging$B$rH/9T$7$?>l9g!$J8=q$NKvHx$GI,$:(B\disablehanging$B$rH/9T$9$k$3$H!%(B

- $BOBJ8$N>l9g(B
  $B6gFIE@$r(B\$B!%(B\$B!$(B\$B!#(B\$B!"$G5-=R$9$k$H!$$V$i2<$2AH$_BP>]$H$J$k!%(B
