\begin{table}[h]
\centering
\caption{User-Story ID: 01}
\begin{tabular}{|l|l|}
\hline
\textbf{User-Story ID:} & 01 \\
\hline
\textbf{Title:} & Physician Registration \\
\hline
\textbf{Actor:} & Physician \\
\hline
\textbf{Priority} & 01 \\
\hline
\textbf{Estimate} & not written yet \\
\hline
\multicolumn{2}{|l|}{\textbf{User Story:} As a physician, I want an interface
from where I can register myself in the website by giving my details, so that
I can have access to the different functionalities of physicians. The
interface should be easily understandable and shows all requirements needed
for registration} \\
\hline
\multicolumn{2}{|l|}{\textbf{Acceptance Criteria:}} \\
\hline
\end{tabular}
\end{table}
我正在尝试调整桌子,但不知道该怎么做。
答案1
我建议您使用tabularx
环境而不是tabular
环境,将环境的整体宽度设置tabularx
为\textwidth
,并使用X
右侧列的列类型以允许自动换行;LaTeX 将为您计算第二列的列宽 - 无需任何手动计算。
\documentclass{article}
\usepackage{tabularx,ragged2e}
\newcolumntype{L}{>{\RaggedRight}X}
\begin{document}
\begin{table}[h]
\setlength\extrarowheight{2pt} % for a less-craped "look"
\caption{User-Story ID: 01\strut}
\begin{tabularx}{\textwidth}{|l|L|}
\hline
\textbf{User-Story ID} & 01 \\
\hline
\textbf{Title} & Physician Registration \\
\hline
\textbf{Actor} & Physician \\
\hline
\textbf{Priority} & 01 \\
\hline
\textbf{Estimate} & not written yet \\
\hline
\textbf{User Story} & As a physician, I want an interface from where
I can register myself in the website by giving my details, so that I
can have access to the different functionalities of physicians. The
interface should be easily understandable and show all requirements
needed for registration. \\
\hline
\multicolumn{2}{|l|}{\textbf{Acceptance Criteria}:} \\
\hline
\end{tabularx}
\end{table}
\end{document}
答案2
假设您想保留\multicolumn
基于的方法,您可以使用以下两个建议之一来获得与文本宽度一样宽的表格:
\documentclass{article}
\begin{document}
\begin{table}
\caption{User-Story ID: 01}
\begin{tabular}{|l|l|}
\hline
\textbf{User-Story ID:} & 01 \\
\hline
\textbf{Title:} & Physician Registration \\
\hline
\textbf{Actor:} & Physician \\
\hline
\textbf{Priority} & 01 \\
\hline
\textbf{Estimate} & not written yet \\
\hline
\multicolumn{2}{|p{\dimexpr\linewidth-2\tabcolsep-2\arrayrulewidth}|}{\textbf{User Story:} As a physician, I want an interface
from where I can register myself in the website by giving my details, so that
I can have access to the different functionalities of physicians. The
interface should be easily understandable and shows all requirements needed
for registration} \\
\hline
\multicolumn{2}{|l|}{\textbf{Acceptance Criteria:}} \\
\hline
\end{tabular}
\end{table}
\begin{table}
\caption{User-Story ID: 01}
\begin{tabular}{|l|l|}
\hline
\textbf{User-Story ID:} & 01 \\
\hline
\textbf{Title:} & Physician Registration \\
\hline
\textbf{Actor:} & Physician \\
\hline
\textbf{Priority} & 01 \\
\hline
\textbf{Estimate} & not written yet \\
\hline
\multicolumn{2}{|p{\dimexpr\linewidth-2\tabcolsep-2\arrayrulewidth\hangindent=10pt}|}{\textbf{User Story:} As a physician, I want an interface
from where I can register myself in the website by giving my details, so that
I can have access to the different functionalities of physicians. The
interface should be easily understandable and shows all requirements needed
for registration} \\
\hline
\multicolumn{2}{|l|}{\textbf{Acceptance Criteria:}} \\
\hline
\end{tabular}
\end{table}
\end{document}
答案3
我已经在这里修复了,希望它有帮助。
\begin{table}[]
\centering
\caption{User-Story ID: 01}
\begin{tabular}{|c|l|}
\hline
\textbf{User-Story ID:} & 01 \\ \hline
\textbf{Title:} & Physician Registration \\ \hline
\textbf{Actor:} & Physician \\ \hline
\textbf{Priority} & 01 \\ \hline
\textbf{Estimate} & not written yet \\ \hline
\textbf{User Story:} & \begin{tabular}[c]{@{}l@{}}
As a physician, I want an interface\\ from where I can register myself
in the website by giving my details, \\ so that I can have access to the
different functionalities of physicians. \\ The interface should be
easily understandable \\ and shows all requirements needed for
registration
\end{tabular} \\ \hline
\multicolumn{2}{|l|}{\textbf{Acceptance Criteria:}} \\ \hline
\end{tabular}
\end{table}