如何在多列/表格中左对齐文本

如何在多列/表格中左对齐文本

我有以下 tex 代码。我无法让“测试中的用户需求”下方的文本左对齐。我尝试添加 \multicolumn{1}{l}{text...},但这只会将文本从文档发送到左侧。参见图片

\begin{table}[h]
\begin{center}
\caption{\textit{Use Case 1 specification}} % Number of use case
\begin{tabular}{c}
\bottomrule
\multicolumn{1}{c}{\textbf{User requirement under test:}} \\
\midrule
\multicolumn{1}{l}{The user should be able to access a interface for ordering. The interface should contain all the possible products you could potentially order, and verify if the order has been sent-} \\

\bottomrule
\multicolumn{1}{c}{\textbf{Stakeholders:}}\\ %List stakeholders
\toprule
\begin{minipage}[l]{\linewidth}
\begin{flushleft}
 \begin{itemize} 
    \item \textbf{Primary actor:} User
    \item \textbf{Stakeholder:} System

    
 \end{itemize}   
\end{flushleft}
\end{minipage} \\
\bottomrule
\multicolumn{1}{c}{\textbf{Preconditions:}}\\ %List preconditions
\toprule
\begin{minipage}[l]{\linewidth}
\begin{flushleft}
 \begin{itemize} 
    \item The repository has been downloaded
    \item System is turned on
    \item No errors received from any active windows 
    
 \end{itemize}   
\end{flushleft}
\end{minipage}\\
\bottomrule
\multicolumn{1}{c}{\textbf{Postcondition:}}\\ %List preconditions
\toprule
\multicolumn{1}{l}{The user should be able to see an interface which is used for placing product orders.}\\
\multicolumn{1}{l}{Selecting a product and sending it should put the order in the production queue} \\

% List how to set it up
\bottomrule
\multicolumn{1}{c}{\textbf{Setup:}} \\
\toprule
\begin{minipage}[l]{\linewidth}
\begin{flushleft}
 \begin{enumerate} 
    \item Open a terminal
    \item Navigate to the folder containing the file \code{GUI.py}
    \item Run the command \code{python3 GUI.py}
    \item Click an item saying "circle" or "rectangle"
    \item Click "send order" button
    
 \end{enumerate}   
\end{flushleft}
\end{minipage} \\
\multicolumn{1}{c}{\textbf{Extensions:}}\\ %List preconditions
\toprule
\begin{minipage}[l]{\linewidth}
\begin{flushleft}
 \begin{itemize} 
    \item The GUI does nothing if the system, as a whole, is not running.
    \item The the product selected for the order, must have a stock above 0
    
     
 \end{itemize}   
\end{flushleft}
\end{minipage}
\end{tabular} \end{center}\end{table}

latex编译后的图片

答案1

我建议您(a)\begin{tabular}{c}\begin{tabular}{@{}p{\textwidth}@{}}(以允许自动换行)替换并且(b)删除所有三个\multicolumn{1}{l}包装器。

还有一件事:minipage环境知道t(top)、c(center() 和b(bottom)定位说明符。选项l(left??)无法识别并且会被忽略。

我必须承认我不明白minipageOP 代码中包装器的用途。

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs}
\providecommand\code[1]{\texttt{#1}} % ??

\begin{document}

\begin{table}[h]

\caption{\textit{Use Case 1 specification}} % Number of use case

\begin{tabular}{@{}p{\textwidth}@{}} % <-- new

\toprule % why start with "\bottomrule"?
User requirement under test \\
\midrule
The user should be able to access a interface for ordering. 
The interface should contain all the possible products you 
could potentially order, and verify if the order has been
sent- \\
\bottomrule

\multicolumn{1}{c}{\textbf{Stakeholders:}}\\ %List stakeholders
\toprule
\begin{minipage}{\linewidth}
\begin{flushleft}
 \begin{itemize} 
    \item \textbf{Primary actor:} User
    \item \textbf{Stakeholder:} System
 \end{itemize}   
\end{flushleft}
\end{minipage} \\
\bottomrule

\multicolumn{1}{c}{\textbf{Preconditions:}}\\ %List preconditions
\toprule
\begin{minipage}{\linewidth} % "[l]" does absolutely nothing
\begin{flushleft}
 \begin{itemize} 
    \item The repository has been downloaded
    \item System is turned on
    \item No errors received from any active windows    
 \end{itemize}   
\end{flushleft}
\end{minipage}\\
\bottomrule

\multicolumn{1}{c}{\textbf{Postcondition:}}\\ %List preconditions
\toprule
The user should be able to see an interface which is used for placing product orders.\\  
Selecting a product and sending it should put the order in the production queue \\
% List how to set it up
\bottomrule

\multicolumn{1}{c}{\textbf{Setup:}} \\
\toprule
\begin{minipage}{\linewidth}
\begin{flushleft} 
 \begin{enumerate} 
    \item Open a terminal
    \item Navigate to the folder containing the file \code{GUI.py}
    \item Run the command \code{python3 GUI.py}
    \item Click an item saying "circle" or "rectangle"
    \item Click "send order" button 
 \end{enumerate}   
\end{flushleft}
\end{minipage} \\
\bottomrule

\multicolumn{1}{c}{\textbf{Extensions:}}\\ %List preconditions
\toprule
\begin{minipage}[l]{\linewidth}
\begin{flushleft}
 \begin{itemize} 
    \item The GUI does nothing if the system, as a whole, is not running.
    \item The the product selected for the order, must have a stock above 0
\end{itemize}   
\end{flushleft}
\end{minipage}

\end{tabular}
\end{table}
\end{document}

相关内容