关于我的上一个问题和答案由 egreg 提供。现在我想添加一列。
我如何在这两列和文本之间添加更多空间?
另外,如果您有任何想法让它看起来更美观,请提出建议。
\documentclass[journal]{IEEEtran}
\usepackage{booktabs,capt-of}
\usepackage{array,multirow,bm,adjustbox}
\usepackage{blindtext}
\begin{document}
\blindtext[1]
\begin{table}[!t]
\centering
\caption{A table}
\label{tab:table 1}
\begin{adjustbox}{max width=\linewidth}
$\setlength{\arraycolsep}{1pt}
\begin{array}{cc@{}cccccccl @{}c }
\toprule
\textbf{No} & \multicolumn{9}{c}{\textbf{Example}} & \multicolumn{1}{c}{\textbf{Comment}} \\
\midrule
1 & ( & x_1, & x_2, & x_3, & x_1, & x_5, & x_6, & x_7 & ) & \begin{tabular}[l]{@{}l@{}}This is an example \\of two line text\end{tabular}\\
\addlinespace
2 & ( & y_1, & y_2, & y_3, & y_4, & y_5, & y_6, & y_7 & ) &\begin{tabular}[l]{@{}l@{}}Two lines \\for the second row\end{tabular}\\
\addlinespace
3 & ( & z_1, & z_2, &-z_8-z_3, & z_2, & z_5, &-z_1-z_4, & z_1 & ) \\
\bottomrule
\end{array}$
\end{adjustbox}
\end{table}
\end{document}
答案1
你@{}
有一个论点,可能是,例如\hspace
:
\documentclass[journal]{IEEEtran}
\usepackage{booktabs,capt-of}
\usepackage{array,multirow,bm,adjustbox}
\usepackage{blindtext}
\begin{document}
\blindtext[1]
\begin{table}[!t]
\centering
\caption{A table}
\label{tab:table 1}
\begin{adjustbox}{max width=\linewidth}
$\setlength{\arraycolsep}{1pt}
%\begin{array}{cc@{}cccccccl @{}c }
\begin{array}{cc@{}cccccccl @{\hspace{9pt}}c }
\toprule
\textbf{No} & \multicolumn{9}{c}{\textbf{Example}} & \multicolumn{1}{c}{\textbf{Comment}} \\
\midrule
1 & ( & x_1, & x_2, & x_3, & x_1, & x_5, & x_6, & x_7 & ) & \begin{tabular}[l]{@{}l@{}}This is an example \\of two line text\end{tabular}\\
\addlinespace
2 & ( & y_1, & y_2, & y_3, & y_4, & y_5, & y_6, & y_7 & ) &\begin{tabular}[l]{@{}l@{}}Two lines \\for the second row\end{tabular}\\
\addlinespace
3 & ( & z_1, & z_2, &-z_8-z_3, & z_2, & z_5, &-z_1-z_4, & z_1 & ) \\
\bottomrule
\end{array}$
\end{adjustbox}
\end{table}
\end{document}
答案2
我建议您使用一个tabular*
环境并将其整体宽度设置为\columnwidth
。然后,在最后一列(文本)的左侧提供一些额外的空白,就像以下示例中使用的那样。
\documentclass[journal]{IEEEtran}
\usepackage{booktabs,array,bm}
\newcolumntype{C}{>{$}c<{$}} % automatic math mode
\usepackage{lipsum}
\begin{document}
\begin{table}[!t]
\caption{A table} \label{tab:table 1}
\setlength{\tabcolsep}{0pt}
\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}} l *{7}{C} @{\quad} l }
\toprule
\textbf{No} & \multicolumn{7}{c}{\textbf{Example}} & \multicolumn{1}{c}{\textbf{Comment}} \\
\midrule
1 & (x_1, & x_2, & x_3, & x_1, & x_5, & x_6, & x_7) &
\begin{tabular}[c]{@{}l@{}}
This is an example \\of two line text
\end{tabular}\\
\addlinespace
2 & (y_1, & y_2, & y_3, & y_4, & y_5, & y_6, & y_7) &
\begin{tabular}[c]{@{}l@{}}
Two lines \\for the second row
\end{tabular}\\
\addlinespace
3 & (z_1, & z_2, &-z_8-z_3, & z_2, & z_5, &-z_1-z_4, & z_1) \\
\bottomrule
\end{tabular*}
\end{table}
\lipsum
\end{document}
答案3
Shortunderstack
您可以使用命令进行对齐stackengine
。至于最后一列的间距,添加,例如,\quad
在 内@{}
:
\documentclass[journal]{IEEEtran}
\usepackage{booktabs,capt-of}
\usepackage{array,multirow,bm,adjustbox}
\usepackage[usestackEOL]{stackengine}
\usepackage{blindtext}
\begin{document}
\blindtext[1]
\begin{table}[!t]
\centering
\caption{A table}
\label{tab:table 1}
\begin{adjustbox}{max width=\linewidth}
$\setlength{\arraycolsep}{1pt}
\begin{array}{cc@{}cccccccl @{\quad}c }
\toprule
\textbf{No} & \multicolumn{9}{c}{\textbf{Example}} & \multicolumn{1}{c}{\textbf{Comment}} \\
\midrule
1 & ( & x_1, & x_2, & x_3, & x_1, & x_5, & x_6, & x_7 & ) & \Shortunderstack[l]{This is an example \\ of two line text}\\
\addlinespace
2 & ( & y_1, & y_2, & y_3, & y_4, & y_5, & y_6, & y_7 & ) & \Shortunderstack[l]{Two lines \\for the second row
}\\
\addlinespace
3 & ( & z_1, & z_2, &-z_8-z_3, & z_2, & z_5, &-z_1-z_4, & z_1 & ) \\
\bottomrule
\end{array}$
\end{adjustbox}
\end{table}
\end{document}