I have a table that I would like to split over pages, but I can't seem to figure out how I can do it with my current lay-out or commands that I use.
At this time, I used landscape and minipage so that it would fit on one page:
\documentclass[11pt]{article}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage{lipsum}
\usepackage{bm}
\usepackage{makecell}
\begin{document}
\begin{landscape}
\centering
\begin{table}[!htb]
\caption{\label{CH2_tab:P80L} Empirical power from the simulation study with the indicators having an overall reliability of 80\% and a linear relationship with the latent variable. The highest power per setting is indicated in bold.}
\renewcommand{\arraystretch}{1.5}
\begin{minipage}{.5\linewidth}
\centering
\medskip
\scalebox{0.45}{
\begin{tabular}{rcccccc}
\hline
& \multicolumn{6}{c}{\textbf{Linear}} \\
\cline{2-7}
& \makecell{\textbf{WMW -- max rel} } & \makecell{\textbf{WMW -- mean }} & \makecell{\textbf{\textit{t} test -- max rel }} & \makecell{\textbf{\textit{t} test -- mean }} & \makecell{\textbf{SEM} } & \makecell{\textbf{SEM -- corrected}} \\
\hline
\multicolumn{7}{l}{$\mathcal{N}(0,1)$} \\
\multicolumn{7}{l}{\bm{$m=n=15$}} \\
\hline
Setting 1 & 29.7 & 31.0 & \textbf{33.2} & 32.9 & 32.4 & 32.1 \\
Setting 2 & 28.4 & 29.2 & 30.7 & \textbf{31.3} & 30.0 & 30.3 \\
Setting 3 & 29.5 & 29.3 & 31.8 & \textbf{32.3} & 32.0 & 31.9 \\
Setting 4 & 25.8 & 26.2 & 28.5 & 27.4 & \textbf{29.4} & 28.6 \\
\hline
\multicolumn{7}{l}{\bm{$m=n=50$}} \\
\hline
Setting 1 & 78.7 & 79.1 & 81.7 & 81.4 & \textbf{83.2} & 83.1 \\
Setting 2 & 79.5 & 78.8 & 81.0 & 80.4 & 82.0 & \textbf{82.1} \\
Setting 3 & 79.2 & 79.9 & 81.2 & 81.8 & \textbf{82.2} & 82.0 \\
Setting 4 & 74.8 & 72.3 & 77.6 & 74.4 & \textbf{80.0} & \textbf{80.0} \\
\hline
\multicolumn{7}{l}{\bm{$m=n=100$}} \\
\hline
Setting 1 & 98.2 & 98.1 & 98.5 & 98.6 & \textbf{98.7} & \textbf{98.7} \\
Setting 2 & 97.7 & 97.7 & 98.2 & \textbf{98.3} & \textbf{98.3} & \textbf{98.3} \\
Setting 3 & 97.6 & 97.5 & 98.1 & \textbf{98.2} & \textbf{98.2} & \textbf{98.2} \\
Setting 4 & 97.4 & 95.1 & 98.1 & 95.8 & 98.1 & \textbf{98.2} \\
\hline
\multicolumn{7}{l}{$t_5$} \\
\multicolumn{7}{l}{\bm{$m=n=15$}} \\
\hline
Setting 1 & 23.5 & 23.9 & 24.2 & 24.1 & \textbf{24.4} & 23.9 \\
Setting 2 & 24.0 & \textbf{24.1} & 23.1 & 22.6 & 22.0 & 22.2 \\
Setting 3 & 23.7 & \textbf{23.8} & 22.4 & 23.1 & 22.5 & 23.3 \\
Setting 4 & 22.1 & 22.4 & 22.2 & 22.4 & 22.4 & \textbf{23.5} \\
\hline
\multicolumn{7}{l}{\bm{$m=n=50$}} \\
\hline
Setting 1 & 65.8 & \textbf{66.1} & 60.8 & 60.9 & 61.8 & 61.4 \\
Setting 2 & \textbf{68.7} & \textbf{68.7} & 62.2 & 62.2 & 63.7 & 63.4 \\
Setting 3 & 67.3 & \textbf{67.6} & 61.1 & 61.4 & 62.7 & 62.2 \\
Setting 4 & \textbf{63.9} & 58.4 & 57.6 & 53.7 & 60.2 & 60.0 \\
\hline
\multicolumn{7}{l}{\bm{$m=n=100$}} \\
\hline
Setting 1 & 92.3 & \textbf{92.4} & 87.6 & 87.6 & 88.0 & 88.1 \\
Setting 2 & \textbf{91.7} & \textbf{91.7} & 87.0 & 87.4 & 87.9 & 87.8 \\
Setting 3 & 93.2 & \textbf{93.4} & 88.9 & 88.7 & 89.4 & 89.5 \\
Setting 4 & \textbf{90.6} & 86.8 & 85.7 & 83.4 & 87.4 & 87.4 \\
\hline
\hline
\end{tabular}
}
\end{minipage}\hfill
\begin{minipage}{.5\linewidth}
\centering
\medskip
\scalebox{0.45}{
\begin{tabular}{rcccccc}
\hline
& \multicolumn{6}{c}{\textbf{Linear}} \\
\cline{2-7}
& \makecell{\textbf{WMW -- max rel} } & \makecell{\textbf{WMW -- mean }} & \makecell{\textbf{\textit{t} test -- max rel }} & \makecell{\textbf{\textit{t} test -- mean }} & \makecell{\textbf{SEM} } & \makecell{\textbf{SEM -- corrected}} \\
\hline
\multicolumn{7}{l}{$Laplace(0,1.25)$} \\
\multicolumn{7}{l}{\bm{$m=n=15$}} \\
\hline
Setting 1 & 21.5 & \textbf{22.3} & 19.6 & 20.4 & 19.3 & 19.0 \\
Setting 2 & \textbf{21.9} & 21.4 & 21.0 & 21.1 & 19.8 & 21.0 \\
Setting 3 & 22.0 & \textbf{22.5} & 20.6 & 20.3 & 20.1 & 20.3 \\
Setting 4 & 17.3 & \textbf{19.8} & 16.5 & 18.8 & 19.4 & 19.3 \\
\hline
\multicolumn{7}{l}{\bm{$m=n=50$}} \\
\hline
Setting 1 & 61.8 & \textbf{62.0} & 53.2 & 53.2 & 55.0 & 54.6 \\
Setting 2 & 62.2 & \textbf{63.2} & 52.7 & 53.3 & 54.5 & 53.8 \\
Setting 3 & 64.6 & \textbf{66.0} & 52.9 & 52.8 & 54.7 & 54.2 \\
Setting 4 & \textbf{58.9} & 56.9 & 51.7 & 49.8 & 56.0 & 56.1 \\
\hline
\multicolumn{7}{l}{\bm{$m=n=100$}} \\
\hline
Setting 1 & \textbf{92.3} & 92.2 & 83.2 & 82.9 & 83.5 & 83.4 \\
Setting 2 & \textbf{88.1} & 87.9 & 77.7 & 77.5 & 78.2 & 78.1 \\
Setting 3 & \textbf{91.0} & 90.7 & 82.6 & 82.9 & 82.9 & 83.0 \\
Setting 4 & \textbf{85.5} & 80.4 & 77.7 & 74.2 & 79.3 & 79.3 \\
\hline
\multicolumn{7}{l}{Exp} \\
\multicolumn{7}{l}{\bm{$m=n=15$}} \\
\hline
Setting 1 & 22.2 & \textbf{23.1} & 18.1 & 18.2 & 18.7 & 18.3 \\
Setting 2 & 19.7 & \textbf{19.8} & 17.0 & 17.5 & 17.2 & 17.5 \\
Setting 3 & 19.4 & \textbf{20.2} & 16.9 & 17.6 & 16.9 & 17.0 \\
Setting 4 & 15.7 & \textbf{16.0} & 13.4 & 14.9 & 14.8 & 14.9 \\
\hline
\multicolumn{7}{l}{\bm{$m=n=50$}} \\
\hline
Setting 1 & 61.9 & \textbf{62.0} & 40.8 & 41.8 & 42.6 & 42.6 \\
Setting 2 & 56.2 & \textbf{57.6} & 38.0 & 38.2 & 39.9 & 39.3 \\
Setting 3 & 63.0 & \textbf{63.5} & 42.6 & 42.6 & 44.9 & 44.8 \\
Setting 4 & \textbf{50.1} & 45.0 & 36.9 & 36.7 & 40.6 & 40.4 \\
\hline
\multicolumn{7}{l}{\bm{$m=n=100$}} \\
\hline
Setting 1 & 86.7 & \textbf{87.2} & 67.2 & 67.5 & 67.7 & 67.8 \\
Setting 2 & 85.4 & \textbf{85.6} & 65.5 & 66.0 & 66.6 & 66.8 \\
Setting 3 & 88.2 & \textbf{88.4} & 66.4 & 66.3 & 67.3 & 67.6 \\
Setting 4 & \textbf{83.5} & 76.1 & 65.2 & 61.1 & 66.9 & 67.7 \\
\hline
\hline
\end{tabular}
}
\end{minipage}\hfill
\end{table}
\end{landscape}
\end{document}
However, I would like to split this table nicely over multiple pages (and thus by using e.g. longtable), in such way that on one page, I have the results for the N(0,1) and Laplace distribution (side by side), and then on the second page the t_5 and Exp distribution (side by side), i.e. split each table over 2 pages, but have 2 tables side by side by using minipage inside long table.
I know I could converge them and just make one large table and then use long table, however, I would really like not to rewrite the code (since I have 10 more tables like this). Does someone know how I could do this? I tried several ways, but none of them produce the result I am looking for.
Thank you for all your feedback!
Heidelinde
I am creating a longtable in rmarkdown, which is text heavy. I'm setting the column width using column_spec to space text over multiple lines, but would like to insert manual line breaks to improve the readability. I have followed the advice here but still get an error saying the \n are not recognised:
! Undefined control sequence.
l.135 Aoike 2018 & H-Ex (12); \nCenter
-Ex (13); \nCon (15)
This is my code:
```{r setup, include=FALSE}
library(knitr)
knitr::opts_chunk$set(echo = FALSE)
library(readxl)
library(dplyr)
library(kableExtra)
book1 = read_excel("Table tests/Book1.xlsx", sheet = 1)
book1[is.na(book1)] <- " "
\begin{landscape}
```{r table,}
book1%>%
mutate_all(linebreak)%>%
kbl("latex", longtable = TRUE, escape = F, booktabs = T, caption = '(ref:exstudies)')%>%
column_spec(2, width= "5em")%>%
kable_styling(latex_options= c("striped", "repeat_header"), font_size =10, repeat_header_method = "replace")%>%
footnote(general = "some text", general_title = "")
\end{landscape}
This is a mwe of my dataframe:
book1 = data.frame(Reference = c("Adams 2012", "Aoike 2018"),
`Groups (n)` = c("H-Ex (14); Con (15)", "H-Ex (12); \nCenter-Ex (13); \nCon (15)"))
Here is the contents of the .tex file:
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
11pt,
]{article}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\setmainfont[]{Garamond}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\#ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
pdftitle={General Introduction},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage[margin=1in]{geometry}
\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if#noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin#nat#width>\linewidth\linewidth\else\Gin#nat#width\fi}
\def\maxheight{\ifdim\Gin#nat#height>\textheight\textheight\else\Gin#nat#height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps#figure{htbp}
\makeatother
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{5}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{colortbl}
\usepackage{pdflscape}
\usepackage{tabu}
\usepackage{threeparttable}
\usepackage{threeparttablex}
\usepackage[normalem]{ulem}
\usepackage{makecell}
\usepackage{xcolor}
\ifluatex
\usepackage{selnolig} % disable illegal ligatures
\fi
\title{General Introduction}
\author{}
\date{\vspace{-2.5em}}
\begin{document}
\maketitle
{
\setcounter{tocdepth}{2}
\tableofcontents
}
CKD exercise studies. See Table \ref{tab:exstudies}.
\begin{landscape}
\begingroup\fontsize{10}{12}\selectfont
\begin{longtable}[t]{>{\raggedright\arraybackslash}p{5em }>{\raggedright\arraybackslash}p{5em}>{\raggedright\arraybackslash}p{3em}>{\raggedright\arraybackslash}p{5em}>{\raggedright\arraybackslash}p{5em }>{\raggedright\arraybackslash}p{3em }>{\raggedright\arraybackslash}p{8em }>{\raggedright\arraybackslash}p{8em }>{\raggedright\arraybackslash}p{5em }>{\raggedright\arraybackslash}p{5em }}
\caption{\label{tab:exstudies}Exercise studies in patients with CKD. All studies in the table were randomised-controlled trials except Pechter\ldots{}}\\
\toprule
Study Reference & Groups (n) & Study duration (weeks) & CKD Stage & Other population characteristics & Age (years) & Frequency/ duration & Aerobic & Resitance & Other elements of intervention\\
\midrule
\endfirsthead
\caption[]{\textit{(continued)}}\\
\toprule
Study Reference & Groups (n) & Study duration (weeks) & CKD Stage & Other population characteristics & Age (years) & Frequency/ duration & Aerobic & Resitance & Other elements of intervention\\
\midrule
\endhead
\endfoot
\bottomrule
\multicolumn{10}{l}{\rule{0pt}{1em}All studies in the table were randomised-controlled trials except Pechter... }\\
\endlastfoot
\cellcolor{gray!6}{Aoike 2015} & \cellcolor{gray!6}{H-Ex (14); Con (15)} & \cellcolor{gray!6}{12} & \cellcolor{gray!6}{3-4} & \cellcolor{gray!6}{BMI>25} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{30-50 min., 3 x per wk} & \cellcolor{gray!6}{Walking; aiming for VT} & \cellcolor{gray!6}{Nil} & \cellcolor{gray!6}{Dietary instruction for all patients}\\
Aoike 2018 & H-Ex (12); \n Center Ex (13); \nCon (15) & 24 & 3-4 & Overweight & 56 & 40-60 min., 3 x per wk & Moderate (40-60\% VO2max): home-based = walking; centre-based = treadmill & Nil & \\
\cellcolor{gray!6}{Barcellos 2018} & \cellcolor{gray!6}{Ex (76); Con (74)} & \cellcolor{gray!6}{16} & \cellcolor{gray!6}{2-4} & \cellcolor{gray!6}{Hypertensive} & \cellcolor{gray!6}{65} & \cellcolor{gray!6}{60 min., 3 x per wk, supervised} & \cellcolor{gray!6}{Yes, no details} & \cellcolor{gray!6}{Yes, no details} & \cellcolor{gray!6}{}\\
Baria 2014 & Centre-Ex (10); H-Ex (8); Con (9) & 12 & 3-4 & BMI > 25; male & 52 & 30-50 min., 3 x per wk & Centre= treadmill; Home = walking\slash running; HR at VT & Nil & \\
\cellcolor{gray!6}{Beetham 2019} & \cellcolor{gray!6}{HIIT (9); Mod Ex (5)} & \cellcolor{gray!6}{12} & \cellcolor{gray!6}{3-4} & \cellcolor{gray!6}{1+ uncontrolled CVD risk factors (BP, HbA1C, lipids)} & \cellcolor{gray!6}{61} & \cellcolor{gray!6}{HIIT: 4x4 min.; Mod Ex: 40 min. 3 days per wk} & \cellcolor{gray!6}{HIIT: 80-95\% PeakHR, Mod Ex: 65\% peakHR; treadmill} & \cellcolor{gray!6}{Nil} & \cellcolor{gray!6}{}\\
\addlinespace
Castaneda 2001/2004 & Ex + low-protein diet (14); low-protein diet only (12) & 12 & SCr 133-442 $\mu$mol/L & Age >50 & 64 & 45 min., 3 x per wk & Nil & 8 reps x 3 sets of chest and leg press, latissimus pull-down, knee extension, and knee flexion & \\
\cellcolor{gray!6}{Eidemak 1997} & \cellcolor{gray!6}{Ex (15); Con (15)} & \cellcolor{gray!6}{Median 78} & \cellcolor{gray!6}{GFR 10-43} & \cellcolor{gray!6}{Non-diabetic} & \cellcolor{gray!6}{44} & \cellcolor{gray!6}{30 min., daily; unsupervised} & \cellcolor{gray!6}{60-75\% maximal exercise capacity, static bike, running, swimming or walking} & \cellcolor{gray!6}{Nil} & \cellcolor{gray!6}{}\\
Greenwood 2015 & Ex (8); Con (10) & 52 & 3-4 & & 53 & 40 min., 3 x per wk (2 x supervised, 1 x home) & stationary exercise cycle; 80\% HRR & Free weights or therabands 80\% of 1RM & \\
\cellcolor{gray!6}{Headley 2012} & \cellcolor{gray!6}{Ex (10); Con (11)} & \cellcolor{gray!6}{48} & \cellcolor{gray!6}{2-4} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{55} & \cellcolor{gray!6}{45 min., 3 x per wk, supervised} & \cellcolor{gray!6}{50-60\% VO2 peak} & \cellcolor{gray!6}{Weeks 24-48; optional; weight machines} & \cellcolor{gray!6}{Dietary instruction for exercise group}\\
Headley 2014 & Ex (25); Con (21) & 16 & 3a-3b & DM or HTN as primary cause of CKD & 58 & 30-45 min., 3 x per wk, supervised & 50-60\% VO2 peak, mixed apparatus & Nil & \\
\addlinespace
\cellcolor{gray!6}{Hellberg 2019} & \cellcolor{gray!6}{Endurance \& strength (73); Endurance \& balance (75)} & \cellcolor{gray!6}{52} & \cellcolor{gray!6}{3-5} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{66} & \cellcolor{gray!6}{150 min./ wk} & \cellcolor{gray!6}{2 x 30 minutes; RPE = 13-15} & \cellcolor{gray!6}{3 x 30 minutes; RPE =13-17; 2-3 sets of 10 reps of wither free weight/body weight (resistance) or balance exercises} & \cellcolor{gray!6}{}\\
Hiraki 2017 & H-Ex (14); Con (14) & 52 & 3-4 & Male & 68.5 & 30 min. /day or 8000-10000 steps & Walking & Hand grip, squats and calf raises; 20-30 reps 3x per week & \\
\cellcolor{gray!6}{Howden 2013/2015} & \cellcolor{gray!6}{Ex \& lifestyle intervention (36); Con (36)} & \cellcolor{gray!6}{52} & \cellcolor{gray!6}{eGFR 25-60} & \cellcolor{gray!6}{1 or more uncontrolled CV risk factors (BP, HbA1C, lipids)} & \cellcolor{gray!6}{61} & \cellcolor{gray!6}{150 min./wk, beginning with 8 wks 2-3 x per wk supervised in gym; subsequently at home} & \cellcolor{gray!6}{Moderate, RPE 11-13} & \cellcolor{gray!6}{Whole-body with therabands and Swiss ball} & \cellcolor{gray!6}{Lifestyle intervention with dietician and psychologist (sustainable diet and behaviour change for weight loss)}\\
Ikizler 2018 & Ex vs usual activity; Calory restriction vs usual diet (104 total) & 16 & 3-4 & BMI> 25 & 53-58 & 30-45 min., 3 x per wk, supervised & & & 10-15\% calory reduciton\\
\cellcolor{gray!6}{Kirkman 2019} & \cellcolor{gray!6}{Ex (15); Con (16)} & \cellcolor{gray!6}{12} & \cellcolor{gray!6}{3-5} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{58} & \cellcolor{gray!6}{45 min., 3 x per wk; supervised} & \cellcolor{gray!6}{60-85\% heart rate reserve; cycling, treadmill or epliptical} & \cellcolor{gray!6}{Nil} & \cellcolor{gray!6}{}\\
\addlinespace
Kiuchi 2017 & HIIT (25); Mod Ex (25) & 156 & 3-4 & & 58 & HIIT: 4-30 min.; Mod Ex: 30-60 min. 5 days per wk & HIIT: up to maximal intensity; Mod Ex: 55-85\% max HR & Nil & \\
\cellcolor{gray!6}{Leehey 2016} & \cellcolor{gray!6}{Ex + diet (14); Diet alone (18)} & \cellcolor{gray!6}{52} & \cellcolor{gray!6}{2-4} & \cellcolor{gray!6}{T2DM, obese, male} & \cellcolor{gray!6}{66} & \cellcolor{gray!6}{60 min., 3 x per wk; superveised for first 12 wks} & \cellcolor{gray!6}{45-85\% VO2 peak; Treadmill,elliptical or cycle; intervals} & \cellcolor{gray!6}{Additional 20-30 minutes/ session} & \cellcolor{gray!6}{Nutritional counselling session}\\
Leehey 2009 & Ex (7); Con (4) & 24 & 2-4 & Diabetic, BMI > 30, proteinuria & 66 & 30-40 min., 3 x per wk, supervised for first 6 wks & Walking; supervised sessions were up to 60-84\% VO2peak & Nil & \\
\cellcolor{gray!6}{Miele 2017} & \cellcolor{gray!6}{Ex (25); Con (21)} & \cellcolor{gray!6}{16} & \cellcolor{gray!6}{3} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{15-55 min., 3 x per wk, supervised} & \cellcolor{gray!6}{Moderate, 50-60\% VO2peak} & \cellcolor{gray!6}{Nil} & \cellcolor{gray!6}{}\\
Mustata 2011 & Ex (10); Con (10) & 52 & 3-4 & & 68 & 20-60 min., 5 x per wk (3 unsupervised, 2 supervised) & 40-60\% VO2peak, treadmill, cycle, ellipitcal trainer; unsupervised = walking & & \\
\addlinespace
\cellcolor{gray!6}{Pechter 2003} & \cellcolor{gray!6}{Ex (11); Con (9)} & \cellcolor{gray!6}{12} & \cellcolor{gray!6}{NA} & \cellcolor{gray!6}{Proteinuria; 2+ CV risk factors} & \cellcolor{gray!6}{49} & \cellcolor{gray!6}{30 min., 2x per wk} & \cellcolor{gray!6}{Aquatic exercise} & \cellcolor{gray!6}{Nil} & \cellcolor{gray!6}{}\\
Rossi 2014 & Ex (59); Con (48) & 12 & 3-4 & & 68 & 60 min., 2 x per wk, supervised & Treadmill or static cycle; PLE<11(60-65\% HRM) & Free weights3 sets x 15 reps & Provided with pedometer\\
\cellcolor{gray!6}{Small 2017} & \cellcolor{gray!6}{Ex + lifestyle} & \cellcolor{gray!6}{52} & \cellcolor{gray!6}{eGFR 25-60} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{62} & \cellcolor{gray!6}{150 min./wk, beginning with 8 wks 2-3 x per wk supervised in gym; subsequently at home} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{4 weeks of group behavior and lifestyle modification and dietary advice}\\
Shi 2014 & Ex (11); Con (10) & 12 & NA & Evidence of CVD & 69 & 30 min., 3-5 x per wk, supervised for first 4 wks & Tai Chi & Nil & \\
\cellcolor{gray!6}{Tang 2017} & \cellcolor{gray!6}{H-Ex (45); Con (45)} & \cellcolor{gray!6}{12} & \cellcolor{gray!6}{1-3} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{45} & \cellcolor{gray!6}{30 min., 3 x per wk, at home} & \cellcolor{gray!6}{Walking, cycling jogging; 12-15 RPE} & \cellcolor{gray!6}{Nil} & \cellcolor{gray!6}{Exercise education (3 sessions)}\\
\addlinespace
Van Craenenbroeck 2015 & Ex (19); Con (21) & 12 & 3-4 & & 53 & 10 min., 4x per day, at home & Static cycling, 90\% HR of anaerobic threshold & Nil & \\
\cellcolor{gray!6}{Huppertz 2020} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{}\\
Zhou 2020 & & & & & & & & & \\*
\end{longtable}
\endgroup{}
\end{landscape}
\end{document}
I want to do something like this:
It has two headings: the upper one I'm done with but now I want to add a lower heading for only some columns.
Is there a way to add such a heading in latex?
My attempt:
\begin{tabular}{lcccccccc}\hline \hline
& Whole world & Base sample & Whole world & Base sample & Whole world & Base sample & Whole world & Base sample \\
& (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) \\ \hline \\
& & & & & & & & & \\
\multicolumn{6}{c}{Dependent variable is log GDP per capita in 1995 } \\
& & & & & & & & \\
The following uses the eqparbox package to set the integer and decimal part of each number wrapped inside a \fmtnum
\documentclass{article}
\usepackage{booktabs,makecell,eqparbox}
\newcommand{\mc}{\multicolumn{1}{c}}
\makeatletter
\newcommand{\fmtnum}[1]{\#fmtnum#1\relax}
\def\#fmtnum#1.#2\relax{\eqmakebox[int][r]{$#1.$}\eqmakebox[dec][l]{$#2$}}
\makeatother
\begin{document}
\noindent
\begin{tabular}{ *{8}{c} }
\toprule
\makecell{Whole \\ world \\ (1)} &
\makecell{Base \\ sample \\ (2)} &
\makecell{Whole \\ world \\ (3)} &
\makecell{Base \\ sample \\ (4)} &
\makecell{Whole \\ world \\ (5)} &
\makecell{Base \\ sample \\ (6)} &
\makecell{Whole \\ world \\ (7)} &
\makecell{Base \\ sample \\ (8)} \\
\midrule
\multicolumn{6}{c}{\small Dependent variable is log GDP per capita in 1995} &
\multicolumn{2}{c}{\small \makecell[b]{Dependent variable \\ is log output per \\ worker in 1998}} \\
\cmidrule(lr){1-6}\cmidrule{7-8}
\fmtnum{ 0.54 } & \fmtnum{ 0.52 } & \fmtnum{ 0.47 } & \fmtnum{ 0.43 } & \fmtnum{ 0.47 } & \fmtnum{ 0.41 } & \fmtnum{ 0.45 } & \fmtnum{ 0.46 } \\
\fmtnum{(0.04)} & \fmtnum{(0.06)} & \fmtnum{(0.06)} & \fmtnum{(0.05)} & \fmtnum{(0.06)} & \fmtnum{(0.06)} & \fmtnum{(0.04)} & \fmtnum{(0.06)} \\
\addlinespace
& & \fmtnum{ 0.89 } & \fmtnum{ 0.37 } & \fmtnum{ 1.60 } & \fmtnum{ 0.92 } \\
& & \fmtnum{(0.49)} & \fmtnum{(0.51)} & \fmtnum{(0.70)} & \fmtnum{(0.63)} \\
& & & \fmtnum{-0.62 } & & \fmtnum{-0.60 } \\
& & & \fmtnum{(0.19)} & & \fmtnum{(0.23)} \\
& & & \fmtnum{-1.00 } & & \fmtnum{-0.90 } \\
& & & \fmtnum{(0.15)} & & \fmtnum{(0.17)} \\
& & & \fmtnum{-0.25 } & & \fmtnum{-0.04 } \\
& & & \fmtnum{(0.20)} & & \fmtnum{(0.32)} \\
\fmtnum{ 0.62 } & \fmtnum{ 0.54 } & \fmtnum{ 0.63 } & \fmtnum{ 0.73 } & \fmtnum{ 0.56 } & \fmtnum{ 0.69 } & \fmtnum{ 0.55 } & \fmtnum{ 0.49 } \\
\mc{110} & \mc{64} & \mc{110} & \mc{110} & \mc{64} & \mc{64} & \mc{108} & \mc{61} \\
\bottomrule
\end{tabular}
\end{document}
While it is a bit cumbersome, there is very little uniformity across the table, with mixtures of decimal values using parentheses and negative numbers, numbers without decimal parts and also headers that are wider than their column constituents (columns 7-8).
The above code requires at least 2 compilations with every change in the maximum width of a number's integer or decimal part.
You can streamline the input a little using collcell:
\documentclass{article}
\usepackage{booktabs,makecell,eqparbox,collcell}
\newcommand{\mc}{\multicolumn{1}{c}}
\makeatletter
\newcommand{\fmtnum}[1]{\if\relax\detokenize{#1}\relax\else\#fmtnum#1\relax\fi}
\def\#fmtnum#1.#2\relax{\eqmakebox[int][r]{$#1.$}\eqmakebox[dec][l]{$#2$}}
\makeatother
\begin{document}
\noindent
\begin{tabular}{ *{8}{>{\collectcell\fmtnum}c<{\endcollectcell}} }
\toprule
\mc{\makecell{Whole \\ world \\ (1)}} &
\mc{\makecell{Base \\ sample \\ (2)}} &
\mc{\makecell{Whole \\ world \\ (3)}} &
\mc{\makecell{Base \\ sample \\ (4)}} &
\mc{\makecell{Whole \\ world \\ (5)}} &
\mc{\makecell{Base \\ sample \\ (6)}} &
\mc{\makecell{Whole \\ world \\ (7)}} &
\mc{\makecell{Base \\ sample \\ (8)}} \\
\midrule
\multicolumn{6}{c}{\small Dependent variable is log GDP per capita in 1995} &
\multicolumn{2}{c}{\small \makecell[b]{Dependent variable \\ is log output per \\ worker in 1998}} \\
\cmidrule(lr){1-6}\cmidrule{7-8}
0.54 & 0.52 & 0.47 & 0.43 & 0.47 & 0.41 & 0.45 & 0.46 \\
(0.04) & (0.06) & (0.06) & (0.05) & (0.06) & (0.06) & (0.04) & (0.06) \\
\addlinespace
& & 0.89 & 0.37 & 1.60 & 0.92 \\
& & (0.49) & (0.51) & (0.70) & (0.63) \\
& & & -0.62 & & -0.60 \\
& & & (0.19) & & (0.23) \\
& & & -1.00 & & -0.90 \\
& & & (0.15) & & (0.17) \\
& & & -0.25 & & -0.04 \\
& & & (0.20) & & (0.32) \\
0.62 & 0.54 & 0.63 & 0.73 & 0.56 & 0.69 & 0.55 & 0.49 \\
\mc{110} & \mc{64} & \mc{110} & \mc{110} & \mc{64} & \mc{64} & \mc{108} & \mc{61} \\
\bottomrule
\end{tabular}
\end{document}
I have created a table in Latex and it has stopped displaying it but I need it to work on the document I am currently working on. When I input into a new document, it works again. I am getting the following errors:
LaTex error: Illegal character in array arg. Overfull \Hbox (56.47151pt too wide) in paragraph at lines at lines 70--98
Error alignment tab has been changed to \cr.
It does not work either when I include the array package. I am using the following packages:
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{url}
\usepackage[round]{natbib}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{float}
\usepackage{amsmath}
\usepackage[toc,page]{appendix}
\begin{table}[h!]
\begin{center}
\caption{A comparison between Rwanda and The Gambia}
\begin{tabular}{l|s|r|m}
\textbf{Variable} &
\textbf{Specific Variable} &
\textbf{Rwanda} &
\textbf{Gambia} &
\hline \hline
\textit{Size} & Surface area (sq. km) & 26,340 & 11,300 \\
& Population (total) & 12,208,407 & 2,100,568 \\
\hline
\textit{Economy} & GDP growth (annual \%) & 6.1 & 4.6 \\
& GDP per capita & 720 & 680 \\
\hline
\textit{Education} & Literacy rate (gender parity index) & 1.029 & 0.851 \\
& School enrolment (primary \% gross) & 133.425 & 97.115 \\
& School enrolment (secondary \% gross) & 32.988 & 57.096 \\
& School enrolment (tertiary \% gross) & 6.695 & 3.094 \\
\hline
\textit{Health and Survival} & Life expectancy at birth (total years) & 67.129 & 61.193 \\
\hline
\textit{Politics} & Political Elections & 4 & 8 \\
& Freedom Rights Score & Not Free & Not Free \\
\hline
\textit{Gender Equality} & Gender equality rating & 4.5 & 3.5 \\
& The Global Gender Gap Report& 121 & 6 \\
\hline
\textit{Aid Rates} & Net ODA received per capita & 100.373 & 128.356 \\
& Net official development assistance & 37.3 & 46.8 \\
\end{tabular}
\end{center}
\end{table}
Concerning the first problem, "Illegal character in array arg", it is indeed cause by by an unrecognised argument to tabular.
Legal arguments are supposed to describe column types and are c (centered), l (left aligned), r (right aligned), p{width} (top aligned paragraph) and | to describe an intercolumn rule for the most common ones. There are packages that add extra column types, but in your code \begin{tabular}{l|s|r|m} 's' is unknown and do not correspond to a valid column type. 'm' exists to specify a middle aligned paragraph in the 'array' package; it would require the insertion of the package and an extra argument with the desired width of the paragraph. Just change 's' and 'm' wih legal parameters and all is OK. There are many documentation available that describe valid column types.
The second message says that you specify an array with four columns but the fist line contains 5 entries:
\textbf{Variable} &
\textbf{Specific Variable} &
\textbf{Rwanda} &
\textbf{Gambia} &
the fifth one is an empty entry following the ampersand after 'Gambia'. Replace it with an end-of-line to suppress the problem.
Here is a corrected version.
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{url}
\usepackage[round]{natbib}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{float}
\usepackage{amsmath}
\usepackage[toc,page]{appendix}
\begin{document}
\begin{table}[h!]
\begin{center}
\caption{A comparison between Rwanda and The Gambia}
\begin{tabular}{l|c|r|c}
\textbf{Variable} &
\textbf{Specific Variable} &
\textbf{Rwanda} &
\textbf{Gambia} \\
\hline \hline
\textit{Size} & Surface area (sq. km) & 26,340 & 11,300 \\
& Population (total) & 12,208,407 & 2,100,568 \\
\hline
\textit{Economy} & GDP growth (annual \%) & 6.1 & 4.6 \\
& GDP per capita & 720 & 680 \\
\hline
\textit{Education} & Literacy rate (gender parity index) & 1.029 & 0.851 \\
& School enrolment (primary \% gross) & 133.425 & 97.115 \\
& School enrolment (secondary \% gross) & 32.988 & 57.096 \\
& School enrolment (tertiary \% gross) & 6.695 & 3.094 \\
\hline
\textit{Health and Survival} & Life expectancy at birth (total years) & 67.129 & 61.193 \\
\hline
\textit{Politics} & Political Elections & 4 & 8 \\
& Freedom Rights Score & Not Free & Not Free \\
\hline
\textit{Gender Equality} & Gender equality rating & 4.5 & 3.5 \\
& The Global Gender Gap Report& 121 & 6 \\
\hline
\textit{Aid Rates} & Net ODA received per capita & 100.373 & 128.356 \\
& Net official development assistance & 37.3 & 46.8 \\
\end{tabular}
\end{center}
\end{table}
\end{document}
I'm attempting to align two tables in Latex document to be next to each other. Although this is working, the positions of the tables are off. The first is located lower than the second:
Does anyone know how to fix this? Below is my code:
\begin{table}[t]
\begin{minipage}{.55\linewidth}
\begin{tabular}{l|l}
\multicolumn{1}{c|}{\textbf{WordNet}} & \textbf{FreeBase} \\ \hline
domain\_region & cause\_of\_death \\
domain\_topic & ethnicity \\
has\_instance & gender \\
has\_part & institution \\
member\_holonym & nationality \\
member\_meronym & profession \\
part\_of & religion \\
similar\_to & \\
subordinate\_instance\_of & \\
synset\_domain\_topic & \\
type\_of &
\end{tabular}
\label{table1}
\caption{Relationships in WordNet \& FreeBase KBs}
\end{minipage}%
\begin{minipage}{.5\linewidth}
\centering
\begin{tabular}{cccc}
\multicolumn{4}{c}{\textbf{Holdout Set Construction}} \\
\multicolumn{2}{c}{\textbf{WordNet}} & \multicolumn{2}{c}{\textbf{FreeBase}} \\ \hline
Word Removed & \multicolumn{1}{c|}{\# Triples} & Name Removed & \# Triples \\
adult & \multicolumn{1}{c|}{166} & Alan Turing & 15 \\
botany & \multicolumn{1}{c|}{166} & Carl Sagan & 18 \\
building & \multicolumn{1}{c|}{185} & Frank Zappa & 16 \\
center & \multicolumn{1}{c|}{180} & Isaac Asimov & 20 \\
form & \multicolumn{1}{c|}{172} & John Denver & 16 \\
game & \multicolumn{1}{c|}{267} & Karl Marx & 13 \\
lake & \multicolumn{1}{c|}{227} & Mary Astor & 14 \\
land & \multicolumn{1}{c|}{153} & Su Song & 13 \\
mythology & \multicolumn{1}{c|}{178} & Tupac Shakur & 14 \\
room & \multicolumn{1}{c|}{189} & ... & ...
\end{tabular}
\caption{Ten words and a sample of 60 names used for constructing Holdout sets for WordNet and FreeBase, respectively. The numbers of triples that each entity occurs in are listed to the right. These triples comprise the Holdout sets}
\label{table2}
\end{minipage}
\end{table}
You can try setting the tabulars with the same content, even though some rows might be empty. This will ensure they have the same height:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[landscape]{geometry}% Just for this example
\usepackage{booktabs}
\begin{document}
\begin{table}
\mbox{}\hfill
\begin{minipage}[t]{.48\linewidth}
\centering{\ttfamily
\begin{tabular}{ l l }
\toprule
\\
\multicolumn{1}{ c }{\normalfont\bfseries WordNet} & \multicolumn{1}{ c }{\normalfont\bfseries FreeBase} \\
\midrule
domain\_region & cause\_of\_death \\
domain\_topic & ethnicity \\
has\_instance & gender \\
has\_part & institution \\
member\_holonym & nationality \\
member\_meronym & profession \\
part\_of & religion \\
similar\_to & \\
subordinate\_instance\_of & \\
synset\_domain\_topic & \\
type\_of & \\
\bottomrule
\end{tabular}}
\caption{Relationships in WordNet \& FreeBase KBs.}
\end{minipage}\hfill
\begin{minipage}[t]{.48\linewidth}
\centering
\begin{tabular}{ c c c c }
\toprule
\multicolumn{4}{c}{\bfseries Holdout Set Construction} \\
\multicolumn{2}{c}{\bfseries WordNet} & \multicolumn{2}{c}{\bfseries FreeBase} \\
\midrule
\itshape Word Removed & \itshape\# Triples & \itshape Name Removed & \itshape \# Triples \\
adult & 166 & Alan Turing & 15 \\
botany & 166 & Carl Sagan & 18 \\
building & 185 & Frank Zappa & 16 \\
center & 180 & Isaac Asimov & 20 \\
form & 172 & John Denver & 16 \\
game & 267 & Karl Marx & 13 \\
lake & 227 & Mary Astor & 14 \\
land & 153 & Su Song & 13 \\
mythology & 178 & Tupac Shakur & 14 \\
room & 189 & \ldots & \ldots \\
\bottomrule
\end{tabular}
\caption{Ten words and a sample of 60 names used for constructing Holdout sets for WordNet and FreeBase,
respectively. The numbers of triples that each entity occurs in are listed to the right.
These triples comprise the Holdout sets.}
\end{minipage}\hfill
\mbox{}
\end{table}
\end{document}
I've used
fontenc to produce a better \_ within the typewriter font (used in the left-hand table);
booktabs to provide better-looking tables.
\itshape to distinguish a sub-heading within the right-hand table from other content within the same table.