How can somene create two tables side by side in beamer? - latex

How can somene create two tables side by side in beamer? I use the following to insert one table
\begin{table}
\begin{tabular}{l | c | c | c | c | c}
Model & intercept & X & Y & Adjusted $R^2$ & \\
\hline \hline
Coeff & 2.229 & -0.274 & 1.221 & 38\%\\
t-value & 3.404 & -0.49 & 3.907 \\
GMM-t & 2.542 & -0.444 & 3.814\\
\end{tabular}
\end{table}
which command should I use to have two tables side by side like the aforementioned table?

If your tables are narrow enough to fit side by side, you can simply place them next to each other like you would do for any normal letter.
\documentclass{beamer}
\begin{document}
\begin{frame}
\begin{table}
\begin{tabular}{l | c | c | }
Model & intercept & X \\
\hline \hline
Coeff & 2.229 & -0.274 \\
t-value & 3.404 & -0.49\\
GMM-t & 2.542 & -0.444 \\
\end{tabular}
\hfill
\begin{tabular}{l | c | c | }
Model & intercept & X \\
\hline \hline
Coeff & 2.229 & -0.274 \\
t-value & 3.404 & -0.49\\
GMM-t & 2.542 & -0.444 \\
\end{tabular}
\end{table}
\end{frame}
\end{document}

As suggested by this blog, you can try columns environment. For example, with code like
\begin{frame}{Example}
\begin{columns}
\begin{column}{0.3\textwidth}
\begin{table}
\begin{tabular}{c|c|c}
sid & bid & day \\ \hline \hline
22 & 101 & 10/10/96 \\
58 & 103 & 11/12/96 \\
\end{tabular}
\caption{reserves}
\end{table}
\end{column}
\begin{column}{0.3\textwidth}
\begin{table}
\begin{tabular}{c|c|c|c}
sid & sname & rating & age \\ \hline \hline
22 & dustin & 7 & 45.0 \\
31 & lubber & 8 & 55.5 \\
58 & rusty & 10 & 35.0 \\
\end{tabular}
\caption{Sailors}
\end{table}
\end{column}
\end{columns}
\end{frame}
You can get something like below (ignoring the background image)

Related

Multi column and multi row table in LaTeX?

How do I draw the following table in LaTeX? The data inside is not that important.
I wrote the following code:
\begin{table}[H]
\centering
\begin{tabular}{cccccc}
\hline
\multicolumn{6}{|c|}{Feature Vector of Samples} \\
\hline
\headerrow & 1 & 2 & 3 & 4 & 5\\
1 & \(9.87*e^{-01}\) & \(8.67*e^{-17} \)& \(4.13*e^{-24}\) & \(1.16*e^{-17}\) & \(4.58*e^{-17}\) \\
2 & \(1.16*e^{-16}\) & \(9.99*e^{-01}\) & \(9.14*e^{-25}\) & \(3.63*e^{-22}\) & \(2.69*e^{-11}\) \\
3 & \(4.35*e^{-33}\) & \(7.85*e^{-34}\) & \(9.93*e^{-01}\) & \(3.74*e^{-04}\) & \(4.55*e^{-34}\) \\
4 & \(5.51*e^{-26}\)& \(5.13*e^{-31}\)& \(5.02*e^{-04}\) & \(9.99*e^{-01}\) & \(1.71*e^{-29}\) \\
5& \(9.60*e^{-18}\) & \(2.21*e^{-07}\)& \(2.52*e^{-25}\)& \(4.64*e^{-20}\)& \(9.99*e^{-01}\)
\end{tabular}
\caption{wasssss}
\label{tbl:wasss}
\end{table}
and here is the result:
What I need to add is one multi row, and the first row should not include the first column.
In theory you could create a table like this using the following code, but please have a look at http://betterposters.blogspot.com/2012/08/the-data-prison.html before you inflict such a table on your readers
\documentclass{article}
\usepackage{graphicx}
\usepackage{multirow}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{} &\multicolumn{5}{|c|}{Feature Vector of Samples} \\
\cline{3-7}
\multicolumn{2}{|c|}{} & 1 & 2 & 3 & 4 & 5\\\hline
\multirow{5}{*}{\rotatebox{90}{samples}} & 1 & \(9.87*e^{-01}\) & \(8.67*e^{-17} \)& \(4.13*e^{-24}\) & \(1.16*e^{-17}\) & \(4.58*e^{-17}\) \\\cline{2-7}
&2 & \(1.16*e^{-16}\) & \(9.99*e^{-01}\) & \(9.14*e^{-25}\) & \(3.63*e^{-22}\) & \(2.69*e^{-11}\) \\\cline{2-7}
& 3 & \(4.35*e^{-33}\) & \(7.85*e^{-34}\) & \(9.93*e^{-01}\) & \(3.74*e^{-04}\) & \(4.55*e^{-34}\) \\\cline{2-7}
& 4 & \(5.51*e^{-26}\)& \(5.13*e^{-31}\)& \(5.02*e^{-04}\) & \(9.99*e^{-01}\) & \(1.71*e^{-29}\) \\ \cline{2-7}
& 5& \(9.60*e^{-18}\) & \(2.21*e^{-07}\)& \(2.52*e^{-25}\)& \(4.64*e^{-20}\)& \(9.99*e^{-01}\)\\
\hline
\end{tabular}
\caption{wasssss}
\label{tbl:wasss}
\end{table}
\end{document}
you can use the excel2latex. It's a powerful tool for tables write. You'll need add the packagins after, like it's on the follow script:
https://www.ctan.org/tex-archive/support/excel2latex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow} %for multirow
\usepackage{rotating} %for sideways, rotating "samples" at 90°"
\usepackage{bigstrut} %for bigstrut
\begin{document}
% Table generated by Excel2LaTeX from sheet 'Planilha1'
\begin{table}[htbp]
\centering
\caption{Add caption}
\begin{tabular}{|c|r|r|r|r|r|r|}
\hline
\multicolumn{2}{|c|}{\multirow{2}[4]{*}{}} & \multicolumn{5}{c|}{Feature Vector of Samples} \bigstrut\\
\cline{3-7} \multicolumn{2}{|c|}{} & 1 & 2 & 3 & 4 & 5 \bigstrut\\
\hline
\multirow{5}[10]{*}{\begin{sideways}samples\end{sideways}} & 1 & Value & Value & Value & Value & Value \bigstrut\\
\cline{2-7} & 2 & Value & Value & Value & Value & Value \bigstrut\\
\cline{2-7} & 3 & Value & Value & Value & Value & Value \bigstrut\\
\cline{2-7} & 4 & Value & Value & Value & Value & Value \bigstrut\\
\cline{2-7} & 5 & Value & Value & Value & Value & Value \bigstrut\\
\hline
\end{tabular}%
\label{tab:addlabel}%
\end{table}%
\end{document}

Having problems fitting a table to a Column in LaTeX

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}

labeling side by side tables in latex

I have two side by side tables in latex, however, I can not label them separately for using in ref tag. Is there any way to refer their name in my text using ref tag? For example, I need to say in table 1 ... and table 2 .....
Any comment?
\begin{table}[ht]
\parbox{.45\linewidth}{
\centering
\begin{tabular}{|l|l|l|}
\hline
person id & seq id & feature vector$_1$ \\\hline
1 & 1 & 1 \\
1 & 2 & 1 \\ \hline
1 & 1 & 1 \\ \hline
1 & 1 & 1 \\ \hline
\end{tabular}
\caption{HRV Dataset}
}
\hfill
\parbox{.45\linewidth}{
\centering
\begin{tabular}{|l|l|l|l|}
\hline
person id & seq id & feature vector$_1$ & feature vector$_2$ \\\hline
1 & 1 &1 \\
1 & 2 & 1 \\ \hline
1 & 1 &1\\ \hline
1 & 1 & 1 \\ \hline
% \begin{tabular}{|l|l|l|l|}
% \end{tabular}
\end{tabular}
\caption{BAC Dataset}}
\end{table}
You can include the labels within the captions, this will allow you to \ref each of the tables separately later in the document.
\documentclass{article}
\begin{document}
\begin{table}[ht]
\parbox{.40\linewidth}{
\centering
\begin{tabular}{|l|l|l|}
\hline
person id & seq id & feature vector$_1$ \\\hline
1 & 1 & 1 \\
1 & 2 & 1 \\ \hline
1 & 1 & 1 \\ \hline
1 & 1 & 1 \\ \hline
\end{tabular}
\caption{HRV Dataset \label{HRVtable}}
}
\hfill
\parbox{.45\linewidth}{
\centering
\begin{tabular}{|l|l|l|l|}
\hline
person id & seq id & feature vector$_1$ & feature vector$_2$ \\\hline
1 & 1 &1 &1 \\
1 & 2 & 1&1 \\ \hline
1 & 1 &1 &1\\ \hline
1 & 1 & 1 &1 \\ \hline
\end{tabular}
\caption{BAC Dataset \label{BACtable}}}
\end{table}
HRV data in Table \ref{HRVtable} and BAC data in Table \ref{BACtable}.
\end{document}
You should have no issue by adding \label either inside the \caption, or just after it, within the same construction (like \parbox or minipage - see below). I've also added some booktabs pizzaz...
\documentclass{article}
\usepackage{booktabs,makecell}
\begin{document}
\begin{table}
\begin{minipage}{.5\linewidth}
\centering
\begin{tabular}{ *{3}{c} }
\toprule
\makecell{person \\ id} & \makecell{seq \\ id} & \makecell{feature \\ vector$_1$} \\
\midrule
1 & 1 & 1 \\
1 & 2 & 1 \\
1 & 1 & 1 \\
1 & 1 & 1 \\
\bottomrule
\end{tabular}
\caption{HRV Dataset}\label{tab:first}
\end{minipage}%
\begin{minipage}{.5\linewidth}
\centering
\begin{tabular}{ *{4}{c} }
\toprule
\makecell{person \\ id} & \makecell{seq \\ id} & \makecell{feature \\ vector$_1$} & \makecell{feature \\ vector$_2$} \\
\midrule
1 & 1 & 1 & 4 \\
1 & 2 & 1 & 3 \\
1 & 1 & 1 & 2 \\
1 & 1 & 1 & 1 \\
\bottomrule
\end{tabular}
\caption{BAC Dataset}\label{tab:second}
\end{minipage}
\end{table}
See Table~\ref{tab:first} and Table~\ref{tab:second}\ldots
\end{document}

Latex minipage table alignment

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.

LaTex: how does the include-command work?

I supposed the include-command copy-pastes code in the compilation, it is wrong because the code stopped working. Please, see the middle part in the code. I only copy-pasted the code to the file and added the include-command.
$ cat results/frames.tex
10.31 & 8.50 & 7.40 \\
10.34 & 8.53 & 7.81 \\
8.22 & 8.62 & 7.78 \\
10.16 & 8.53 & 7.44 \\
10.41 & 8.38 & 7.63 \\
10.38 & 8.57 & 8.03 \\
10.13 & 8.66 & 7.41 \\
8.50 & 8.60 & 7.15 \\
10.41 & 8.63 & 7.21 \\
8.53 & 8.53 & 7.12 \\
Latex code, see the middle part
\begin{table}
\begin{tabular}{ | l | m | r |}
\hline
$t$ / s & $d_{1}$ / s & $d_{2}$ / s \\
$\Delta h = 0,01 s$ & $\Delta d = 0,01 s$ & $\Delta d = 0,01 s$ \\
\hline
% I JUST COPIED THE CODE from here to the file, included.
% It stopped working, why?
\include{results/frames.tex}
\hline
$\pi (\frac{d_{1}}{2} - \frac{d_{2}}{2})$ & $2 \pi R h$ & $2 \pi r h$ \\
\hline
\end{tabular}
\end{table}
Use \input instead of \include, that will work.
\include additionally performs a \clearpage command which will not work in the context of a table.
Try with \input, \include is old and very limited..

Resources