自动调整表格单元格大小?

自动调整表格单元格大小?

我本质上想让我的文本在表格的第三列换行。根据我现在的做法,文本会继续穿过我的表格并移出文档的右侧。这是我的代码。

\begin{table}[h]
\centering
\begin{tabularx}{\linewidth}{|l|l|X|}
\hline
\textbf{Item} & \textbf{Due} & \textbf{Specifics and Owner}                                                                                                                                                                                                                         
\\ \hline
Progress Report 1 & 2/15 & \begin{tabular}[c]{@{}l@{}}Preprocess data. Create simple neural network as proof of concept.\\ Owners: Group Effort\end{tabular}                                                                                                                   \\ \hline
Progress Report 2 & 3/15 & \begin{tabular}[c]{@{}l@{}}First implementation of working neural network x-ray classifier. Includes any improvement over randomly classifying data.\\ Owners: Group Effort\end{tabular}                                                            \\ \hline
Preliminary Writeup & 4/12 & \begin{tabular}[c]{@{}l@{}}Strong improvement in classification by supervising neural network weight selection. \\ Owners: Group Effort\end{tabular}                                                                                                \\ \hline
Final Oral Presentation \& Report & 4/24 - 4/26  & \begin{tabular}[c]{@{}l@{}}Finished product that is demonstrable. Possibly a final push to see improvements over Preliminary Writeup results. Make sure there is a group understanding of all applied concepts.\\ Owners: Group Effort\end{tabular} \\ \hline
\end{tabularx}
\end{table}

当前发生的情况如下:https://i.stack.imgur.com/oPwzO.jpg

答案1

请始终提供可编译的最小工作示例!

您不需要嵌套表格。X的列tabularx已经换行了。为了在X列中的单元格内放置换行符,请放置\newline而不是\\(这将启动新的表格行)。

\documentclass{article}
\usepackage{tabularx}

\begin{document}

\begin{table}[h]
%\centering   % see Mico's comment
\begin{tabularx}{\linewidth}{|l|l|X|}
\hline
\textbf{Item} & \textbf{Due} & \textbf{Specifics and Owner} \\ \hline
Progress Report 1 & 2/15 & Preprocess data. Create simple neural network as proof of concept.\newline Owners: Group Effort \\ \hline
Progress Report 2 & 3/15 & First implementation of working neural network x-ray classifier. Includes any improvement over randomly classifying data.\newline Owners: Group Effort \\ \hline
Preliminary Writeup & 4/12 & Strong improvement in classification by supervising neural network weight selection. \newline Owners: Group Effort \\ \hline
Final Oral Presentation \& Report & 4/24--4/26 & Finished product that is demonstrable. Possibly a final push to see improvements over Preliminary Writeup results. Make sure there is a group understanding of all applied concepts.\newline Owners: Group Effort \\ \hline
\end{tabularx}
\end{table}

\end{document}

生成:

在此处输入图片描述


编辑:

另一个版本使用booktabs并由\RaggedRight几条评论提出:

\documentclass{article}
\usepackage{tabularx,booktabs,ragged2e}

\begin{document}

\begin{table}[h]
%\centering   % see Mico's comment
\begin{tabularx}{\linewidth}{l l >{\RaggedRight}X}
\toprule
\textbf{Item} & \textbf{Due} & \textbf{Specifics and Owner} \\ \midrule
Progress Report 1 & 2/15 & Preprocess data. Create simple neural network as proof of concept.\newline Owners: Group Effort \\ \midrule
Progress Report 2 & 3/15 & First implementation of working neural network x-ray classifier. Includes any improvement over randomly classifying data.\newline Owners: Group Effort \\ \midrule
Preliminary Writeup & 4/12 & Strong improvement in classification by supervising neural network weight selection. \newline Owners: Group Effort \\ \midrule
Final Oral Presentation \& Report & 4/24--4/26 & Finished product that is demonstrable. Possibly a final push to see improvements over Preliminary Writeup results. Make sure there is a group understanding of all applied concepts.\newline Owners: Group Effort \\ \bottomrule
\end{tabularx}
\end{table}

\end{document}

在此处输入图片描述

相关内容