5

I need this code to be compilable without errors:

\documentclass{article}
\usepackage{tabularx}
\usepackage{amsmath, mathdots, paralist}
\usepackage{ltablex} % uncommenting this line will work

\begin{document}

\begin{tabularx}{\textwidth}{lX}
% & influential variables &
\textbf{Setting 1:} & This is my  description $X_{\text{bla}} \in \{1, \hdots , 20\}$.\\
\textbf{Setting 2:} & This splits into
\begin{compactitem}
        \item First item
        \item Second item
\end{compactitem} \\
\end{tabularx}
\end{document}

I am getting the error Something's wrong--perhaps a missing \item. \end{tabularx}. If I remove the line \usepackage{ltablex} it will work. However, I need the ltablex package and therefore I am looking for a possibility to let the code above be compilable. Any suggestions?

2

2 Answers 2

7

ltablex changes too much really, if you must merge longtable and tabularx I'd probably use ltxtable, but 99% of the time that i see tables set with {lX} they would be better set as a list, which naturally expands to full width and naturally breaks over a page, without any of the contortions that tabularx and longtable do.

However ltablex has a \keepXColumns to make it be a bit more compatible:

\documentclass{article}
\usepackage{tabularx}
\usepackage{amsmath, mathdots, paralist}
\usepackage{ltablex} % uncommenting this line will work

\keepXColumns
\begin{document}

\begin{tabularx}{\textwidth}{lX}
% & influential variables &
\textbf{Setting 1:} & This is my  description $X_{\text{bla}} \in \{1, \hdots , 20\}$.\\
\textbf{Setting 2:} & This splits into
\begin{compactitem}
        \item First item
        \item Second item
\end{compactitem} \\
\end{tabularx}
\end{document}
1

A workaround consists in inserting your compactitem environment in a \parbox of a suitable size. However there is a small problem with the vertical spacing of the environment (see image). It can be solved with the enumitem version of the compact itemize. Moreover, enumitem lists are easily customisable.

 \documentclass{article}
\usepackage{tabularx}
\usepackage{amsmath, mathdots, paralist}
\usepackage{ltablex} % uncommenting this line will work
\usepackage{enumitem} 

\begin{document}

\begin{tabularx}{\textwidth}{lX}
% & influential variables &
\textbf{Setting 1:} & This is my description $X_{\text{bla}} \in \{1, \hdots , 20\}$.\\
\textbf{Setting 2:} & This splits into\par
\parbox{10cm}{%
\begin{compactitem}
 \item First item
 \item Second item
\end{compactitem}
}%
\\
\end{tabularx}

\begin{tabularx}{\textwidth}{lX}
% & influential variables &
\textbf{Setting 1:} & This is my description $X_{\text{bla}} \in \{1, \hdots , 20\}$.\\
\textbf{Setting 2:} & This splits into\par
\parbox{10cm}{%
\begin{itemize}[noitemsep, topsep=1pt, wide = 1em]
 \item First item
 \item Second item
\end{itemize}
}%
\\
\end{tabularx}

\end{document} 

enter image description here

1
  • but using a parbox forces you to specify a width which negates the point of an X column, you may as well not use tabularx and just use p which will have the same result but vastly more efficient. Nov 30, 2014 at 23:01

You must log in to answer this question.

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