为什么第 1 列有额外的空间?

为什么第 1 列有额外的空间?

我想要一个非常简单的表格,左列中有一个段落,右列中有一个图像,图像下方有一个标签。出于某种奇怪的原因,LaTeX 在段落前放置了一堆空白,我不知道为什么:

\noindent\begin{tabular}{|p{4in} p{1in}|}
\hline
Note: The strange word which occurs three times on the form above (including alone on the far right column) has been explained to me by a French speaker as the Latin word "idem" meaning "the same" or as we would say colloquially in English, ``ditto.''& \includegraphics[width=1in]{img/ch06-Ditto.png} ``ditto''\\
\hline
\end{tabular}

结果如下:

在此处输入图片描述

有人知道为什么左栏顶部似乎添加了一个额外的空白行吗?

答案1

这是因为图像被设置在第一行的基线,这使得它(垂直)突出于该行之上。

为了避免这种情况,请将图像“提升”到位:

在此处输入图片描述

\documentclass{article}

\usepackage{graphicx}

\begin{document}

\noindent\begin{tabular}{ | p{4in} p{1in} | }
  \hline
  Note: The strange word which occurs three times on the form above (including alone on 
  the far right column) has been explained to me by a French speaker as the Latin 
  word ``idem'' meaning ``the same'' or as we would say colloquially in English, ``ditto.''
  & {\centering\begin{tabular}[t]{ @{} c @{} }
    \raisebox{\dimexpr-\height+.6\normalbaselineskip}{\includegraphics[width=0.5in]{example-image}} \\ 
    ``ditto''
  \end{tabular}\par} \\
  \hline
\end{tabular}

\end{document}

请注意,我已将右侧列设置在它自己的 内tabular。这样,您可以自由地按自己想要的方式换行,而不是强制将换行符作为图像的标签。

答案2

无需猜测:

\documentclass{article}
\usepackage{graphicx}

\begin{document}

\noindent
\begin{tabular}{|p{4in} p{1in}|}
\hline
Note: The strange word which occurs three times on the form above 
(including alone on the far right column) has been explained to me 
by a French speaker as the Latin word ``idem'' meaning ``the same''
or as we would say colloquially in English, ``ditto.''
& \centering
\vspace{-\ht\strutbox}\includegraphics[width=1in,height=0.4in]{example-image} ``ditto''
\tabularnewline
\hline
\end{tabular}

\end{document}

在此处输入图片描述

\vspace将设置第二列中(顶部对齐) parbox 的基线,但我们需要通过 LaTeX 自动添加的支柱高度进行备份。

在代码中我添加了height模拟您的图片;当然您必须将其删除。

相关内容