2 つのマトリックスを含む表があります。これらのマトリックスを中央揃えではなく左揃えにしたいです。IEEE 形式を使用しています。また、[]
マトリックスの括弧が表の に非常に近いです\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 にリセットすることはできますが、それでも適切なスペースは得られません。 これを解決する 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}