2

I am having troubles with the correct visualization of the formula in the following table.

1) The height of the rows is too short. I want to keep the first row smaller than the following 4 rows. I tried arraystretch but wasn't unable to set it properly

2) I am not able to center the formula vertically. I tried the {|m{1in}|m{1in}|...} command but it gets messy

3) I want to align the text of the 1st cell in the last row to the left, but since it is on multiple lines I couldn't get the \multicolumn work properly

\begin{table*}[h]
\caption{Electromagnetic field regions.}
\label{tab:field_regions}
\centering
\resizebox{0.7\textwidth}{!}
{% 
    \begin{tabular} {|c|c|c|c|}

        %\toprule
        \hline
        \rowcolor[gray]{0.85}

      \textbf{Ratio $D_a/\lambda$}              & \textbf{Near field}        & \textbf{Mid field}        & \textbf{Far field} \\ 

      \hline

     $\displaystyle \frac{D_a}{\lambda}<1$          & $\displaystyle \frac{d}{\lambda}<1$      & -                         & $\displaystyle\frac{d}{\lambda}>1$ \\ 

     \hline

       $\rule{0pt}{20pt} \displaystyle 1<\frac{D_a}{\lambda}<10 $              & $\displaystyle \frac{d}{\lambda}<1.2\frac{D_a}{\lambda}$  & $\displaystyle 1.2 \frac{D_a}{\lambda}<\frac{d}{\lambda}<2\left(\frac{D_a}{\lambda}\right)^2$ & $\displaystyle \frac{d}{\lambda}>2\left(\frac{D_a}{\lambda}\right)^2 $ \\

       \hline

      $\displaystyle \frac{D_a}{\lambda}>10$ & $\displaystyle \frac{d}{\lambda}<\frac{1}{2} \sqrt[\leftroot{-1}\uproot{2}\scriptstyle 3]{\left(\frac{D_a}{\lambda}\right)^4} & \displaystyle \frac{1}{2}\sqrt[\leftroot{-1}\uproot{2}\scriptstyle 3]{\left(\frac{D_a}{\lambda}\right)^4}<\frac{d}{\lambda}< 2\left(\frac{D_a}{\lambda}\right)^2 $ &  $\displaystyle\frac{d}{\lambda}>2\left(\frac{D_a}{\lambda}\right)$\\ 

        \hline

      \cellcolor[gray]{0.85}  \makecell{\textbf{Dominant term} \\ \textbf{in the region}} & $\displaystyle  \frac{1}{d^3} $ & $\displaystyle \frac{1}{d^2}$ & $\displaystyle \frac{1}{d}$ \\           
      \hline          
    \end{tabular}}\end{table*}
2
\documentclass{article}
\usepackage{amsmath,graphicx,colortbl,makecell}
\begin{document}

\newcommand{\addstrut}[1]{\vcenter{\hbox{\rule{0pt}{#1}}}}

\begin{table*}[!htb]
\caption{Electromagnetic field regions.}
\label{tab:field_regions}
\centering
\resizebox{0.7\textwidth}{!}
{% 
    \begin{tabular}{|*4{>{$\displaystyle}c<{$}|}}
      %\toprule
      \hline
      \rowcolor[gray]{0.85}
      \textbf{Ratio $D_a/\lambda$} & \textbf{Near field}   & \textbf{Mid field} & \textbf{Far field} \\
      \hline
      \frac{D_a}{\lambda}<1      &  \frac{d}{\lambda}<1    & -               & \frac{d}{\lambda}>1 \addstrut{3em}\\ 
     \hline
       \rule{0pt}{20pt} \displaystyle 1<\frac{D_a}{\lambda}<10               &  \frac{d}{\lambda}<1.2\frac{D_a}{\lambda}  &  1.2 \frac{D_a}{\lambda}<\frac{d}{\lambda}<2\left(\frac{D_a}{\lambda}\right)^2 &  \frac{d}{\lambda}>2\left(\frac{D_a}{\lambda}\right)^2  \addstrut{3em}\\
       \hline
       \frac{D_a}{\lambda}>10 &  \frac{d}{\lambda}<\frac{1}{2} \sqrt[\leftroot{-1}\uproot{2}\scriptstyle 3]{\left(\frac{D_a}{\lambda}\right)^4} &  \frac{1}{2}\sqrt[\leftroot{-1}\uproot{2}\scriptstyle 3]{\left(\frac{D_a}{\lambda}\right)^4}<\frac{d}{\lambda}< 2\left(\frac{D_a}{\lambda}\right)^2  &  \frac{d}{\lambda}>2\left(\frac{D_a}{\lambda}\right) \addstrut{3.5em}\\ 
        \hline
      \cellcolor[gray]{0.85}\makecell[l]{\textbf{Dominant term}\\\textbf{in the region}} &   \frac{1}{d^3}  &  \frac{1}{d^2} &  \frac{1}{d} \addstrut{3em}\\           
      \hline          
    \end{tabular}
}
\end{table*}

\end{document}

enter image description here

1

I propose some code simplifications with the cellspace package, and layout improvements (in particular, caption provides a more sensible vertical spacing between caption above and table):

\documentclass[twocolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{siunitx, caption, adjustbox, makecell, array, cellspace}
\setlength{\cellspacetoplimit}{6pt}
\setlength{\cellspacebottomlimit}{6pt}
\usepackage[table]{xcolor}

\begin{document}

\begin{table*}[h]
\caption{Electromagnetic field regions.}
\label{tab:field_regions}
\centering
\resizebox{0.7\textwidth}{!}
{\everymath{\displaystyle}%
    \begin{tabular} {|*{4}{Cc|}}
        \hline
        \rowcolor[gray]{0.85}
      \textbf{Ratio \boldmath$D_a/\lambda$} & \textbf{Near field} & \textbf{Mid field} & \textbf{Far field} \\
      \hline
     $\frac{D_a}{λ} < 1$ & $ \frac{d}{λ} < 1$ & $-$ & $\frac{d}{λ} > 1$ \\
     \hline
       $\rule{0pt}{20pt} 1 < \frac{D_a}{λ} < 10 $ & $ \frac{d}{λ} < 1.2\,\frac{D_a}{λ}$ & $ 1.2\, \frac{D_a}{λ} < \frac{d}{λ} < 2\left(\frac{D_a}{λ}\right)^{\mkern-5mu 2}$ & $ \frac{d}{λ} > 2\left(\frac{D_a}{λ}\right)^{\mkern-5mu 2} $ \\
       \hline
 $ \frac{D_a}{λ} > 10$ & $ \frac{d}{λ} < \frac{1}{2} √[\leftroot{-1}\uproot{2}\scriptstyle 3]{\left(\frac{D_a}{λ}\right)^{\mkern-5mu 4}}$ & $ \frac{1}{2}√[\leftroot{-1}\uproot{2}\scriptstyle 3]{\left(\frac{D_a}{λ}\right)^{\mkern-5mu 4}} < \frac{d}{λ} < 2\left(\frac{D_a}{λ}\right)^{\mkern-5mu 2} $ & $\frac{d}{λ} > 2\left(\frac{D_a}{λ}\right)$\\
 \hline
 \cellcolor[gray]{0.85} \makecell{\textbf{Dominant term} \\ \textbf{in the region}} & $ \frac{1}{d³} $ & $ \frac{1}{d²}$ & $ \frac{1}{d}$ \\
 \hline
    \end{tabular}}\end{table*}

    \end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.