编辑:

编辑:

我正在尝试创建表格

这是我的代码:

\begin{table}[]
\begin{tabular}{|c|l|}
\hline
\textbf{Week number} & \multicolumn{1}{c|}{\textbf{A A}}\\ \hline 
\textbf{1} & \begin{tabular}[c]{@{}l@{}}Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s \\ when an unknown printer took a galley of type and scrambled it to make a type specimen book.\end{tabular}\\ \hline                                       
\textbf{2} & \begin{tabular}[c]{@{}l@{}}It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.\end{tabular} \\ \hline
\end{tabular}
\end{table}

图形结果是: 在此处输入图片描述

因此表格超出了文档范围。有什么问题吗?

编辑:

当我尝试使用例如p{10cm}

所以我的代码现在:

\begin{table}[]
\begin{tabular}{|c|p{10cm}|}
\hline
\textbf{Week number} & \multicolumn{1}{c|}{\textbf{A A}}\\ \hline 
\textbf{1} & \begin{tabular}[c]{@{}l@{}}Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s \\ when an unknown printer took a galley of type and scrambled it to make a type specimen book.\end{tabular}\\ \hline                                       
\textbf{2} & \begin{tabular}[c]{@{}l@{}}It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.\end{tabular} \\ \hline
\end{tabular}
\end{table}

结果: 在此处输入图片描述

答案1

请尝试以下操作:

\documentclass[11pt,a4paper]{article}
\usepackage{tabularx}

\begin{document}

\begin{table}[]
\begin{tabularx}{\linewidth}{|>{\bfseries}c|X|}
    \hline
Week number & \multicolumn{1}{c|}{\textbf{A A}} \\
    \hline
1
    &   Lorem Ipsum is simply dummy text of the printing and typesetting industry.

    Lorem Ipsum has been the industry's standard dummy text ever since the 1500s  when an unknown printer took a galley of type and scrambled it to make a type specimen book.          \\ \hline
2
    &  It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English.\\
    \hline
\end{tabularx}
\end{table}
\end{document}

在此处输入图片描述

您在表格内部嵌套了表格。嵌套表格仍然具有c列类型,当其比主表中的列长时不会换行。删除嵌套表格。这只会造成问题...

tabularx简单,就能实现你想要的。

相关内容