TeX/ClassFile/glcproc.cls

glcproc.cls の実装(v1.0)

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

複数ファイルの管理の問題

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

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

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

論文集の体裁

その他に

コマンドの実装

\includearticle コマンドの定義

\@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 ファイルヘの書き出し

(親ファイル名).gtc(global table of contents)ファイルに以下の項目を書き出す.

  1. 論文タイトル
  2. 論文副題
  3. 著者名
  4. ページ

この処理は,\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

  1. 論文集全体の目次
  2. 個々の論文の目次(個々の論文の冒頭)

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

論文集全体の目次

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

  1. 論文タイトル
  2. 論文副題(存在すれば)
  3. 著者
  4. ページ

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

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

参考文献

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

#amazon(4774119407,left,奥村)

#amazon(4774115460,left,『基礎解説』)

#amazon(4774117587,left,『実践解説』)

#amazon(,clear)


*1 \include の処理と大体同じ.
*2 読み込まない場合は,okumacro.sty の該当部分をコピーして親ファイルのプリアンブルに書き込んでおく.
*3 \articlesubtitle が定義されていなくてもエラーは出ない.
*4 言語系ではまず用いることはないが.
*5 図目次などを加えればそれ以上あるが,論文集では普通用いない.ここでは狭義の目次についてのみ述べる.
*6 実際の処理としては改段落.
*7 通常の場合と同じように,論文タイトル等の後,記事本文の前に記述する.
*8 例えば \subsubsection まで出力させるには,\articletoc の前に \setcounter{tocdepth}{3} と記述しておく.
*9 論文集の目次は \chapter と同じ.
*10 しかしこれを何が何でも消さなければならない,という人は,普通いないであろう.
*11 thebibliography 環境.

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2019-03-30 (土) 04:06:20