¿Cómo alinear a la izquierda una matriz dentro de la tabla?

¿Cómo alinear a la izquierda una matriz dentro de la tabla?

Tengo una tabla que contiene dos matrices. Quiero alinear estas matrices a la izquierda, en lugar de alinearlas al centro. Estoy usando el formato IEEE. Además, el soporte []de la matriz está muy cerca del \hlinede la tabla. ¿Podríamos tener alguna forma de hacer un margen entre el corchete y la línea h?

\begin{table*}[!t]
\renewcommand{\arraystretch}{1.3}
\caption{This is table}
\label{table_network_architecture}
\centering
\begin{tabular}{c|c}
\hline
\bfseries Name & \bfseries Matrix  \\
\hline\hline
%Dense 2
Text 1 & $\left[ \begin{array}{c} 30 \times 30 \\ 30 \times 30 \end{array}\right]$\\
\hline
Text 1 & $\left[ \begin{array}{c} 30 \times 30 \\ 30 \times 30 \end{array}\right]-100$\\
\hline
\hline
\end{tabular}   
\end{table*}

Respuesta1

Preferiría la booktabsforma que muestra Gernot, pero si insistes en gobernar tu mesa, puedes usar makecell:

\documentclass{article}
\usepackage{amsmath}
\usepackage{newtxtext,newtxmath}
\usepackage{makecell}

\begin{document}

\begin{table}[htp]
\centering

\caption{This is table}
\label{table_network_architecture}
\medskip

\setcellgapes{3pt}\makegapedcells

\begin{tabular}{l|l}
\hline
\multicolumn{1}{c|}{\bfseries Name} & \multicolumn{1}{c}{\bfseries Matrix} \\
\hline
Text 1 & $\begin{bmatrix} 30 \times 30 \\ 30 \times 30 \end{bmatrix}$ \\
\hline
Text 2, longer & $\begin{bmatrix} 30 \times 30 \\ 30 \times 30 \end{bmatrix}-100$ \\
\hline
\end{tabular}

\end{table}

\end{document}

ingrese la descripción de la imagen aquí

Respuesta2

Para alinear a la izquierda los elementos de una columna, utilice len lugar de ccomo especificador de columna.

El problema del espacio extra no se puede solucionar simplemente aumentando \arraystretch, porque afecta a la tabla de la misma manera que a los arrays. Se puede restablecer a \arraystretch1 inmediatamente antes de las matrices, pero esto todavía no proporciona un buen espacio. Una forma de solucionarlo es utilizar el booktabspaquete.

Observación final: en lugar de \left[\begin{array}{c} ... \end{array}\right]puedes usar \begin{bmatrix} ... \end{bmatrix}; bmatrixestá definido en el paquete amsmath.

ingrese la descripción de la imagen aquí

\documentclass{IEEEtran}
\usepackage{booktabs}
\usepackage{amsmath}
\begin{document}
\begin{tabular}{cl}
\toprule
\bfseries Name & \bfseries Matrix  \\
\midrule
Text 1 & 
$\begin{bmatrix} 30 \times 30 \\ 30 \times 30 \end{bmatrix}$\\
\midrule
Text 1 &
$\begin{bmatrix} 30 \times 30 \\ 30 \times 30 \end{bmatrix}-100$\\
\bottomrule
\end{tabular}   
\end{document}

Respuesta3

Se puede agregar un \fboxsepespacio de 2 puntos ( } en todos los lados usando \fboxwith \fboxrule=0pt.

\documentclass[twocolumn]{article}
\usepackage{mathtools}
\begin{document}
\begin{table*}[!t]
\renewcommand{\arraystretch}{1.3}
\setlength{\fboxrule}{0pt}
\caption{This is table}
\label{table_network_architecture}
\centering
\begin{tabular}{c|l}
\hline
\bfseries Name & \bfseries Matrix  \\
\hline\hline
%Dense 2
Text 1 & \fbox{$\left[ \begin{array}{c} 30 \times 30 \\ 30 \times 30 \end{array}\right]$}\\
\hline
Text 1 & \fbox{$\left[ \begin{array}{c} 30 \times 30 \\ 30 \times 30 \end{array}\right]-100$}\\
\hline
\hline
\end{tabular}   
\end{table*}
\end{document}

manifestación


Alternativamente, se pueden agregar puntales apropiados para texto extra grande usando

\documentclass[twocolumn]{article}
\usepackage{mathtools}

\newcommand{\arraybox}[1]% #1 = extra large text
{\bgroup
  \sbox0{#1}% measure
  \rule{0pt}{\arraystretch\ht0}% top strut
  \rule[-\arraystretch\dp0]{0pt}{0pt}% bottom strut
  \box0
\egroup}

\begin{document}
\begin{table*}[!t]
\renewcommand{\arraystretch}{1.3}
\caption{This is table}
\label{table_network_architecture}
\centering
\begin{tabular}{c|l}
\hline
\bfseries Name & \bfseries Matrix  \\
\hline\hline
%Dense 2
Text 1 & \arraybox{$\left[ \begin{array}{c} 30 \times 30 \\ 30 \times 30 \end{array}\right]$}\\
\hline
Text 1 & \arraybox{$\left[ \begin{array}{c} 30 \times 30 \\ 30 \times 30 \end{array}\right]-100$}\\
\hline
\hline
\end{tabular}   
\end{table*}
\end{document}

demostración 2

información relacionada