![헤더를 업데이트하기 위해 보조 파일의 문자열을 사용하는 방법은 무엇입니까?](https://rvso.com/image/281466/%ED%97%A4%EB%8D%94%EB%A5%BC%20%EC%97%85%EB%8D%B0%EC%9D%B4%ED%8A%B8%ED%95%98%EA%B8%B0%20%EC%9C%84%ED%95%B4%20%EB%B3%B4%EC%A1%B0%20%ED%8C%8C%EC%9D%BC%EC%9D%98%20%EB%AC%B8%EC%9E%90%EC%97%B4%EC%9D%84%20%EC%82%AC%EC%9A%A9%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
문서(일반적인 문서)에는 텍스트 문자열 형식("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}
입력 텍스트 앞에 문서 헤더에 나타나는 개정 줄에 타임스탬프의 새 값이 필요한 경우 좀 더 열심히 작업해야 합니다.문서의 다른 부분에 텍스트를 복사하는 방법은 무엇입니까?