테이블 내부의 행렬을 왼쪽 정렬하는 방법은 무엇입니까?

테이블 내부의 행렬을 왼쪽 정렬하는 방법은 무엇입니까?

두 개의 행렬이 포함된 테이블이 있습니다. 중앙 정렬 대신 이 행렬을 왼쪽 정렬하고 싶습니다. IEEE 형식을 사용하고 있습니다. 또한 행렬의 브래킷은 테이블의 []브래킷과 매우 가깝습니다 . \hline대괄호와 hline 사이에 여백을 만들 수 있는 방법이 있나요?

\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*}

답변1

나는 gernot이 보여준 방식을 선호 booktabs하지만 테이블 지배를 고집한다면 다음을 사용할 수 있습니다 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}

여기에 이미지 설명을 입력하세요

답변2

열의 요소를 왼쪽 정렬하려면 l대신 c열 지정자로 사용하세요.

추가 공간 문제는 \arraystretch배열과 마찬가지로 테이블에도 영향을 미치기 때문에 단순히 를 늘리는 것만으로는 해결할 수 없습니다. \arraystretch배열 바로 앞에서 을 1로 재설정할 수 있지만 여전히 좋은 간격이 제공되지 않습니다. 이를 해결하는 한 가지 방법은 패키지 를 사용하는 것입니다 booktabs.

최종 설명: 대신에 ; \left[\begin{array}{c} ... \end{array}\right]를 사용할 수 있습니다 \begin{bmatrix} ... \end{bmatrix}. bmatrix패키지에 정의되어 있습니다 amsmath.

여기에 이미지 설명을 입력하세요

\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}

답변3

with 를 \fboxsep사용하면 모든 면에 2pt( } 간격을 추가할 수 있습니다 .\fbox\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}

데모


또는 다음을 사용하여 매우 큰 텍스트에 적합한 스트럿을 추가할 수 있습니다.

\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}

데모 2

관련 정보