我正在学习 Tex。我试图将无序列表扩展到 2 列,但不起作用,我无法找出问题所在。对于常规文本字符串,它工作正常。以下是我无法运行的示例代码:
\documentclass[12pt,a4paper]{article}
\usepackage{enumitem}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{\linewidth}{|X|X|}
\hline
Col 1 & Col 2\\
\hline
\multicolumn{2}{|>{\hsize=\dimexpr2\hsize+2\tabcolsep+\arrayrulewidth\relax}X|}{A long sentence that successfully spans across 2 cols.}\\
\hline
\multicolumn{2}{|>{\hsize=\dimexpr2\hsize+2\tabcolsep+\arrayrulewidth\relax}X|}{
\begin{itemize}
\item An item in Itemize that should span across 2 cols.
\item Another item in Itemize that should also span across 2 cols.
\end{itemize}}\\
\hline
\end{tabularx}
\end{document}
非常感谢您的帮助!
答案1
您也需要设置\linewidth
(手册可能应该提到这一点)
\documentclass[12pt,a4paper]{article}
\usepackage{enumitem}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{\linewidth}{|X|X|}
\hline
Col 1 & Col 2\\
\hline
\multicolumn{2}{|>{\hsize=\dimexpr2\hsize+2\tabcolsep+\arrayrulewidth\relax}X|}{A long sentence that successfully spans across 2 cols.}\\
\hline
\multicolumn{2}{|>{\hsize=\dimexpr2\hsize+2\tabcolsep+\arrayrulewidth\relax\linewidth=\hsize}X|}{
\begin{itemize}
\item An item in Itemize that should span across 2 cols.
\item Another item in Itemize that should also span across 2 cols.
\end{itemize}}\\
\hline
\end{tabularx}
\end{document}