%
%
% パッケージリスト
%
%
% 標準でインストールされているパッケージ
%
\usepackage{float}
\usepackage[dvipdfm]{graphicx}
\usepackage{multirow}
\usepackage{okumacro}
\usepackage{misc}
%
% インターネットで入手するパッケージ
%
\usepackage{mediabb}
\usepackage{indent}
\usepackage{fancyhdr}
\usepackage{lastpage}
%
% フォントの設定（おそらくインストール済み）
%
\usepackage{lmodern}%{lmodern}{txfonts}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
%
%
% 余白の設定
%
%
% A4用紙の設定
%
\setlength{\topmargin}{0.2truein}
\setlength{\voffset}{-1truein}
\setlength{\headheight}{0.6truein}
\setlength{\headsep}{0.2truein}
\setlength{\paperheight}{297truemm}
\setlength{\textheight}{\paperheight}
\addtolength{\textheight}{-2truein}
\setlength{\paperwidth}{210truemm}
\setlength{\textwidth}{\paperwidth}
\addtolength{\textwidth}{-2truein}
%
% 欄外の設定
%
\addtolength{\hoffset}{-0.4truein}
\addtolength{\textwidth}{1truein}
\addtolength{\textwidth}{-18truept}
\setlength{\headwidth}{\textwidth}
\setlength{\marginparwidth}{0.25\textwidth}
\setlength{\textwidth}{0.75\textwidth}
\setlength{\footskip}{0.5truein}
%
% フロート環境の設定
%
\setlength{\abovecaptionskip}{.1\baselineskip} % 元: 10\p@
\setlength{\belowcaptionskip}{.1\baselineskip} % 元: 0\p@
\setlength{\floatsep}{.4\baselineskip}         % 移動体間のスペース
\setlength{\textfloatsep}{.4\baselineskip}     % 本文と移動体間のスペース
\setlength{\intextsep}{.4\baselineskip}        % 本文中のフロートとの距離
\setlength{\dblfloatsep}{.4\baselineskip}      % 2段抜き（組み？）の場合
\setlength{\dbltextfloatsep}{.4\baselineskip}  % 2段抜きの場合
%
%
% マクロ
%
%
% これ説明しにくい（でも必須）
%
\newlength{\leftindent}
\def\bangou#1#2{\mbox{}\hbox to#1{#2{\hfill}}}
\def\habajidou#1{%自動文字幅取得
\settowidth{\@tempdima}{#1}%文字列の長さを測る
\ifdim\@tempdima<1.5zw \bangou{2zw}{#1}\setlength{\leftindent}{2zw}%1 文字
\else\ifdim\@tempdima<2.5zw \bangou{3zw}{#1}\setlength{\leftindent}{3zw}%2 文字
\else\ifdim\@tempdima<3.5zw \bangou{4zw}{#1}\setlength{\leftindent}{4zw}%3 文字
\else\ifdim\@tempdima<4.5zw \bangou{5zw}{#1}\setlength{\leftindent}{5zw}%4 文字
\else\ifdim\@tempdima<5.5zw \bangou{6zw}{#1}\setlength{\leftindent}{6zw}%5 文字
\else\ifdim\@tempdima<6.5zw \bangou{7zw}{#1}\setlength{\leftindent}{7zw}%6 文字
\else\ifdim\@tempdima<7.5zw \bangou{8zw}{#1}\setlength{\leftindent}{8zw}%7 文字
\else\ifdim\@tempdima<8.5zw \bangou{9zw}{#1}\setlength{\leftindent}{9zw}%8 文字
\else \mbox{#1}\hspace{1zw}\setlength{\leftindent}{\@tempdima}\addtolength{\leftindent}{1zw}%9 文字以上
\fi\fi\fi\fi\fi\fi\fi\fi}
%
% 傍注（日本語訳）
%
\newcounter{marginpar}%
\newcommand{\marginnote}[1]{%
 \refstepcounter{marginpar}%
 \kern0pt$^{*\themarginpar}$% 本文での傍注番号
 \marginpar{\footnotesize{}$*$\themarginpar~#1}% 傍注
}
\def\yaku#1{\marginnote{#1}}
%
% 名前
%
\def\name#1{%
 \def\thename{#1}%
 }
%
% 見出し
%
\def\chap#1#2{%
 \def\chapnum{#1}%
 \def\chapname{#2}%
 \def\thechap{CHAPTER \habajidou{\chapnum{} }\chapname}%
 \def\thesect{}%
 \def\thesubsect{}%
 }
\def\makechap{%
 \section*{\thechap}%
 }
\def\chapja#1{%
 \begin{ja}%
 \habajidou{\chapnum{}章 }#1%
 \end{ja}%
 }
%
\def\sect#1#2{%
 \def\sectnum{\chapnum{}.#1}%
 \def\sectname{#2}%
 \def\thesect{\habajidou{\sectnum{} }\sectname}%
 \def\thesubsect{}%
 }
\def\makesect{%
 \subsection*{\thesect}%
 }
\def\sectja#1{%
 \begin{ja}%
 \habajidou{\sectnum{} }#1%
 \end{ja}%
 }
%
\def\subsect#1{%
 \def\thesubsect{#1}%
 }
\def\makesubsect{%
 \subsection*{\thesubsect}%
 }
\def\subsectja#1{%
 \begin{ja}%
 #1%
 \end{ja}%
 }
%
% 段落環境
%
\newenvironment{parag}{%
 \par\mbox{}\vspace{-1\baselineskip}\par%
 \vspace{.5\baselineskip}\par%
 \ignorespaces%
}{%
 \vspace{\baselineskip}\par%
 \ignorespaces%
}
%
% 日本語訳環境
%
\newenvironment{ja}{%
 \par\mbox{}\vspace{-1\baselineskip}\par%
 \vspace{.5\baselineskip}\par%
 \begin{indentation}{2\Cwd}{0\Cwd}%
 \setlength{\parindent}{-2\Cwd}%
 \mbox{}\hbox to 2zw{\hfill{}%
 ---%
 \hfill{}}%
 %\mbox{}\raisebox{-0.3ex}{\hbox to 2zw{\hfill{}%
 %\includegraphics[scale=0.05,clip]{logo-color}%
 %\hfill{}}}%
 \setlength{\parindent}{0\Cwd}%
 \ignorespaces%
}{%
 \end{indentation}%
 \par\mbox{}\vspace{-1\baselineskip}\par%
 \vspace{1\baselineskip}\par%
 \ignorespaces%
}
%
%
% 書式の設定
%
%
% ヘッダー，フッター
%
\pagestyle{fancy}
\lhead{\thechap{}\\{}}
\chead{}
\rhead{\thesect{}\\{}\thesubsect{}}
\lfoot{\thename{}}%{\jobname} % このファイル自身の名前を出力
\cfoot{}
\rfoot{\thepage{} / \pageref{LastPage}} % 頁番号
\renewcommand{\headrulewidth}{0pt} % ヘッダーラインは打ち出さない
\renewcommand{\footrulewidth}{0pt} % {0.4pt} フッターラインの線幅の変更
%
% インデント
%
\setlength{\parindent}{0\Cwd}
