2

I try to use tcolorbox environment inside longtable environments. Minimal sample:

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{longtable}
\usepackage{lipsum}

\begin{document}
\begin{longtable}{|p{\linewidth}|}
\hline
\begin{tcolorbox}
\lipsum[3]
\end{tcolorbox}
\\
\hline
\end{longtable}
\end{document}

Unfortunately, the code does not compile:

! Misplaced \noalign.                                                                                                            
\pagebreak ->\noalign                                                                                                            
                      {\ifnum `}=0\fi \@testopt {\LT@no@pgbk -}4                                                                 
l.11 \end{tcolorbox}                                                                                                             

Is there any magic option/hack/workaround to do it?

4

You must reset the before key. In the default it contains a \pagebreak and as longtable redefines \pagebreak you get errors. This here compiles:

\documentclass{article}
\usepackage{tcolorbox}
\usepackage{longtable}
\usepackage{lipsum}

\begin{document}

\begin{longtable}{|p{\linewidth}|}
\hline
\begin{tcolorbox}[before={}]
\lipsum[3]
\end{tcolorbox}
\\
\hline
\end{longtable}
\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.