0

I have the following code:

\newcolumntype{Z}{>{\centering\arraybackslash}m{2.5cm}}
\newcolumntype{S}{>{\centering\arraybackslash}m{0.5cm}}
\begin{table*}[htbp]
\caption{Table Type Styles}
\begin{center}
\begin{tabular}{|S|S|c|S|Z|}
\hline
\multicolumn{2}{|c|}{\textbf{Model}} & \textbf{PL {[}dB{]}, $f_c$ {[}GHz{]}, $d$ {[}m{]}} & \textbf{$\sigma_{SF}$ {[}dB{]}} & \textbf{Applicability range and default values} \\ \hline
\multirow{2}{*}{\rotatebox{90}{3GPP UMa}} & \rotatebox{90}{LOS} & $\begin{aligned}[t]
    PL_{\textnormal{UMa-LOS}} &=
    \begin{cases}
    PL_1  &\quad \text{if } 10\text{ m} \leq d_{2D} \leq d^{'}_{BP} \\
    PL_2 &\quad \text{if } d^{'}_{BP} < d_{2D} \leq 5\text{ km} \end{cases} \\ PL_1 &= 28 + 22\log_{10}(d_{3D}) + 20\log_{10}(f_{c}) \\ PL_2 &= 28 + 40\log_{10}(d_{3D}) + 20\log_{10}(f_{c}) \\ &-9\log_{10}(({d^{'}_{\text{BP}}})^2 + h_{eff}^2) 
    \end{aligned} $ & 4 & \multirow{2}{*}{$\begin{aligned} 0.5<f_c<100 \text{ GHz} \\ 10 < d_{2D} < 5000\text{ m} \\ 1.5\leq h_{\text{UE}}\leq22.5\text{ m} \\ h_{\text{BS}}=25\text{ m} \end{aligned}$} \\ \cline{2-4}
& \rotatebox{90}{NLOS} & $\begin{aligned}  PL_{\textnormal{UMa-NLOS}} &= \max\left(PL_{\textnormal{UMa-LOS}}, PL_{\textnormal{UMa-NLOS}}^{'}\right) \\ PL_{\textnormal{UMa-NLOS}}^{'} &= 13.54 + 39.08\log_{10}(d_{3D}) + 20\log_{10}(f_{c}) \\& - 0.6\log_{10}(h_{\text{UE}}-1.5) \end{aligned}$& 6 & \\ \hline
\end{tabular}
\label{tab:models}
\end{center}
\end{table*}

which when compiled:

table

How can I center all cells, both horizontally and vertically?

EDIT 1: @Zarko solutions almost works, but now I need to add a few more rows below:

\multirow{2}{*}{\rotatebox{90}{mmMAGIC UMi}} & \rotatebox[origin=c]{90}{LOS} & $PL_{\textnormal{UMi-LOS}} = 32.9 + 19.2\log_{10}(d_{3D}) + 20.8\log_{10}(f_{c})$ & 2 & \multirow{2}{*}{} \\ \cline{2-4}
    & \rotatebox[origin=c]{90}{NLOS} & $PL_{\textnormal{UMi-NLOS}} =31.0 + 45.0\log_{10}(d_{3D}) + 20.0\log_{10}(f_{c})$ & 7.82 & \\ \hline

When I do that: edit1 Is there any way of splitting in two "vertical rows"? In addition, the following is happening:

large

which is different from the figure in the answer.

2
  • Does adding a \vfill{} before and after the things you want vertically centered work? Apr 28, 2020 at 13:01
  • Any news? Now you have two answers, which solved your problem. It is time to accept one of them ...
    – Zarko
    Aug 23, 2021 at 8:23

2 Answers 2

2

You can use {NiceTabular} of nicematrix.

  • You can set the option cell-space-limits (without having to put a pre-specifier of column).
  • You use \Block for the merged cells (horizontally and vertically).
  • You use the key hvlines and all the rules are drawn excepted in the blocks.

You may have to compile twice.

\documentclass{article}
\usepackage{nicematrix}        

  
\begin{document}  
\newcolumntype{Z}{>{\centering\arraybackslash}m{3cm}}
\newcolumntype{S}{>{\centering\arraybackslash}m{0.7cm}}
\begin{table*}[htbp]
\caption{Table Type Styles}
\begin{center}
\begin{NiceTabular}{Sw{c}{7mm}cSZ}[hvlines,cell-space-limits=3pt]
\Block{1-2}{\textbf{Model}} 
& 
& \textbf{PL {[}dB{]}, $f_c$ {[}GHz{]}, $d$ {[}m{]}} 
& \textbf{$\sigma_{SF}$ {[}dB{]}} 
& \textbf{Applicability range and default values} 
\\ 
\Block{2-1}{\rotate 3GPP UMa} 
& \rotatebox[origin=c]{90}{LOS} 
& $\begin{aligned}
    PL_{\textnormal{UMa-LOS}} & =
    \begin{cases}
      PL_1 & \quad \text{if } 10\text{ m} \leq d_{2D} \leq d^{'}_{BP} \\
      PL_2 & \quad \text{if } d^{'}_{BP} < d_{2D} \leq 5\text{ km} 
    \end{cases} \\ 
    PL_1 & = 28 + 22\log_{10}(d_{3D}) + 20\log_{10}(f_{c}) \\ 
    PL_2 & = 28 + 40\log_{10}(d_{3D}) + 20\log_{10}(f_{c}) \\ 
         & -9\log_{10}(({d^{'}_{\text{BP}}})^2 + h_{eff}^2) 
    \end{aligned} $ 
& 4 
& \Block{2-1}%
    {
       $\begin{aligned} 
          0.5<f_c<100 \text{ GHz} \\ 
          10 < d_{2D} < 5000\text{ m} \\ 
          1.5\leq h_{\text{UE}}\leq22.5\text{ m} \\ 
          h_{\text{BS}}=25\text{ m} 
        \end{aligned}$
     } 
\\ 
&\rotatebox[origin = c]{90}{NLOS}
& $\begin{aligned}  
    PL_{\textnormal{UMa-NLOS}}     & = \max\left(PL_{\textnormal{UMa-LOS}}, PL_{\textnormal{UMa-NLOS}}^{'}\right) \\ 
    PL_{\textnormal{UMa-NLOS}}^{'} & = 13.54 + 39.08\log_{10}(d_{3D}) + 20\log_{10}(f_{c}) \\
                                & - 0.6\log_{10}(h_{\text{UE}}-1.5) 
   \end{aligned}$
& 6 
& \\ 
\end{NiceTabular}
\end{center}
\end{table*}    
\end{document}

Result of above code

0
1

enter image description here

\documentclass{article}
\usepackage{geometry}
\usepackage{mathtools}
\usepackage{rotating}
\usepackage{cellspace, makecell, multirow, tabularx}
    \renewcommand\theadfont{\small\bfseries}
    \setlength\cellspacetoplimit{5pt}
    \setlength\cellspacebottomlimit{5pt}
\newcolumntype{C}{>{\centering\arraybackslash}X}
    \addparagraphcolumntypes{C}

\begin{document}
    \begin{table}[htbp]
\caption{Table Type Styles}
\label{tab:models}
    \centering
\begin{tabularx}{\linewidth}{|*{4}{Sc|}>{\centering\arraybackslash}X|}
\hline
\multicolumn{2}{|c|}{\thead{Model}} 
    & \thead{PL {[}dB{]}, $f_c$ {[}GHz{]}, $d$ {[}m{]}} 
        & \thead{$\sigma_{SF}$\\ {[}dB{]}} 
            & \thead{Applicability range\\ and default values} \\ \hline
\multirow{8}{*}{\rotatebox{90}{3GPP UMa}} 
    & \rotatebox[origin=c]{90}{LOS} 
        & $\begin{aligned}
            PL_{\mathrm{UMa-LOS}} & = \begin{cases}
                PL_1 &\quad \text{if } 10\text{ m} \leq d_{2D} \leq d^{'}_{BP} \\
                PL_2 &\quad \text{if } d^{'}_{BP} < d_{2D} \leq 5\text{ km}
                                      \end{cases} \\
            PL_1 & = 28 + 22\log_{10}(d_{3D}) + 20\log_{10}(f_{c}) \\ 
            PL_2 & = 28 + 40\log_{10}(d_{3D}) + 20\log_{10}(f_{c}) \\
                 &\qquad         
                    -9\log_{10}(({d^{'}_{\text{BP}}})^2 + h_{eff}^2)
        \end{aligned}$ 
            & 4
                & \multirow{6}{=}{$\begin{aligned}
                    0.5<    & f_c<100 \text{ GHz} \\
                    10 <    & d_{2D} < 5000\text{ m} \\
                    1.5\leq & h_{\text{UE}}\leq22.5\text{ m} \\
                            & h_{\text{BS}}=25\text{ m}
                                 \end{aligned}$} \\
    \cline{2-4}
    & \rotatebox[origin=c]{90}{NLOS} 
        & $\begin{aligned}  
            PL_{\mathrm{UMa-NLOS}}      
                & = \max\left(PL_{\mathrm{UMa-LOS}}, PL_{\mathrm{UMa-NLOS}}^{'}\right) \\
            PL_{\mathrm{UMa-NLOS}}^{'}  
                & = 13.54 + 39.08\log_{10}(d_{3D}) + 20\log_{10}(f_{c}) \\
                &\qquad - 0.6\log_{10}(h_{\text{UE}}-1.5)
        \end{aligned}$
            & 6 &   \\ 
    \hline
\end{tabularx}
    \end{table}
\end{document}

Addendum:

You should be aware, that height of \multirow cells had to be equal or les than height of spanned adjacent rows. If this is not a case, than content of them will protrude out of cells as you show in your edited question. To prevent this, you have two choices:

  • reduce height of \multirow cells (as is done in the next MWE), or
  • increase heights of spanned rows, for example with bigger additional vertical spaces around those rows contents or insert empty lines in them

At considering of the first option your table as follows can write as:

\documentclass{article}
\usepackage{mathtools}
\usepackage{makecell, multirow, tabularx}
    \renewcommand\theadfont{\small\bfseries}
    \renewcommand\theadgape{} % new
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcommand\RH[1]{\rotatebox[origin=c]{90}{\makecell{#1}}}% new
\usepackage{geometry}
\usepackage{siunitx}    % new, used version 3

\begin{document}
    \begin{table}[htbp]
\caption{Table Type Styles}
\label{tab:models}
    \centering
    \setcellgapes{7pt}  % new
    \makegapedcells     % new
    \setlength\tabcolsep{3pt}
\begin{tabularx}{\linewidth}{|*{4}{c|} C|}
    \Xhline{1pt}
\multicolumn{2}{|c|}{\thead{Model}}
    & \thead{PL {[\unit{dB}]}, $f_c$ {[\unit{GHz}]}, $d$ {[\unit{m}]}}
        & \thead{$\sigma_{SF}^{}$\\ {[\unit{dB}]}}
            & \thead{Applicability range\\ and default values} \\ 
    \Xhline{0.8pt}
\multirow{8}{*}{\RH{3GPP UMa}}
    & \RH{LOS}
        & $\begin{aligned}
            PL_{\mathrm{UMa-LOS}} 
                  & = \begin{cases*}
                PL_1 & if \qty{10}{m} $\leq d_{2D} \leq d^{'}_{BP}$ \\%[-1ex]
                PL_2 & if $d^{'}_{BP} < d_{2D} \leq \qty{5}{km}$
                      \end{cases*} \\
            PL_1 & = 28 + 22\log_{10}(d_{3D}) + 20\log_{10}(f_{c}) \\
            PL_2 & = \begin{multlined}[t]
                    28 + 40\log_{10}(d_{3D}) + \\[-2ex] 
                    20\log_{10}(f_{c}) -9 \log_{10}\bigl(({d'_{\text{BP}}})^2 + h_{eff}^2\bigr)
                     \end{multlined}
        \end{aligned}$
            & 4
                & \multirow{8.4}{=}{$\begin{aligned}
                    0.5<    & f_c<\qty{100}{GHz} \\
                    10 <    & d_{2D} < \qty{5000}{m} \\
                    1.5\leq & h_{\text{UE}}\leq \qty{22.5}{m} \\
                            & h_{\text{BS}}=\qty{25}{m}
                                 \end{aligned}$} \\
    \cline{2-4}
    & \RH{NLOS}
        & $\begin{aligned}
            PL_{\mathrm{UMa-NLOS}}
                & = \max\left(PL_{\mathrm{UMa-LOS}}, PL_{\mathrm{UMa-NLOS}}^{'}\right) \\
            PL_{\mathrm{UMa-NLOS}}^{'}
                & = \begin{multlined}[t]
                13.54 + 39.08\log_{10}(d_{3D}) + \\[-2ex]
                20\log_{10}(f_{c}) - 0.6\log_{10}(h_{\text{UE}}-1.5)
                    \end{multlined}
          \end{aligned}$
            & 6 &   \\
    \hline
\multirow{2}{*}{\RH{mmMAGIC\\ UMi}}
    & \RH{LOS}
        & $PL_{\mathrm{UMi-LOS}}=32.9 + 19.2\log_{10}(d_{3D}) + 20.8\log_{10}(f_{c})$
            & 2 &       \\ 
    \cline{2-4}
    & \RH{NLOS}
        & $PL_{\mathrm{UMi-NLOS}}=31.0 + 45.0\log_{10}(d_{3D}) + 20.0\log_{10}(f_{c})$
            & 7.82 &    \\ 
    \Xhline{1pt}
\end{tabularx}
    \end{table}
\end{document}

which produce:

enter image description here

4
  • please see EDIT 1 above
    – rocker996
    Apr 28, 2020 at 13:53
  • @rocker996, please extend your MWE with this new rows. For start use code from my answer and ass to them new rows. On this way we can see, with which problem(s) you faced when adding new rows. BTW, you not provide any information about your document. If you tested my answer, as it is, the result had to be the same as I show you.
    – Zarko
    Apr 28, 2020 at 14:12
  • overleaf.com/3547813158rjmkthqpypjh this is the link to the project. Below the title there should be 3 columns aligned, and the problem is when I add those new commands in the preamble, there are only 2 columns and the 3rd goes below
    – rocker996
    Apr 28, 2020 at 14:48
  • Please make from your document a MWE and copy it to your question. Link can be death after while and other will not see, what is the problem and if they have similar one.
    – Zarko
    Apr 28, 2020 at 15:14

You must log in to answer this question.

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