怎样才能在表格的单个列中拥有多行?

怎样才能在表格的单个列中拥有多行?

我正在尝试制作一个标记指南表,但是当我这样做时,第二列不会关闭并且行长度不断变短,如下所示:在此处输入图片描述

我写如下:

\ProvidesPackage{exam}
\usepackage{amsmath}    
\usepackage{amssymb}    
\usepackage{anyfontsize}
\usepackage{asymptote}  
\usepackage{changepage} 
\usepackage{color}      
\usepackage{enumitem}  
\usepackage{fancyhdr}   
\usepackage{framed}     
\usepackage{geometry}   
\usepackage{graphicx}   
\usepackage{helvet}     
\usepackage{marginnote}
\usepackage{mathptmx}   
\usepackage{multicol}   
\usepackage{multirow}   
\usepackage{pgffor}     
\usepackage{setspace}   
\usepackage{tikz}      
\usepackage{totalcount} 
\usepackage{accents}   
\usepackage{pifont} 
\usepackage{array}
\usepackage{tabulary}
\usepackage{multirow}
\usepackage{booktabs}
\newcommand{\tabitem}{~~\llap{\textbullet}~~}

\begin{center}
\setlength{\extrarowheight}{5pt}
\setlength{\tabcolsep}{10pt}
\begin{tabular}{ |c|c| } 
\hline
\textbf{Criteria} & \textbf{Marks} \\
\hline
 \tabitem Skilfully evaluates the statement with close reference to the prescribed texts\\
 \tabitem Demonstrates a well-informed understanding of context, language, form & 17-20 \\ 
  \hline
 cell5 & cell6 \\ 
 cell8 & cell9 \\ 
\hline
\end{tabular}
\end{center}

当我添加额外的行时,如何使表格填补第二列的间隙,以及如何使行对齐以便点对齐以及使第二列的标记居中?

\begin{center}
\setlength{\cellspacetoplimit}{1cm}
\setlength{\cellspacebottomlimit}{1cm}
\begin{tabular}{ |Sl| Sl| } 
\hline
\textbf{Criteria} & \textbf{Marks} \\
\hline
 \tabitem Skilfully evaluates the statement with close reference to the prescribed texts &\\
 \tabitem Demonstrates a well-informed understanding of context, language, form & 17-20 \\ 
  \hline
 cell5 & cell6 \\ 
 cell8 & cell9 \\ 
\hline
\end{tabular}
\end{center}

在此处输入图片描述

答案1

该软件包nicematrix可以帮助解决几个问题,并且代码更简单。

该环境NiceTabularX允许将表格保留在文本区域内。\begin{NiceTabularX}{<total width>}{ X ....

\Block{<nro of rows - nro of columns>}{<content>} 将内容置于分配的空间内(本例中为 1x1 单元格)

如您所见,添加新项目将自动扩展左侧和右侧单元格,同时保持它们垂直居中。

cell-space-limits将扩大所有单元格的底部和顶部。

hlines将绘制水平线。

添加此enumitem包是为了方便地抑制itemize环境的默认左边距。

A

\documentclass[12pt,a4paper]{article}

\usepackage{nicematrix}
\usepackage{enumitem}

\begin{document}

\noindent\begin{NiceTabularX}{\linewidth}{ X c }[hlines, cell-space-limits=10pt]        
    \Block{1-1}{\bfseries Criteria} & \textbf{Marks} \\     
    \Block{1-1}{%
        \raggedright
        \begin{itemize}[leftmargin=*]
            \item Skilfully evaluates the statement with close reference to the prescribed texts. 
            \item Demonstrates a well-informed understanding of context, language, form.
            \item More items
        \end{itemize}}
            &\Block{1-1}{17--20}\\
    cell5   & cell6 \\ 
    cell8   & cell9 \\      
\end{NiceTabularX}

\end{document}

答案2

  • 定义p{<width>}(at tabular) 的列或X(at tabularx`) 类型的列。两者都允许在单元格中写入多行文本
  • 多行文本,从你的图片可以得出结论,写成列表会更简单(类似于@Simon Dispa 答案中所建议的)
  • 使用tabukarray包代码相对简单,经过一次编译后即可给出最终结果:
\documentclass[12pt,a4paper]{article}
\usepackage{tabularray}
\UseTblrLibrary{varwidth}
\usepackage{enumitem}

\begin{document}
    \begin{center}
\begin{tblr}{hlines, vlines,
             colspec = {X[l,m] r},
             rowsep  = 7pt,
             row{1}  = {font=\bfseries},  % <---
             measure = vbox,            % <---
             stretch = -1,         
             }
Criteria    &   Marks   \\
    \begin{itemize}[nosep, leftmargin=*]
\item Skilfully evaluates the statement with close reference to the prescribed texts.
\item Demonstrates a well-informed understanding of context, language, form.
\item More items
    \end{itemize}
            &   17 -- 20    \\
cell 5       &   cell 6     \\
cell 8       &   cell 9     \\
\end{tblr}
    \end{center}
\end{document}

在此处输入图片描述

相关内容