I simple want to combine some cells in a row of a table in Latex. For instance,
I tried to compile the following table:
\begin{tabular}{|l|l|l|}
\hline
\multicolumn{3}{|c|}{Team sheet} \\
\hline
Goalkeeper & GK & Paul Robinson \\ \hline
\multirow{4}{*}{Defenders} & LB & Lucus Radebe \\
& DC & Michael Duberry \\
& DC & Dominic Matteo \\
& RB & Didier Domi \\ \hline
\multirow{3}{*}{Midfielders} & MC & David Batty \\
& MC & Eirik Bakke \\
& MC & Jody Morris \\ \hline
Forward & FW & Jamie McMaster \\ \hline
\multirow{2}{*}{Strikers} & ST & Alan Smith \\
& ST & Mark Viduka \\
\hline
\end{tabular}
Then I get the error:
! Undefined control sequence.
<recently read> \multirow
l.821 \multirow
Does anyone have an idea what I am doing wrong? Do I need a special package? Interestingly enough, the multicolumn command is working! Weird.
How about trying
\usepackage{multirow}
?
Multirow is not a defined command. This is because of the structure of tables in LaTeX: line by line. You can use the \cline command to make sure that horizontal lines between rows do not separate the first column, but the label "Defenders" would still be at the top of the cell.
It seems that the multirow package (which comes with the complete MikTeX distribution) addresses this issue.
See also:
Manual of the multirow package
Small tutorial on multirow
EDIT: You don't want to combine cells in a row, as you have wrote, but you want to combine cells in one column. Simply write empty cells:
\begin{tabular}{|l|l|l|}
\hline
\multicolumn{3}{|c|}{Team sheet} \\
\hline
Goalkeeper & GK & Paul Robinson \\ \hline
Defenders & LB & Lucus Radebe \\
& DC & Michael Duberry \\
& DC & Dominic Matteo \\
& RB & Didier Domi \\ \hline
Midfielders & MC & David Batty \\
& MC & Eirik Bakke \\
& MC & Jody Morris \\ \hline
Forward & FW & Jamie McMaster \\ \hline
Strikers & ST & Alan Smith \\
& ST & Mark Viduka \\
\hline
\end{tabular}
Related
I am working with Stata to create a balance table for some data using the balancetable ado package. While I believe the balancetable commands are working, the output LaTeX document won't run the table that it is trying to print. Given that I am still learning how to use LaTeX, any assistance with trying to see what the syntax issue is with this LaTeX code would be much appreciated. I'm getting issues related to the document name, typesetting and compiler issues.
\begin{tabular}{l*{3}c}
\hline\hline
& (1) & (2) & (3) \\
\hline
agesq&677.315&717.395&40.079\\
&(428.784)&(431.252)&(41.341)\\
educ&10.088&10.346&0.257\\
&(1.614)&(2.011)&(0.172)\\
black&0.827&0.843&0.016\\
&(0.379)&(0.365)&(0.036)\\
hisp&0.108&0.059&-0.048*\\
&(0.311)&(0.237)&(0.027)\\
married&0.154&0.189&0.035\\
&(0.361)&(0.393)&(0.036)\\
nodegree&0.835&0.708&-0.127***\\
&(0.372)&(0.456)&(0.039)\\
mosinex&17.862&18.492&0.630\\
&(5.574)&(4.911)&(0.511)\\
re74&2.107&2.096&-0.011\\
&(5.688)&(4.887)&(0.516)\\
re75&1.267&1.532&0.265\\
&(3.103)&(3.219)&(0.303)\\
\hline
Observations & 260 & 185 & 445 \\
\hline\hline
\end{tabular}
```!LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.1 \begin{tabular}
{l*{3}c}
?```
In LaTeX, there's some lines you should always have. \documentclass{article} (doesn't have to be the article format). Afterwards, there is the document environment where your tabular environment would be in. This would look like:
\documentclass{article}
\begin{document}
\begin{tabular}{l*{3}c}
\hline\hline
& (1) & (2) & (3) \\ \hline
agesq & 677.315 & 717.395 & 40.079 \\
& (428.784) & (431.252) & (41.341) \\
educ & 10.088 & 10.346 & 0.257 \\
& (1.614) & (2.011) & (0.172) \\
black & 0.827 & 0.843 & 0.016 \\
& (0.379) & (0.365) & (0.036) \\
hisp & 0.108 & 0.059 & -0.048* \\
& (0.311) & (0.237) & (0.027) \\
married & 0.154 & 0.189 & 0.035 \\
& (0.361) & (0.393) & (0.036) \\
nodegree& 0.835 & 0.708 & -0.127*** \\
& (0.372) & (0.456) & (0.039) \\
mosinex & 17.862 & 18.492 & 0.630 \\
& (5.574) & (4.911) & (0.511) \\
re74 & 2.107 & 2.096 & -0.011 \\
& (5.688) & (4.887) & (0.516) \\
re75 & 1.267 & 1.532 & 0.265 \\
& (3.103) & (3.219) & (0.303) \\
\hline
Observations & 260 & 185 & 445 \\
\hline\hline
\end{tabular}
\end{document}
Indentations and spacing aren't required but they do make the document more understandable for the writer. Here's what this document generates:
I have my template set that subsections go into 2 columns, however when I try and insert a table, it does not compile instead being left blank. I think the reason is that the table is too wide/not being fitted.
Here is my LaTeX
\subsection{On examination}
\begin{table}[]
\begin{tabular}{|l|l|l|}
\hline
{\ul \textbf{Symptom}} & {\ul \textbf{Patient}} & {\ul \textbf{Normal}} \\ \hline
\textit{Temperature} & 36.7C & 36-36.8 \\ \hline
\textit{BMI} & 31 kg/m\textasciicircum{}2 & 18.5-24.9 \\ \hline
\textit{Heart Rate} & 70bpm & 60-100bpm \\ \hline
\textit{Blood Pressure} & 145/80 mmHg & \textless{}140/90mmHg \\ \hline
\textit{Respiratory Rate} & 12 breaths/min & 12-18 breaths/min \\ \hline
\textit{Misc} & & \\ \hline
\end{tabular}
\end{table}
I'm sorry if this question has been asked before, but I just canĀ“t figure out how to create this table, while keeping it somewhat nice looking.
I have attached an image, containing an Excel representation of the table I'm trying to create.
I hope a Latex master can help me out here!
Use \multicolumn{n-cells}{alignment}{content}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Outer Fold & \multicolumn{2}{c|}{ANN model} & \multicolumn{2}{c|}{Lin Reg model} & Baseline model \\
\hline
i & $h_i^*$ & $E_i^{test}$ & $L_i^*$ & $E_i^{test}$ & $E_i^{test}$ \\
\hline
1 & 3 & 0.301 & 128 & 1.206 & 1.219 \\
1 & 3 & 0.301 & 128 & 1.206 & 1.219 \\
1 & 3 & 0.301 & 128 & 1.206 & 1.219 \\
\hline
\end{tabular}
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.