
나는 내 템플릿에 매우 멋진 변경 로그 테이블을 가져오려고 노력하고 있으며 목차 방식을 사용하여 그렇게 하려고 합니다(따라서 파일에 쓰고 나중에 그 내용을 읽음). 이것은 잘 작동하지만 (내가 볼 수 있는 한) 이 줄을 REAL 테이블에 쓰는 것을 허용하지 않습니다(따라서 toc는 아니지만 tabu 또는 tabularx와 같습니다).
여기 누가 나를 도와줄 수 있나요?
내가 시도한 것은 다음과 같습니다.
\documentclass{article}
\usepackage{hyperref}
\usepackage{verbatim}
\usepackage{tabu}
\makeatletter
\newcommand{\l@changelogline[2]}{
#2\\
}
\makeatother
\newcommand{\changelog}{
%\csname @starttoc\endcsname{cl}%
\begin{tabu} spread \textwidth {l l l X[l]}
\csname @starttoc\endcsname{cl}%
\end{tabu}
}
\addcontentsline{cl}{changelogline}{V0.1 & 21-02-2018 & Foitn & Initial version}
\addcontentsline{cl}{changelogline}{V0.2 & 22-02-2018 & Foitn & Some kind of change}
\begin{document}
asdf
\bigskip
\changelog
\end{document}
지금은 다음과 같은 오류가 발생합니다.
Missing } inserted. ...18 & Foitn & Initial version}{1}{Doc-Start}
Missing \endgroup inserted. ...18 & Foitn & Initial version}{1}{Doc-Start}
답변1
이것이 파일을 만드는 데 사용한 코드입니다. *.aux 파일에 쓰지 않고 \jobname.cl
.
\documentclass{article}
\usepackage{hyperref}
\usepackage{verbatim}
\usepackage{tabu}
\makeatletter
\newwrite\@changelog
\newcommand*\changelog@filename{\jobname.cl}
\newcommand*\changelog
{%
\IfFileExists{./\changelog@filename}
{%
\begin{tabu} spread \textwidth {l l l X[l]}%
\input{\changelog@filename}
\end{tabu}%
}{}%
}
\newcommand*\changelog@contents{}
\newcommand*\addchangelogline[4]
{%
\xdef\changelog@contents
{%
\unexpanded\expandafter{\changelog@contents
#1 & #2 & #3 & #4\string\\
}%
}%
}
\AtEndDocument
{%
\immediate\openout\@changelog=\changelog@filename
\immediate\write\@changelog{\changelog@contents}%
\immediate\closeout\@changelog
}
\makeatother
\addchangelogline{v0.1}{21-02-2018}{Foitn}{Initial version}
\addchangelogline{v0.2}{22-02-2018}{Foitn}{Some kind of change}
\begin{document}
asdf
\bigskip
\changelog
\end{document}
사용 방법 \addtocontents
등:
\documentclass{article}
\usepackage{hyperref}
\usepackage{verbatim}
\usepackage{tabu}
\makeatletter
\newwrite\@changelog
\newcommand*\changelog@extension{cl}
\newcommand*\changelog@filename{}
\edef\changelog@filename{\jobname.\changelog@extension}
\newcommand*\changelog
{%
\IfFileExists{./\changelog@filename}
{%
\begin{tabu} spread \textwidth {l l l X[l]}%
\input{\changelog@filename}
\end{tabu}%
}{}%
\bgroup
\renewcommand*\changelogline[4]{}%
\@starttoc{\changelog@extension}%
\egroup
}
\newcommand*\changelog@contents{}
\newcommand*\changelogline[4]{#1 & #2 & #3 & #4\\}
\newcommand*\addchangelogline[4]
{%
\addtocontents{\changelog@extension}
{\protect\changelogline{#1}{#2}{#3}{#4}}%
}
%\show\@starttoc
\makeatother
\addchangelogline{v0.1}{21-02-2018}{Foitn}{Initial version}
\addchangelogline{v0.2}{22-02-2018}{Foitn}{Some kind of change}
\begin{document}
asdf
\bigskip
\changelog
\end{document}