%tundline.sty %Copyright (C) 1998/08/28 by Shinsaku Fujita %\typeout{jundline.sty by Shinsaku Fujita 1996/03/31} \typeout{tundline.sty by Shinsaku Fujita 1998/08/28} \typeout{藤田眞作「LaTeX本づくりの八衢」第4章参照} \typeout{藤田眞作「続LaTeX2e階梯(縦組み編)」参照} % % 複数行にわたる傍線を引くマクロ % % 書式: \tundline[位置]{内容} % % [位置] r: 右傍線(デフォルト)、 l: 左傍線 % % 作成者: 藤田眞作 fujitas@chem.kit.ac.jp % % 無保証 % % badnessの評価 % \def\undline@badness{2.8}%近似のために\hbadnessを100で割って三乗根をとる % (2.8)^3>(2.16)^3=10.0777 == 1000/100 % % 本文字と傍線との間隔を可変にするために設定 % 標準値 % \newdimen\bousensep \bousensep=0.5zw % \def\bousensepstretch{1.4} % \newdimen\bousensep \bousensep=0.5zw \def\bousensepstretch{1.4} % % 命令本体 % \def\tundline{\@ifnextchar[%] {\@tundline}{\@tundline[r]}} % \newif\if@hidaribou \@hidariboufalse \def\@tundline[#1]#2{% \def\aaa{#1}\def\bbb{l}\@hidariboufalse \ifx\aaa\bbb\relax \@hidariboutrue\else\@hidariboufalse\fi \gdef\maemoji{}\gdef\mojitest{}\gdef\maemojitest{}% \leavevmode\thitomoji#2\endthitomoji} % % 1個の文字を下線付きで出力 % % \tPrintmaemoji --- 現文字の直前の文字を,禁則penaltyとともに % 出力(左寄せ) % \tPrintrightmaemoji --- 現文字の直前の文字を,禁則penaltyとともに % 出力(右寄せ) % \tprintmaemoji --- 現文字の直前の文字を,空きとともに % 出力(左寄せ) % \tprintpuncmaemoji --- 現文字の直前の括弧類を,空きとともに % 出力(左寄せ) \def\tPrintmaemoji{\hbox{\maemoji% \kern-\dimen0% \lowerorraise\bousensepstretch\bousensep% \hbox{\vrule width\dimen0 height0.4pt}}} \def\tPrintrightmaemoji{\hbox to\dimen0{\hss\maemoji}% \kern-\dimen0% \lowerorraise\bousensepstretch\bousensep% \hbox{\vrule width\dimen0 height0.4pt}}% \def\tprintmaemoji{% \hbox to\dimen0{\maemoji\hss}% \kern-\dimen0% \lowerorraise\bousensepstretch\bousensep% \hbox{\vrule width\dimen0 height0.4pt}% \dimen2= \undline@badness\dimen2% \xleaders\hbox{\tul@linebox{\dimen2}}\hskip\dimen2% \hskip-\dimen2\relax} \def\tul@linebox#1{\lowerorraise\bousensepstretch\bousensep% % \hbox{\vrule width#1 height0.05em}}% \hbox{\vrule width#1 height0.4pt}}% \def\tprintpuncmaemoji{% \setbox0=\hbox{\maemoji\hss}% \copy0% \kern-\wd0\lowerorraise\bousensepstretch\bousensep% \hbox{\vrule width\wd0 height0.4pt}% \advance\dimen0-\wd0% \advance\dimen0 \undline@badness\dimen2% \xleaders\hbox{\tul@linebox{\dimen0}}\hskip\dimen0% \hskip-\dimen0\relax} % % 和字--欧文,括弧和字--欧字などの,分離禁則かどうかを調べる. % 分離禁則ならば\nonxk@anjitrueとする % ---あとで\penalty 10000を入れる % 分離禁則でないならば\nonxk@anjifalseとする % ---あとで\xkanjiskipを入れる % \newif\ifnonxk@nji \nonxk@njifalse \def\testxk@nji#1#2{% \setbox0=\hbox{#1}\setbox1=\hbox{#2}\setbox2=\hbox{#1#2}% \dimen3=\wd2 \advance\dimen3-\wd0 \advance\dimen3-\wd1\relax \ifdim\dimen3<0.01pt \global\nonxk@njitrue \else\global\nonxk@njifalse\fi}% % % 内部命令 % \def\thitomoji#1{% \dimen2=0pt %左右の切り替え \if@hidaribou\let\lowerorraise=\lower \else\let\lowerorraise=\raise\fi \ifx#1\endthitomoji%最後尾の処理 \setbox0=\hbox{\maemoji}% \copy0% \kern-\wd0\lowerorraise\bousensepstretch\bousensep% \hbox{\vrule width\wd0 height0.4pt}% \ifcase\mojitest%和字 \def\u@line{\hskip\kanjiskip}% \or%句読点 \def\u@line{\hskip.5zw\hskip\kanjiskip \spacefactor=3000\relax}% \or%始め括弧類 \def\u@line{\penalty\@M}% \or%そのほか \def\u@line{}% \fi \else%途中の処理 \setbox0=\hbox{#1}\setbox1=\hbox{#1\null}\setbox2=\hbox{\null#1}% \dimen3=1zw \advance\dimen3 by-\wd0\relax \dimen4=1zw \advance\dimen4 by-\wd1\relax \dimen5=1zw \advance\dimen5 by-\wd2\relax %\ifdim\wd0=1zw\gdef\mojitest{0}%通常の和字 \ifdim\dimen3<0.01pt\gdef\mojitest{0}%通常の和字 \dimen1=\wd0 \else %\ifdim\wd1=1zw\gdef\mojitest{1}%句読点類 \ifdim\dimen4<0.01pt\gdef\mojitest{1}%句読点類 \dimen1=\wd1 %\else\ifdim\wd2=1zw\gdef\mojitest{2}%始め括弧類 \else\ifdim\dimen5<0.01pt\gdef\mojitest{2}%始め括弧類 \dimen1=\wd2 \else\gdef\mojitest{3}%そのほか %\ifmmode \typeout{数式}\fi \dimen1=\wd0 \fi\fi\fi \ifx\maemojitest\empty\else \ifcase\maemojitest%直前の文字が0(和字) \ifcase\mojitest%和字--和字 \dimen2=.5pt \tprintmaemoji \hskip\kanjiskip \or%和字--句読点類 \tPrintmaemoji \penalty\@M \or%和字--始め括弧 \dimen2=.5pt \tprintmaemoji \hskip\kanjiskip \or%和字--その他 \testxk@nji{\maemoji}{#1}% \ifnonxk@nji \tPrintmaemoji \penalty\@M \else \advance\dimen0 by.25zw \dimen2=.1zw \tprintmaemoji \hskip\xkanjiskip \fi\fi \or%直前の文字が句読点 \ifcase\mojitest%句読点--和字 \dimen2=.5pt \tprintpuncmaemoji \hskip\kanjiskip \or%句読点--句読点類 \tPrintmaemoji \penalty\@M \or%句読点--始め括弧 \advance\dimen0 by.25zw \dimen2=.1zw \tprintpuncmaemoji \hskip\kanjiskip \or%句読点--その他 \testxk@nji{\maemoji}{#1}% \ifnonxk@nji \tPrintmaemoji \penalty\@M \else \advance\dimen0 by.25zw \dimen2=.1zw \tprintpuncmaemoji \hskip\xkanjiskip \fi\fi \or%直前の文字が始め括弧 \ifcase\mojitest%始め括弧類--和字 \tPrintrightmaemoji \penalty\@M \or%始め括弧類--句読点類 \tPrintrightmaemoji \penalty\@M \or%始め括弧類--始め括弧 \tPrintrightmaemoji \penalty\@M \or%始め括弧類--その他 \tPrintrightmaemoji \penalty\@M \fi \or \ifcase\mojitest%その他--和字 \testxk@nji{\maemoji}{#1}% \ifnonxk@nji \tPrintmaemoji \penalty\@M \else \advance\dimen0 by.25zw \dimen2=.1zw \tprintmaemoji \hskip\xkanjiskip \fi \or%その他--句読点類 \tPrintmaemoji \penalty\@M \or%その他--始め括弧 \testxk@nji{\maemoji}{#1}% \ifnonxk@nji \tPrintmaemoji \penalty\@M \else \dimen2=.5pt \tprintmaemoji \hskip\xkanjiskip \fi \or%その他--その他 \let\@sf=\empty \ifhmode\edef\@sf{\spacefactor=\the\spacefactor}\fi \tprintmaemoji \@sf \fi\fi %% \let\maemaemojitest=\mojitest %% \fi \let\u@line=\thitomoji \gdef\maemoji{#1}% \let\maemojitest=\mojitest \dimen0=\dimen1 \fi\u@line} \endinput