I make a table like this one :
\documentclass[pdfa,sl,draft,english]{letter}
\usepackage[flushleft]{threeparttable}
\begin{document}
\begin{table}
\begin{center}
\begin{threeparttable}
\caption{Table caption}
\begin{tabular}{ | c | c| c | c |}
\hline
a
& \multicolumn{1}{|p{3cm}|}{\centering b \\ (unit) }
& c ${}^{a}$
& d ${}^{b}$ \\ \hline
1 & 1b & 1c & 1d \\
2 & 2b & 2c & 2d \\ \hline
\end{tabular}
\begin{tablenotes}
\small
\item ${}^{a}$ Note for c column
\item ${}^{b}$ Note for d column
\end{tablenotes}
\end{threeparttable}
\end{center}
\end{table}
\end{document}
The compilation make a thicker right line on the first column and first row. Do you have an idea to avoid this?
This works. It is a bit of a hack, but essentially you set the columns to a width that you predefine. It seems to look okay like this.
\documentclass[pdfa,sl,draft,english]{letter}
\usepackage[flushleft]{threeparttable}
\usepackage{makecell}
\newcolumntype{?}{!{\vrule width 0.1pt}}
\begin{document}
Table With Bold Line
\begin{tabular}{ | c | c | c | c |}
\hline
a
& \multicolumn{1}{|p{3cm}|}{\centering b \\ (unit) }
& c ${}^{a}$
& d ${}^{b}$ \\ \hline
1 & 1b & 1c & 1d \\
2 & 2b & 2c & 2d \\ \hline
\end{tabular}
Table Without Bold Line
\begin{tabular}{ ? c ? c ? c ? c ?}
\hline
a
& \multicolumn{1}{|p{3cm}|}{\centering b \\ (unit) }
& c ${}^{a}$
& d ${}^{b}$ \\ \hline
1 & 1b & 1c & 1d \\
2 & 2b & 2c & 2d \\ \hline
\end{tabular}
\end{document}
Related
so i started working with latex and i'm trying to fit a table with statistical content into another table for better alignment.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx,dashrule}
\usepackage{tabularx}
\usepackage{xcolor}
\usepackage[a4paper,left=2cm,right=2cm,top=1cm,bottom=1cm]{geometry}
% Document metadata
\title{Statistische Auswertung}
\author{Automatisch Generiert}
\date{2023-02-09 16:24:04}
\begin{document}
% Dokumententitel und Datum generieren
\maketitle
\begin{tabularx}{\textwidth}{|X|X|}
{\begin{tabularx}{\linewidth}{|X|X|}
\hline
age & --- \\
count & 343.0 \\
mean & 60.8 \\
std & 12.1 \\
min & 28.0 \\
25\% & 53.0 \\
50\% & 60.0 \\
75\% & 70.0 \\
max & 89.0 \\
\hline
\end{tabularx}} & \frame{\includegraphics[width=\linewidth]{age.png}} \\
\hline
{\begin{tabularx}{\linewidth}{|X|X|}
\hline
status-fu & --- \\
count & 356 \\
unique & 2 \\
top & False \\
freq & 297 \\
\hline
\end{tabularx}} & \frame{\includegraphics[width=\linewidth]{status_fu.png}} \\
\hline
\end{tabularx}
\end{document}
The Output lools like this:
I want the Sub-tables on the left to be center top aligned with the Images on the right.
Any help???
Cheers!
I am making a table and I am not able to make vertical lines to appear. I followed a few examples and they are still not appearing.
\begin{table}[h!]
\centering
\begin{tabular}{||c c c c||}
\hline
\multicolumn{4}{|c|}{Telescope Data} \\
\hline
Channels & \makecell{Beam Size\\ (arcsec)} & \makecell{Noise \\ (mJy/beam)} & Position of Peak Flux \\ [0.5ex]
\hline
1-10 & \makecell{\textbf{min:} 1.42 \\ \textbf{max:} 1.95} & 4.9928 & \makecell{\textbf{peak(x):} 15 \\ \textbf{peak(y):} -13.5 \\ \textbf{peak(flux, max):} 0.002846} \\ [3ex]
\hline
52-61 & \makecell{\textbf{min:} 1.423 \\ \textbf{max:} 1.95} & 0.0018912 & \makecell{\textbf{peak(x):} -0.25 \\ \textbf{peak(y):} 0 \\ \textbf{peak(flux, max):} 0.029341} \\ [3ex]
\hline
103-112 & \makecell{\textbf{min:} 1.427 \\ \textbf{max:} 1.956} & 0.000802855 & \makecell{\textbf{peak(x):} -16 \\ \textbf{peak(y):} 0 \\ \textbf{peak(flux, max):} 0.00241892} \\ [3ex]
\hline
\end{tabular}
\end{table}
I have the following table in Latex
Created with this code:
\begin{table}[h]
\caption{aaaa}
\label{tab:treatments}
\centering
\scalebox{0.8}{
\begin{tabular}{l c c c}
\toprule
\tabhead{Por 1} & \tabhead{Por 3} & \tabhead{Quantificazione log-dim} & \tabhead{cintin\'a} \\
\midrule
A & M & 99.3\%& 5.4\\
B& A & 2.0\%& 4.6\\
C & N & 5.8\% & 4.6\\
D & N & 3.5\% & 4.26\\
E & K & 22.5\% & 3.7\\
\bottomrule\\
\end{tabular}
}
\end{table}
I would like to have the third column of percentages aligned to the right
At the same time the column label is too large. If I aligned the column to the right it would and up visually weird.
In a Word table I would align the column to the right and than add a right margin to the cells. The numbers would move toward the cell center while keeping their alignment to the right.
How do I do that in Latex? How do I add a margin to the right?
There are a number of options you can try:
Original:
Multi-row header:
Manual alignment of centred columns using \phantoms:
Manual alignment of centred columns using \eqmakeboxes (from eqparbox):
Automated alignment of centred columns using siunitx:
\documentclass{article}
\usepackage{booktabs,graphicx,makecell,siunitx,eqparbox}
\newcommand{\tabhead}{\textbf}
\begin{document}
Original:
\begin{tabular}{ l c c c }
\toprule
\tabhead{Por 1} & \tabhead{Por 3} & \tabhead{Quantificazione log-dim} & \tabhead{cintin\'a} \\
\midrule
A & M & 99.3\% & 5.4 \\
B & A & 2.0\% & 4.6 \\
C & N & 5.8\% & 4.6 \\
D & N & 3.5\% & 4.26 \\
E & K & 22.5\% & 3.7 \\
\bottomrule
\end{tabular}
\bigskip
Multi-row header:
\begin{tabular}{ l c c c }
\toprule
\tabhead{Por 1} & \tabhead{Por 3} & \tabhead{\makecell[b]{Quantificazione \\ log-dim}} & \tabhead{cintin\'a} \\
\midrule
A & M & 99.3\% & 5.4 \\
B & A & 2.0\% & 4.6 \\
C & N & 5.8\% & 4.6 \\
D & N & 3.5\% & 4.26 \\
E & K & 22.5\% & 3.7 \\
\bottomrule
\end{tabular}
\bigskip
Manual alignment of centred columns using \verb|\phantom|s:
\begin{tabular}{ l c c c }
\toprule
\tabhead{Por 1} & \tabhead{Por 3} & \tabhead{\makecell[b]{Quantificazione \\ log-dim}} & \tabhead{cintin\'a} \\
\midrule
A & M & 99.3\% & 5.4\phantom{0} \\
B & A & \phantom{0}2.0\% & 4.6\phantom{0} \\
C & N & \phantom{0}5.8\% & 4.6\phantom{0} \\
D & N & \phantom{0}3.5\% & 4.26 \\
E & K & 22.5\% & 3.7\phantom{0} \\
\bottomrule
\end{tabular}
\bigskip
Manual alignment of centred columns using \verb|\eqmakebox|es:
\begin{tabular}{ l c c c }
\toprule
\tabhead{Por 1} & \tabhead{Por 3} & \tabhead{\makecell[b]{Quantificazione \\ log-dim}} & \tabhead{cintin\'a} \\
\midrule
A & M & \eqmakebox[log][r]{99.3\%} & \eqmakebox[cint][l]{5.4} \\
B & A & \eqmakebox[log][r]{ 2.0\%} & \eqmakebox[cint][l]{4.6} \\
C & N & \eqmakebox[log][r]{ 5.8\%} & \eqmakebox[cint][l]{4.6} \\
D & N & \eqmakebox[log][r]{ 3.5\%} & \eqmakebox[cint][l]{4.26} \\
E & K & \eqmakebox[log][r]{22.5\%} & \eqmakebox[cint][l]{3.7} \\
\bottomrule
\end{tabular}
\newpage
Automated alignment of centred columns using \verb|siunitx|:
\begin{tabular}{ l c S[table-format = 2.1, table-space-text-post = \%] S[table-format = 1.2] }
\toprule
\tabhead{Por 1} & \tabhead{Por 3} & \tabhead{\makecell[b]{Quantificazione \\ log-dim}} & \tabhead{cintin\'a} \\
\midrule
A & M & 99.3\% & 5.4 \\
B & A & 2.0\% & 4.6 \\
C & N & 5.8\% & 4.6 \\
D & N & 3.5\% & 4.26 \\
E & K & 22.5\% & 3.7 \\
\bottomrule
\end{tabular}
\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}|}
I'm trying to create a table in Latex but without success. I tried different solutions but no one solves my problem.
I would like create a table like the picture below:
Can anyone show how to do this in Latex please?
One first sketch may be the following:
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\multirow{3}{*}{A} & \multicolumn{2}{c|}{User B} & %
\multicolumn{2}{c|}{User C} & \multirow{3}{*}{D}\\
\cline{2-5}
& \multicolumn{2}{c|}{Value} & \multicolumn{2}{c|}{Value} & \\
\cline{2-5}
& B1 & B2 & C1 & C2 & \\
\hline
& & & & & \\
\hline
& & & & & \\
\hline
% etc. ...
\end{tabular}
\end{document}
It produces:
Addendum:
\documentclass{article}
\usepackage{multirow}
\begin{document}
{\sffamily %
\begin{tabular}{|c|c|c|c|c|c|c|}% seven columns now, not six...
\hline
\multirow{3}{*}{A} & \multicolumn{2}{c|}{User B} & \multirow{3}{*}{X} & %
\multicolumn{2}{c|}{User C} & \multirow{3}{*}{D}\\
\cline{2-3}\cline{5-6}
& \multicolumn{2}{c|}{Value} & & \multicolumn{2}{c|}{Value} & \\
\cline{2-3}\cline{5-6}
& B1 & B2 & & C1 & C2 & \\
\hline
& & & & & & \\
\hline
& & & & & & \\
\hline
% etc. ...
\end{tabular}
}%
\end{document}
produces:
Please, critically check all the differences between the original code and this latter.
Don't forget that several LaTeX packages can help you improving style, dimensions and spacing of your table: among these, I advise you to have a look at bigstrut.
Also:
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\multirow{3}{*}{A} & \multirow{3}{*}{X} & \multicolumn{2}{c|}{User B} & \multicolumn{2}{c|}{User C} & \multirow{3}{*}{D}\\
\cline{3-6}
& & \multicolumn{2}{c|}{Value} & \multicolumn{2}{c|}{Value} & \\
\cline{3-6}
& & B1 & B2 & C1 & C2 & \\
\hline
& & & & & & \\
\hline
\end{tabular}
\end{document}
You should now be able to operate on your own further changes to the model of table.
Check out the multirow package:
http://texblog.org/2012/12/21/multi-column-and-multi-row-cells-in-latex-tables/
You have to include the library:
%multi-column
\multicolumn{number cols}{align}{text} % align: l,c,r
%multi-row
\usepackage{multirow}
\multirow{number rows}{width}{text}
Then it looks like this:
\documentclass[11pt]{article}
\usepackage{multirow}
\begin{document}
\begin{table}[ht]
\caption{Multi-column and multi-row table}
\begin{center}
\begin{tabular}{ccc}
\hline
\multicolumn{2}{c}{\multirow{2}{*}{Multi-col-row}}&X\\
\multicolumn{2}{c}{}&X\\
\hline
X&X&X\\
\hline
\end{tabular}
\end{center}
\label{tab:multicol}
\end{table}
\end{document}
note: code examples from the link provided