长表有多列问题

长表有多列问题

我尝试使用乳胶来构建这个表格,但不知道出了什么问题。 我想要的是

\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{@{\extracolsep{\fill}}|[c]@{}}


 \hline
 \multicolumn{2}{| r |}{\cellcolor{gray!25} Begin of Table}\\
 \hline
 A) Something & B) something j\\
  \hline
  C) Something & D) something j\\
 \hline
 \endfirsthead



 \hline
 \endfoot


 \endlastfoot

 \end{longtable}

答案1

目前尚不清楚您想要获取哪个表格。如果是第一个,并且末尾的表格长度超过一页,则解决方案可以是:

\documentclass{article}
\usepackage{geometry}
\usepackage[table]{xcolor}
\usepackage{longtable, tabularx}

%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    with \verb+longtable+:
\begin{longtable}{|*{2}{p{\dimexpr0.5\linewidth-2\tabcolsep-\arrayrulewidth\relax}|}}
    \hline
\multicolumn{2}{| c |}{\cellcolor{gray!25} Begin of Table}\\
    \hline
 A) Something   & B) something j    \\
    \hline
 C) Something & D) something j\\
    \hline
    \end{longtable}

with \verb+tabularx+:
    \begin{center}
\begin{tabularx}{\linewidth}{|X|c|X|c|}
    \hline
    \rowcolor{gray!25}
\multicolumn{4}{| l |}{What is capital of Canada?}  \\
    \hline
Berlin   & C &  Ottawa  & A    \\
    \hline
Rome    & D &  Canberra & B    \\
    \hline
\end{tabularx}
    \end{center}
\end{document}

给予

在此处输入图片描述

相关内容