4

My question stems from an adaptation of the solution shown here : Generating lists and tables of items from commands in the document

The idea is to sum up the reviews of a given document in a table. Since the table is on the front page of a whole series of document, I was looking for a way to automatize it.

In my document class :

\usepackage{datatool}
\usepackage{booktabs} 
\usepackage{longtable}

\DTLnewdb{docreview}

\newcommand{\review}[6]{%
  \DTLnewrow{docreview}%
  \DTLnewdbentry{docreview}{Date}{#1}%
  \DTLnewdbentry{docreview}{Redacteur}{#2}% 
  \DTLnewdbentry{docreview}{Verificateur}{#3}%
  \DTLnewdbentry{docreview}{Approbateur}{#4}%   
  \DTLnewdbentry{docreview}{Modification}{#5}%    
  \DTLnewdbentry{docreview}{Indice}{#6}%
}

\renewcommand{\maketitle}{
  [...]
  \begin{tabular}{|c|c|c|c|c|c|c|} \hline
    Date &  Redacteur &  Verificateur &  Approbateur & Visa de l'approbateur &  Modification & Indice \\ \hline\hline
    \DTLforeach{docreview}{%
    \Date=Date,\Redacteur=Redacteur,\Verificateur=Verificateur,\Approbateur=Approbateur,\Modification=Modification, \Indice=Indice}{%
    \Date & \Redacteur & \Verificateur & \Approbateur & & \Modification & \Indice \\\hline} 
  \end{tabular}
}

In my document itself :

\begin{document}
\review{1 janvier 1970}{Me}{Verif.}{Approb.}{Epoch}{0}
\review{22 avril 2019}{Me}{Verif.}{Approb.}{Mod.}{0}
\maketitle
\end{document}

That solution works like a charm except for a detail which I can't figure out. The generated table shows the two first vertical bar (1st column limits) and only these that continues an additional row...

pdf output

Does anyone have any idea ?

Thanks a lot

8

The last \\\hline shouldn't be inside the the loop but after it, so that the code of the loop doesn't triggers the creation of a new row:

\documentclass{article}

\usepackage{datatool}
\usepackage{booktabs}
\usepackage{longtable}

\DTLnewdb{docreview}

\newcommand{\review}[6]{%
  \DTLnewrow{docreview}%
  \DTLnewdbentry{docreview}{Date}{#1}%
  \DTLnewdbentry{docreview}{Redacteur}{#2}%
  \DTLnewdbentry{docreview}{Verificateur}{#3}%
  \DTLnewdbentry{docreview}{Approbateur}{#4}%
  \DTLnewdbentry{docreview}{Modification}{#5}%
  \DTLnewdbentry{docreview}{Indice}{#6}%
}

\renewcommand{\maketitle}{
  [...]


  \begin{tabular}{|c|c|c|c|c|c|c|} \hline
    Date &  Redacteur &  Verificateur &  Approbateur & Visa de l'approbateur &  Modification & Indice \\ \hline\hline
    \DTLforeach{docreview}{%
    \Date=Date,\Redacteur=Redacteur,\Verificateur=Verificateur,\Approbateur=Approbateur,\Modification=Modification, \Indice=Indice}{%
    \Date & \Redacteur & \Verificateur & \Approbateur & & \Modification & \Indice
   \DTLiflastrow{}{\\\hline}} %<-------
    \\\hline %<---------
  \end{tabular}
}


\begin{document}
\review{1 janvier 1970}{Me}{Verif.}{Approb.}{Epoch}{0}
\review{22 avril 2019}{Me}{Verif.}{Approb.}{Mod.}{0}
\maketitle
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.