
Estou tentando obter uma tabela de changelog muito boa em meu modelo e estou tentando fazer isso usando o método do índice (gravando em um arquivo e lendo-o depois). Isso funciona bem, porém não me permite (até onde posso ver) escrever essas linhas em uma tabela REAL (portanto, não um toc, mas como um tabu ou tabularx).
Alguém aqui pode me ajudar com isso?
Aqui está o que eu tentei:
\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}
No momento está me dando este erro:
Missing } inserted. ...18 & Foitn & Initial version}{1}{Doc-Start}
Missing \endgroup inserted. ...18 & Foitn & Initial version}{1}{Doc-Start}
Responder1
Esse é o código que usei para criar o arquivo. Ele não grava no arquivo *.aux, mas diretamente no arquivo \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}
Maneira de usar \addtocontents
e similares:
\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}