表格内容有问题

表格内容有问题

我绘制了一个有 2 列 5 行的表格。但是由于第二行、第二列的内容很长,,,表格只显示了一半,其他部分没有显示。请帮帮我......我试了很多次,但找不到解决办法。

这是代码。

\begin{table}[h]
\caption {Methods Of Validation }

\begin{tabular}{| l | l | }
\hline
Validation Example & Explanation \\ \hline
Unit Testing & The testing of a single program\\ \hline
Integration Testing  &  The testing of related Program or units of code. Validates that multiple parts of  the system interact according to the system design. \\ \hline 
System Testing & The testing of an entire system \\ \hline
Acceptance Testing & The testing the mobile app to make sure it Works as what the system requirements indicate \\ \hline

\end{tabular}
\end{table}

答案1

您可以使用tabularx环境在第二列中拥有多行单元格。我重新定义了类型,X以便拥有垂直居中的单元格,并使用了caption包(标题和表格之间的正确垂直间距)和cellspace包(单元格之间的更好垂直间距):

\documentclass[a4paper, 11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{fourier}%
\usepackage{heuristica}
\usepackage{geometry}

\usepackage{array}
\usepackage{caption}

\usepackage{tabularx}
\renewcommand{\tabularxcolumn}[1]{m{#1}}%
\newcolumntype{C}{>{\centering\arraybackslash}X}

\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\addparagraphcolumntypes{X}

\begin{document}

\begin{table}[h]
\caption {Methods Of Validation }
\begin{tabularx}{\linewidth}{|l|S{X}|}
\hline
Validation Example & Explanation \\
\hline
Unit Testing & The testing of a single program\\
\hline
Integration Testing & The testing of related Program or units of code. Validates that multiple parts of the system interact according to the system design. \\
\hline
System Testing & The testing of an entire system \\
\hline
Acceptance Testing & The testing the mobile app to make sure it Works as what the system requirements indicate \\
\hline
\end{tabularx}
\end{table}

\end{document} 

在此处输入图片描述

答案2

无需任何额外软件包:

\documentclass{article}

\begin{document}

\begin{table}[h]
\caption {Methods Of Validation }
\begin{tabular}{|p{\dimexpr0.3\linewidth-2\tabcolsep-\arrayrulewidth\relax}|
                 p{\dimexpr0.7\linewidth-2\tabcolsep-2\arrayrulewidth\relax}|}
\hline
Validation Example & Explanation \\
\hline
Unit Testing & The testing of a single program\\
\hline
Integration Testing & The testing of related Program or units of code. Validates that multiple parts of the system interact according to the system design. \\
\hline
System Testing & The testing of an entire system \\
\hline
Acceptance Testing & The testing the mobile app to make sure it Works as what the system requirements indicate \\
\hline
\end{tabular}
\end{table}

\end{document}

在此处输入图片描述

相关内容