I would like to create a report summary at the beginning of my report. The report consists of sections/subsections that outline a test that either passed or failed.

The idea is to only add \passed or \failed in a section to print out passed/failed as well as add passed/failed to the report summary together with the test name (test name equals title of that section - see image below for an example).

The dynamic list from this post seemed to be a great solution, however I can't figure out how to pass along the test name. I've tried many things like adding \label{\thetitle} to each section to reference using \nameref{\thetitle}. But I guess the problem always is that the list is printed before everything else happens. Maybe writing to a temp file is a solution, or some different solution using a modified TOC, or maybe I'm completely off track and there are much better solutions. I'm happy to hear you suggestions.

Just for a better understanding: The goal is to generate this report automatically, that's why it is important to not find a hard coded solution but one that can scale dynamically.


 {\seq_new:c { g_chrillof_list_#1_seq }}
 {\iow_shipout:cn { @auxout } { \chrillofaddtolist { #1 } { #2 } }}
 {\seq_gput_right:cn { g_chrillof_list_#1_seq } { #2 }}
 {\seq_use:cn { g_chrillof_list_#1_seq } { }}
\AtEndDocument{\cs_set_eq:NN \chrillofaddtolist \use_none:nn }

    \addToList{ReportSummary}{PASSED & Test Name X\\}}
    \addToList{ReportSummary}{FAILED & Test Name X\\}}  


\section{Report Summary}
\begin{tabular}{l l}
    Status & Test Name\\

\section{Test 1}

\section{Test 2}
\subsubsection{Test 2a}

\subsubsection{Test 2b}


report summary example

1 Answer 1


This is a different approach to include or exclude parts of the report using the codesection package, so the "summary" is simply a standard TOC.

To add also "passed" or "failed" to the ToC (that only have sense if you print all the test) you only need to add this word to the optional argument od the \section (e.g., instead of \section{Foo} some like \section[Foo (passed)]{Foo}. You can use the xesearch package (using xelatex) to mark this keywords in colors automatically. The example print both passed and failed test except one "too bad to show". Setting \DefineCodeSection[true]{Passed} to false will hide sections 1, 2.2 and 2.3 and so on ...




    \SearchList*{green}{ \textcolor{green}{#1}}{Passed}
    \SearchList{red}{ \textcolor{red}{#1}}{Failed}
    \DefineCodeSection[true]{Passed} % show Passed ...
    \DefineCodeSection[true]{Failed} % and show also (some failed ...) 
\newcommand\Section[2]{\section[#1 -- #2]{#1}}
\newcommand\Subsection[2]{\subsection[#1 --~#2]{#1}}
\renewcommand\contentsname{Report summary\par\noindent\hrulefill}




\Section{Test 1}{Passed}  \par Bla bla bla passed this test. 

\section[So so ...]{Test 2}

    \Subsection{Foo}{Failed} Bla bla bla failed this test.

    \Subsection{Bar}{Passed} Bla bla bla ...

    \Subsection{Baz}{Passed} Bla bla bla ...

\SetCodeSection{Failed}{false} % Too bad pitfall to be showed ... 

    \Subsection{Whatever}{Failed} Bla bla bla failed miserably ... 

\SetCodeSection{Failed}{true} % 

    \Subsection{Whatever else}{Failed} Bla bla bla ... 

  • This wasn't what I had in mind, however this is a very neat solution. Thanks.
    – SimonL
    Aug 8, 2022 at 7:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .