I'm trying to generate a LaTeX jinja template for a table split over multiple pages which will be populated with automatically generated LaTeX. To achieve this, I use the longtable environment, however, when a cell contains a word with too many characters, it is not correctly wrapped. Here is the relevant snippet of code for the table (with dummy content):
\def\arraystretch{1.2}
\begin{document}
\begin{longtable}{p{0.1\linewidth} p{0.2\linewidth} p{0.7\linewidth} }
# & question & answer \
\arrayrulecolor{brand_dark} \hline
\endhead
\rowcolor{brand_light} \multicolumn{3}{l}{tXRcRDxdKJOJHbSAAZeOCcoEPlpNzymLx} \
\rowcolor{white}
LRenA &
\begin{minipage}[t]{\linewidth}
\begin{flushleft}KMtMfYwfHkGLLbaZFAfRtTFj\end{flushleft}
\end{minipage} & \hspace{0pt}
\begin{minipage}[t]{\dimexpr \linewidth - 0pt}
\begin{flushleft}
udrPJNdJGqOLzgGJjs
\end{flushleft}
\end{minipage}
\
\rowcolor{light-grey}
ZCKhv &
\begin{minipage}[t]{\linewidth}
\begin{flushleft}hnjtmbuJPwyvBkbGjKJMEojGlUHREvvzwKwSSQeOEU\end{flushleft}
\end{minipage} & \hspace{0pt}
\begin{minipage}[t]{\dimexpr \linewidth - 0pt}
\begin{flushleft}
NmEwyZowJszdELsNktHfOvSaSNmIqIDHqabyKtNzuUgReEauJpiwjppdQWrHqorhMBgopxsROQEHPs
\end{flushleft}
\end{minipage}
\
\rowcolor{white}
DPzyJ &
\begin{minipage}[t]{\linewidth}
\begin{flushleft}ikHnifxdnsPJNGEqvwTWjvHZ\end{flushleft}
\end{minipage} & \hspace{0pt}
\begin{minipage}[t]{\dimexpr \linewidth - 0pt}
\begin{flushleft}
BRiTGeOBvY
\end{flushleft}
\end{minipage}
\
\rowcolor{light-grey}
LYYiI &
\begin{minipage}[t]{\linewidth}
\begin{flushleft}ALdgFWrSKqcNpBEeDvtnZX\end{flushleft}
\end{minipage} & \hspace{0pt}
\begin{minipage}[t]{\dimexpr \linewidth - 0pt}
\begin{flushleft}
UtyYPYhXSSmSUzgnO
\end{flushleft}
\end{minipage}
\
\rowcolor{white}
plBsz &
\begin{minipage}[t]{\linewidth}
\begin{flushleft}VckBeukgwVihwVXtYbAPqgzd\end{flushleft}
\end{minipage} & \hspace{0pt}
\begin{minipage}[t]{\dimexpr \linewidth - 0pt}
\begin{flushleft}
VTEQmsYvTjinhubaqZDqVXSEdtmZVpwuYlLAIWGQbQmcRLnfhISiIdIpmhEEbGPMqoWCroWOHqJuMvCCEgtWqganBlBoJomZLvQQpSArshkAUXscRwLUyWbslXqMmEgUgdLvxnGnNcvMZgnRii
\end{flushleft}
\end{minipage}
\end{longtable}
\end{document}
The results in the following table:
Not that the content of the middle and right-most cells is encapsulated
in a mini page as in general, it can contain newlines as well as arbitrarily nested itemize, enumerate, flushleft, flushright and center environments and uses of \emph, \textbf and \color.
What would be the best way of making this sort of text wrap correctly?



xcolorwith the optiontable, the instruction\usepackage{colortbl}is redundant. – Mico Apr 09 '21 at 16:39hnjtmbuJPwyvBkbGjKJMEojGlUHREvvzwKwSSQeOEUdoes not line break using English hyphenation patterns. You could have just posted a paragraph with these strings without any table or packages in the example which would have made it much easier for people to provide a focussed example. – David Carlisle Apr 10 '21 at 12:52