如何仅对前两列使用 hline?

如何仅对前两列使用 hline?

我想在前两列中使用水平线。详情请参阅我的图片。

在此处输入图片描述

\documentclass[12pt,letterpaper]{article}    
\usepackage[left=20mm,top=30mm,bottom=30mm,right=20mm]{geometry}

\begin{document}
\begin{table}
\centering
\resizebox{0.7\columnwidth }{!}{%

\begin{tabular}{ |p{5cm}|p{5cm}|p{6cm}|  }
\hline

\hline
\textbf{Portion of Scenario} & \textbf{Description} & \textbf{Possible Values} \\
\hline
Sources & This specify where the fault comes from & Internal/external: people, hardware, software, physical infrastructure, physical environment\\
\hline
Stimulus & The stimulus to an availability scenario is a fault.   & Fault: omission, crash, incorrect timing, incorrect response \\
\hline
Artifact & This specifies which portions of the system are responsible for and affected by the fault.& Processors, communication channels, storage, processes, affected artifacts in the system's
environment \\
\hline
Environment    &We may be interested in not only how a system behaves in its "normal" environment, but also how it behaves in situations such as when it is already recovering from a fault. & Normal operation, startup, shutdown, repair mode, degraded operation, overloaded operation \\
\hline
Response & The most commonly desired response is to prevent the fault from becoming a failure, but other responses may also be important, such as notifying people or logging the fault for later analysis. This section specifies the desired system response. & Prevent the fault from becoming a failure
\newline
Detect the fault:
\begin{itemize}
\item Log the fault
\item Notify the appropriate entities (people or systems)
\item Recover from the fault
\item Disable the source of events causing the fault
\item Be temporarily unavailable while a repair is
being effected
\item Fix or mask the fault/failure or contain the damage it causes
\item Operate in a degraded mode while a repair is
being effected
\item Time or time interval when the system must be available
\item Availability percentage (e.g., 99.999 percent)
\item Time to detect the fault
\item Time to repair the fault
\item Time or time interval in which system can be in degraded mode
\item Proportion (e.g., 99 percent) or rate (e.g., up to 100 per second) of a certain class of faults that the system prevents, or handles without failing 
\end{itemize}
\\
Response measure & We may focus on a number of measures of availability, depending on the criticality of the service being provided.  \\
\hline
\end{tabular}
}
\end{table}

\end{document}

答案1

我认为您的表格的主要问题是字体太小,这是由于说明的原因\resizebox。看来您插入了\resizebox说明,以便使表格适合一页。

我想推荐一种不同的方法来使表格适合页面:使用环境tabularx,让三列具有不同的宽度,并使用 enumitem 包的机制使itemize第三列的环境占用更少的空间。

在此处输入图片描述

\documentclass[12pt,letterpaper]{article}    
\usepackage[hmargin=20mm, vmargin=30mm]{geometry}

% new code:
\usepackage{enumitem}
\usepackage{tabularx,ragged2e}
% See section 4.3, "column widths", of user guide of 'tabularx' package:
\newcolumntype{L}[1]{>{\RaggedRight\hsize=#1\hsize\linewidth=\hsize}X}

\begin{document}

\begin{table}[p!]
\small % for a 10% linear font size reduction
\begin{tabularx}{\textwidth}{ |L{0.45}|L{0.9}|L{1.65}| }
\hline
\textbf{Portion of Scenario} & 
\textbf{Description} & 
\textbf{Possible Values} 
\\ \hline
Sources & 
This specifies where the fault comes from. & 
Internal/external: people, hardware, software, physical infrastructure, physical environment
\\ \hline
Stimulus & 
The stimulus to an availability scenario is a fault. & 
Fault: omission, crash, incorrect timing, incorrect response 
\\ \hline
Artifact & 
This specifies which portions of the system are responsible for and affected by the fault. & 
Processors, communication channels, storage, processes, affected artifacts in the system's environment 
\\ \hline
Environment &
We may be interested in not only how a system behaves in its ``normal'' environment, but also how it behaves in situations such as when it is already recovering from a fault. & 
Normal operation, startup, shutdown, repair mode, degraded operation, overloaded operation 
\\ \hline
Response & 
The most commonly desired response is to prevent the fault from becoming a failure, but other responses may also be important, such as notifying people or logging the fault for later analysis. This section specifies the desired system response. & 
Prevent the fault from becoming a failure. \newline
Detect the fault: 
\begin{itemize}[nosep, left=0pt]
\item Log the fault
\item Notify the appropriate entities (people or systems)
\item Recover from the fault
\item Disable the source of events causing the fault
\item Be temporarily unavailable while a repair is being effected
\item Fix or mask the fault/failure or contain the damage it causes
\item Operate in a degraded mode while a repair is being effected
\item Time or time interval when the system must be available
\item Availability percentage (e.g., 99.999 percent)
\item Time to detect the fault
\item Time to repair the fault
\item Time or time interval in which system can be in degraded mode
\item Proportion (e.g., 99 percent) or rate (e.g., up to 100 per second) of a certain class of faults that the system prevents, or handles without failing.
\end{itemize}
\\ \cline{1-2}
Response measure & 
We may focus on a number of measures of availability, depending on the criticality of the service being provided. & 
\\ \hline
\end{tabularx}
\end{table}

\end{document}

答案2

tabularraylibrary varwidth文档中的第 5.8 节一样,我\resizebox用替换sriptsize \resizebox似乎不是一个好主意。请参阅此帖子tex.stackexchange.com/questions/425453/…使用调整框而不改变字体大小

enumitem编辑:根据 Mico 的建议,以及使用该包设置 itemize 环境的想法

代码

\documentclass[12pt,letterpaper]{article}
%\usepackage[left=20mm,top=30mm,bottom=30mm,right=20mm]{geometry}
\usepackage[hmargin=20mm, vmargin=30mm]{geometry}%<-- Mico's comment
\usepackage{tabularray,varwidth,enumitem}%<-- package enimitem
\pagestyle{empty}
\begin{document}
%\begin{scriptsize}%<-- Mico's explanation
{\scriptsize
\begin{tblr}{
    colspec = {*{2}{Q[wd=5cm]} Q[wd=6cm]},
    row{1} = {font=\bfseries},
    vlines,
}
\hline
Portion of Scenario & Description & Possible Values \\
\hline
Sources & This specify where the fault comes from & Internal/external: people, hardware, software, physical infrastructure, physical environment\\
\hline
Stimulus & The stimulus to an availability scenario is a fault.   & Fault: omission, crash, incorrect timing, incorrect response \\
\hline
Artifact & This specifies which portions of the system are responsible for and affected by the fault.& Processors, communication channels, storage, processes, affected artifacts in the system's
environment \\
\hline
Environment    &We may be interested in not only how a system behaves in its "normal" environment, but also how it behaves in situations such as when it is already recovering from a fault. & Normal operation, startup, shutdown, repair mode, degraded operation, overloaded operation \\
\hline
Response & The most commonly desired response is to prevent the fault from becoming a failure, but other responses may also be important, such as notifying people or logging the fault for later analysis. This section specifies the desired system response. & Prevent the fault from becoming a failure
\newline
Detect the fault:
\begin{itemize}[nosep, left=0pt]
\item Log the fault
\item Notify the appropriate entities (people or systems)
\item Recover from the fault
\item Disable the source of events causing the fault
\item Be temporarily unavailable while a repair is
being effected
\item Fix or mask the fault/failure or contain the damage it causes
\item Operate in a degraded mode while a repair is
being effected
\item Time or time interval when the system must be available
\item Availability percentage (e.g., 99.999 percent)
\item Time to detect the fault
\item Time to repair the fault
\item Time or time interval in which system can be in degraded mode
\item Proportion (e.g., 99 percent) or rate (e.g., up to 100 per second) of a certain class of faults that the system prevents, or handles without failing 
\end{itemize}
\\
\cline{1-2}
Response measure & We may focus on a number of measures of availability, depending on the criticality of the service being provided.  \\
\hline
\end{tblr}
}%<-- end of scriptsize
%\end{scriptsize}%
\end{document}

在此处输入图片描述

相关内容