Latex 表:旋转的列没有像应有的那样收缩

Latex 表:旋转的列没有像应有的那样收缩

我正在尝试创建下表。我尝试旋转“影响区域”列,并成功完成,但由于某种原因,该列之后不会缩小到文本。以下是代码:

[![enter image description here][1]][1]\multicolumn{1}{l|}{\multirow{-8}{*}{\cellcolor[HTML]
{C0C0C0}\textbf{\rotatebox{90}{Impact Areas}}}}                                          

表格图像

有谁知道如何解决这一问题?

编辑:

\documentclass{article}
\usepackage{colortbl,xcolor,multirow,graphicx}
\begin{document}
\begin{table}[]
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{r>{\centering\arraybackslash}m{1.7cm}lll|l|}
\hline
\multicolumn{2}{|l|}{\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} Allegro Worksheet 10}}                                                                                                                                    & \multicolumn{4}{l|}{Information Asset Risk Worksheet}                                                                                                                                                                                                                            \\ \hline
\multicolumn{1}{|r|}{\cellcolor[HTML]{C0C0C0}}                                               & \multicolumn{1}{l|}{\cellcolor[HTML]{C0C0C0}}                                                                                 & \multicolumn{1}{>{\centering\arraybackslash}m{1.7cm}|}{\cellcolor[HTML]{C0C0C0}Information Asset}                                                 & \multicolumn{3}{>{\centering\arraybackslash}m{3.7cm}|}{}                                                                                                                                           \\ \cline{3-6} 
\multicolumn{1}{|r|}{\cellcolor[HTML]{C0C0C0}}                                               & \multicolumn{1}{l|}{\cellcolor[HTML]{C0C0C0}}                                                                                 & \multicolumn{1}{>{\centering\arraybackslash}m{1.7cm}|}{\cellcolor[HTML]{C0C0C0}Area of concern}                                                   & \multicolumn{3}{>{\centering\arraybackslash}m{3.7cm}|}{}                                                                                                                                           \\ \cline{3-6} 
\multicolumn{1}{|r|}{\cellcolor[HTML]{C0C0C0}}                                               & \multicolumn{1}{l|}{\cellcolor[HTML]{C0C0C0}}                                                                                 & \multicolumn{1}{>{\centering\arraybackslash}m{1.7cm}|}{\cellcolor[HTML]{EFEFEF}(1) Actor}                                                         & \multicolumn{3}{>{\centering\arraybackslash}m{3.7cm}|}{}                                                                                                                                           \\ \cline{3-6} 
\multicolumn{1}{|r|}{\cellcolor[HTML]{C0C0C0}}                                               & \multicolumn{1}{l|}{\cellcolor[HTML]{C0C0C0}}                                                                                 & \multicolumn{1}{>{\centering\arraybackslash}m{1.7cm}|}{\cellcolor[HTML]{EFEFEF}(2) Means}                                                         & \multicolumn{3}{>{\centering\arraybackslash}m{3.7cm}|}{}                                                                                                                                           \\ \cline{3-6} 
\multicolumn{1}{|r|}{\cellcolor[HTML]{C0C0C0}}                                               & \multicolumn{1}{l|}{\cellcolor[HTML]{C0C0C0}}                                                                                 & \multicolumn{1}{>{\centering\arraybackslash}m{1.7cm}|}{\cellcolor[HTML]{EFEFEF}(3) Motive}                                                        & \multicolumn{3}{>{\centering\arraybackslash}m{3.7cm}|}{}                                                                                                                                           \\ \cline{3-6} 
\multicolumn{1}{|r|}{\cellcolor[HTML]{C0C0C0}}                                               & \multicolumn{1}{l|}{\cellcolor[HTML]{C0C0C0}}                                                                                 & \multicolumn{1}{>{\centering\arraybackslash}m{1.7cm}|}{\cellcolor[HTML]{EFEFEF}(4) Outcome}                                                       & \multicolumn{3}{>{\centering\arraybackslash}m{3.7cm}|}{\textbf{\begin{tabular}[c]{@{}l@{}}Disclosure              Destruction  \\ Modification          Interruption\end{tabular}}}                \\ \cline{3-6} 
\multicolumn{1}{|r|}{\cellcolor[HTML]{C0C0C0}}                                               & \multicolumn{1}{l|}{\cellcolor[HTML]{C0C0C0}}                                                                                 & \multicolumn{1}{>{\centering\arraybackslash}m{1.7cm}|}{\cellcolor[HTML]{EFEFEF}(5) Security requirements}                                         & \multicolumn{3}{>{\centering\arraybackslash}m{3.7cm}|}{}                                                                                                                                           \\ \cline{3-6} 
\multicolumn{1}{|r|}{\cellcolor[HTML]{C0C0C0}}                                               & \multicolumn{1}{l|}{\multirow{-8}{*}{\cellcolor[HTML]{C0C0C0}\textbf{\rotatebox{90}{Impact Areas}}}}                                          & \multicolumn{1}{>{\centering\arraybackslash}m{1.7cm}|}{\cellcolor[HTML]{EFEFEF}(6) Probability}                                                   & \multicolumn{1}{>{\centering\arraybackslash}m{3.7cm}|}{\textbf{High}}                                             & \textbf{Medium}                        & \textbf{Low}                          \\ \cline{2-6} 
\multicolumn{1}{|r|}{\cellcolor[HTML]{C0C0C0}}                                               & \multicolumn{2}{l|}{}                                                                                                                                                                                                                          & \multicolumn{3}{l|}{\begin{tabular}[c]{@{}l@{}}(8) Severity\end{tabular}} \\ \cline{4-6} 
\multicolumn{1}{|r|}{\cellcolor[HTML]{C0C0C0}}                                               & \multicolumn{2}{l|}{\multirow{-2}{*}{\begin{tabular}[c]{@{}l@{}}(7) Consequences \end{tabular}}} & \multicolumn{1}{l|}{\textbf{Impact Area}}                                      & \textbf{Value}                         & \textbf{Score}                        \\ \cline{2-6} 
\multicolumn{1}{|r|}{\cellcolor[HTML]{C0C0C0}}                                               & \multicolumn{2}{l|}{}                                                                                                                                                                                                                          & \multicolumn{1}{>{\centering\arraybackslash}m{2.7cm}|}{Reputation \& Customer Confidence}                         &                                        &                                       \\ \cline{4-6} 
\multicolumn{1}{|r|}{\cellcolor[HTML]{C0C0C0}}                                               & \multicolumn{2}{l|}{\multirow{-2}{*}{}}                                                                                                                                                                                                        & \multicolumn{1}{>{\centering\arraybackslash}m{2.7cm}|}{Financial}                                                 &                                        &                                       \\ \cline{2-6} 
\multicolumn{1}{|r|}{\cellcolor[HTML]{C0C0C0}}                                               & \multicolumn{2}{l|}{}                                                                                                                                                                                                                          & \multicolumn{1}{>{\centering\arraybackslash}m{2.7cm}|}{Productivity}                                              &                                        &                                       \\ \cline{4-6} 
\multicolumn{1}{|r|}{\cellcolor[HTML]{C0C0C0}}                                               & \multicolumn{2}{l|}{\multirow{-2}{*}{}}                                                                                                                                                                                                        & \multicolumn{1}{>{\centering\arraybackslash}m{2.7cm}|}{Safety \& Health}                                          &                                        &                                       \\ \cline{2-6} 
\multicolumn{1}{|r|}{\cellcolor[HTML]{C0C0C0}}                                               & \multicolumn{2}{l|}{}                                                                                                                                                                                                                          & \multicolumn{1}{>{\centering\arraybackslash}m{2.7cm}|}{Fines \& Legal Penalties}                                  &                                        &                                       \\ \cline{4-6} 
\multicolumn{1}{|r|}{\multirow{-16}{*}{\cellcolor[HTML]{C0C0C0}\textbf{\rotatebox{90} {Internal Personnel}}}} & \multicolumn{2}{l|}{\multirow{-2}{*}{}}                                                                                                                                                                                                        & \multicolumn{1}{>{\centering\arraybackslash}m{2.7cm}|}{User Defined Impact Area}                                  &                                        &                                       \\ \hline
\multicolumn{5}{r}{Relative Risk Score}                                                                                                                                                                                                                                                                                                                                                                                                                                 &                                       \\ \hline
\multicolumn{6}{|l|}{\cellcolor[HTML]{C0C0C0}\begin{tabular}[c]{@{}l@{}}(9) Risk Mitigation\\ Based on the total score for this risk, what action will you take?\end{tabular}}                                                                                                                                                                                                                                                                                                                                  \\ \hline
\multicolumn{2}{|l|}{Accept}                                                                                                                                                                                                 & \multicolumn{1}{l|}{Defer}                                                                                     & \multicolumn{1}{>{\centering\arraybackslash}m{2.7cm}|}{\cellcolor[HTML]{C0C0C0}Mitigate}                          & \multicolumn{2}{l|}{Transfer}                                                  \\ \hline
\multicolumn{6}{|l|}{\cellcolor[HTML]{C0C0C0}For the risks that you decide to mitigate, do the following:}                                                                                                                                                                                                                                                                                                                                                                                                      \\ \hline
\multicolumn{2}{|l|}{\cellcolor[HTML]{C0C0C0}On what container would you apply controls?}                                                                                                                                    & \multicolumn{4}{>{\centering\arraybackslash}m{9.5cm}|}{\cellcolor[HTML]{C0C0C0}What administrative, technical, and physical controls would you apply on this container? What residual risk would still be accepted by the organization?}                                                                            \\ \hline
\multicolumn{2}{|l|}{}                                                                                                                                                                                                       & \multicolumn{4}{l|}{}                                                                                                                                                                                                                                                            \\ \hline
\end{tabular}
\end{table}
\end{document}

答案1

这当然不是一个答案,唯一的目的是为了向你展示宽度是由下行控制的,这些行在你的屏幕截图中没有显示,以及第一行。我所做的就是将倒数第二行更改为以p{2cm}获得在此处输入图片描述

如您所见,“影响区域”列的宽度确实减小了,现在由第一行设置(即第一行和第二行的宽度需要适合“Allegro Worksheet 10”。所有进一步的更改将取决于您想要如何构造第一行和下行。

答案2

无关: (大多数情况下,但在您将来的表格设计中会非常有用)表格的代码很简单,只需转到丢失处。我将托盘(用于练习)清理得干干净净,然后弄清楚表格应该是什么样子。在此,我对一个单元格使用\makecell包中的宏makecell,删除所有不必要的\multicolumn{1}{...}{...},并使用定义表格宽度\begin{tabular*}{\linewidth}{...}。这使我能够计算表格中一些多列单元格的宽度。

在此处输入图片描述

(红线表示文本边框)

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{makecell, multirow}
\usepackage{graphicx}

%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{table}[]
    \centering
\caption{My caption}
    \label{my-label}
    \setlength\tabcolsep{4pt}
\begin{tabular*}{\linewidth}{
                |>{\columncolor{gray!50}}l
                |l
                |>{\centering\arraybackslash}m{2.4cm}
                |>{\centering\arraybackslash}m{2.4cm}
                |l|l|}
\hline
\multicolumn{2}{l|}{\cellcolor{black}{\color{white} Allegro Worksheet 10}}
    & \multicolumn{4}{l|}{Information Asset Risk Worksheet} \\ \hline
    & \cellcolor{gray!50}
    & \cellcolor{gray!50} Information Asset                                                 & \multicolumn{3}{c|}{}                                                                                                                                           \\ \cline{3-6}
    & \cellcolor{gray!50}                                                                                & \cellcolor{gray!50} Area of concern                                                   & \multicolumn{3}{c|}{}                                                                                                                                           \\ \cline{3-6}
    & \cellcolor{gray!50}                                                                               & \cellcolor{gray!15}(1) Actor                                                         & \multicolumn{3}{c|}{}                                                                                                                                           \\ \cline{3-6}
    & \cellcolor{gray!50}                                                                                 & \cellcolor{gray!15}(2) Means                                                         & \multicolumn{3}{c|}{}                                                                                                                                           \\ \cline{3-6}
    & \cellcolor{gray!50}                                                                                 & \cellcolor{gray!15}(3) Motive                                                       & \multicolumn{3}{c|}{}                                                                                                                                           \\ \cline{3-6}
    & \cellcolor{gray!50}                                                                                 & \cellcolor{gray!15}(4) Outcome                                                       & \multicolumn{3}{l|}
            {\bfseries\makecell[l]{Disclosure Destruction\\
                                   Modification Interruption}}
    \\ \cline{3-6}
    & \cellcolor{gray!50}                                                                              & \cellcolor{gray!15}(5) Security requirements                                        & \multicolumn{3}{c|}{}                                                                                                                                           \\ \cline{3-6}
    & \cellcolor{gray!50}\multirow{-8}{*}{\textbf{\rotatebox{90}{Impact Areas}}}                                          & \cellcolor{gray!15}(6) Probability                                                   & \textbf{High}
    & \textbf{Medium}
    & \textbf{Low}
    \\ \cline{2-6}
    & \multicolumn{2}{l|}{}                                                                                                                                                                                                                          & \multicolumn{3}{l|}{ Severity}
    \\ \cline{4-6}
   & \multicolumn{2}{l|}{\multirow{-2}{*}{(7) Consequences}}
    & \textbf{Impact Area}
    & \textbf{Value}
    & \textbf{Score}
    \\ \cline{2-6}
    & \multicolumn{2}{l|}{}                                                                                                                                                                                                                          & Reputation \& Customer Confidence &   &
    \\ \cline{4-6}
    & \multicolumn{2}{l|}{\multirow{-2}{*}{}}                                                                                                                                                                                                        & Financial                         &   &
    \\ \cline{2-6}
    & \multicolumn{2}{l|}{}                                                                                                                                                                                                                          & Productivity                      &   &
    \\ \cline{4-6}
    & \multicolumn{2}{l|}{\multirow{-2}{*}{}}                                                                                                                                                                                                        & Safety \& Health                  &   &
    \\ \cline{2-6}
    & \multicolumn{2}{l|}{}                                                                                                                                                                                                                          & Fines \& Legal Penalties          &   &
    \\ \cline{4-6}
\multirow{-24}{*}{\rotatebox{90}{\textbf{Internal Personnel}}}
    & \multicolumn{2}{l|}{}                                                                                                                                                                                                        & User Defined Impact Area          &   &
    \\ \hline
%
 \multicolumn{3}{c}{}
    &   \multicolumn{3}{c}{Relative Risk Score}
    \\ \hline
%
    \rowcolor{gray!50}
\multicolumn{6}{|p{\dimexpr\linewidth-2\tabcolsep-2\arrayrulewidth\relax}|}{(9) Risk Mitigation\newline
                     Based on the total score for this risk, what action will you take?}
    \\  \hline
\multicolumn{2}{|l|}{Accept}
    & Defer                                                                                    & \cellcolor{gray!50}Mitigate
    & \multicolumn{2}{l|}{Transfer}                                                  \\ \hline
    \rowcolor{gray!50}
\multicolumn{6}{|l|}{For the risks that you decide to mitigate, do the following:}                                                                                                                                                                                                                                                                                                                                                                                                      \\ \hline
    \rowcolor{gray!50}
\multicolumn{2}{|>{\raggedright\arraybackslash}p{22ex}|}% estimated width of the first two columns
               {On what container would you apply controls?}
    & \multicolumn{4}{>{\raggedright\arraybackslash}p{\dimexpr\linewidth-4\tabcolsep-3\arrayrulewidth-22ex\relax}|}%
                     {What administrative, technical, and physical controls
    would you apply on this container? What residual
    risk would still be accepted by the organization?}                                                                            \\ \hline
\multicolumn{2}{|l|}{}                                                                                                                                                                                                       & \multicolumn{4}{l|}{}                                                                                                                                                                                                                                                            \\ \hline
\end{tabular*}
    \end{table}
\end{document}

相关内容