このページでは glcproc.cls v1.0 の実装方法について説明する.v.2.0 での変更点については TeX/ClassFile/glcproc.cls で確認してほしい.
複数の論文を一つにまとめることの面倒さについては,『実践解説』の第9.1節(pp. 283--288)にわかりやすい記述がある.Web 上にも次のような情報(質問と回答)がある(奥村晴彦氏の「TeX FAQ」).
ただし『実践解説』第9.1節の記述とは違い,(理系と違って TeX で原稿を提出する人は少ないため)個々の論文(これ以降は「記事」と呼ぶ)で定義されるマクロについては,ほとんど考慮する必要がない.
さて,『実践解説』第9.1節の方針に従って,次のようにクラスファイルを定義することにした.
その他に
\@input を用いて,\includearticle コマンドを定義する.これによって,親ファイルに
\includearticle{article1}
と記述すれば,article1.tex を読み込んで記事を生成する.
\def\includearticle#1 {%
\clearpage
\refstepcounter{article}
\begingroup
\edef\@curr@filename{#1}%%% 現在のファイル名の保存
\if@filesw
\immediate\openout\@articleaux=#1.aux\relax
\fi
\global\@write@articletocfalse
\@init@article@data
\@input@{#1}%
\clearpage
\if@filesw
\immediate\closeout\@articleaux
\fi
\if@write@articletoc%%% 記事ごとの toc ファイルの作成
\begingroup\makeatletter
\@input@{#1.aux}%
\endgroup
\immediate\closeout\tf@toc
\global\@write@articletocfalse
\fi
\endgroup}
以上で次のような処理を行っている.
記事内には次のように記述する.\makearticletitle が実際に論文タイトル等を出力するコマンドである.
\articletitle{論文タイトル}
\articlesubtitle{\−−{}論文副題\−−}
\articleauthor{著者1 \AND 著者2}
\makearticletitle
論文副題は \−− で囲んだ方が良いだろう.\−− というコマンドは okumacro.sty に含まれている*2.
定義は次のようになる.
\def\articletitle#1{\gdef\@articletitle{#1}}
\def\@articletitle{\@latex@error{No \noexpand\articletitle given}\@ehc}
\def\articlesubtitle#1{\gdef\@articlesubtitle{#1}}
\def\@articlesubtitle{\relax}
\gdef\articleauthor#1{\gdef\@articleauthor{#1}}
\gdef\@articleauthor{\@latex@warning@no@line{No \noexpand\articleauthor given}}
\def\AND{\hspace{2zw}}
\def\makearticletitle{%
\begingroup
\cleardoublepage
\@makearticletitle
\begingroup
\protected@write\@auxout
{\let\index\@gobble \let\label\@gobble \let\glossary\@gobble}%
{\string\@writefile{gtc}{%
\protect\contentsline{article}%
{{\@articletitle}{\@articlesubtitle}{\@articleauthor}}{\thepage}}}
\endgroup
\endgroup
}
\def\@makearticletitle{%
\begingroup
\thispagestyle{empty}%
\begin{center}%
{\LARGE\bfseries \@articletitle \par}%
\vskip 1.5em%
\ifx\@articlesubtitle\@empty\else%
{\Large\bfseries \@articlesubtitle \par}%
\vskip 1.5em
\fi
\begingroup
\endgroup
\large \lineskip .5em
\begin{tabular}[t]{c}%
\bfseries\@articleauthor
\end{tabular}\par%
\vskip 1em
\end{center}%
\par\vskip 1em
\endgroup
}
(親ファイル名).gtc(global table of contents)ファイルに以下の項目を書き出す.
この処理は,\makearticletitle が実行されたときに行う.
定義を再掲すると,以下のようになっている.
\protected@write\@auxout
{\let\index\@gobble \let\label\@gobble \let\glossary\@gobble}%
{\string\@writefile{gtc}{%
\protect\contentsline{article}%
{{\@articletitle}{\@articlesubtitle}{\@articleauthor}}{\thepage}}}
すると gtc ファイルには,以下のように書き出される.
\contentsline {article}{{論文題名}{論文副題}{著者名}}{123}
記事が変わるごとに,当然節番号,脚注番号はリセットされなければならない.そのために,「article」というカウンタを定義する.「article」というカウンタを増やすごとに,しかるべきカウンタをリセットするようにすれば良い.
次のように定義した.
\newcounter{article}
\newcounter{chapter}[article]
\newcounter{section}[article] \@addtoreset{section}{article}
\newcounter{subsection}[section]
\newcounter{subsubsection}[subsection]
\newcounter{paragraph}[subsubsection]
\newcounter{subparagraph}[paragraph]
この定義では,「article」カウンタが増えるごとに「chapter」「section」カウンタがリセットされる.
一方,「part」カウンタは「article」カウンタが増えてもリセットされない.これは,例えば
といった具合に,記事の種類ごとに区分を設ける場合を考慮に入れているためである.
数式*4・脚注番号をリセットするために次の記述を加えた.
\@addtoreset{equation}{article}
\@addtoreset{footnote}{article}
記事ファイルを読み込むごとに,然るべきコマンドを初期化する必要がある.そのためのコマンド \@init@article@data を次のように定義した.
\def\@init@article@data{%
\global\let\@articletitle\@empty
\global\let\@articlesubtitle\@empty
\global\let\@articleauthor\@empty
\global\let\@thanks\@empty}
\@init@article@data
これで \let の後にあるコマンドが初期化される.実際には,\includearticle コマンドの中で,\@input@ コマンドが記事ファイルを読み込む直前にこのコマンドを実行して各種のコマンドを初期化している.
目次には次の2種類がある*5.
処理方法としては,「章ごとの目次」など「複数箇所に作成する目次」と同じになる.特に『実践解説』の第8.1節「複数箇所に作成する目次」(pp. 261-275,特に「(3) 章ごとに aux ファイルを作成する方法」),第9.3節「目次の作成・LaTeX カウンタの管理」(pp. 296-302)を参考にした.
論文集全体の目次には,次の項目を出力する.
出力するには,親ファイルに
\tableofarticles
と書いておく.
出力形式は
論文タイトル 123 −−論文副題−− 著者名
のようにここでは定義した.
実際の定義は以下のようにした.
\long\def\@firstofthree#1#2#3{#1}
\long\def\@secondofthree#1#2#3{#2}
\long\def\@thirdofthree#1#2#3{#3}
\newdimen\@articlesubtitle@indent
\newdimen\@articleauthor@indent
\newcommand*{\l@article}[2]{%
\addpenalty{-\@highpenalty}%
\addvspace{1.0em \@plus\p@}
\begingroup
\parindent\z@
\rightskip\@pnumwidth
\parfillskip-\rightskip
\@articlesubtitle@indent=1zw
\@articleauthor@indent=2zw
\@firstofthree#1\@empty\@empty\@empty%
\nobreak\hfil\nobreak\hbox to\@pnumwidth{\hss#2}\par
\leavevmode
\if\@secondofthree#1\@empty%
\else
\hspace\@articlesubtitle@indent%
\@secondofthree#1\@empty\@empty\@empty%
\nobreak\hfil\nobreak\hbox to\@pnumwidth{\hss}\par
\leavevmode
\fi
\hspace\@articleauthor@indent%
\@thirdofthree#1\@empty\@empty\@empty%
\nobreak\hfil\nobreak\hbox to\@pnumwidth{\hss}
\par
\endgroup
}
\def\tableofarticles{%
\clearpage
\chapter*{\contentsname}%
\@mkboth{\contentsname}{}%
\thispagestyle{empty}%
\@starttoc{gtc}%
\clearpage}
まず,\@firstoftwo などと同様に,{{1}{2}{3}} のように格納されているデータを一つずつ取り出すコマンドを以下のように定義した.
次に,先に挙げた出力形式のように,論文副題,著者名を出力する際のインデントを決めるコマンドを用意した.
次の \newcommand*{\l@article}[2] 以下で,実際の出力形式を定めている.
まず,
の記述を変更すれば,それぞれのインデントが調整できる.
出力処理のメインの部分は次のようになっている.
通常の目次作成と変わらないが,toc ファイルの出力先が (記事ファイル名).toc のように,個々の記事に対応するものになる点に注意する必要がある.
記事内目次を作成するには,記事ファイル中に
\articletoc
と記述しておく*7.
定義は次のようにした.
\newwrite\tf@toc
\newif\if@write@articletoc
\global\@write@articletocfalse
\def\@articletoc{%
\setcounter{tocdepth}{2}
\section*{\contentsname}%
\begingroup\makeatletter
\@input@{\@curr@filename.toc}%
\endgroup
\if@filesw%
\immediate\openout\tf@toc=\@curr@filename.toc\relax
\global\@write@articletoctrue
\fi}
\let\articletoc\@articletoc
\newwrite\@articleaux
\def\addcontentsline#1#2#3{%
\addtocontents{#1}{\protect\contentsline{#2}{#3}{\thepage}}}
\long\def\addtocontents#1#2{%
\protected@write\@articleaux
{\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
{\string\@writefile{#1}{#2}}}
次のような処理をしている.
論文集の一般的な形式として柱には,
を入れることにする.jsbook.cls の以下の部分を変更した.
\def\ps@headings{%
...
\def\@evenhead{%
\if@mparswitch \hss \fi
\underline{\hbox to \fullwidth{\autoxspacing
\textbf{\thepage}\hfil\@articleauthor\hfil}}%
...
\def\@oddhead{\underline{\hbox to \fullwidth{\autoxspacing
{\if@twoside\hfil\@articletitle\else\leftmark\fi}\hfil\textbf{\thepage}}}\hss}%
jsbook.cls のデフォルトの脚注の形式は,この Wiki ページと同じように,本文中の文章の右肩につく記号は「*1」であり,ページ下の脚注の欄にも同じように「*1」と表示される.
この形式は,日本語の場合には jarticle.cls / jbook.cls の場合におけるような,数字のみの形式と比較して見やすくて良いと思う.
ただし脚注番号を参照するときには,若干不都合が生じる(と思う).
脚注番号を参照するために
注\ref{fn_1}
という記述をした場合,jsbook.cls の場合,
注*1
という表記になる.これはあまり気にならない.しかし,
Douglas Olson (n. \ref{fn_1})
と記述した場合,
Douglas Olson (n. *1)
という表記になってしまう.これは若干気になる.
Douglas Olson (n. 1)
という表記が正しいだろう.また,「注*1」という表記の代わりに,「注1」という表記でも自然に思える.
よって
する,という方針を立てて,jsbook.cls の該当部分を次のように変更した.
\def\thefootnote{\ifnum\c@footnote>\z@\leavevmode%\lower.5ex\hbox{*}%
\@arabic\c@footnote\fi}
\def\@makefnmark{\hbox{\textsuperscript{\lower.5ex\hbox{*}\@thefnmark}}}
この処置を行うと,副作用として \footnotetext[0] で出力した脚注には,jsbook.cls の場合脚注欄に「*」が現れなかったのが,現れてしまう,という症状が現れる*10.
西洋古典学での文献表と LaTeX の標準の文献表*11 の違いは主に以下の2つである.
そのため,次のような方針を立てて,classicsbibliography 環境を定義した.
定義は以下のようにした.
\newenvironment{classicsbibliography}{%
\list{}{%
\leftmargin2em
\itemindent-2em
\labelwidth\z@
\labelsep\z@
}
\sloppy
\clubpenalty4000
\@clubpenalty\clubpenalty
\widowpenalty4000%
\sfcode`\.\@m}
{\def\@noitemerr
{\@latex@warning{Empty `classicsbibliography' environment}}%
\endlist}
使うときは以下のようにする.
\section*{参考文献}
\subsection*{注釈}
\begin{classicsbibliography}
\item aaaaa
\item bbbbb
\end{classicsbibliography}
#amazon(4774119407,left,奥村)
#amazon(4774115460,left,『基礎解説』)
#amazon(4774117587,left,『実践解説』)
#amazon(,clear)