TransWikia.com

Can anyone help me draw this table?

TeX - LaTeX Asked by Soumyadeep Chandra on June 20, 2021

Table fotmat

Draw a table with the following text wraps and center vertical and horizontal alignment for the cell. I am having problem in text wrapping using multirow package.

A snippet of my code:

newcolumntype{L}{>{centeringarraybackslash}m{0.73in}}
newcolumntype{M}{>{centeringarraybackslash}m{1.5in}}
begin{table}[!ht]
    begin{center}
    setlengthcellspacetoplimit{12pt}
    setlengthcellspacebottomlimit{12pt}
    resizebox{textwidth}{!}{
begin{tabular}{|L|M|M|M|M|}
hline
textbf{Scenario} & textbf{Description} & textbf{Delivery of Motors} & textbf{Productive Reservoir} & textbf{Non-Productive Reservoir} 
hline
1 & Basic two system & Both get delivered equally. & Few get detached into  reservoir due to provision of movement. & Almost all the others are reattached within the given time, as a result no leakage has occurred.
hline
2 & Parallel with no movement & Without the provision of movement, faster are hindered due to crowding. &   Almost all the one are waiting in the reservoirs due to crowding. & The leakage might occur depending on the influx rate and crowding. 
hline 
3 & 90% staggering at the initial segment & A smaller level allows very few numbers of ones to move out of the system. & multirow{3}{*}{begin{minipage}{1.5in}When staggering occurs in the initial segment, most of the  wait in the reservoirs.end{minipage}}& multirow{3}{*}{begin{minipage}{1.5in}Due to heavy crowding of influx in the initial segment, most of the within their given lifetime, and are out of the system.end{minipage}}  [5pt]
cline{1-3}
4 & 95 % staggering at the initial segment  &  multirow{2}{*}{begin{minipage}{1.5in}
 Almost no one cross the 95% barrier and thus move out via the lines.
 As ones in middle track never experience congestion, so they move freely in a single line only. end{minipage}} & ~ & ~    
cline{1-2}
5 & 100% staggering at the initial segment of & ~ & ~ & ~  
hline
6 & 90% staggering at the later segment & multirow{3}{*}{begin{minipage}{1.5in}As the staggering is at the later end, the output affected. Only a few numbers, who has overcome gets output within their lifetime.end{minipage}}& multirow{3}{*}{begin{minipage}{1.5in}The starts to occur beyond the point only.end{minipage}} & multirow{3}{linewidth}{begin{minipage}{1.5in}As the staggering is at the later end, which were moving in those staggered tracks. As a result, both the one are gradually moved out from the point.end{minipage}}  
cline{1-2}
7 & 95% staggering at the later segment  & ~ & ~ & ~  
cline{1-2}
8 & 100% staggering at the later segment & ~ & ~ & ~  
hline
end{tabular}
    }
end{center}
caption{label{tab:one}A detailed analysis of different scenarios simulated with parametric values as discussed in Simulation I}
end{table}

Overlapped text

As you can see the cells text are overlapping and not contained in one cell. Also row heights are irregular.

3 Answers

Like this:

enter image description here

  • Your problem is caused because the content in the multirow cell is higher then sum of heights of rows spanned by this cell.
  • One possible work around is add vertical spaces in all cells, for example with use of the makegapedcells or with use of cellspace package and reduce linespread in table text.
  • Unfortunately makegapedcells is not compatible with m column types, but this can be fix with hack suggested by Ulrike Fisher.
  • Since you not provide any information about your page layout, in MWE below it has 20mm with page borders. In the case, that you have wider pages' borders, than may suggested solution in MWE below will not give satisfied result. In such a case I will need to tweak cell gapes and number of lines in in multi row cells.
documentclass{article}
usepackage[margin=20mm]{geometry}
usepackage{siunitx}
usepackage{ragged2e}
usepackage{makecell, multirow, tabularx}
renewcommandtheadfont{smallbfseries}
renewcommandtheadgape{}
newcolumntype{L}{>{RaggedRight}X}
%%--------------------------------------------------------------%
%%  patch of Ulrike Fisher (on my request)                      %
%   (http://tex.stackexchange.com/questions/319768/             %
%%--------------------------------------------------------------%
makeatletter
renewcommandmcell@classz{@classx
   @tempcnta count@
   prepnext@tok
   @addtopreamble{%mcell@mstyle
      ifcase@chnum
         hfil
         mcell@agape{d@llarbegininsert@columnd@llarend}hfil or
         hskip1sp
         mcell@agape{d@llarbegininsert@columnd@llarend}hfil or
         hfilhskip1sp
         mcell@agape{d@llarbegin insert@columnd@llarend}or
         mcell@agape{$vcenter
         @startpbox{@nextchar}insert@column@endpbox$}or
         mcell@agape{vtop
         @startpbox{@nextchar}insert@column@endpbox}or
         mcell@agape{vbox
         @startpbox{@nextchar}insert@column@endpbox}%
      fi
      globalletmcell@leftrelaxgloballetmcell@rightrelax
    }prepnext@tok}
makeatletter


begin{document}
begin{table}[!ht]
    centering
    renewcommandtabularxcolumn[1]{m{#1}}
    setcellgapes{11pt}
    makegapedcells
    setlengthtabcolsep{3pt}
    smalllinespread{0.84}selectfont
begin{tabularx}{linewidth}{|c|L|L|L|L|}
    hline
thead{Sce-nario}    
        & thead{Description}           & thead{Delivery of Motors} 
        & thead{Productive Reservoir} & thead{Non-Productive Reservoir} 
    hline
1       & Basic two system              & Both get delivered equally.   
        & Few get detached into  reservoir due to provision of movement. 
                                        & Almost all the others are reattached within the given time, as a result no leakage has occurred.
    hline
2       & Parallel with no movement     & Without the provision of movement, faster are hindered due to crowding. 
        &   Almost all the one are waiting in the reservoirs due to crowding. 
                                        & The leakage might occur depending on the influx rate and crowding.
    hline
3       & SI{90}{%} staggering at the initial segment 
                                        & A smaller level allows very few numbers of ones to move out of the system. 
        & multirow{9}{=}{When staggering occurs in the initial segment, 
                          most of the  wait in the reservoirs.}
                                        & multirow{9}{=}{Due to heavy crowding of influx in the initial segment, 
                                                          most of the within their given lifetime, and are out of the system.} 
    cline{1-3}
4       & SI{95}{%} staggering at the initial segment  
                                        &   multirow{8}{=}[1.2em]{
                                        Almost no one cross the SI{95}{%} barrier and thus move out via the lines.              
                                        As ones in middle track never experience congestion, so they move freely in               
                                        a single line only.} 
        & ~                                             &  
    cline{1-2}
5       & SI{100}{%} staggering at the initial segment of 
                        & ~             & ~             & ~ 
    hline
6       & SI{90}{%} staggering at the later segment 
                                        & multirow{10}{=}{As the staggering is at the later end, the output affected. 
                                                          Only a few numbers, who has overcome gets output within their lifetime.}
        & multirow{10}{=}{The starts to occur beyond the point only.} 
                                        & multirow{10}{=}{As the staggering is at the later end, which were moving in those staggered tracks. 
                                                          As a result, both the one are gradually moved out from the point.} 
    cline{1-2}
7       & SI{95}{%} staggering at the later segment  & ~ & ~ & ~ 
        cline{1-2}
8       & SI{100}{%} staggering at the later segment & ~ & ~ & ~ 
    hline
end{tabularx}
    end{table}
end{document}

Correct answer by Zarko on June 20, 2021

Try this, I used https://www.latex-tables.com/ to generate my table, I didnt check ur code just made a quick table for you hope this can solve ur problem.

documentclass[10pt]{article}
usepackage{multirow}
begin{document}
begin{table}
centering
begin{tabular}{|c|l|l|l|l|} 
hline
www & UUUU & xxxxx             & yyyyyy            & zzzzz               
hline
1   &      &                   &                   &                     
hline
2   &      &                   &                   &                     
hline
3   &      &                   & multirow{3}{*}{} & multirow{3}{*}{}   
cline{1-3}
4   &      & multirow{2}{*}{} &                   &                     
cline{1-2}
5   &      &                   &                   &                     
hline
6   &      & multirow{3}{*}{} & multirow{3}{*}{} & multirow{3}{*}{}   
cline{1-2}
7   &      &                   &                   &                     
cline{1-2}
8   &      &                   &                   &                    
hline
end{tabular}
end{table}
end{document}

enter image description here

Answered by nar on June 20, 2021

I propose this code, mainly based on the Gape command from makecell, and tabularx. No minipage required:

documentclass{article}
usepackage{geometry}
usepackage{ragged2e} 
usepackage[table, svgnames]{xcolor}
usepackage{adjustbox}
usepackage{tabularx, multirow, makecell}
renewcommand{theadfont}{smallbfseries}

begin{document}

begin{table}[!ht]
   centeringsmall
setlength{tabcolsep}{3pt}
setlength{extrarowheight}{3pt}
renewcommand{tabularxcolumn}[1]{>{arraybackslashRaggedRight}m{#1}}
begin{tabularx}{linewidth}{|c|*{4}{X|}}
hline
thead{Scenario} & thead{Description} & thead{Delivery of Motors} & thead{Productive Reservoir} & thead{Non-Productive Reservoir} 
hline
1 & Basic two system & Both get delivered equally. & Few get detached into reservoir due to provision of movement. & Almost all the others are reattached within the given time, as a result no leakage has occurred.
hline
2 & Parallel with no movement & Without the provision of movement, faster are hindered due to crowding. & Almost all the one are waiting in the reservoirs due to crowding. & The leakage might occur depending on the influx rate and crowding.[4.5ex]
hline
3 & 90,% staggering at the initial segment & A smaller level allows very few numbers of ones to move out of the system. & multirow{9}{=}{When staggering occurs in the initial segment, most of the wait in the reservoirs.}& multirow{9}{=}{Due to heavy crowding of influx in the initial segment, most of the within their given lifetime, and are out of the system.} 
cline{1-3}
Gape[6ex]{4} & parbox{hsize}{95 ,% staggering at the initial segment} & & & %
cline{1-2}
Gape[6ex]{5} &parbox{hsize}{100,% staggering at the initial segment of }& multirow{-5.8}{=}
{RaggedRight%
 Almost no one cross the 95,% barrier and thus move out via the lines.
 newline As ones in middle track never experience congestion, so they move freely in a single line only.}%
 & & 
hline
Gape[3.4ex]{6 }& parbox{hsize}{90,% staggering at the later segment} & & & 
cline{1-2}
Gape[3.4ex]{7 }& parbox{hsize}{95,% staggering at the later segment} & & & 
cline{1-2}
Gape[3.4ex]{8} & parbox{hsize}{100,% staggering at the later segment}
& multirow{-5.5}{=}{As the staggering is at the later end, the output affected. Only a few numbers, who has overcome gets output within their lifetime.}
& multirow{-5.5}{=}{The starts to occur beyond the point only.}
& multirow{-5.8}{=}{As the staggering is at the later end, which were moving in those staggered tracks. As a result, both the one are gradually moved out from the point.}
hline
end{tabularx}
caption{label{tab:one}A detailed analysis of different scenarios simulated with parametric values as discussed in Simulation I}
end{table}

end{document} 

enter image description here

Answered by Bernard on June 20, 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