How to top align a table in a table LaTeX - latex

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!

Related

Latex table alignment problem with multicolumn and multirow

How can I align this table. It does not algin column two and three at center.
I am using following code:
\begin{table}[htbp]
\caption{Comparison with the hybrid architecture}
\label{tab:comparison}
\begin{center}
\begin{tabular}{|l|c|c|}
\hline
\multicolumn{1}{|c|}{} & \multicolumn{2}{c|}{\textit{Average Episode Reward for 10 Runs (deviation)}} \\ \cline{2-3}
\multicolumn{1}{|c|}{} & \multicolumn{2}{c|}{\textit{Disturbance Magnitude}} \\
\cline{2-3}
\multicolumn{1}{|c|}{\multirow{-3}{*}{\textit{Architecture}}}
& 65\% & 70\% \\ \hline
PID & -17.71 & -23.54 \\
CoL-DRL & -2.58 & -12.25 \\
\rowcolor[HTML]{9AFF99} CoL-DRPRL & -1.85 & -6.25 \\ \hline
\end{tabular}
\end{center}
\end{table}

Latex Overfull /hbox when inserting table. Cannot change width without changing table structure

When I insert my table into latex I get an overfull /hbox error and cannot figure out how to change the width without changing the structure of my table. The code of my table follows as such:
\begin{center}
\begin{tabular}{||c c c||}
\hline
Function() & Computational Cost (Gas)& USD Equivalent \\ [0.5ex]
\hline\hline
Total Deployment & 8342204 & 1.195559526 \\
\hline
Security Registration & 3849155 & 0.5516400614 \\
\hline
\textit{MintSecurity} & 76293 & 0.01093389983 \\
\hline
\textit{TransferFrom} & 55146 & 0.007903226248 \\
\hline
\textit{Swap} & 89343 & 0.0128041552 \\
\hline
\textit{AddLiquidity} & 185368 & 0.02656593847 \\
\hline
\textit{Remove Liquidity} & 67137 & 0.009621711468 \\ [1ex]
\hline
\end{tabular}
\end{center}
In the template you are using, tables are set in a smaller font size, so the problem is solved automatically if you use a table environment instead of center.
In addition, you can use the tabularray package, so the table will automatically match the text width:
\documentclass[conference]{IEEEtran}
\usepackage{tabularray}
\usepackage{lipsum}
\begin{document}
\lipsum[2]
\begin{table}[htbp]
\begin{tblr}{||c X[c] c||}
\hline
Function() & Computational Cost (Gas)& USD Equivalent \\
\hline\hline
Total Deployment & 8342204 & 1.195559526 \\
\hline
Security Registration & 3849155 & 0.5516400614 \\
\hline
\textit{MintSecurity} & 76293 & 0.01093389983 \\
\hline
\textit{TransferFrom} & 55146 & 0.007903226248 \\
\hline
\textit{Swap} & 89343 & 0.0128041552 \\
\hline
\textit{AddLiquidity} & 185368 & 0.02656593847 \\
\hline
\textit{Remove Liquidity} & 67137 & 0.009621711468 \\
\hline
\end{tblr}%
\end{table}
\lipsum[2]
\end{document}

How can I make the verticle line in the table without any gaps?

The verticle line in the third column has 2 gaps. How do I do I make it look full?
Here's the code:
\begin{table}[H]
\centering
\caption{Enzymatic cocktails and the respective tested concentrations in \%(v/v) used in Combined Hydrolysis}
\label{enzymatic cocktails}
\begin{tabular}{#{}ccc#{}}
\toprule
\textbf{Cocktail} & \textbf{Enzymes} & \textbf{Concentration \%(v/v)} \\ \midrule
\multirow{2}{*}{A} & \multicolumn{1}{c|}{Cellulase} & \multirow{8}{*}{\begin{tabular}[c]{#{}c#{}}0.25\\ 0.50\\ 1.00\end{tabular}} \\
& \multicolumn{1}{c|}{$\boldsymbol{\beta}$-glucosidase} & \\ \cmidrule(r){1-2}
\multirow{3}{*}{B} & \multicolumn{1}{c|}{Cellulase} & \\
& \multicolumn{1}{c|}{$\boldsymbol{\beta}$-glucosidase} & \\
& \multicolumn{1}{c|}{xylanase} & \\ \cmidrule(r){1-2}
\multirow{3}{*}{C} & \multicolumn{1}{c|}{Cellulase} & \\
& \multicolumn{1}{c|}{$\boldsymbol{\beta}$-glucosidase} & \\
& \multicolumn{1}{c|}{$\boldsymbol{\beta}$-glucanase and xylanase} & \\ \bottomrule
\end{tabular}
\end{table}
Vertical lines like in c| and horizontal lines such as toprule, bottomrule, midrule, cmidrule from the package booktabs do not match.
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{table}%[H]
\centering
\caption{Enzymatic cocktails and the respective tested concentrations in \%(v/v) used in Combined Hydrolysis}
\label{enzymatic_cocktails}
\begin{tabular}{#{}ccc#{}}
\hline
\textbf{Cocktail} & \textbf{Enzymes} & \textbf{Concentration \%(v/v)}\\
\hline
\multirow{2}{*}{A} & \multicolumn{1}{c|}{Cellulase} & %
\multirow{8}{*}{\begin{tabular}[c]{#{}c#{}}0.25\\ 0.50\\ 1.00\end{tabular}}\\
& \multicolumn{1}{c|}{$\mathbb{\beta}$-glucosidase} & \\
\cline{1-2}
\multirow{3}{*}{B} & \multicolumn{1}{c|}{Cellulase} & \\
& \multicolumn{1}{c|}{$\boldsymbol{\beta}$-glucosidase} & \\
& \multicolumn{1}{c|}{xylanase} & \\
\cline{1-2}
\multirow{3}{*}{C} & \multicolumn{1}{c|}{Cellulase} & \\
& \multicolumn{1}{c|}{$\mathbb{\beta}$-glucosidase} & \\
& \multicolumn{1}{c|}{$\mathbb{\beta}$-glucanase and xylanase} & \\
\hline
\end{tabular}
\end{table}
\end{document}
So I went back to hlines in my code. Better would be to use the above mentioned package booktabs and avoid vertical lines instead.

How do you add vertical lines to a table?

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}

Wrong column spacing due to multicolumn in latex

in the LaTeX table below, the third column gets too way much spacing due to the long \multicolumn cell in the last line. Can anyone think of a way of getting LaTeX to distribute the additional spacing needed evenly across columns?
\documentclass[11pt]{article}
\usepackage{booktabs}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}{lrrr}
\toprule
& ICE-GB & ICE-SING & ICE-EA \\
\midrule
NP & 619 & 595 & 496 \\
\textbf{Arithmetic mean}& \textbf{1.36} & \textbf{1.33} & \textbf{1.22} \\
SD&0.73 & 0.71 & 0.53 \\
Variation coefficient& 0.54 & 0.52 & 0.44 \\
\midrule
Kruskal Wallis rank sum test&\multicolumn{3}{l}{$H = 16.3941, df = 2, p= 0.0002755123$} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Thanks!
Excess width \multicolumns end up assigning the excess to the last column. You can avoid this by either using a fixed-width \multicolumn - that is, use a p{<len>} column, or for even spreading of columns use a fixed-width column for the non-\multicolumn columns:
\documentclass[11pt]{article}
\usepackage{booktabs,array}
\begin{document}
\noindent
\begin{tabular}{l*{3}{>{\raggedleft\arraybackslash}p{5em}}}
\toprule
& ICE-GB & ICE-SING & ICE-EA \\
\midrule
NP & 619 & 595 & 496 \\
\textbf{Arithmetic mean} & \textbf{1.36} & \textbf{1.33} & \textbf{1.22} \\
SD & 0.73 & 0.71 & 0.53 \\
Variation coefficient & 0.54 & 0.52 & 0.44 \\
\midrule
Kruskal Wallis rank sum test & \multicolumn{3}{r}{$H = 16.3941, df = 2, p= 0.0002755123$} \\
\bottomrule
\end{tabular}
\end{document}
In the above example, the last three columns each have width 5em, and are \raggedleft (similar to an r-column specification).

Resources