
私はテンプレートに非常に優れた変更ログ テーブルを作成しようとしており、目次方式 (つまり、ファイルに書き込み、後でそこから読み取る) を使用してそれを実行しようとしています。これはうまく機能しますが、(私が見る限り) これらの行を実際のテーブル (つまり、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}