TransWikia.com

How to change the subcell height in latex?

TeX - LaTeX Asked by Khalid Ibne Masood on July 19, 2021

I want to make a table in LaTeX which will be just like the picture.

enter image description here

I have used the code:

begin{table}[h!]
    begin{tabular}{|c|c|c|c|c|}hline
        Class & Format & Constant Value & Slope Value & Slope at  hline
Gain  &    K &$ 0^0 if K > 0$ &        0    &  -$infty$  cline{3-3}& &$ 180^0 if K > 0$ & &  hline
        
makecell{Zero at  origin}&    $s^{n_0}$   & $90 n_0$ & -    &  -$infty$  hline 
        
makecell{Simple Zero  at  $z_i$}&     $left(1 + frac{s}{z_i}right)^{n_1}$   & - & $45^o n_1$    &  $0.1 times z_i$  cline{4-5} & & & $-45^o n_1$    &  $10 times z_i$  
 hline
makecell{Quatrature  Zero at $z_j$}&     $left( 1 + 2zetafrac{s}{z_j} + left(frac{s}{z_j}   right)^2 right)^{n_2}$   & - & $90^o n_2$    &  $0.1 times z_j$  cline{4-5} & & & $-90^o n_2$    &  $10 times z_j$  hline
        
makecell{Pole at  origin}&    $1/s^{m_0}$   & $-90 m_0$ & -    &  -$infty$  hline 
makecell{Simple Pole  at  $p_i$}&     $frac{1}{left(1 + frac{s}{p_i}right)^{m_1}}$   & - &  $-45^o m_1$    &  $0.1 times p_i$  cline{4-5} & & & $+45^o m_1$    &  $10 times p_i$  hline
makecell{Quatrature   Pole at $p_j$}&     $frac{1}{left( 1 + 2zetafrac{s}{p_j} + left(frac{s}{p_j} right)^2 right)^{m_2}}$   & - &$-90^o m_2$    &  $0.1 times p_j$  cline{4-5} & & & $+90^o m_2$    &  $10 times p_j$   hline
    end{tabular}
end{table}

However, as you can see, the subcell height is not same in row 4-5 and 7-8. How I can match the subcell height?

2 Answers

The following should get you started. Adapt the rest of the table accordingly:

enter image description here

documentclass{article}
usepackage{amsmath}
usepackage{geometry}
usepackage{makecell}
renewcommand{theadfont}{normalsize}
usepackage[column=0]{cellspace}
setlength{cellspacetoplimit}{tabcolsep}
setlength{cellspacebottomlimit}{tabcolsep}
begin{document}

begin{table}[h!]
centering
    begin{tabular}{|0c|>{(}c<{)}|>{(}c<{)}|@{}>{(}c<{)}@{}|@{}>{(}c<{)}@{}|}hline
        thead{Class} 
          & thead{text{Format}} 
            & thead{text{Constant} text{Value}} 
              & thead{text{Slope} text{Value}} 
                & thead{text{Slope at}}  hline

makecell{Zero at  origin}
  & s^{n_0}   
    & 90 n_0 
      & - 
        &  -infty  
hline 
        
makecell{Simple Zero  at  $z_i$}
  & left(1 + frac{s}{z_i}right)^{n_1}   
    & - 
      & begin{tabular}{>{(}0c<{)}} 45^o n_1  hline -45^o n_1 end{tabular}    
        &  begin{tabular}{>{(}0c<{)}} 0.1 times z_i  hline  10 times z_i end{tabular} 
hline
    end{tabular}
end{table}

end{document}

Correct answer by leandriis on July 19, 2021

I would like to suggest that you (a) get rid of all vertical rules, (b) use fewer but well-spaced horizontal rules (by using the macros of the booktabs package) and (c) use more makecell directives to group the results in the final two columns for some rows. Optionally, use a tabular* environment rather than a tabular environment to assure that the table fits inside the text block. And, do replace the instances of ^0 and ^o with ^{circ}.

enter image description here

documentclass{article}
usepackage{makecell}
usepacakge{amsmath} % for text macro
usepackage{booktabs}% for toprule, midrule, bottomrule, and addlinespace macros
begin{document}

begin{table}[h!]
setlengthtabcolsep{0pt} % let LaTeX figure out intercolumn whitespace amounts
begin{tabular*}{textwidth}{@{extracolsep{fill}} l cccc}
toprule
Class & Format & Constant Value & Slope Value & Slope at  
midrule
Gain  & 
  $K$ & 
  makecell{text{$phantom{00}0^{circ}$ if $K>0$}[0.25ex]
            text{$180^{circ}$ if $K>0$}} & 
  0 &  $-infty$  
addlinespace addlinespace

makecell[l]{Zero at  origin}&
  $s^{n_0}$ & $90 n_0$ & -- & $-infty$  
addlinespace
makecell[l]{Simple Zero  at $z_i$} & 
  $bigl(1+frac{s}{z_i} bigr)^{n_1}$ & 
  -- & 
  makecell{$phantom{-}45^{circ}n_1$[0.25ex] $-45^{circ}n_1$} &  
  makecell{$0.1cdot z_i$[0.25ex] $10 cdot z_i$}  
addlinespace
makecell[l]{Quatrature  Zero at $z_j$}& 
  $bigl( 1 + 2zetafrac{s}{z_j} + (frac{s}{z_j})^2 bigr)^{n_2}$ 
  & -- & 
  makecell{$phantom{-}90^{circ}n_2$[0.25ex] $-90^{circ}n_2$} &
  makecell{$0.1cdot z_j$[0.25ex] $10 cdot z_j$}  
addlinespaceaddlinespace
    
makecell[l]{Pole at  origin}&  $1/s^{m_0}$ & $-90 m_0$ & --  &  $-infty$  
addlinespace 
makecell[l]{Simple Pole  at  $p_i$} &   
  $1big/bigl(1 + frac{s}{p_i}bigr)^{m_1}$ & 
  -- &  
  makecell{$-45^{circ}m_1$[0.25ex] $+45^{circ} m_1$} &
  makecell{$0.1 cdot p_i$[0.25ex] $10 cdot p_i$}  
addlinespace
makecell[l]{Quatrature  Pole at $p_j$} &   
  $1big/bigl( 1 + 2zetafrac{s}{p_j} + (frac{s}{z_j})^2 bigr)^{m_2}$ & 
  -- &
  makecell{$-90^{circ} m_2$[0.25ex] $+90^{circ} m_2$} &  
  makecell{$0.1 cdot p_j$ [0.25ex] $10 cdot p_j$}   
bottomrule
end{tabular*}
end{table}
end{document}

Answered by Mico on July 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP