\begin{longtable}{p{0.5cm}p{4cm}p{2cm}|p{2cm}p{2cm}|p{2cm}|}
\cline{4-6}
& & & \multicolumn{3}{c|}{Percentages and averages} \\ \hline
\multicolumn{1}{|l|}{Nr.} & \multicolumn{1}{p{4cm}|}{Question Question Question Question Question Question Question Question Question Question Question Question Question} & Answers & Pulukan & Tumbak Bayuh & Denpasar \\ \hline
\multicolumn{1}{|l|}{\multirow{2}{*}{23}} & \multicolumn{1}{p{4cm}|}{\multirow{2}{*}{Do you know of any organizations that can collect plastic from you? Do you know of any organizations that can collect plastic from you?}} & Yes & \% & \% & \% \\ \cline{3-6}
\multicolumn{1}{|l|}{} & \multicolumn{1}{l|}{} & No & \% & \% & \% \\ \hline
\end{longtable}
有人知道如何解决这个问题吗?提前谢谢您!
答案1
以下是使用更简单的代码来实现此目的的方法:我使用环境,它将的xltabular
功能带到,因此 longtable 不会溢出到边距中。我添加了 ,它定义了带有以字母为前缀的说明符的列的单元格中的最小垂直填充(或者如果您加载)。longtable
tabularx
cellspace
S
C
siunitx
\documentclass{article}
\usepackage{ragged2e}
\usepackage{xltabular}
\usepackage{longtable}
\usepackage{array, multirow, bigstrut, cellspace}
\setlength{\cellspacetoplimit}{3pt}
\setlength{\cellspacebottomlimit}{3pt}
\addparagraphcolumntypes{X}
\begin{document}
\setlength{\tabcolsep}{4pt}
\setlength{\bigstrutjot}{6.2ex}
\begin{xltabular}{\linewidth}{|Sl>{\hsize=1.6\hsize\RaggedRight}S{X}|Sl|*{3}{>{\hsize=0.8\hsize\arraybackslash}X|}}
\cline{4-6}
\multicolumn{3}{c|}{} & \multicolumn{3}{Sc|}{Percentages and averages} \\ \hline
Nr. & Question Question Question Question Question Question Question Question Question Question Question Question Question & Answers & Pulukan & Tumbak Bayuh & Denpasar \\ \hline
23 & \smash{\parbox[t]{\hsize}{Do you know of any organizations that can collect plastic from you? Do you know of any organizations that can collect plastic from you?}} & Yes \bigstrut[b] & \% & \% & \% \\ \cline{3-6}
& & No \bigstrut[b] & \% & \% & \% \\ \hline
\end{xltabular}
\end{document}
答案2
这里还有三条建议:
\documentclass{article}
\usepackage{geometry}
\usepackage{longtable}
\usepackage{pdflscape}
\usepackage{multirow}
\usepackage{xltabular}
\usepackage{makecell}
\renewcommand{\theadfont}{\normalsize}
\usepackage{booktabs}
\begin{document}
\begin{longtable}{|l|p{4cm}|l|l|l|l|}
\cline{4-6}
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & & \multicolumn{3}{c|}{Percentages and averages} \\ \hline
Nr. & Question Question Question Question Question Question Question Question Question Question Question Question Question & Answers & Pulukan & Tumbak Bayuh & Denpasar \\ \hline
\multirow{2}{*}{23} & \multirow{6}{=}{Do you know of any organizations that can collect plastic from you? Do you know of any organizations that can collect plastic from you?} & Yes & \% & \% & \% \\
& & & & & \\
& & & & & \\ \cline{3-6}
& & No & \% & \% & \% \\
& & & & & \\
& & & & & \\ \hline
\end{longtable}
\begin{landscape}
\begin{xltabular}{\linewidth}{|l|X|l|l|l|l|}
\cline{4-6}
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & & \multicolumn{3}{c|}{Percentages and averages} \\ \hline
\thead{Nr.} & \thead{Question} & \thead{Answers} & \thead{Pulukan} & \thead{Tumbak\\ Bayuh} & \thead{Denpasar} \\ \hline
\multirow{2}{*}{23} & \multirow{2}{=}{Do you know of any organizations that can collect plastic from you? Do you know of any organizations that can collect plastic from you?} & Yes & \% & \% & \% \\\cline{3-6}
& & No & \% & \% & \% \\ \hline
\end{xltabular}
\begin{xltabular}{\linewidth}{lXllll}
\toprule
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & & \multicolumn{3}{c}{Percentages and averages} \\ \cmidrule{4-6}
\thead{Nr.} & \thead{Question} & \thead{Answers} & \thead{Pulukan} & \thead{Tumbak\\ Bayuh} & \thead{Denpasar} \\
\midrule
\multirow{2}{*}{23} & \multirow{2}{=}{Do you know of any organizations that can collect plastic from you? Do you know of any organizations that can collect plastic from you?} & Yes & \% & \% & \% \\
& & No & \% & \% & \% \\ \bottomrule
\end{xltabular}
\end{landscape}
\end{document}