0

I found a "protocol" environment to write protocoles in Latex.

The problem is that when the list of items to be added to the protocol gets too long, the items are continued on the same page, therefore hiding a lot of times.

Is there a way to make sure that the new environment can take care of long lists? Especially without manually breaking the list?

Here is an example:

\documentclass{article}

\usepackage{tabularx}
\usepackage{siunitx}
\usepackage{textcomp}
\usepackage{longtable}

\newcommand\Tstrut{\rule{0pt}{1.9\normalbaselineskip}}
\newcommand\Bstrut{\rule[-0.10ex]{0pt}{0pt}}
\renewcommand{\labelenumii}{\theenumii}
\renewcommand{\theenumii}{\theenumi.\arabic{enumii}.}

\newcounter{protocol}
\newenvironment{protocol}[1]
  {\par\addvspace{\topsep}
   \noindent
   \tabularx{\linewidth}{@{} X @{}}
    \hline
    \Tstrut
    \refstepcounter{protocol}\textbf{Protocol \theprotocol} #1 \\
    \Bstrut\\
    \hline
    \\}
  { \\
    \hline
   \endtabularx
   \par\addvspace{\topsep}}

\newcommand{\sbline}{\\[.5\normalbaselineskip]}% small blank line

\begin{document}
\begin{protocol}{extraction}

\begin{enumerate}
  \item
  Section 1
    \begin{enumerate}
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \end{enumerate}

  \item
  Section 2
    \begin{enumerate}
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
      \begin{enumerate}
      \item
      \item
        \begin{enumerate}
        \item
        \end{enumerate}
      \item
      \item
      \item
      \item
      \item
      \end{enumerate}
    \item
    \item
    \item
    \end{enumerate}

  \item
  Section 3
    \begin{enumerate}
    \item
    test
      \begin{enumerate}
      \item
      set
      \item
      \item
      ets
      \item
      ste
      \item
      tset
      \item
      est
      \item
      This item is shown
      \item
      This item is hidden
      \item
      \end{enumerate}
    
    \item
      \begin{enumerate}
      \item
      \item
      \item
      \item
      \item

      \item
      \item
      \item
      \item
      \item
      \item
      \end{enumerate}
    \end{enumerate}
    
  \item
  Section 4
    \begin{enumerate}
    \item
    \item
    \item
    \end{enumerate}

  \end{enumerate}

\end{protocol}


\end{document}
3
  • 3
    tabularx cannot break across penvironment, which brings theages. You might try try to replace tabularx with the xltabular , which brings the functionalities of longtable (and its syntax) to `tabularx. Be aware that a tabular environment can be split between two pages only between rows, not inside a row.
    – Bernard
    Commented Feb 1, 2021 at 19:41
  • 1
    What is exactly is the purpose of a table here, especially since it only contains a single column?
    – leandriis
    Commented Feb 2, 2021 at 6:36
  • @leandriis, I don't know other than it was in the post here; tex.stackexchange.com/questions/408900/… Commented Feb 2, 2021 at 14:39

1 Answer 1

0

Thanks @Bernard for the input. Here is how it would look like. The only thing is that it is not "page-breaking automatically", but it gets the job done!

\documentclass{article}

\usepackage{tabularx}
\usepackage{xltabular}
\usepackage{siunitx}
\usepackage{textcomp}
\usepackage{longtable}
\usepackage{array}
\usepackage{enumitem}

\newcommand\Tstrut{\rule{0pt}{1.9\normalbaselineskip}}
\newcommand\Bstrut{\rule[-0.10ex]{0pt}{0pt}}
\renewcommand{\labelenumii}{\theenumii}
\renewcommand{\theenumii}{\theenumi.\arabic{enumii}.}

\newcounter{protocol}
\newenvironment{protocol}[1]
  {\par\addvspace{\topsep}
   \noindent
   \xltabular{\linewidth}{@{} X @{}}
    \hline
    \Tstrut
    \refstepcounter{protocol}\textbf{Protocol \theprotocol} #1 \\
    \Bstrut\\
    \hline
    \\}
  { \\
    \hline
   \endxltabular
   \par\addvspace{\topsep}}

\newcommand{\sbline}{\\[.5\normalbaselineskip]}% small blank line

\begin{document}
\begin{protocol}{extraction}

\begin{enumerate}[series=TE]
  \item
  Section 1
    \begin{enumerate}
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \end{enumerate} % sect 1 

  \item
  Section 2
    \begin{enumerate}
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
    \item
      \begin{enumerate}
      \item
      \item
        \begin{enumerate}
        \item
        \end{enumerate}
      \item
      \item
      \item
      \item
      \item
      \end{enumerate}
    \item
    \item
    \item
    last item in here.
    \end{enumerate} % section 2 

\end{enumerate} \\

\begin{enumerate}[resume*=TE]

  \item
  Section 3
    \begin{enumerate}
    \item
    test
      \begin{enumerate}
      \item
      set
      \item
      \item
      ets
      \item
      ste
      \item
      tset
      \item
      est
      \item
      This item is shown
      \item
      This item is not hidden anymore. 
      \item
      \end{enumerate}
    
    \item
      \begin{enumerate}
      \item
      \item
      \item
      \item
      \item

      \item
      \item
      \item
      \item
      \item
      \item
      \end{enumerate}
    \end{enumerate}
    
  \item
  Section 4
    \begin{enumerate}
    \item
    \item
    \item
    \end{enumerate}

\end{enumerate}

\end{protocol}


\end{document}
1
  • 1
    You can accept ow answer and by this inform people, that your problem is solved.
    – Zarko
    Commented Oct 25, 2022 at 5:46

You must log in to answer this question.

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