0

I have this table:

\documentclass[10pt,conference]{IEEEtran}
\usepackage{pgfplots}
\usepackage{tikz}        
\pgfplotsset{compat=newest}
\usepackage{cite}
\usepackage{newtxtext,newtxmath}
\usepackage{booktabs,siunitx}
\usepackage{multirow}
\usepackage{amsmath,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{pifont}
\usepackage{textcomp}
\usepackage{tabularx,ragged2e,bm,newtxmath} % new packages
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{xcolor}
\usepackage{array}

\begin{document}
\begin{table*}[bt]
\newcommand{\mr}[1]{\multirow{2}{*}{#1}}
\newcommand{\mc}[1]{\multicolumn{2}{c}{#1}}
\newcommand{\ts}[1]{\textsubscript{#1}}
\newcommand{\edcoh}{\mathrm{ed}_{\mathrm{coh}}}
\newcommand{\cderr}{\mathrm{cd}_{\mathrm{err}}}
\newcommand{\true}{\mathrm{true}}
\setlength{\tabcolsep}{0pt}
\caption{Scenarios results 2 }\label{tab:results}
\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  c
  *{3}{ccc}
  @{}
}
\toprule
&
\multicolumn{3}{c}{Anomaly propagation step 1} &
\multicolumn{3}{c}{Anomaly propagation  step 2} &
\multicolumn{3}{c}{Anomaly propagation  step 3} \\

\cmidrule{2-4}
\cmidrule{5-7}
\cmidrule{8-10}

Scenario  
& Detection & Propagation Path & PIS
& Detection & Propagation Path & PIS
& Detection & Propagation Path & PIS
 \\
\midrule
\addlinespace
%Scenario 1
\mr{1} & \begin{tabular}[c]{@{}l@{}}$\edcoh=\true$ \\ $t=\SI{57}{\hour}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}
PU2-T1-PLC2-SCADA \\PU2-T1-PLC2-PLC1-SCADA \\PU2-T1-PLC2-PLC1-PU1-T1 
\\PU2-T1-PLC2-PLC1-PU2\end{tabular}  
& \begin{tabular}[c]{@{}l@{}}
27 \\ 41 \\ 47,75 \\ 41
\end{tabular}

& \begin{tabular}[c]{@{}l@{}}$\edcoh=\true$ \\ $t=\SI{79}{\hour}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}
PU1-T1-PLC2-SCADA \\PU1-T1-PLC2-PLC1-SCADA \\PU1-T1-PLC2-PLC1-PU2-T1 
\\PU1-T1-PLC2-PLC1-PU1  
\end{tabular}  
& \begin{tabular}[c]{@{}l@{}}
27 \\ 41 \\ 47,75 \\ 41
\end{tabular}

& \begin{tabular}[c]{@{}l@{}}$\edcoh=\true$ \\ $t=\SI{79.6}{\hour}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}
T1-PLC2-SCADA \\T1-PLC2-PLC1-SCADA \\T1-PLC2-PLC1-PU1-T1
\\T1-PLC2-PLC1-PU2-T1 
\end{tabular}    
& \begin{tabular}[c]{@{}l@{}}
20,25 \\ 34.25 \\ 41 \\ 41
\end{tabular}   \\
\addlinespace
%Scenario 2
\mr{2} & \begin{tabular}[c]{@{}l@{}}$\edcoh=\true$ \\ $t=\SI{30}{\hour}$\end{tabular} & \begin{tabular}[l]{@{}l@{}}
T7-PLC9-SCADA \\T7-PLC9-PLC5-SCADA \\T7-PLC9-PLC5-PU10-T7 
\\T7-PLC9-PLC5-PU11-T7\end{tabular}  
& \begin{tabular}[c]{@{}l@{}}
20,25 \\ 34,25 \\ 41 \\ 41
\end{tabular}

& n/a 
& n/a
& n/a
& n/a   
& n/a
& n/a \\
\addlinespace
%Scenario 3
\mr{3} & \begin{tabular}[c]{@{}l@{}}$\edcoh=\true$ \\ $t=\SI{3,9}{\hour}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}
PU2-T1-PLC2-SCADA \\PU2-T1-PLC2-PLC1-SCADA \\PU2-T1-PLC2-PLC1-PU1-T1 
\\PU2-T1-PLC2-PLC1-PU2\end{tabular}  
& \begin{tabular}[c]{@{}l@{}}
27 \\ 41 \\ 47,75 \\ 41
\end{tabular}

& \begin{tabular}[c]{@{}l@{}}$\edcoh=\true$ \\ $t=\SI{11,3}{\hour}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}
PU2-T1-PLC2-SCADA \\PU2-T1-PLC2-PLC1-SCADA \\PU2-T1-PLC2-PLC1-PU1-T1 
\\PU2-T1-PLC2-PLC1-PU2  
\end{tabular}  
& \begin{tabular}[c]{@{}l@{}}
27 \\ 41 \\ 47,75 \\ 41
\end{tabular}

& \begin{tabular}[c]{@{}l@{}}$\edcoh=\true$ \\ $t=\SI{13,7}{\hour}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}
PU2-T1-PLC2-SCADA \\PU2-T1-PLC2-PLC1-SCADA \\PU2-T1-PLC2-PLC1-PU1-T1 
\\PU2-T1-PLC2-PLC1-PU2  
\end{tabular}    
& \begin{tabular}[c]{@{}l@{}}
27 \\ 41 \\ 47,75 \\ 41
\end{tabular}   \\

\midrule[\heavyrulewidth]
\multicolumn{8}{l}{PIS: Propagation Impact Score}
\end{tabular*}
\end{table*}


\end{document}

I am using table in cell instead of using multirow. I can't get them to center or left center, despite using \begin{tabular}[c]{@{}l@{}} or \begin{tabular}[l]{@{}l@{}}. I have tried to change the column type but it seems that it doesn't change anything. I would like to center each "Detection" column, and center left each "Propagation path" column.

Here is the obtained result: enter image description here As you can see "Detection" column is not centered, and the third cell of the second row is not left centered.

Thanks for your help.

[EDIT]

Thanks to @Simon Dispa I centered the columns I wanted. I also modified my code to align the text of each "Propagation path" column. I used \begin{tabular}{|L{34mm}|} T7-PLC9-SCADA \\T7-PLC9-PLC5-SCADA \\T7-PLC9-PLC5-PU10-T7 \\T7-PLC9-PLC5-PU11-T7\end{tabular}

With \newcolumntype{L}[1]{>{\RaggedRight\hspace{0pt}}p{#1}} enter image description here

1 Answer 1

1

But your code produces centered columns! They might be tight, but centered.

I added vertical lines for better visualization. It also centered the last cell in the bottom row (PIS column). I think it looks better. The same could be applied to the cells in the Detection column.

b

        & \begin{tabular}[c]{@{}c@{}} % <<<< changed
            27 \\ 41 \\ 47,75 \\ 41
        \end{tabular} 

To align the shorter (two in the example) it could be used \multicolumn{1}{l}{...}

        & \begin{tabular}[c]{@{}l@{}}$\edcoh=\true$ \\ $t=\SI{79.6}{\hour}$\end{tabular} & \multicolumn{1}{l}{\begin{tabular}{@{}l@{}} %<<<<<<<<<<<<<<< changed
            T1-PLC2-SCADA \\T1-PLC2-PLC1-SCADA \\T1-PLC2-PLC1-PU1-T1
            \\T1-PLC2-PLC1-PU2-T1 
        \end{tabular}}

Centering Detection and PIS cells, aligning left two Propagation Path cells. d

This is the final code.

\documentclass[10pt,conference]{IEEEtran}
\usepackage{pgfplots}
\usepackage{tikz}        
\pgfplotsset{compat=newest}
\usepackage{cite}
\usepackage{newtxtext,newtxmath}
\usepackage{booktabs,siunitx}
\usepackage{multirow}
\usepackage{amsmath,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{pifont}
\usepackage{textcomp}
\usepackage{tabularx,ragged2e,bm,newtxmath} % new packages
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{xcolor}
\usepackage{array}

\begin{document}
    \begin{table*}[bt]
        \newcommand{\mr}[1]{\multirow{2}{*}{#1}}
        \newcommand{\mc}[1]{\multicolumn{2}{c}{#1}}
        \newcommand{\ts}[1]{\textsubscript{#1}}
        \newcommand{\edcoh}{\mathrm{ed}_{\mathrm{coh}}}
        \newcommand{\cderr}{\mathrm{cd}_{\mathrm{err}}}
        \newcommand{\true}{\mathrm{true}}
        \setlength{\tabcolsep}{0pt}
        \caption{Scenarios results 2 }\label{tab:results}
    
        \begin{tabular*}{\textwidth}{
                @{\extracolsep{\fill}}
                c
                *{3}{ccc}
                @{}
            }
            \toprule
            &
            \multicolumn{3}{c}{Anomaly propagation step 1} &
            \multicolumn{3}{c}{Anomaly propagation  step 2} &
            \multicolumn{3}{c}{Anomaly propagation  step 3} \\
            
            \cmidrule{2-4}
            \cmidrule{5-7}
            \cmidrule{8-10}
            
            Scenario  
            & Detection & Propagation Path & PIS
            & Detection & Propagation Path & PIS
            & Detection & Propagation Path & PIS
            \\
            \midrule
            \addlinespace
            %Scenario 1
            \mr{1} & \begin{tabular}[c]{@{}c@{}}$\edcoh=\true$ \\ $t=\SI{57}{\hour}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}
                PU2-T1-PLC2-SCADA \\PU2-T1-PLC2-PLC1-SCADA \\PU2-T1-PLC2-PLC1-PU1-T1 
                \\PU2-T1-PLC2-PLC1-PU2\end{tabular}  
            & \begin{tabular}[c]{@{}c@{}}
                27 \\ 41 \\ 47,75 \\ 41
            \end{tabular}
            
            & \begin{tabular}[c]{@{}c@{}}$\edcoh=\true$ \\ $t=\SI{79}{\hour}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}
                PU1-T1-PLC2-SCADA \\PU1-T1-PLC2-PLC1-SCADA \\PU1-T1-PLC2-PLC1-PU2-T1 
                \\PU1-T1-PLC2-PLC1-PU1  
            \end{tabular}  
            & \begin{tabular}[c]{@{}c@{}}
                27 \\ 41 \\ 47,75 \\ 41
            \end{tabular}
            
            & \begin{tabular}[c]{@{}c@{}}$\edcoh=\true$ \\ $t=\SI{79.6}{\hour}$\end{tabular} & \multicolumn{1}{l}{\begin{tabular}{@{}l@{}} %<<<<<<<<<<<<<<< changed
                T1-PLC2-SCADA \\T1-PLC2-PLC1-SCADA \\T1-PLC2-PLC1-PU1-T1
                \\T1-PLC2-PLC1-PU2-T1 
            \end{tabular} }   
            & \begin{tabular}[c]{@{}c@{}}
                20,25 \\ 34.25 \\ 41 \\ 41
            \end{tabular}   \\
            \addlinespace
            %Scenario 2
            \mr{2} & \begin{tabular}[c]{@{}c@{}}$\edcoh=\true$ \\ $t=\SI{30}{\hour}$\end{tabular} & \multicolumn{1}{l}{\begin{tabular}[l]{@{}l@{}}
                T7-PLC9-SCADA \\T7-PLC9-PLC5-SCADA \\T7-PLC9-PLC5-PU10-T7 
                \\T7-PLC9-PLC5-PU11-T7\end{tabular}} 
            & \begin{tabular}[c]{@{}c@{}}
                20,25 \\ 34,25 \\ 41 \\ 41
            \end{tabular}
            
            & n/a 
            & n/a
            & n/a
            & n/a   
            & n/a
            & n/a \\
            \addlinespace
            %Scenario 3
            \mr{3} & \begin{tabular}[c]{@{}c@{}}$\edcoh=\true$ \\ $t=\SI{3,9}{\hour}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}
                PU2-T1-PLC2-SCADA \\PU2-T1-PLC2-PLC1-SCADA \\PU2-T1-PLC2-PLC1-PU1-T1 
                \\PU2-T1-PLC2-PLC1-PU2\end{tabular}  
            & \begin{tabular}[c]{@{}c@{}}
                27 \\ 41 \\ 47,75 \\ 41
            \end{tabular}
            
            & \begin{tabular}[c]{@{}c@{}}$\edcoh=\true$ \\ $t=\SI{11,3}{\hour}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}
                PU2-T1-PLC2-SCADA \\PU2-T1-PLC2-PLC1-SCADA \\PU2-T1-PLC2-PLC1-PU1-T1 
                \\PU2-T1-PLC2-PLC1-PU2  
            \end{tabular}  
            & \begin{tabular}[c]{@{}c@{}}
                27 \\ 41 \\ 47,75 \\ 41
            \end{tabular}
            
            & \begin{tabular}[c]{@{}c@{}}$\edcoh=\true$ \\ $t=\SI{13,7}{\hour}$\end{tabular} & \begin{tabular}[c]{@{}l@{}}
                PU2-T1-PLC2-SCADA \\PU2-T1-PLC2-PLC1-SCADA \\PU2-T1-PLC2-PLC1-PU1-T1 
                \\PU2-T1-PLC2-PLC1-PU2  
            \end{tabular}    
            & \begin{tabular}[c]{@{}c@{}} % <<<< changed
                27 \\ 41 \\ 47,75 \\ 41
            \end{tabular}   \\
            
            \midrule[\heavyrulewidth]
            \multicolumn{8}{l}{PIS: Propagation Impact Score}
        \end{tabular*}
    \end{table*}        
    
\end{document}
3
  • Indeed, it's my bad I modified the wrong part of the column specification.
    – nicope13
    May 3, 2021 at 17:06
  • Do you think I should modify the horizontal padding to align the text in each "Propagation path" column ?
    – nicope13
    May 3, 2021 at 17:21
  • @nicope13 It will look better if the narrowed entries are left align. (two in the example) May 3, 2021 at 17:31

You must log in to answer this question.

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