0

I would like to make a table that looks like in the image enter image description here

but I unable to make it the way I want by using the online LaTeX Table Maker. Here is how it is looking:

enter image description here

Here is my attempt:

% 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}
2
  • Could you please post a compilable code of what you've tried?
    – Bernard
    Aug 7, 2022 at 20:56
  • i was trying to post it but i was not able to make it in the coded form here. let me try again: =>Done
    – awais umar
    Aug 7, 2022 at 21:03

2 Answers 2

2

A solution with tabularray package which in table formatting use ragged2e, rotating and makecell packages. Your table code I was cleanup from all clutter on the similar way as @Bernard did in his answer. The height of cells in table body is determined by length of the longest word in the first column:

\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}

enter image description here

8
  • can you try on your end again? because maybe I have so many packages which now even i do not know what their purpose was. but I am getting a similar table as made by @Bernard. i do not see the first columns rotated. Getting error for this "cell{2-Z}{1} = {cmd=\rotcell}," when i remove Z then only "Chrachteristics" cell is rotated.
    – awais umar
    Aug 9, 2022 at 0:07
  • @awaisumar, what I should try again? Proposed MWE works and compilation result is shown in answer. How (where) you test my MWE? Using Overleaf? If this is the case, than you are in trouble, They use too old version of the tabularray package. In this case you need to ask their support how you can upload the recent version (2022C). If you have own (local) LaTeX instalation, than please update it.
    – Zarko
    Aug 9, 2022 at 6:12
  • 1
    @awaisumar, instead of cell{2-Z}{1} = ... try to use cell{2-5}{1} = .... Z means that should be considered the last row in table (which is the fifth in the your table).
    – Zarko
    Aug 9, 2022 at 6:25
  • it works thank you
    – awais umar
    Aug 9, 2022 at 23:05
  • is there an option to vary the overall table dimensions like we have figures,so as to force it to let say has an overall height of X and overall width of Y and the underlying boxes and text adjust accordingly? i actually would like to keep it on the same page and [ht] is not helping
    – awais umar
    Aug 9, 2022 at 23:13
2

A solution with tabularx. I added some improvements with cellspace, ragged2e and geometry to have more decent margins, and some simplifications to the code.

    \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} 

enter image description here

7
  • thank you for looking at it. the solution is really good but i am getting a compilation error when i am pasting the code in my report. the only difference I see is that i am using report class. but it work if i use it in isolation
    – awais umar
    Aug 7, 2022 at 22:17
  • Normally it should work in any standard class. What is your compilation error?
    – Bernard
    Aug 7, 2022 at 22:21
  • Multiple error came so i will list here: 1) Package array Error: Illegal pream-token (X): c' used. 2) Package xcolor Error: Undefined color Gainsboro'. others are of the undefined control sequence.
    – awais umar
    Aug 7, 2022 at 22:36
  • @awaisumar: for 1), did you load tabularx? For 2) , xcolor has to be load with with svgnames option (and table, so that \rowcolor and \columncolor are defined.
    – Bernard
    Aug 8, 2022 at 7:52
  • 1
    @awaisumar: I forgot to mention that if you load siunitx, the letter S, used as a prefix to the column specifier to ensure vertical spacing in cells , should be replaced with the letter C (or any letter you please with a loading time option of cellspace).
    – Bernard
    Aug 9, 2022 at 8:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .