表格中嵌入的数字前总是有一个空格-我该如何去掉它?

表格中嵌入的数字前总是有一个空格-我该如何去掉它?

我正在将图形放在 tabularx 中,但无法正确嵌入它们。图形前面总是出现烦人的间隔符...现在,如果这个间隔符可以在图形前后均匀分布,我就不介意了,但它总是在左边 - 无论我怎么尝试(>\centering 不起作用,>\raggedright 也不起作用)。

你有什么建议吗?

这是我的代码和屏幕截图:

\begin{table*}[t!]
%make things in tabularx columns vertically centered
\renewcommand{\tabularxcolumn}[1]{>{\small}m{#1}}
\newcolumntype{y}{>{\small\centering\arraybackslash}X}
\centerline{
\begin{small}
\begin{tabularx}{7in}{>{\small\raggedright\arraybackslash}p{0.05\textwidth}|y|y|y|y|y|y|y|y|}
Symbol  &
\includegraphics[width=0.70in]{../images/paper/charlie.jpg}&
\includegraphics[width=0.70in]{../images/paper/charlie.jpg}& 
\includegraphics[width=0.70in]{../images/paper/charlie.jpg}& 
\includegraphics[width=0.70in]{../images/paper/charlie.jpg}& 
\includegraphics[width=0.70in]{../images/paper/charlie.jpg}& 
\includegraphics[width=0.70in]{../images/paper/charlie.jpg}& 
\includegraphics[width=0.70in]{../images/paper/charlie.jpg}& 
\includegraphics[width=0.70in]{../images/paper/charlie.jpg}\\ \hline
B   & & & test & is text centered &
\end{tabularx}
\end{small}}
    \caption{RAAAAAAAAAGE}
    \label{tab:rage}    
\renewcommand{\tabularxcolumn}[1]{>{\small}p{#1}}
\end{table*}

来自地狱的令人恼火的空间。

编辑:经过一番折腾,我认为这些空格是边距,因为我的表格太拥挤,所以它们在右侧被省略了……因此,减小图像尺寸就解决了这个问题。完毕!但是,如果您还有什么要补充的,请继续,我很乐意听听您的意见!

这是我移除一列以腾出空间后的样子…… 不再愤怒

答案1

我不确定还能说什么。您可能对控制 tabcolsep 参数感兴趣:

\documentclass[10pt]{article}
\usepackage{tabularx}
\usepackage{xcolor}

\begin{document}

\begin{tabular}{c|c|c}
\colorbox{yellow}{point}& \colorbox{yellow}{point}&\colorbox{yellow}{point} \\
\end{tabular}

\setlength\tabcolsep{0pt}
\begin{tabular}{c|c|c}
\colorbox{red}{line}& \colorbox{blue}{line}&\colorbox{green}{line} \\
\end{tabular}

\end{document}

答案2

修改\tabcolsep是一个可行的解决方案。然而,不是一般来说,这是最好的解决方法,因为它会产生“文档全局”效果,而不是“表局部”效果。换句话说,以这种方式编码,所有后续的表格布局都会受到它的影响。因此,您很少会看到像这样编写的 TeX/LaTeX 代码。更常见的方法是@{}在表格列说明符中插入您想要消除 TeX 提供的额外列填充的位置。

(顺便说一句,您可以在括号之间包含任何您想要的内容@{},例如,@{:}引入:列分隔符。在您的情况下,您不需要任何东西,因此{}参数为空。)

这里有一些代码来说明一些更标准的替代方案:

\documentclass[10pt]{article}
\usepackage{tabularx}
\usepackage{xcolor}

\begin{document}

% Problem: unwanted column separator spacing
\begin{tabular}{|c|c|c}
\colorbox{red}{box}&\colorbox{yellow}{box}&\colorbox{green}{box} \\
\end{tabular}\vspace{\baselineskip}

% Solution 1: Eliminates column spacing. However, the effect is global. Unless
%             some care is taken by inserting it in a group or by manually
%             saving and restoring the column separator spacing, it breaks
%             subsequent table layouts.
\setlength\tabcolsep{0pt}
\begin{tabular}{|c|c|c|}
\colorbox{red}{box}&\colorbox{yellow}{box}&\colorbox{green}{box} \\
\end{tabular}\vspace{\baselineskip}

% Solution 1b: fixes the problem introduced in the solution above.
\begingroup
\setlength\tabcolsep{0pt}
\begin{tabular}{|c|c|c|}
\colorbox{red}{box}&\colorbox{yellow}{box}&\colorbox{green}{box} \\
\end{tabular}\vspace{\baselineskip}
\endgroup

% Solution 2: `TeX-standard' solution - include `@{}' at places where extra
%             columnar padding is unwanted.
\begin{tabular}{|@{}c@{}|@{}c@{}|@{}c@{}|}
\colorbox{red}{box}&\colorbox{yellow}{box}&\colorbox{green}{box} \\
\end{tabular}\vspace{\baselineskip}

% Solution 2b: Best solution - write `*{n}{column pattern}' to repeat the pattern
%              n times (saves a little typing, maybe easier to maintain).
\begin{tabular}{*{3}{|@{}c@{}}|}
\colorbox{red}{box}&\colorbox{yellow}{box}&\colorbox{green}{box} \\
\end{tabular}

\end{document}

答案3

在图片前留一个空格,就在&(更准确地说是换行符)后面。我很确定只需注释就可以了:

\includegraphics[width=0.70in]{../images/paper/charlie.jpg}&%

相关内容