Centrar un valor en una fila con varias columnas

Centrar un valor en una fila con varias columnas

Tengo la siguiente tabla con 5 filas con una primera columna de texto y 4 columnas de datos:

\newenvironment{mytable}[1][h!]{\begin{table}[#1]\centering\small}{\end{table}} 

\begin{mytable}
\begin{center}
\begingroup
\setlength{\tabcolsep}{3pt} % Default value: 6pt
\renewcommand{\arraystretch}{1} % Default value: 1
\begin{tabular}{|c|c|c|c|c|}
\hline
\addstackgap{Redshift central bin} & 1.0 & 1.2 & 1.4 & 1.65 \\ \hline
\addstackgap{$\mathrm{d}N / \mathrm{d}\Omega\mathrm{d}z\left[\mathrm{deg}^{-2}\right]$} & 1815.0 & 1701.5 & 1410.0 & 940.97 \\ \hline
\addstackgap{$\Delta z$ : width of bin} & 0.2 & 0.2 & 0.2 & 0.3 \\ \hline
\addstackgap{$\rho_{gal}$\,(gal.arcmin$^{-2}$}) & 0.1008 & 0.0945 & 0.0783 & 0.0784 \\ \hline
\addstackgap{$\rho_{gal,tot}$\,(gal.arcmin$^{-2}$)} & 
\multicolumn{1}{c}{}  0.3521 &
\multicolumn{1}{c}{} &  
\multicolumn{1}{c}{} & \\
\hline
\end{tabular}
\endgroup
\end{center}
\caption{Spectroscopic specifications from \citetalias{IST:paper1} with 4 bins}
\label{density1}
\end{mytable}\\

Aquí está la representación:

mesa

Me gustaría mantener el mismo formato excepto el hecho de que debo centrar el valor 0.3521en la última fila, entre la primera y la cuarta columna.

¿Alguien podría ver cómo realizar este centrado?

Respuesta1

Para obtener información, aquí se explica la forma de construir esa tabla con nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\begin{table}
\centering
\renewcommand{\arraystretch}{1.4}
\begin{NiceTabular}{ccccc}[hvlines]
Redshift central bin & 1.0 & 1.2 & 1.4 & 1.65 \\ 
$\mathrm{d}N / \mathrm{d}\Omega\mathrm{d}z\left[\mathrm{deg}^{-2}\right]$ & 1815.0 & 1701.5 & 1410.0 & 940.97 \\ 
$\Delta z$ : width of bin & 0.2 & 0.2 & 0.2 & 0.3 \\ 
$\rho_{gal}$\,(gal.arcmin$^{-2}$) & 0.1008 & 0.0945 & 0.0783 & 0.0784 \\ 
$\rho_{gal,tot}$\,(gal.arcmin$^{-2}$) & \Block{1-4}{0.3521}
\end{NiceTabular}
\caption{Spectroscopic specifications from XXXXXXX with 4 bins}\label{density1}
\end{table}

\end{document}

Salida del código anterior

Respuesta2

Me gustaría mostrarles una solución con tabularray:

\documentclass{article}
\usepackage{tabularray}

\newenvironment{mytable}[1][h]{\begin{table}[#1]\centering\small}{\end{table}} 

\begin{document}

\begin{mytable}
\begin{tblr}{
    colspec={*5{c}},
    hlines,vlines,
    rows={rowsep+=2pt},
    colsep=3pt
    }
Redshift central bin & 1.0 & 1.2 & 1.4 & 1.65 \\ 
$\mathrm{d}N / \mathrm{d}\Omega\mathrm{d}z\left[\mathrm{deg}^{-2}\right]$ & 1815.0 & 1701.5 & 1410.0 & 940.97 \\ 
$\Delta z$ : width of bin & 0.2 & 0.2 & 0.2 & 0.3 \\ 
$\rho_{gal}$\,(gal.arcmin$^{-2}$) & 0.1008 & 0.0945 & 0.0783 & 0.0784 \\ 
$\rho_{gal,tot}$\,(gal.arcmin$^{-2}$) & 
\SetCell[c=4]{c} 0.3521 &&&\\
\end{tblr}
\caption{Spectroscopic specifications from XXXXXXX with 4 bins}\label{density1}
\end{mytable}

\end{document}

ingrese la descripción de la imagen aquí

Sin embargo, con su MWE, como sugiere Frabjous, use \multicolumn{4}{c|}{0.3521}:

\documentclass{article}
\usepackage{stackengine}

\newenvironment{mytable}[1][h]{\begin{table}[#1]\centering\small}{\end{table}} 

\begin{document}

\begin{mytable}
%\begin{center}<--- no, you're already using \centering and see https://tex.stackexchange.com/questions/23650/when-should-we-use-begincenter-instead-of-centering
%\begingroup<--- Why this? you're already in a group
\setlength{\tabcolsep}{3pt} % Default value: 6pt
\renewcommand{\arraystretch}{1} % Default value: 1
\begin{tabular}{|c|c|c|c|c|}
\hline
\addstackgap{Redshift central bin} & 1.0 & 1.2 & 1.4 & 1.65 \\ \hline
\addstackgap{$\mathrm{d}N / \mathrm{d}\Omega\mathrm{d}z\left[\mathrm{deg}^{-2}\right]$} & 1815.0 & 1701.5 & 1410.0 & 940.97 \\ \hline
\addstackgap{$\Delta z$ : width of bin} & 0.2 & 0.2 & 0.2 & 0.3 \\ \hline
\addstackgap{$\rho_{gal}$\,(gal.arcmin$^{-2}$)} & 0.1008 & 0.0945 & 0.0783 & 0.0784 \\ \hline
\addstackgap{$\rho_{gal,tot}$\,(gal.arcmin$^{-2}$)} & \multicolumn{4}{c|}{0.3521} \\
\hline
\end{tabular}
%\endgroup
%\end{center}
\caption{Spectroscopic specifications from XXXXXXX with 4 bins}\label{density1}
\end{mytable}%\\<--- don't use \\ outside tables

\end{document}

ingrese la descripción de la imagen aquí

información relacionada