我怎样才能使右边 4 列的宽度均等化?

我怎样才能使右边 4 列的宽度均等化?
\begin{table}[]

\begin{tabular}{|l|c|c|c|c|c|}

\hline & \multicolumn{1}{l|}{} & 
\multicolumn{4}{l|}{Forskningsspørsmål den kan besvare}  \\ \cline{3-6}
\multirow{-2}{*}{Kilde} & \multicolumn{1}{l|}{\multirow{-2}{*}{Relevant?}}  & 1 & 2 & 3 & 4 \\ \hline 

\rowcolor[HTML]{B4EAAB} 
This column needs to be quite wide & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark \\ \hline

\rowcolor[HTML]{F9BDBD} 
kilde 2  & X   & -  & -    & -   & -      \\ \hline

kilde 3            & JA/NEI   & V/-  & V/-  & V/- & V/-  \\ \hline

kilde  4    &   &   &    &   &      \\ \hline

kilde 5  &     &    &  &         &       \\ \hline

kilde 6  &   &     &    &     &     \\ \hline

kilde 7  &  &    &    &    &     \\ \hline

kilde 8  &  &  &  &       &      \\ \hline

kilde 9 &    &     &     &      &   \\ \hline

kilde 10  &    &  &   &    &   \\ \hline

kilde 11  &   &   &  &   &   \\ \hline

kilde 12 &   &  &   &   &   \\ \hline

kilde 13   &   &   &     &   &  \\ \hline

kilde 14   &  &   &    &  &    \\ \hline

kilde 15 &   &  &   &   &    \\ \hline

kilde 16  &    &   &   &     &   \\ \hline

kilde 17    &  & &    &   &    \\ \hline

kilde 18  &    &  &     &  &    \\ \hline

kilde 19  &   &  &     &    &    \\ \hline

kilde 20  &  &     &   &  &     \\ \hline

kilde 21   &  &    &   &    &  \\ \hline

kilde 22  &   &   &  &    &  \\ \hline

kilde 23  &     &  &  & &    \\ \hline

kilde 24  &    &   &  &    &  \\ \hline

kilde 25  &  &  &   &    &    \\ \hline

kilde 26  &  &  &  &   &   \\ \hline

kilde 27 &  &   &   &   &  \\ \hline

kilde 28 & \multicolumn{1}{l|}{}   & \multicolumn{1}{l|}{} & \multicolumn{1}{l|}{} & \multicolumn{1}{l|}{} & \multicolumn{1}{l|}{} \\ \hline

\end{tabular}
\end{table}

答案1

单元格中的文本长度multicolumn大于跨列长度的总和,因此它使最后一列更宽。您可以通过两种方式解决此问题:

  • 对于最后四列,规定宽度之和大于multucolumn单元格的宽度
  • 将单元格内容multicolumn分成两行:

下面的 MWE 考虑第二种可能性

\documentclass{article}
\usepackage{amssymb}
\usepackage{makecell, multirow}

\usepackage[table,xcdraw]{xcolor}

\begin{document}
\begin{table}[ht]

\begin{tabular}{|l|c|c|c|c|c|}

\hline & \multicolumn{1}{l|}{} &
\multicolumn{4}{l|}{\makecell{Forskningsspørsmål\\ den kan besvare}}  \\ \cline{3-6}
\multirow{-2}{*}{Kilde} & \multicolumn{1}{l|}{\multirow{-2}{*}{Relevant?}}  & 1 & 2 & 3 & 4 \\ \hline

\rowcolor[HTML]{B4EAAB}
This column needs to be quite wide & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark- \\ \hline 
\rowcolor[HTML]{F9BDBD}
kilde 2  & X   & -  & -    & -   & -      \\ \hline

kilde 3            & JA/NEI   & V/-  & V/-  & V/- & V/-  \\ \hline

kilde  4    &   &   &    &   &      \\ \hline

kilde 5  &     &    &  &         &       \\ \hline
\end{tabular}
\end{table}
\end{document}

在此处输入图片描述

编辑。 考虑@egreg 评论和单元格中垂直空间的一些小调整得出:

\documentclass{article}
\usepackage{amssymb}
\usepackage{makecell, multirow}

\usepackage[table,xcdraw]{xcolor}

\begin{document}
\begin{table}[ht]
\setlength\extrarowheight{2pt}
\renewcommand\arraystretch{1.1}
\begin{tabular}{|l|c|c|c|c|c|}
    \hline 
Kilde   & Relevant? &   \multicolumn{4}{l|}{%
                \makecell{Forskningsspørsmål\\ den kan besvare}}        \\
    \cline{3-6}
        &           & 1     & 2     & 3     & 4                         \\
    \hline
\rowcolor[HTML]{B4EAAB}
This column needs to be quite wide 
        & \checkmark& \checkmark & \checkmark & \checkmark & \checkmark\\
    \hline 
\rowcolor[HTML]{F9BDBD}
kilde 2& X          & --    & --    & --    & --                        \\
    \hline
kilde 3& JA/NEI     & V/--  & V/--  & V/--  & V/--                      \\ 
    \hline
kilde  4&           &       &       &       &                           \\ 
    \hline
kilde 5&            &       &       &       &                           \\ 
    \hline
\end{tabular}
\end{table}
\end{document}

在此处输入图片描述

答案2

均等地设置列宽,这样您就可以获得均匀分布的表列:

\begin{tabular}{|p{160pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|p{50pt}|}

答案3

基于 Zarko 的良好回答,我将用来tabularx保证最后 4 列具有相同的宽度。

\documentclass{article}
\usepackage{amssymb}
\usepackage{makecell, multirow, tabularx}
\usepackage[table,xcdraw]{xcolor}
\begin{document}

\begin{table}
  \begin{tabularx}{\linewidth}{|l|c| *{4}{>{\centering\arraybackslash}X|} }
  \hline 
  Kilde & Relevant? & \multicolumn{4}{c|}{\makecell{Forskningsspørsmål\\ den kan besvare}}\\ \cline{3-6}
  & & 1 & 2 & 3 & 4 \\ \hline 
  \rowcolor[HTML]{B4EAAB} 
  This column needs to be quite wide & \checkmark & \checkmark & \checkmark & \checkmark & \checkmark \\ \hline
  \rowcolor[HTML]{F9BDBD} 
  kilde 2  &   X    &  -  &  -  &  -  &  -  \\ \hline
  kilde 3  & JA/NEI & V/- & V/- & V/- & V/- \\ \hline
  kilde 4  &        &     &     &     &     \\ \hline
  kilde 5  &        &     &     &     &     \\ \hline
  kilde 6  &        &     &     &     &     \\ \hline
  kilde 7  &        &     &     &     &     \\ \hline
  kilde 28 &        &     &     &     &     \\ \hline
  \end{tabularx}
\end{table}

\end{document}

在此处输入图片描述

相关内容