헤더를 업데이트하기 위해 보조 파일의 문자열을 사용하는 방법은 무엇입니까?

헤더를 업데이트하기 위해 보조 파일의 문자열을 사용하는 방법은 무엇입니까?

문서(일반적인 문서)에는 텍스트 문자열 형식("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

나는 이것이 당신이 원하는 것이라고 생각합니다. 새 파일이 필요하지 않습니다 .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}

여기에 이미지 설명을 입력하세요

입력 텍스트 앞에 문서 헤더에 나타나는 개정 줄에 타임스탬프의 새 값이 필요한 경우 좀 더 열심히 작업해야 합니다.문서의 다른 부분에 텍스트를 복사하는 방법은 무엇입니까?

관련 정보