![自动调整表格单元格大小?](https://linux22.com/image/370180/%E8%87%AA%E5%8A%A8%E8%B0%83%E6%95%B4%E8%A1%A8%E6%A0%BC%E5%8D%95%E5%85%83%E6%A0%BC%E5%A4%A7%E5%B0%8F%EF%BC%9F.png)
我本质上想让我的文本在表格的第三列换行。根据我现在的做法,文本会继续穿过我的表格并移出文档的右侧。这是我的代码。
\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}