单元格宽度和高度可变和固定的表格

单元格宽度和高度可变和固定的表格

我想制作一张如图所示的表格 在此处输入图片描述

但我无法使用在线 LaTeX 表格制作器按照我想要的方式制作它。它看起来是这样的:

在此处输入图片描述

这是我的尝试:

% Please add the following required packages to your document preamble:
% \usepackage{graphicx}
% \usepackage[table,xcdraw]{xcolor}
% If you use beamer only pass "xcolor=table" option, i.e. \documentclass[xcolor=table]{beamer}
\begin{table}[]
\resizebox{\textwidth}{!}{%
\begin{tabular}{|
>{\columncolor[HTML]{C0C0C0}}l |l|l|l|l|}
\hline
 &
  \cellcolor[HTML]{C0C0C0}Corrective Maintenance &
  \cellcolor[HTML]{C0C0C0}Scheduled Maintenance &
  \cellcolor[HTML]{C0C0C0}Condition-based Maintenance &
  \cellcolor[HTML]{C0C0C0}Predictive Maintenance \\ \hline
Characteristics &
  Performed after fault or breakdown &
  Performed at pre-defined  intervalss &
  \begin{tabular}[c]{@{}l@{}}Performed after observing certain\\ conditions in an item\end{tabular} &
  \begin{tabular}[c]{@{}l@{}}Performed on the most suitable and\\ cost effective date.\end{tabular} \\ \hline
Requirements &
  \begin{tabular}[c]{@{}l@{}}Skilled Staff, Spare components \\ availability, Short reaction time\end{tabular} &
  \begin{tabular}[c]{@{}l@{}}In depth knowledge of the lifespan\\ of an item,the precise planning of \\ staff, and supply of spare parts\end{tabular} &
  \begin{tabular}[c]{@{}l@{}}Monitoring devies/systems,IT-infrastructure;\\ skilled staff\end{tabular} &
  \begin{tabular}[c]{@{}l@{}}Monitoring systems, IT-infrastructure, \\ data models and algorithms\end{tabular} \\ \hline
Advantages &
  \begin{tabular}[c]{@{}l@{}}No Planning cost, Maximization\\ of the service life of an item\end{tabular} &
  \begin{tabular}[c]{@{}l@{}}Minimizes the downtime, fewer\\ failures caused by wear out,high\\ plannability\end{tabular} &
  \begin{tabular}[c]{@{}l@{}}Maximizes the productivity time of the\\ machine, Maximizes the service life of the\\ equipment.\end{tabular} &
  \begin{tabular}[c]{@{}l@{}}Maximizes the productivity time of assets,\\ Maximizes the service live of assets,\\ High plannability.\end{tabular} \\ \hline
Disadvantages &
  \begin{tabular}[c]{@{}l@{}}Huge maintenance costs due to\\ unplanned downtime\end{tabular} &
  \begin{tabular}[c]{@{}l@{}}Planning is cost intensive,does not\\ prevent from random failures,\\ labour intensive\end{tabular} &
  \begin{tabular}[c]{@{}l@{}}High investment for continuous monitoring\\ and prognostic equipment\end{tabular} &
  \begin{tabular}[c]{@{}l@{}}High initial investment for monitoring,\\ prognostic and diagnostic equipment,\\ particularly immature technology\end{tabular} \\ \hline
\end{tabular}%
}
\caption{Comparison of the Four Different Maintenance Strategies}
\label{tab:Maintenance strategies}
\end{table}

答案1

解决方案是使用和包来tabularray格式化表格。我按照与 @Bernard 在其回答中所做的类似方式清理了表格代码中的所有杂乱内容。表格主体中单元格的高度由第一列中最长单词的长度决定:ragged2erotatingmakecell

\documentclass{article}
\usepackage{ragged2e}
\usepackage{rotating,
            makecell}
\usepackage[svgnames]{xcolor}
\usepackage{tabularray}

\begin{document}
    \begin{table}[ht]
    \settowidth\rotheadsize{\small Characteristics}
\begin{tblr}{hlines, vlines,
             colspec = {Q[c, font=\small, bg=Gainsboro] *{4}{X[h, cmd=\RaggedRight]}},
             colsep=3pt,
             cell{2-Z}{1} = {cmd=\rotcell},
             row{1}  = {cmd=\centering, bg=Gainsboro}
             }
    &   Corrective Maintenance
        &   Scheduled Maintenance
            &   Condition-based Maintenance
                &   Predictive Maintenance      \\
Characteristics
    &   Performed after fault or breakdown
        &   Performed at pre-defined intervals
            &   Performed after observing certain conditions in an item
                &   Performed on the most suitable and cost effective date.
                                                \\
Requirements
    &   Skilled Staff, Spare components availability, Short reaction time
        &   In depth knowledge of the lifespan of an item, the precise planning of staff, and supply of spare parts
            &   Monitoring devices/systems, IT-infrastructure; skilled staff
                &   Monitoring systems, IT-infrastructure, data models and algorithms
                                                \\
Advantages
    &   No Planning cost, Maximization of the service life of an item
        &   Minimizes the downtime, fewer failures caused by wear out, high plannability
            &   Maximizes the productivity time of the machine, Maximizes the service life of the equipment
                &   Maximizes the productivity time of assets, Maximizes the service live of assets, High plannability.
                                            \\
Disadvantages
    &   Huge maintenance costs due to unplanned downtime
        &   Planning is cost intensive,does not prevent from random failures, labour intensive
            &   High investment for continuous monitoring and prognostic equipment
                &   High initial investment for monitoring, prognostic and diagnostic equipment, particularly immature technology
                                            \\
\end{tblr}%
\caption{Comparison of the Four Different Maintenance Strategies}
\label{tab:Maintenance strategies}
    \end{table}
\end{document}

在此处输入图片描述

答案2

一个解决方案tabularx。我使用和进行了一些改进,cellspace, ragged2egeometry获得更合适的边距,并对代码进行了一些简化。

    \documentclass{article}
    \usepackage{geometry}
    \usepackage{ragged2e}
    \usepackage{array, tabularx}
    \usepackage{graphicx}
    \usepackage[table, svgnames, xcdraw]{xcolor}
    \usepackage{cellspace}
    \setlength{\cellspacetoplimit}{6pt}
    \setlength{\cellspacebottomlimit}{6pt}
    \addparagraphcolumntypes{X}

    \begin{document}

    \begin{table}[]
    \begin{tabularx}{\textwidth}{|>{\columncolor{Gainsboro}}l |*{3}{ >{\RaggedRight}S{X}|} >{\columncolor{WhiteSmoke}\RaggedRight}S{X}|}
    \hline
     \rowcolor{Gainsboro} & Corrective Maintenance & Scheduled Maintenance &
     Condition-based Maintenance & Predictive Maintenance \\ \hline
    Characteristics &
      Performed after fault or breakdown &
      Performed at pre-defined intervals &
    Performed after observing certain conditions in an item &
     Performed on the most suitable and cost effective date. \\ \hline
    Requirements &
     Skilled Staff, Spare components availability, Short reaction time &
      In depth knowledge of the lifespan of an item, the precise planning of staff, and supply of spare parts &
    Monitoring devies/systems,IT-infrastructure; skilled staff &
     Monitoring systems, IT-infrastructure, data models and algorithms \\ \hline
    Advantages & No Planning cost, Maximization of the service life of an item &
    Minimizes the downtime, fewer failures caused by wear out, high plannability &
    Maximizes the productivity time of the machine, Maximizes the service life of the equipment &
    Maximizes the productivity time of assets, Maximizes the service live of assets, High plannability. \\ \hline
    Disadvantages &
    Huge maintenance costs due to unplanned downtime &
    Planning is cost intensive,does not prevent from random failures, labour intensive &
    High investment for continuous monitoring and prognostic equipment &
    High initial investment for monitoring, prognostic and diagnostic equipment, particularly immature technology \\ \hline
    \end{tabularx}%
    \caption{Comparison of the Four Different Maintenance Strategies}
    \label{tab:Maintenance strategies}
    \end{table}

    \end{document} 

在此处输入图片描述

相关内容