Kodama's home / tips.
また, これに対応する latex2html 用 Perl スクリプト も作成した.
次の例では, 後で説明する comment-k.sty を usepackage して, 2つのコメント関数 commentA と commentB を作っている. LaTeX コンパイルすると, commentA の部分は DVI ファイルの表示には出ず, commentB の部分は表示される.
\documentclass{article}
\usepackage{comment-k}
\excomment{commentA} % exclude comment
\incomment{commentB} % include comment
\begin{document}
\commentA{A1\\
A2
A3}
\commentB{B1\\
B2
B3}
\end{document}
以下でこのコメント機能を実現するスタイルを作る. 発想としては以下のような定義が元になっている.
\def\commentA#1{\relax}
\def\commentB{\relax}
incomment や excomment が文字列を受け取って, その文字列から関数を定義する. そのためには csname を使うと良い.
まとめると以下のようになる.
%% comment-k.sty : exclude/include comment.
%% 2002.01.01 K.Kodama
%% See comment.sty for another approach.
\long\def\ex@comment#1{\relax}
\def\excomment#1{\expandafter\def\csname #1\endcsname{\ex@comment}}
\def\incomment#1{\expandafter\def\csname #1\endcsname{\relax}}
\endinput
Kodama's home / tips.