Seyma Kalay
Seyma Kalay

Reputation: 2861

convert longtable to sidewaystable in latex

I have a table below which I would like to fit in 1 page, I guess using sidewaystable may help, and additionally need to arrange the week range like below. Any help would be appreciated, many thanks in advance.

0 - <2 weeks 
1 – 2-4 weeks 
3 - >4 weeks


\documentclass[10pt,authoryear,sort&compress]{report}
\usepackage{amsmath,amstext,amssymb,amsfonts,amsthm}
\usepackage{graphicx,color,epstopdf,setspace} %
\usepackage[round]{natbib}
\usepackage{amssymb}
\usepackage{array}
\usepackage[T1]{fontenc}
\usepackage{amssymb}
\usepackage{calc}
\usepackage{bbm}
\usepackage{multirow}
%\usepackage{siunitx}
%\newlength\mylen
%\settowidth\mylen{Demirguc-Kunt A;}
\usepackage{textcomp}
\usepackage{rotating}
\usepackage{threeparttable}
\usepackage{makecell}
\usepackage{pdflscape}
\usepackage[table]{xcolor}
\usepackage{blkarray}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{array}

\begin{document}
    
    
    \begin{footnotesize}
        \begin{longtable} 
            {   >{\raggedright\arraybackslash}p{2cm}
                >{\raggedright\arraybackslash}p{2cm}
                >{\raggedright\arraybackslash}p{2cm}
                >{\raggedright\arraybackslash}p{2cm}
                >{\raggedright\arraybackslash}p{2cm}
                >{\raggedright\arraybackslash}p{3cm}
                >{\raggedright\arraybackslash}p{3cm}}
            
            \caption{Description of established and modified scoring in Keith Edwards TB Score, The Union Desk Guide and the New World Health Organization (WHO) Algorithm}
            \label{tab:SO.AU}\\
            \toprule
            & Keith Edwards TB Score (1994) & Modified Keith Edwards TB Score & Union Desk Guide (2016)
            & Modified Union Desk Guide & New WHO Algorithm (2022) & New WHO Algorithm (2022)  \\ 
            \toprule
            \endfirsthead
            \toprule
            & Keith Edwards TB Score (1994) & Modified Keith Edwards TB Score & Union Desk Guide (2016)
            & 1 & 2 & 3 \\ 
            \toprule
            \endhead
            \bottomrule 
            \endfoot
            \bottomrule 
            \endlastfoot
            
            \\
            Diagnostic feature 
            & \multicolumn{2}{c}{Scoring system (points-based)} 
            & \multicolumn{2}{c}{Diagnostic guide}
            & \multicolumn{2}{c}{Operational algorithm} \\
            
            Cough 
            & 0 - <2 weeks   
            1 – 2-4 weeks
            3 - >4 weeks
            & 0 – $\le$2 weeks 
            2 – >2 weeks
            &  0 – $\le$2 weeks 
            2 – >2 weeks           
            &  0 – $\le$2 weeks 
            2 – >2 weeks   
            &  0 – $\le$2 weeks 
            2 – >2 weeks
            &  0 – $\le$2 weeks 
            2 – >2 weeks \\ 
            
            Fever
            & 0 - <2 weeks
            1 – 2-4 weeks
            3 - >4 weeks      
            &  0 – $\le$2 weeks 
            2 – >2 weeks    
            &   0 – $\le$2 weeks 
            2 – >2 weeks    
            & 0 – $\le$2 weeks 
            2 – >2 weeks  
            & 0 – $\le$2 weeks
            1 – >2 weeks
            & 0 – $\le$2 weeks
            5 – >2 weeks \\ 
            
            
            Weight loss 
            & 3 - malnutrition not improving after four weeks of nutritional rehabilitation 
            & Excluded ** 
            & 0 – not reported
            1 – reported    
            & 0 – not reported
            1 – reported 
            & 0 – not reported
            1 – reported     
            & 0 – not reported
            1 – reported \\
            
            
            Night sweats 
            &  0 - <2 weeks
            1 – 2-4 weeks
            3 - >4 weeks 
            &  0 - $\leq$ 2 weeks
            2 – >2 weeks        
            &  0 - $\leq$ 2 weeks
            2 – >2 weeks
            &  0 - $\leq$ 2 weeks
            2 – >2 weeks 
            &  0 - $\leq$ 2 weeks
            2 – >2 weeks
            &  0 - $\leq$ 2 weeks
            2 – >2 weeks \\
            
            
            Swollen lymph nodes 
            &  0 – not present
            3 – present 
            & 0 – not present
            3 – present     
            & Not specified
            & 0 – not present
            1 – present     
            & 0 – not reported
            4 – reported
            &  0 – not reported
            4 – reported \\
            
            
            TB contact 
            & 0 – no family history of TB
            1 – contact with sputum smear negative TB
            3 – contact with sputum smear positive TB 
            &  0 – no family history of TB
            3* – known TB contact of either sputum smear positive or negative
            &  0 – no TB contact history
            1 – TB contact history
            & 0 – no TB contact history
            1 – TB contact history
            & 0 – no TB contact history in previous 12 months 
            
            0 – TB contact history in previous 12 months without persistent symptoms
            
            0 – no TB contact history in previous 12 months 
            
            
            
            & 0 – no TB contact history in previous 12 months 
            
            0 – TB contact history in previous 12 months without persistent symptoms
            
            Treat - TB contact history in previous 12 months with persistent symptoms\\
            
            
            Weight-for-age (WFA)
            & 0 - >80\% expected WFA
            1 - 60-80\% WFA
            3 - <60\% WFA   
            & 0 - $\ge$15th WFA percentile 
            1 - 3-14th percentile
            3 - < 3rd percentile  
            & N/A 
            & N/A
            & Severe Acute Malnutrition – eligible to progress to through until the end of the algorithm
            &  < 3rd percentile - eligible to progress to through until the end of the algorithm  \\
            
            
            
            HIV
            & N/A
            & N/A  
            & N/A***
            & N/A
            & HIV positive - eligible to progress to through until the end of the algorithm
            & HIV positive - eligible to progress to through until the end of the algorithm  \\
            
            
            TB Infection 
            & 3 – positive tuberculin skin test
            &  Excluded 
            &  N/A
            & N/A
            & N/A
            & N/A \\
            
            Chest x-ray findings
            & N/A
            & N/A
            &  0 – Not suggestive of TB or nor done
            1 – Suggestive of TB    
            & 0 – Not suggestive of TB or nor done
            1 – Suggestive of TB    
            & 0 – Not suggestive
            6 – Cavities
            17 – Enlarged lymph nodes
            5 – Opacities
            15 – Miliary pattern
            8 – Effusion    
            & 0 – Not suggestive
            6 – Cavities
            17 – Enlarged lymph nodes
            5 – Opacities
            15 – Miliary pattern
            8 – Effusion  \\
            
            
            Specimen for smear/Xpert
            & N/A
            & N/A   
            &  0 – Sputum smear/ Xpert negative or not done
            1 – Sputum smear or Xpert positive      
            & 0 – Sputum smear/ Xpert/culture negative or not done
            1 – Sputum smear/ Xpert/culture positive        
            & 0 – Sputum smear/ Xpert negative or not done
            Treat – Sputum smear or Xpert positive
            & 0 – Xpert/culture negative or not done
            Treat - Xpert/culture positive \\
            
            
            Central nervous system: change in temperament, fits +/- abnormal cerebrospinal fluid findings
            & 3
            & 3 
            & N/A 
            & N/A
            & N/A
            & N/A \\
            
            
            Joint swelling, bone swelling, sinuses 
            & 3
            & 3
            & N/A
            & N/A
            & N/A
            & N/A \\
            
            
            Unexplained abdominal mass, ascites
            & 3
            & 3 
            & N/A
            & N/A
            & N/A
            & N/A \\
            
            
            Angle deformity of spine
            & 4
            & 4  
            & N/A  
            & N/A
            & N/A
            & N/A  \\
            
            
            
            
            \\
            Score interpretation
            & \multicolumn{2}{c}{Treat if score is $\ge$7} 
            & \multicolumn{2}{c}{Treat if $\ge$2 features are present}
            & \multicolumn{2}{c}{Treat if $\ge$2 features are present} \\
            
            
        \end{longtable}
    \end{footnotesize}
    
\end{document}

Upvotes: 0

Views: 1765

Answers (1)

Pre-remarks

  • all your table lacks appropriate use of math mode around -, <, > etc. signs to get proper minus signs instead of hyphens and proper spacing, but I'm too lazy to fix such an enormous table.

  • \footnotesize is a macro and NOT an environment.


You could use the pdflscape package to rotate the pages:

\documentclass[10pt,authoryear,sort&compress]{report}
\usepackage{amsmath,amstext,amssymb,amsfonts,amsthm}
\usepackage{graphicx,color,epstopdf,setspace} %
\usepackage[round]{natbib}
\usepackage{amssymb}
\usepackage{array}
\usepackage[T1]{fontenc}
\usepackage{amssymb}
\usepackage{calc}
\usepackage{bbm}
\usepackage{multirow}
%\usepackage{siunitx}
%\newlength\mylen
%\settowidth\mylen{Demirguc-Kunt A;}
\usepackage{textcomp}
\usepackage{rotating}
\usepackage{threeparttable}
\usepackage{makecell}
\usepackage{pdflscape}
\usepackage[table]{xcolor}
\usepackage{blkarray}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{array}
\usepackage{pdflscape}


\begin{document}
    
    \begingroup
    \footnotesize
    \begin{landscape}
        \begin{longtable} 
            {   >{\raggedright\arraybackslash}p{2cm}
                >{\raggedright\arraybackslash}p{2.1cm}
                >{\raggedright\arraybackslash}p{2.1cm}
                >{\raggedright\arraybackslash}p{2.1cm}
                >{\raggedright\arraybackslash}p{2.1cm}
                >{\raggedright\arraybackslash}p{2.8cm}
                >{\raggedright\arraybackslash}p{2.8cm}}
            
            \caption{Description of established and modified scoring in Keith Edwards TB Score, The Union Desk Guide and the New World Health Organization (WHO) Algorithm}
            \label{tab:SO.AU}\\
            \toprule
            & Keith Edwards TB Score (1994) & Modified Keith Edwards TB Score & Union Desk Guide (2016)
            & Modified Union Desk Guide & New WHO Algorithm (2022) & New WHO Algorithm (2022)  \\ 
            \toprule
            \endfirsthead
            \toprule
            & Keith Edwards TB Score (1994) & Modified Keith Edwards TB Score & Union Desk Guide (2016)
            & 1 & 2 & 3 \\ 
            \toprule
            \endhead
            \bottomrule 
            \endfoot
            \bottomrule 
            \endlastfoot
            
            \\
            Diagnostic feature 
            & \multicolumn{2}{c}{Scoring system (points-based)} 
            & \multicolumn{2}{c}{Diagnostic guide}
            & \multicolumn{2}{c}{Operational algorithm} \\
            
            Cough 
            & 0 - <2 weeks\linebreak   
            1 – 2-4 weeks\linebreak  
            3 - >4 weeks\linebreak  
            & 0 – $\le$2 weeks\linebreak  
            2 – >2 weeks\linebreak  
            &  0 – $\le$2 weeks\linebreak  
            2 – >2 weeks\linebreak  
            &  0 – $\le$2 weeks\linebreak  
            2 – >2 weeks\linebreak  
            &  0 – $\le$2 weeks\linebreak  
            2 – >2 weeks\linebreak  
            &  0 – $\le$2 weeks\linebreak  
            2 – >2 weeks \\ 
            
            Fever
            & 0 - <2 weeks\linebreak  
            1 – 2-4 weeks\linebreak  
            3 - >4 weeks\linebreak        
            &  0 – $\le$2 weeks\linebreak   
            2 – >2 weeks\linebreak      
            &   0 – $\le$2 weeks\linebreak   
            2 – >2 weeks\linebreak      
            & 0 – $\le$2 weeks\linebreak   
            2 – >2 weeks\linebreak    
            & 0 – $\le$2 weeks\linebreak  
            1 – >2 weeks\linebreak  
            & 0 – $\le$2 weeks\linebreak  
            5 – >2 weeks \\ 
            
            
            Weight loss 
            & 3 - malnutrition not improving after four weeks of nutritional rehabilitation 
            & Excluded ** 
            & 0 – not reported\linebreak  
            1 – reported    
            & 0 – not reported\linebreak  
            1 – reported 
            & 0 – not reported\linebreak  
            1 – reported     
            & 0 – not reported\linebreak  
            1 – reported \\
            
            
            Night sweats 
            &  0 - <2 weeks\linebreak  
            1 – 2-4 weeks\linebreak  
            3 - >4 weeks\linebreak   
            &  0 - $\leq$ 2 weeks\linebreak  
            2 – >2 weeks\linebreak          
            &  0 - $\leq$ 2 weeks\linebreak  
            2 – >2 weeks\linebreak  
            &  0 - $\leq$ 2 weeks\linebreak  
            2 – >2 weeks\linebreak   
            &  0 - $\leq$ 2 weeks\linebreak  
            2 – >2 weeks\linebreak  
            &  0 - $\leq$ 2 weeks\linebreak  
            2 – >2 weeks \\
            
            
            Swollen lymph nodes 
            &  0 – not present\linebreak
            3 – present 
            & 0 – not present\linebreak
            3 – present     
            & Not specified
            & 0 – not present\linebreak
            1 – present     
            & 0 – not reported\linebreak
            4 – reported
            &  0 – not reported\linebreak
            4 – reported \\
            
            
            TB contact 
            & 0 – no family history of TB
            1 – contact with sputum smear negative TB
            3 – contact with sputum smear positive TB 
            &  0 – no family history of TB
            3* – known TB contact of either sputum smear positive or negative
            &  0 – no TB contact history
            1 – TB contact history
            & 0 – no TB contact history
            1 – TB contact history
            & 0 – no TB contact history in previous 12 months 
            
            0 – TB contact history in previous 12 months without persistent symptoms
            
            0 – no TB contact history in previous 12 months 
            
            
            
            & 0 – no TB contact history in previous 12 months 
            
            0 – TB contact history in previous 12 months without persistent symptoms
            
            Treat - TB contact history in previous 12 months with persistent symptoms\\
            
            
            Weight-for-age (WFA)
            & 0 - >80\% expected WFA
            1 - 60-80\% WFA
            3 - <60\% WFA   
            & 0 - $\ge$15th WFA percentile 
            1 - 3-14th percentile
            3 - < 3rd percentile  
            & N/A 
            & N/A
            & Severe Acute Malnutrition – eligible to progress to through until the end of the algorithm
            &  < 3rd percentile - eligible to progress to through until the end of the algorithm  \\
            
            
            
            HIV
            & N/A
            & N/A  
            & N/A***
            & N/A
            & HIV positive - eligible to progress to through until the end of the algorithm
            & HIV positive - eligible to progress to through until the end of the algorithm  \\
            
            
            TB Infection 
            & 3 – positive tuberculin skin test
            &  Excluded 
            &  N/A
            & N/A
            & N/A
            & N/A \\
            
            Chest x-ray findings
            & N/A
            & N/A
            &  0 – Not suggestive of TB or nor done
            1 – Suggestive of TB    
            & 0 – Not suggestive of TB or nor done
            1 – Suggestive of TB    
            & 0 – Not suggestive
            6 – Cavities
            17 – Enlarged lymph nodes
            5 – Opacities
            15 – Miliary pattern
            8 – Effusion    
            & 0 – Not suggestive
            6 – Cavities
            17 – Enlarged lymph nodes
            5 – Opacities
            15 – Miliary pattern
            8 – Effusion  \\
            
            
            Specimen for smear/Xpert
            & N/A
            & N/A   
            &  0 – Sputum smear/ Xpert negative or not done
            1 – Sputum smear or Xpert positive      
            & 0 – Sputum smear/ Xpert/culture negative or not done
            1 – Sputum smear/ Xpert/culture positive        
            & 0 – Sputum smear/ Xpert negative or not done
            Treat – Sputum smear or Xpert positive
            & 0 – Xpert/culture negative or not done
            Treat - Xpert/culture positive \\
            
            
            Central nervous system: change in temperament, fits +/- abnormal cerebrospinal fluid findings
            & 3
            & 3 
            & N/A 
            & N/A
            & N/A
            & N/A \\
            
            
            Joint swelling, bone swelling, sinuses 
            & 3
            & 3
            & N/A
            & N/A
            & N/A
            & N/A \\
            
            
            Unexplained abdominal mass, ascites
            & 3
            & 3 
            & N/A
            & N/A
            & N/A
            & N/A \\
            
            
            Angle deformity of spine
            & 4
            & 4  
            & N/A  
            & N/A
            & N/A
            & N/A  \\
            
            
            
            
            \\
            Score interpretation
            & \multicolumn{2}{c}{Treat if score is $\ge$7} 
            & \multicolumn{2}{c}{Treat if $\ge$2 features are present}
            & \multicolumn{2}{c}{Treat if $\ge$2 features are present} \\
            
            
        \end{longtable}
        \end{landscape}
\endgroup
    
\end{document}

Upvotes: 1

Related Questions