修复表格单元格中过大的空格

修复表格单元格中过大的空格

我有以下乳胶表

在此处输入图片描述

如您所见,我在一些单元格中看到了一些尴尬的大空白。我不太确定我到底想要它是什么样子,但如果您有任何建议,让我可以让它看起来更美观,我很乐意听听。

这是重现表格的代码

\usepackage{makecell}
\usepackage{xcolor}
\begin{document}
\begin{center}
    \begin{tabular}{|p{2cm}|p{2cm}|p{2.4cm}|p{2cm}|p{2cm}|p{2cm}|p{2cm}|}
% 0----------------------------------------------------------
        \hline
        \bf{Risk} & 
%------------------------------------------------------------ 
        \bf{Probability} & 
%------------------------------------------------------------ 
        \bf{Consequence} & 
%------------------------------------------------------------ 
        \bf{Risk Value} & 
%------------------------------------------------------------ 
        \bf{Preventive Measures} & 
%------------------------------------------------------------ 
        \bf{Corrective Actions} & 
%------------------------------------------------------------ 
        \bf{Responsible} \\ \hline
% Row 1------------------------------------------------------   
        Data not being validated correctly & 
%------------------------------------------------------------   
        \makecell{
        \\ 3 \\ \textcolor{red}{3} \\ \textcolor{green}{2}
        } & 
%------------------------------------------------------------  
        \makecell{
        \\ 5 \\ \textcolor{red}{5} \\ \textcolor{green}{5}
        } &
%------------------------------------------------------------ 
        \makecell{
        \\ 15 \\ \textcolor{red}{10} \\ \textcolor{green}{10}
        } &
%------------------------------------------------------------ 
        Get validation rules clearly specified by the product owner. Testing validation logic &
%------------------------------------------------------------ 
        Redesign validation logic & 
%------------------------------------------------------------
        Entire group \\ \hline
% Row 2-------------------------------------------------------
        Cannot connect to Mainframe API & 
%-------------------------------------------------------------
        \makecell{
        \\ 2 \\ \textcolor{red}{2} \\ \textcolor{green}{2}
        } & 
%---------------------------------------------------------------
        \makecell{
        \\ 5 \\ \textcolor{red}{5} \\ \textcolor{green}{5}
        } &
%---------------------------------------------------------------
        \makecell{
        \\ 10 \\ \textcolor{red}{10} \\ \textcolor{green}{10}
        } &
%---------------------------------------------------------------
        Ensure connection is possible &
%---------------------------------------------------------------
        Notify responsible team that mainframe system is not working & 
%---------------------------------------------------------------
        Mainframe Team \\ \hline
% Row 3---------------------------------------------------------
        Program crash while user is using it & 
%-------------------------------------------------------------
        \makecell{
        \\ 2 \\ \textcolor{red}{2} \\ \textcolor{green}{2}
        } & 
%---------------------------------------------------------------
        \makecell{
        \\ 5 \\ \textcolor{red}{5} \\ \textcolor{green}{5}
        } &
%---------------------------------------------------------------
        \makecell{
        \\ 10 \\ \textcolor{red}{10} \\ \textcolor{green}{10}
        } &
%---------------------------------------------------------------
        Ensure to have exception handling &
%---------------------------------------------------------------
        Making small backups of users progress & 
%---------------------------------------------------------------
        System \\ \hline
% Row 4---------------------------------------------------------
        User not able to upload file to GFS Upload & 
%-------------------------------------------------------------
        \makecell{
        \\ 1 \\ \textcolor{red}{1} \\ \textcolor{green}{1}
        } & 
%---------------------------------------------------------------
        \makecell{
        \\ 5 \\ \textcolor{red}{5} \\ \textcolor{green}{5}
        } &
%---------------------------------------------------------------
        \makecell{
        \\ 5 \\ \textcolor{red}{5} \\ \textcolor{green}{5}
        } &
%---------------------------------------------------------------
        Ensure GFS Upload can support every version of excel file and csv file. &
%---------------------------------------------------------------
        Tell user which file types can be used to upload.
        Add contact information if the user is still not able to upload. & 
%---------------------------------------------------------------
        User \\ \hline
% Row 5---------------------------------------------------------
        Not able to CRUD database & 
%-------------------------------------------------------------
        \makecell{
        \\ 3 \\ \textcolor{red}{2} \\ \textcolor{green}{1}
        } & 
%---------------------------------------------------------------
        \makecell{
        \\ 3 \\ \textcolor{red}{3} \\ \textcolor{green}{3}
        } &
%---------------------------------------------------------------
        \makecell{
        \\ 9 \\ \textcolor{red}{6} \\ \textcolor{green}{3}
        } &
%---------------------------------------------------------------
        Ensure to have unit testing &
%---------------------------------------------------------------
        Redesign repository logic & 
%---------------------------------------------------------------
        Entire Group \\
        \hline
    \end{tabular}
\end{center}



\begin{center}
    \begin{tabular}{|p{2.3cm}|p{2cm}|p{2cm}|p{2cm}|p{2cm}|p{2cm}|p{2cm}|} \hline
% Row 6---------------------------------------------------------
        External libraries will be outdated & 
%-------------------------------------------------------------
        \makecell{
        \\ 2 \\ \textcolor{red}{2} \\ \textcolor{green}{1}
        } & 
%---------------------------------------------------------------
        \makecell{
        \\ 4 \\ \textcolor{red}{3} \\ \textcolor{green}{3}
        } &
%---------------------------------------------------------------
        \makecell{
        \\ 8 \\ \textcolor{red}{6} \\ \textcolor{green}{3}
        } &
%---------------------------------------------------------------
        Ensure to have libraries locally on project &
%---------------------------------------------------------------
        Notify the developer responsible for the program and use logging to notify the problem for error handler & 
%---------------------------------------------------------------
        GFS Upload responsible \\
        \hline
% Row 7---------------------------------------------------------
        GFS Upload wrong data to Mainframe & 
%-------------------------------------------------------------
        \makecell{
        \\ 3 \\ \textcolor{red}{2} \\ \textcolor{green}{1}
        } & 
%---------------------------------------------------------------
        \makecell{
        \\ 5 \\ \textcolor{red}{5} \\ \textcolor{green}{5}
        } &
%---------------------------------------------------------------
        \makecell{
        \\ 15 \\ \textcolor{red}{10} \\ \textcolor{green}{5}
        } &
%---------------------------------------------------------------
        Exception Handling when sending to host and log properly. &
%---------------------------------------------------------------
        Notify the user that errors occurred and were not able to send to the host. & 
%---------------------------------------------------------------
        System \\
        \hline
% Row 8---------------------------------------------------------
        Authentication not working & 
%-------------------------------------------------------------
        \makecell{
        \\ 2 \\ \textcolor{red}{2} \\ \textcolor{green}{1}
        } & 
%---------------------------------------------------------------
        \makecell{
        \\ 3 \\ \textcolor{red}{3} \\ \textcolor{green}{3}
        } &
%---------------------------------------------------------------
        \makecell{
        \\ 6 \\ \textcolor{red}{6} \\ \textcolor{green}{3}
        } &
%---------------------------------------------------------------
        Ensure there are no errors in code&
%---------------------------------------------------------------
        Redesign authentication logic & 
%---------------------------------------------------------------
        System \\
        \hline
% Row 9---------------------------------------------------------
        Backend crashing & 
%-------------------------------------------------------------
        \makecell{
        \\ 2 \\ \textcolor{red}{2} \\ \textcolor{green}{2}
        } & 
%---------------------------------------------------------------
        \makecell{
        \\ 2 \\ \textcolor{red}{2} \\ \textcolor{green}{2}
        } &
%---------------------------------------------------------------
        \makecell{
        \\ 4 \\ \textcolor{red}{4} \\ \textcolor{green}{4}
        } &
%---------------------------------------------------------------
        Logging and exception handling &
%---------------------------------------------------------------
        Ensure data is backed up on backup database & 
%---------------------------------------------------------------
        System \\
        \hline
% Row 10--------------------------------------------------------
        Not able to deliver software on time & 
%-------------------------------------------------------------
        \makecell{
        \\ 4 \\ \textcolor{red}{3} \\ \textcolor{green}{1}
        } & 
%---------------------------------------------------------------
        \makecell{
        \\ 5 \\ \textcolor{red}{5} \\ \textcolor{green}{5}
        } &
%---------------------------------------------------------------
        \makecell{
        \\ 20 \\ \textcolor{red}{15} \\ \textcolor{green}{5}
        } &
%---------------------------------------------------------------
        Use Release Planning and check weekly burndown chart &
%---------------------------------------------------------------
        Ensure to make enough story points every sprint & 
%---------------------------------------------------------------
        Entire Group \\
        \hline
    \end{tabular}
\end{center}
\end{document}

答案1

类似这样——如果需要的话,标题居中尚未完成

在此处输入图片描述

\documentclass{report}
\usepackage{enumitem}
%\usepackage{tabularx}
\usepackage{lipsum}
\usepackage{array,graphicx}
\usepackage{booktabs}
\newcommand*\rot{\rotatebox{90}}
%\usepackage{rotate}
\renewcommand{\arraystretch}{1.25}
\begin{document}
    \begin{table}

    \begin{tabular}{p{2cm}p{1cm}p{1cm}p{1cm}p{2cm}p{2cm}p{2cm}}
%       \hline
        \rot{Risk} &  \rot{Probability} & \rot{Consequence} & \rot{Risk Value} & \rot{Preventive Measures} & \rot{Corrective Measures} & \rot{Reponsibility}\\\toprule  
        \begin{minipage}[t]{\linewidth}
            \begin{itemize}[leftmargin=0em, label={},]
                \item Data not being validated correctly
            \end{itemize}
        \end{minipage}&
        \begin{minipage}[t]{\linewidth}
            \begin{itemize}[leftmargin=0em, label={}]
                \item 3
                \item 4
                \item 5
            \end{itemize}
        \end{minipage}&
    \begin{minipage}[t]{\linewidth}
        \begin{itemize}[leftmargin=0em, label={}]
            \item 3
            \item 4
            \item 5
        \end{itemize}
    \end{minipage}&
    \begin{minipage}[t]{\linewidth}
        \begin{itemize}[leftmargin=0em, label={}]
            \item 3
            \item 4
            \item 5
        \end{itemize}
    \end{minipage}&
        \begin{minipage}[t]{\linewidth}
            \begin{itemize}[leftmargin=0em, label={}]
                \item Get validation rules clearly specified by the product owner. Testing validation logic
            \end{itemize}
        \end{minipage}&
    \begin{minipage}[t]{\linewidth}
        \begin{itemize}[leftmargin=0em, label={}]
            \item Redesign validation logic
        \end{itemize}
    \end{minipage}&
\begin{minipage}[t]{\linewidth}
    \begin{itemize}[leftmargin=0em, label={}]
        \item Entire group
    \end{itemize}
\end{minipage}\\
\hline
    \end{tabular}
    \end{table}
\end{document}

编辑

修复额外空间

在此处输入图片描述

\documentclass{report}
\usepackage{enumitem}
\usepackage{lipsum}
\usepackage{array,graphicx,xcolor}
\usepackage{booktabs}
\newcommand{\rot}[1]{\rotatebox{90}{\textbf{#1}}}
\renewcommand{\arraystretch}{1.25}
\newcommand{\mc}[1]{\multicolumn{1}{c}{\textbf{#1}}}
\begin{document}
    \noindent
    \begin{table}
\hskip-3.0cm
    \begin{tabular}{p{3cm}p{.5cm}p{.5cm}p{.5cm}p{5cm}p{4cm}p{2cm}}
%       \hline
        \mc{Risk} &  \rot{Probability} & \rot{Consequence} & \rot{Risk Value} & \mc{Preventive Measures} & \mc{Corrective Measures} & \mc{Reponsibility}\\\toprule
        \begin{minipage}[t]{\linewidth}
            \begin{itemize}[leftmargin=0em, label={},]
                \item Data not being validated correctly
            \end{itemize}
        \end{minipage}&
        \begin{minipage}[t]{\linewidth}
            \begin{itemize}[leftmargin=0em, label={}, noitemsep]
                \item \textcolor{red}{3}
                \item \textcolor{green}{4}
                \item \textcolor{blue}{5}
            \end{itemize}
        \end{minipage}&
    \begin{minipage}[t]{\linewidth}
        \begin{itemize}[leftmargin=0em, label={}, noitemsep]
            \item 3
            \item 4
            \item 5
        \end{itemize}
    \end{minipage}&
    \begin{minipage}[t]{\linewidth}
        \begin{itemize}[leftmargin=0em, label={}, noitemsep]
            \item 3
            \item 4
            \item 5
        \end{itemize}
    \end{minipage}&
        \begin{minipage}[t]{\linewidth}
            \begin{itemize}[leftmargin=0em, label={}]
                \item Get validation rules clearly specified by the product owner. Testing validation logic
            \end{itemize}
        \end{minipage}&
    \begin{minipage}[t]{\linewidth}
        \begin{itemize}[leftmargin=0em, label={}]
            \item Redesign validation logic
        \end{itemize}
    \end{minipage}&
\begin{minipage}[t]{\linewidth}
    \begin{itemize}[leftmargin=0em, label={}]
        \item Entire group
    \end{itemize}
\end{minipage}\\
\hline
    \end{tabular}
    \end{table}
\end{document}

相关内容