多列和多行表中的自动换行

多列和多行表中的自动换行

我尝试制作这个表格,但它仍然比页面宽度长。而且它比页面长度长。有人知道如何制作这个表格吗?这也是我第一次使用 LaTeX 和这个论坛。所以如果下面的代码看起来不正确,我很抱歉。

\begin{center}
\begin{tabular}{|l|l|l|}
\hline
\multicolumn{2}{|c|}{Risk Parameter} & \multicolumn{1}{c|}{Classification} \\ \hline
\multirow{4}{*}{\parbox{5cm}{Consequence (C) Number of fatalities This can be calculated by determining the numbers of people present when the area exposed to the hazard is occupied and multiplying by the vulnerability to the identified hazard. The vulnerability is determined by  the nature of the hazard being protected against. The following factors can be used: V = 0,01 Small release of flammable or  toxic material V = 0,1 Large release of flammable or toxic material V = 0,5 As above but also a high probability of catching fire or  highly toxic material V = 1 Rupture or explosion} & C_{A} & Minor Injury \\
 & C_{B} & Range 0.01 to 0.1 \\
 & C_{C} & Range 0.1 to 1 \\
 & C_{D} & Range \textgreater1,0 \\ \cline{1-1}
\multirow{2}{*}{\parbox{5cm}{Occupancy (F) This is calculated by determining the proportional length of time the area exposed to the hazard is occupied during a normal working period. NOTE 1 If the time in the hazardous area is different depending on the shift being operated then the maximum should be selected.NOTE 2 It is only appropriate to use FA where it can be shown that the demand rate is random and not related to when occupancy could be higher than normal. The latter is usually the case with demands which occur at equipment start-up or during the investigation of abnormalities.} & F_{A} & Rare to more frequent exposure in the hazardous zone. Occupancy less than 0.1 \\
 & F_{B} & Frequent to permanent exposure in the hazardous zone \\ \cline{1-1}
\multirow{2}{5cm}{Probability of avoiding the hazardous event (P) if the protection system fails to operate.} & P_{A} & P_{A} should only be selected if all the following are true: - facilities are provided to alert the operator that the SIS has failed; - independent facilities are provided to shut down such that the hazard can be avoided or which enable all persons to escape to a safe area; - the time between the operator being alerted and a hazardous event occurring exceeds 1 hour or is definitely sufficient for the necessary actions. \\
 & P_{B} & Adopted if all the conditions are not satisfied \\ \cline{1-1}
\multirow{4}{*}{\parbox{5cm}{Demand rate (W) The number of times per year that the hazardous event would occur in absence of SIF under consideration. To determine the demand rate it is necessary to consider all sources of failure that can lead to one hazardous event. In determining the demand rate, limited credit can be allowed for control system performance and intervention. The performance which can be claimed if the control system is not to be designed and maintained according to IEC 61511, is limited to below the  performance ranges associated with SIL1.} & W_{1} & Demand rate less than 0.1 D per year \\
 & W_{2} & Demand rate between 0.1 D and D per year \\
 & W_{3} & Demand rate between D and 10 D per year \\
 &  & For demand rates higher than 10 D per year higher integrity shall be needed \\ \cline{1-1}
\end{tabular}
\end{center}

编辑:我稍微修改了一下代码,现在看起来好多了,但\usepackage{multirow}在开始编译时仍然会出现错误

\documentclass{article}
\usepackage[utf8]{inputenc}
%\usepackage{multirow}
\usepackage{longtable}

\begin{document}

\begin{center}
\begin{longtable}[l]{|l|l|p{5cm}|}
\hline
\multicolumn{2}{|c|}{Risk Parameter} & \multicolumn{1}{c|}{Classification} \\ \hline
\multirow{4}{*}{\parbox{5cm}{Consequence (C) Number of fatalities This can be calculated by determining the numbers of people present when the area exposed to the hazard is occupied and multiplying by the vulnerability to the identified hazard. The vulnerability is determined by  the nature of the hazard being protected against. The following factors can be used: V = 0,01 Small release of flammable or  toxic material V = 0,1 Large release of flammable or toxic material V = 0,5 As above but also a high probability of catching fire or  highly toxic material V = 1 Rupture or explosion} & C_{A} & Minor Injury \\
 & C_{B} & Range 0.01 to 0.1 \\
 & C_{C} & Range 0.1 to 1 \\
 & C_{D} & Range \textgreater1,0 \\ \cline{1-1}
\multirow{2}{*}{\parbox{5cm}{Occupancy (F) This is calculated by determining the proportional length of time the area exposed to the hazard is occupied during a normal working period. NOTE 1 If the time in the hazardous area is different depending on the shift being operated then the maximum should be selected.NOTE 2 It is only appropriate to use FA where it can be shown that the demand rate is random and not related to when occupancy could be higher than normal. The latter is usually the case with demands which occur at equipment start-up or during the investigation of abnormalities.} & F_{A} & Rare to more frequent exposure in the hazardous zone. Occupancy less than 0.1 \\
 & F_{B} & Frequent to permanent exposure in the hazardous zone \\ \cline{1-1}
\multirow{2}{*}{\parbox{5cm}{Probability of avoiding the hazardous event (P) if the protection system fails to operate.} & $P_{A}$ & $P_{A}$ should only be selected if all the following are true: - facilities are provided to alert the operator that the SIS has failed; - independent facilities are provided to shut down such that the hazard can be avoided or which enable all persons to escape to a safe area; - the time between the operator being alerted and a hazardous event occurring exceeds 1 hour or is definitely sufficient for the necessary actions. \\
 &  $P_{B}$ & Adopted if all the conditions are not satisfied \\ \cline{1-1}
\multirow{4}{*}{\parbox{5cm}{Demand rate (W) The number of times per year that the hazardous event would occur in absence of SIF under consideration. To determine the demand rate it is necessary to consider all sources of failure that can lead to one hazardous event. In determining the demand rate, limited credit can be allowed for control system performance and intervention. The performance which can be claimed if the control system is not to be designed and maintained according to IEC 61511, is limited to below the  performance ranges associated with SIL1.} & W_{1} & Demand rate less than 0.1 D per year \\
 & W_{2} & Demand rate between 0.1 D and D per year \\
 & W_{3} & Demand rate between D and 10 D per year \\
 &  & For demand rates higher than 10 D per year higher integrity shall be needed \\ \cline{1-1}
\end{longtable}
\end{center}
\end{document}

答案1

这是一个解决方案。我删除了所有垂直线,并使用了booktabsmakecellltablex包(后者结合了longtable和的功能tabularx,并引入了一些itemize单元格内部环境以及对表格布局的一些其他修改:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage[inline]{enumitem}
\usepackage{ragged2e}
\usepackage{booktabs}
\usepackage{array, multirow, makecell, hhline}
\usepackage{ltablex}
\renewcommand\cellalign{lt}\renewcommand\theadfont{\normalfont}
\setcellgapes{4pt}
\makegapedcells
\begin{document}

\begin{tabularx}{\linewidth}{>{\RaggedRight}p{0.5 \linewidth}l>{\RaggedRight\arraybackslash}X}
\hline
\multicolumn{2}{c}{Risk Parameter} & \thead{Classification} \\
\toprule
\multirow{1}{\linewidth}{{Consequence (C) Number of fatalities This can be calculated by determining the numbers of people present when the area exposed to the hazard is occupied and multiplying by the vulnerability to the identified hazard. The vulnerability is determined by the nature of the hazard being protected against. \\
The following factors can be used: %\\
\begin{itemize}[noitemsep,topsep=4pt, wide = 0pt, leftmargin =2.1em]
\item[$ \mathrm{V = 0,01:} $]Small release of flammable or toxic material
\item[$ \mathrm{V = 0,1:} $]Large release of flammable or toxic material
\item[$ \mathrm{V = 0,5:} $]As above but also a high probability of catching fire or highly toxic material
\item[$ \mathrm{V = 1:} $]Rupture or explosion
\end{itemize}}}%
& $ C_{A} $ & Minor Injury \\
 & $ C_{B} $ & Range 0.01 to 0.1 \\
 & $ C_{C} $ & Range 0.1 to 1 \\
 & $ C_{D} $ & Range $ > 1,0 $
\\[9.5\baselineskip]
\cmidrule{1-1}
\multirow{2}{\linewidth}{{Occupancy (F) This is calculated by determining the proportional length of time the area exposed to the hazard is occupied during a normal working period. \\[1ex]
\small\textsc{Note 1:} If the time in the hazardous area is different depending on the shift being operated then the maximum should be selected.}} & $ F_{A} $ & Rare to more frequent exposure in the hazardous zone. Occupancy less than 0.1 \\
 & $ F_{B} $ & Frequent to permanent exposure in the hazardous zone \\
 & & \\[-1ex]
\small\textsc{Note 2:} It is only appropriate to use FA where it can be shown that the demand rate is random and not related to when occupancy could be higher than normal. The latter is usually the case with demands which occur at equipment start-up or during the investigation of abnormalities. & & \\ %
\cmidrule{1-1}
\multirow{2}{\linewidth}{Probability of avoiding the hazardous event (P) if the protection system fails to operate.} & $ P_{A} $ & $ P_{A} $ should only be selected if all the following are true:%
 \begin{itemize*}[label = --, itemjoin = \linebreak, before = \linebreak]%[ noitemsep]
 \item facilities are provided to alert the operator that the SIS has failed;
 \item independent facilities are provided to shut down such that the hazard can be avoided or which enable all persons to escape to a safe area;
 \item the time between the operator being alerted and a hazardous event occurring exceeds 1 hour or is definitely sufficient for the necessary actions.
 \end{itemize*} \\
 & $ P_{B} $ & Adopted if all the conditions are not satisfied \\
\cmidrule{1-1}
\multirow{4}{\linewidth}{{Demand rate (W) The number of times per year that the hazardous event would occur in absence of SIF under consideration. To determine the demand rate it is necessary to consider all sources of failure that can lead to one hazardous event. In determining the demand rate, limited credit can be allowed for control system performance and intervention. The performance which can be claimed if the control system is not to be designed and maintained according to IEC 61511, is limited to below the performance ranges associated with SIL1.}} & $ W_{1} $ & Demand rate less than 0.1 D per year \\
 & $ W_{2} $ & Demand rate between 0.1 D and D per year \\
 & $ W_{3} $ & Demand rate between D and 10 D per year \\
 & & For demand rates higher than 10 D per year higher integrity shall be needed \\[2\baselineskip]
 \bottomrule
\end{tabularx}

\end{document} 

在此处输入图片描述

在此处输入图片描述

相关内容