Can anyone give an idea on how to make this table?
Use \begin{table} [...] \end{table}
Here is a minimal working example:
\begin{table}
\centering
\begin{tabular}{l r}
& 119 Responses\\
Field & Percentage \\
\hline
Very convenient & 63\% \\
Sowewhat convenient & 28\% \\
Neutral & 5\% \\
Somewhat inconvenient & 2\% \\
Very inconvenient & 3\% \\
\end{tabular}
\end{table}
\end{document}
It looks like this:
Related
I am quite a beginner in LaTex and generated the following table:
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{|p{2,5cm}||p{3,5cm}|p{2cm}| p{2cm}|}
\hline
\multicolumn{4}{|c|}{Initial Run of Models} \\
\hline
Objective & Service Level in \% & Costs in € & Number of Lines \\
\hline
Max. direct pass. & 93.48 & 1,258.41 & 7\\
Min. travel time & 77.99 & 933.13 & 7\\
\hline
\end{tabular}
\caption[Initial Run of Models]{\label{Tab:InitialRun}Initial Run of Models}
\end{table}
\end{document}
Is there any way to maintain the width of the columns and still align the text in the columns to be on the right side?
You could use the array package and add >{\raggedleft}:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{array}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{|>{\raggedleft}p{2.5cm}||>{\raggedleft}p{3.5cm}|>{\raggedleft}p{2cm}| >{\raggedleft\arraybackslash}p{2cm}|}
\hline
\multicolumn{4}{|c|}{Initial Run of Models} \\
\hline
Objective & Service Level in \% & Costs in € & Number of Lines \\
\hline
Max. direct pass. & 93.48 & 1,258.41 & 7\\
Min. travel time & 77.99 & 933.13 & 7\\
\hline
\end{tabular}
\caption[Initial Run of Models]{\label{Tab:InitialRun}Initial Run of Models}
\end{table}
\end{document}
Personally, I would suggest to use the tabularray package instead. This package makes it easy to set the alignment for row/columns or individual cells.
You could use Q[2.5cm] to specify a width, but if you don't, tabularray will determine a much better width for you.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularray}
\begin{document}
\begin{table}[h]
\centering
\begin{tblr}{
colspec={|Q||Q|Q|Q|},
rows={halign=r},
column{1}={halign=l},
row{1}={halign=c},
row{2}={halign=l},
}
\hline
\SetCell[c=4]{} Initial Run of Models &&& \\
\hline
Objective & Service Level in \% & Costs in € & Number of Lines \\
\hline
Max. direct pass. & 93.48 & 1,258.41 & 7\\
Min. travel time & 77.99 & 933.13 & 7\\
\hline
\end{tblr}
\caption[Initial Run of Models]{\label{Tab:InitialRun}Initial Run of Models}
\end{table}
\end{document}
If you use the package array as suggested in the first answer, then you can define in your header one or more newcolumntypes, for example this one called R, right aligned with the width to be assigned to each column. More details here.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{array}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{|R{2,5cm}||R{3,5cm}|R{2cm}|R{2cm}|}
\hline
\multicolumn{4}{|c|}{Initial Run of Models}\\
\hline
Objective & Service Level in \% & Costs in € & Number of Lines\\
\hline
Max. direct pass. & 93.48 & 1,258.41 & 7\\
Min. travel time & 77.99 & 933.13 & 7\\
\hline
\end{tabular}
\caption{\label{Tab:InitialRun}Initial Run of Models}
\end{table}
\end{document}
Here I changed to R all of the four columns but they don't have to be all of the same kind.
Make a search because surely there are many "duplicates" of this question here and on TeX SE.
Hi all if anyone can help me. I am new to latex. I am trying to add table in my latex. I know the format but i don't know what I am doing wrong because my table is not in the form I want moreover it is giving me the error when I add caption.
I need some thing like this in the image
but I am getting this when I compile my latex code
Here is my code:
\begin{center}
\begin{tabular}[!ht]{||c c ||}
\caption{Dataset Specifications}
\centering \label{data}
\hline
Dataset & Samples \\ [0.5ex]
\hline\hline
Vovid & 349 \\
\hline
noncovid & 397 \\ [1ex]
\hline
\end{tabular}
\end{center}
My minimal code:
\documentclass{article}
\setlength{\tabcolsep}{1em}
\renewcommand{\arraystretch}{1.5}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}{|c|c|}
\hline
Dataset & Samples \\
\hline
Covid & 349 \\
Non Covid & 397 \\
\hline
\end{tabular}
\caption{Dataset Specifications}
\label{tab:data}
\end{table}
\end{document}
and its output:
Please comment below here if any feature is missing or something is not clear to you :)
How about that:
\begin{table}[!ht]
\centering
\begin{tabular}{|c |c|}
\hline
Dataset & Samples \\ [0.5ex]
\hline
Vovid & 349 \\
noncovid & 397 \\ [1ex]
\hline
\end{tabular}
\caption{Dataset Specifications}
\label{tab:data}
\end{table}
So, the trick is 1) to pack the tabular in a table environment, 2) play with \hline and | to modify the lines around the table cells. More ways to polish tables in https://en.wikibooks.org/wiki/LaTeX/Tables
I would like to ask how to format table above in latex - table is pretty decent but I would like to have "model" bit right not at the very end, also I would like to have no space at the very right of the table.
\documentclass{article}
\usepackage[utf8]{inputenc}
\title{table in stack}
\author{petr102030 Hrobar}
\date{November 2019}
\begin{document}
\maketitle
\section{Introduction}
\begin{table}[!htbp] \centering
\label{exp_rmse}
\begin{tabular}{#{\extracolsep{5pt}}lccccccc}
\\[-1.8ex]\hline
\hline \\[-1.8ex]
Model & \multicolumn{1}{c}{RMSE} & \multicolumn{1}{c}{MAE} & \multicolumn{1}{c}{MAPE} & \\
\hline \\[-1.8ex]
Holt-Winters (add.) & 1256.361 & 924.962 & 3.518 &\\
Holt-Winters (mul.) & 1238.799 & 909.395 & 3.457 &\\
Parab. Trend (model 4) & 2228.310 & 1792.471 & 7.959 &\\
Lin.Trend (model 5) & 3074.307 & 2545.426 & 11.339 &\\
\hline \\[-1.8ex]
\end{tabular}
\end{table}
\end{document}
The "Model" is at the leftmost boarder of your table because the default padding is shallowed by #{\extracolsep{5pt}}. If you remove this, you'll get the padding back. (However the usual advice is to remove this padding, so please consider carefully if you really want to do this)
only specify as many columns as you have in your table and not 8 like in your example
with the siunitx package you can align the numbers nicely by their decimal markers
as already mentioned by Picaud Vincent the booktabs package is very useful to create nice looking tables. Amongst other things, it improves the vertical spacing around rules
using \label{} only makes sense if there also is a caption it can reference
I suggest to remove all the unnecessary \multicolumn{1}{...}, they don't do anything useful and can mess up the formatting
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{siunitx}
\title{table in stack}
\author{petr102030 Hrobar}
\date{November 2019}
\begin{document}
\maketitle
\section{Introduction}
\begin{table}[!htbp]
\centering
\begin{tabular}{#{}lS[table-format=4.3]S[table-format=4.3]S[table-format=2.3]}
\toprule
Model & {RMSE} & {MAE} & {MAPE} \\
\midrule
Holt-Winters (add.) & 1256.361 & 924.962 & 3.518 \\
Holt-Winters (mul.) & 1238.799 & 909.395 & 3.457 \\
Parab. Trend (model 4) & 2228.310 & 1792.471 & 7.959 \\
Lin.Trend (model 5) & 3074.307 & 2545.426 & 11.339 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Hello everyone I am creating a table on latex my code looks like this:
\begin{table}[H]
\centering
\caption{caption}
\label{my-label}
\begin{tabular}{lll}
\hline
\multicolumn{3}{|c|}{\cellcolor[HTML]{34CDF9}{\color[HTML]{000000} Matriz confusión Genero.}} \\ \hline
\multicolumn{1}{|l|}{} & \multicolumn{1}{l|}{M} & \multicolumn{1}{l|}{F} \\ \hline
\multicolumn{1}{|l|}{M} & \multicolumn{1}{l|}{43} & \multicolumn{1}{l|}{7} \\ \hline
\multicolumn{1}{|l|}{F} & \multicolumn{1}{l|}{11} & \multicolumn{1}{l|}{39} \\ \hline
\end{tabular}
\end{table}
It works well but the problem comes when I try to fix the width of the columns I tried:
\begin{tabular}{l{2cm}|l{2cm}|l{2cm}}
The result is the same table, with variable length of columns, I would like to fix the length of the columns, I would like to appreciate any suggestion to solve this problem.
Consider the following code:
\documentclass[a4paper]{article}
\usepackage{}
\begin{document}
\begin{table}%[H]
\centering
\caption{caption}
\label{my-label}
\begin{tabular}{|p{20mm}|p{15mm}|p{10mm}|}
\hline
% \multicolumn{3}{|c|}{\cellcolor[HTML]{34CDF9}{\color[HTML]{000000} Matriz confusión Genero.}} \\ \hline
\multicolumn{3}{|c|}{Matriz confusión Genero.} \\ \hline
& M & F \\ \hline
M & 43 & 7 \\ \hline
F & 11 & 39 \\ \hline
\end{tabular}
\end{table}
\end{document}
that outputs the following table:
You may be interested in particular in the line
\begin{tabular}{|p{20mm}|p{15mm}|p{10mm}|}
implementing paragraph alignment for the contents of a column of given width (here 20, 15 and 10 mm respectively).
To make it simpler, you should just get rid of all of those \multicolumn{1}{}{} and change
\begin{tabular}{l{2cm}|l{2cm}|l{2cm}}
to
\begin{tabular}{|p{2cm}|p{2cm}|p{2cm}|}
In the output below, I'm trying to align Author with the top of the box next to it. I've tried a couple of different boxes and whatnot, but I can't get it to align properly.
Here's the code:
\mbox{
Author
}
\fbox{\begin{minipage}[c]{12cm}
\medskip
$for(author)$
$author.name$\\$if(author.title)$\emph{$author.title$}\\$endif$$if(author.company)$$author.company$$endif$
\par\medskip
$endfor$
\medskip
\end{minipage}}
You should set the entire construction inside a tabular, and then also use a [t]op-aligned tabular for the framed box construction:
\documentclass{article}
\begin{document}
\begin{tabular}{l | l |}
\cline{2-2}
Author & \begin{tabular}[t]{#{}p{12cm}#{}}
Jack Appleseed \\
\emph{Marketing Manager} \\
Unimaginitive Solutions \\ \\
John Appleseed \\
\emph{Business Development Manager} \\
Unimaginitive Solutions \\
\end{tabular} \\
\cline{2-2}
\end{tabular}
\end{document}
I'm assuming you can use the following Pandoc construction (I haven't used Pandoc):
\begin{tabular}{l | l |}
\cline{2-2}
Author & \begin{tabular}[t]{#{}p{12cm}#{}}
$for(author)$
$author.name$ \\ $if(author.title)$\emph{$author.title$} \\ $endif$ $if(author.company)$ $author.company$ \\ $endif$
$endfor$
\end{tabular} \\
\cline{2-2}
\end{tabular}