[[TeX/ClassFile/glcproc.cls]]

*glcproc.cls の実装 [#f60c63dd]
*glcproc.cls の実装(v1.0) [#f60c63dd]

このページでは glcproc.cls v1.0 の実装方法について説明する.v.2.0 での変更点については [[TeX/ClassFile/glcproc.cls]] で確認してほしい.

**複数ファイルの管理の問題 [#f87d71a9]

複数の論文を一つにまとめることの面倒さについては,『実践解説』の第9.1節(pp. 283--288)にわかりやすい記述がある.Web 上にも次のような情報(質問と回答)がある(奥村晴彦氏の「TeX FAQ」).

-[[31514:http://oku.edu.mie-u.ac.jp/~okumura/texfaq/qa/31514.html]]
-[[31515:http://oku.edu.mie-u.ac.jp/~okumura/texfaq/qa/31515.html]]
-[[31516:http://oku.edu.mie-u.ac.jp/~okumura/texfaq/qa/31516.html]]
-[[31517:http://oku.edu.mie-u.ac.jp/~okumura/texfaq/qa/31517.html]]
-[[31518:http://oku.edu.mie-u.ac.jp/~okumura/texfaq/qa/31518.html]]
-[[31519:http://oku.edu.mie-u.ac.jp/~okumura/texfaq/qa/31519.html]]
-[[31520:http://oku.edu.mie-u.ac.jp/~okumura/texfaq/qa/31520.html]]
-[[31521:http://oku.edu.mie-u.ac.jp/~okumura/texfaq/qa/31521.html]]

ただし『実践解説』第9.1節の記述とは違い,(理系と違って TeX で原稿を提出する人は少ないため)個々の論文(これ以降は「記事」と呼ぶ)で定義されるマクロについては,ほとんど考慮する必要がない.

さて,『実践解説』第9.1節の方針に従って,次のようにクラスファイルを定義することにした.

-個々の記事は独立したファイルにして,親ファイルでそれを読み込む((\include の処理と大体同じ.))

**論文集の体裁 [#q77ca851]

-個々の記事の冒頭に(論文)題名,著者名を出力する
-柱には,左ページに著者名,右ページに論文名を出力する
-論文集全体の目次と記事の目次を別々に出力できるようにする

その他に

-文系では論文副題をつけることが多いので,そのためのコマンドを標準で用意する

**コマンドの実装 [#wf8754b4]

***\includearticle コマンドの定義 [#yc65ac5c]

\@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}

以上で次のような処理を行っている.

-\clearpage (二箇所)で常に記事が右ページから始まるようにする(改丁).
-\refstepcounter{article} で記事の数を数えるカウンター「article」(後述)を1増やす.
-\edef\@curr@filename{#1} で今読み込んだ記事ファイルのファイル名を保存する.\edef を用いているので,\def\includearticle の定義の外でも \@curr@filename コマンドを用いることができる.
-\if@filesw \immediate\openout\@articleaux=#1.aux\relax \fi で,今読み込んだ記事ファイルに対応する aux ファイルがあればそれを読み込む.ただし \nofiles などの記述があって,aux ファイルを読み込まないようにしている場合には読み込まない.
-\@init@article@data で記事ごとにリセットすべきコマンド,カウンタ等をリセットする(後述).
-\@input@{#1} で実際に記事を読み込む.
-\if@filesw \immediate\closeout\@articleaux \fi で,aux ファイルを読み込んだ場合に,それを閉じる.
-\if@write@articletoc 以下で記事ごとの toc ファイルを生成する(後述).これを元に記事内目次を作成する.

***記事内の論文タイトル等 [#zc65f4b0]

記事内には次のように記述する.\makearticletitle が実際に論文タイトル等を出力するコマンドである.

 \articletitle{論文タイトル}
 \articlesubtitle{\−−{}論文副題\−−}
 \articleauthor{著者1 \AND 著者2}
 
 \makearticletitle

論文副題は \−− で囲んだ方が良いだろう.\−− というコマンドは okumacro.sty に含まれている((読み込まない場合は,okumacro.sty の該当部分をコピーして親ファイルのプリアンブルに書き込んでおく.)).

定義は次のようになる.

 \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
 }

-\articletitle が定義されていない場合は「No \articletitle given」というエラーが出る((\articlesubtitle が定義されていなくてもエラーは出ない.)).
-\articleauthor が定義されていない場合は「No \articleauthor given」というエラーが出る.
-\makearticletitle の定義の中の \@makearticletitle で実際に論文タイトル等を出力している.
-\@makearticletitle の中で \@articletitle (論文タイトルの文字列),\@articlesubtitle (論文副題の文字列),\@articleauthor (著者の文字列)の出力の体裁を定義している.体裁を変える場合はこの箇所を変更すれば良い.

***gtc ファイルヘの書き出し [#s9efdb6c]

(親ファイル名).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}

***カウンタの定義 [#gffb492f]

記事が変わるごとに,当然節番号,脚注番号はリセットされなければならない.そのために,「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」カウンタが増えてもリセットされない.これは,例えば

-''第1部 論文''
-''第2部 研究ノート''
-''第3部 翻訳''

といった具合に,記事の種類ごとに区分を設ける場合を考慮に入れているためである.

数式((言語系ではまず用いることはないが.))・脚注番号をリセットするために次の記述を加えた.

 \@addtoreset{equation}{article}
 \@addtoreset{footnote}{article}

***各種コマンドの初期化 [#efa43597]

記事ファイルを読み込むごとに,然るべきコマンドを初期化する必要がある.そのためのコマンド \@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@ コマンドが記事ファイルを読み込む直前にこのコマンドを実行して各種のコマンドを初期化している.

**目次 [#zbfecac3]

目次には次の2種類がある((図目次などを加えればそれ以上あるが,論文集では普通用いない.ここでは狭義の目次についてのみ述べる.)).

+論文集全体の目次
+個々の論文の目次(個々の論文の冒頭)

処理方法としては,「章ごとの目次」など「複数箇所に作成する目次」と同じになる.特に『実践解説』の第8.1節「複数箇所に作成する目次」(pp. 261-275,特に「(3) 章ごとに aux ファイルを作成する方法」),第9.3節「目次の作成・LaTeX カウンタの管理」(pp. 296-302)を参考にした.

***論文集全体の目次 [#m1d7252a]

論文集全体の目次には,次の項目を出力する.

+論文タイトル
+論文副題(存在すれば)
+著者
+ページ

出力するには,親ファイルに

 \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}} のように格納されているデータを一つずつ取り出すコマンドを以下のように定義した.

-\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] 以下で,実際の出力形式を定めている.

まず,

-\@articlesubtitle@indent=1zw
-\@articleauthor@indent=2zw

の記述を変更すれば,それぞれのインデントが調整できる.

出力処理のメインの部分は次のようになっている.

-\@firstofthree#1\@empty\@empty\@empty% で論文タイトルを出力する.
-\nobreak\hfil\nobreak\hbox to\@pnumwidth{\hss#2}\par で,行を変えないまま(論文タイトルに続けて)伸縮可能な空白(グルー)を挿入した後,右端にページ数を出力する.その後改行((実際の処理としては改段落.)) する.
-\if\@secondofthree#1\@empty% で,論文副題がある場合とない場合とで処理方法を分けている.
--論文副題がない場合は以下の処理はスキップする.
--論文副題がある場合.
---\hspace\@articlesubtitle@indent% で,インデントを挿入する.
---\@secondofthree#1\@empty\@empty\@empty% で論文副題を出力する.
---\nobreak\hfil\nobreak\hbox to\@pnumwidth{\hss}\par で論文副題がページ数の下まで入り込まないように調整している.
-\hspace\@articleauthor@indent% で,著者名の前のインデントを挿入する.
-\@thirdofthree#1\@empty\@empty\@empty% で著者名を出力する.
-\nobreak\hfil\nobreak\hbox to\@pnumwidth{\hss} で著者名がページ数の下まで入り込まないように調整している.
-\par で一つの項目を終了して,改段落する.

***記事内目次の作成 [#n09001af]

通常の目次作成と変わらないが,toc ファイルの出力先が (記事ファイル名).toc のように,個々の記事に対応するものになる点に注意する必要がある.

記事内目次を作成するには,記事ファイル中に

 \articletoc

と記述しておく((通常の場合と同じように,論文タイトル等の後,記事本文の前に記述する.)).

定義は次のようにした.

 \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}}}

次のような処理をしている.

-\newwrite\tf@toc で toc ファイルの出力先を確保している.
-\setcounter{tocdepth}{2} で \subsection まで目次に出力する設定にしている((例えば \subsubsection まで出力させるには,\articletoc の前に \setcounter{tocdepth}{3} と記述しておく.)).
-\section*{\contentsname} と定義しているので,記事内目次に出力される「目次」という文字列は,\section での出力と同じように(同じレイアウト,文字の大きさで)処理される((論文集の目次は \chapter と同じ.)).
-\@input@{\@curr@filename.toc} で (記事ファイル).toc を読み込んでいる.

**柱 [#pf664c6b]

論文集の一般的な形式として柱には,

-''左ページ'' 著者名
-''右ページ'' 論文名

を入れることにする.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}%

**脚注 [#k8dc39b3]

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」という表記でも自然に思える.

よって

-本文中には,右肩に「*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 の場合脚注欄に「*」が現れなかったのが,現れてしまう,という症状が現れる((しかしこれを何が何でも消さなければならない,という人は,普通いないであろう.)).

**文献表 [#b54f0561]

西洋古典学での文献表と LaTeX の標準の文献表((thebibliography 環境.)) の違いは主に以下の2つである.

-西洋古典学では,番号付けは普通行わない
-「テキスト」「注釈」など,参考文献を分類することがある

そのため,次のような方針を立てて,classicsbibliography 環境を定義した.

-参照の機能は省略し,list 環境のみで定義する
-thebibliography 環境とは違い,『参考文献』などの見出しが出力されないようにする

定義は以下のようにした.

 \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}

**参考文献 [#r445c838]

+奥村晴彦,『LaTeX2e 美文書作成入門』(改訂第3版),技術評論社,1997/2004年(改訂第3版).
+ページ・エンタープライゼズ(株),『LaTeX2e マクロ&クラスプログラミング基礎解説』,技術評論社,2002年.
+吉永徹美,『LaTeX2e マクロ&クラスプログラミング実践解説』,技術評論社,2003年.

#amazon(4774119407,left,奥村)
#amazon(4774115460,left,『基礎解説』)
#amazon(4774117587,left,『実践解説』)
#amazon(,clear)



トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS