TransWikia.com

How to create a multirow table within a longtable?

TeX - LaTeX Asked by user3454353 on July 15, 2021

Kindly review the code below and help me.

begin{longtable}{| c | L{3cm} | L{3cm} | L{3cm} | L{3cm} | L{3cm} | L{3cm} | L{3cm} | }
            hline
            rowcolor{Gainsboro!60}
            makecell{} & makecell{Centrifugal  force}  & makecell{Gravitational  force} & makecell{Inclination} & makecell{Vibration} & makecell{Fluidization} & makecell{Inertial  force} & makecell{Other  Effects}
            hline
            endhead
           Size & multirow{2}{*}{Cyclones} & Counter flow vertical air raise classifiers, Zig-Zag Classifiers & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. & Cyclones, Rotating Wheel Air-Classifiers, High-Efficiency Separator, Turbo-air Classifier, Circulating air-classifiers. & &  
           hline
           Density &  & alpha & echo & charlie & bravo &  & 
          hline
           Shape & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. & &  
           hline
           
        end{longtable}

I suggested this MWE since your example above is not compileable. Starting with documentclass{…} and defining a newcolumntype{L}.

documentclass{article}
usepackage{longtable}
usepackage{makecell}
usepackage{multirow}
newcolumntype{L}[1]{>{centeringarraybackslash}p{#1}}
usepackage{lscape}

begin{document}
    begin{landscape}
    begin{longtable}{| c | L{2cm} | L{2cm} | L{2cm} |L{2cm} | L{2cm} | p{2cm} | p{2cm} | }
        hline
    %   rowcolor{Gainsboro!60}
        makecell{} & makecell{Centrifugal  force}  & makecell{Gravitational  force} & makecell{Inclination} & makecell{Vibration} & makecell{Fluidization} & makecell{Inertial  force} & makecell{Other  Effects}
        hline
        endhead
        Size & multirow{2}{*}{Cyclones} & Counter flow vertical air raise classifiers, Zig-Zag Classifiers & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. & Cyclones, Rotating Wheel Air-Classifiers, High-Efficiency Separator, Turbo-air Classifier, Circulating air-classifiers. & &  
        hline
        Density &  & alpha & echo & charlie & bravo &  & 
        hline
        Shape & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. & &  
        hline
        
    end{longtable}
    end{landscape}
    
end{document}

enter image description here

2 Answers

Maybe this is what you are looking for table

I have used the booktabs package to typeset this table. Your question wasn't very clear, so I just tried what I felt was good.

Code

documentclass{article}
usepackage{longtable}
usepackage{makecell}
usepackage{multirow}
newcolumntype{L}[1]{>{centeringarraybackslash}p{#1}}
usepackage{lscape}
usepackage{booktabs}
usepackage{geometry}

begin{document}
begin{landscape}
    begin{longtable}{
        c 
        >{raggedright}p{2.5cm} 
        >{raggedright}p{2.5cm}
        >{raggedright}p{2.5cm}
        >{raggedright}p{2.5cm}
        >{raggedright}p{2.5cm}
        >{raggedright}p{2.5cm}
        p{2cm}}toprule
        & multicolumn{3}{c}{scshape force} 
            & Inclination 
                & Vibration
                    & Fluidization 
                        & Other cmidrule{2-4}
%
        & multicolumn{1}{c}{Centrifugal} 
            & multicolumn{1}{c}{Gravitational}
                & multicolumn{1}{c}{Inertial} 
                    &&&& Effects midrule
%
        Size 
            & multicolumn{1}{c}{Cyclones} 
                & Counterflow vertical air raise classifiers, Zig-Zag Classifiers 
                    & These kinds of issues are mostly related to the PDF viewer, they will not appear in a print version of the document.
                        & These kinds of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. 
                            & Cyclones, Rotating Wheel Air-Classifiers, High-Efficiency Separator, Turbo-air Classifier, Circulating air-classifiers. 
                                & &  cmidrule{1-1}cmidrule{3-6}
        Density 
            & & aplha
                & echo 
                    & charlie 
                        & bravo 
                            & & midrule
        Shape 
            & These kinds of issues are mostly related to the PDF viewer, they will not appear in a print version of the document.
                & These kinds of issues are mostly related to the PDF viewer, they will not appear in a print version of the document.
                    & These kinds of issues are mostly related to the PDF viewer, they will not appear in a print version of the document.
                        & These kinds of issues are mostly related to the PDF viewer, they will not appear in a print version of the document.
                            & These kinds of issues are mostly related to the PDF viewer, they will not appear in a print version of the document.
                                & &  bottomrule
    end{longtable}
end{landscape}
end{document}

tip: avoid using vertical lines in tables :)

Welcome to TeX.SE

Answered by sRaviolii on July 15, 2021

It is not clear what is your problem (beside that table is to wide for fitting on pages). You may consider the following a wee bit changes of your code:

documentclass{article}
usepackage[margin=25mm]{geometry}
usepackage{ragged2e}
usepackage{longtable, makecell, multirow}
    newcolumntype{L}[1]{>{RaggedRighthspace{0pt}}p{#1}}
usepackage[table, svgnames]{xcolor}

begin{document}
begingroup
    footnotesize
    setlengthtabcolsep{3pt}
    setlengthextrarowheight{2pt}
begin{longtable}{| c | *{7}{L{20mm}|} }
    hline
    rowcolor{Gainsboro!60}
    & makecell{Centrifugal  force}  
        & makecell{Gravitational  force} 
            & makecell{Inclination} 
                & makecell{Vibration} 
                    & makecell{Fluidization} 
                        & makecell{Inertial  force} 
                            & makecell{Other  Effects}       
    hline
endhead
% table body
Size & multirow[t]{12}{=}{Cyclones}
        & Counter flow vertical air raise classifiers, Zig-Zag Classifiers
            & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document.
                & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document.
                    & Cyclones, Rotating Wheel Air-Classifiers, High-Efficiency Separator, Turbo-air Classifier, Circulating air-classifiers.
                        &   &   
   cline{1-1}cline{3-6}
Density 
    &   & makecell{alpha} 
            & makecell{echo}
                & makecell{charlie} 
                    & makecell{bravo}
                        &   &   
  hline
Shape 
    & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. 
        & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. 
            & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. 
                & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. 
                    & These kind of issues are mostly related to the PDF viewer, they will not appear in a print version of the document. 
                        &   &   
   hline
end{longtable}
endgroup
end{document}

enter image description here

Answered by Zarko on July 15, 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