補助ファイル内の文字列を使用してヘッダーを更新するにはどうすればよいですか?

補助ファイル内の文字列を使用してヘッダーを更新するにはどうすればよいですか?

ドキュメント (多くの場合に共通) には、テキスト文字列の形式でタイムスタンプを表示するヘッダーがあります (「2013 年 12 月 25 日」)。タイムスタンプ文字列は、"update"で読み込まれたファイルに由来します\input

最小限の動作例を作成しようとしましたが、例 (3 つのファイル) は期待どおりに動作しません。

% this is a listing of example.cls
\ProvidesPackage{example}
\LoadClassWithOptions{book}
\newcommand{\timestamp}[1]{#1}
\newcommand{\revision}{ \timestamp}
% this is a listing of example.tex
\documentclass[letterpaper]{example}
\begin{document}
This line represents the document header: \revision
\input{update} % update data from external file
Now the header should reflect the update: \revision
\end{document}
% this is a listing of "update"
% the date string should update the document header:
\timestamp{25 December 2013}
This line represents update text, which typically consists of dozens of lines.

いろいろ調べたり読んだりしましたが、まだ、またはなどのどの LaTeX メカニズムが\saveboxこの\renewcommandタスクに適しているのかわかりません。また、\timestampおよびの定義の適切な場所についても混乱しています。これらは、\revisionクラス ファイル ( example.cls)、メイン ドキュメント ファイル ( example.tex)、またはメイン ドキュメント ファイルを定期的に更新するファイル ( update) のどれで定義すればよいのでしょうか。ドキュメント ファイルが 1,000 個以上あるため、できるだけクラス ファイルで定義する方がよいでしょう。

答え1

これで望みどおりになると思います。新しい.clsファイルは必要ありません。

\documentclass{book}

\newcommand{\revision}{dummy value}

\newcommand{\timestamp}[1]{%
\renewcommand{\revision}{#1}
}

\begin{document}
This line represents the document header: \revision

\input{update} % update data from external file, type .tex

Now the header should reflect the update: \revision

\end{document}

ここに画像の説明を入力してください

入力テキストの前の文書ヘッダーに表示されるリビジョン行にタイムスタンプの新しい値が必要な場合は、もう少し作業が必要になります。テキストをドキュメントの別の部分にコピーするにはどうすればよいですか?

関連情報