我目前得到的是:
\begin{figure}[tph]
\begin{minipage}[b]{0.6\textwidth}
\begin{table}[H]
\begin{tabular}{|l|l|l|l|}
\hline
Term & doc\_1& doc\_2& doc\_3\\ \hline
largest & 0.5 & 0.0 & 0.0 \\ \hline
university & 1.0 & 1.0 & 1.0 \\ \hline
oldest & 0.5 & 0.0 & 0.0 \\ \hline
research & 0.5 & 0.0 & 0.0 \\ \hline
1928 & 0.0 & 1.0 & 0.0 \\ \hline
bjarne & 0.0 & 0.0 & 1.0 \\ \hline
founded & 0.0 & 1.0 & 0.0 \\ \hline
second & 0.5 & 0.0 & 0.0 \\ \hline
denmark & 0.5 & 1.0 & 0.0 \\ \hline
stroustrup & 0.0 & 0.0 & 1.0 \\ \hline
aarhus & 0.5 & 1.0 & 1.0 \\ \hline
alumni & 0.0 & 0.0 & 1.0 \\ \hline
\end{tabular}
\end{table}
\end{minipage}
\hfill
\begin{minipage}[b]{0.3\textwidth}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{minipage}
\end{figure}
答案1
- 您的示例中的另一个问题是:在 内部
minipage
,您不应该使用 浮动环境table
。并且没有必要这样做。 - 要将表格和文本段落并排对齐:删除(或注释掉) 上方和下方的空行
\hfill
。LaTeX 将连续的换行符视为\par
。 - 其他改进:
- 用于
[t]
垂直对齐minipage
并tabular
位于其环境内容第一行的基线。 - 使用
\firsthline
来自array
包的第一行来对齐tabular
,而不是第一个\hline
。
- 用于
完整示例:
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{figure}[tph]
\begin{minipage}[t]{0.6\textwidth}%
\begin{tabular}[t]{|l|l|l|l|}
\firsthline
Term & doc\_1& doc\_2& doc\_3\\ \hline
largest & 0.5 & 0.0 & 0.0 \\ \hline
university & 1.0 & 1.0 & 1.0 \\ \hline
oldest & 0.5 & 0.0 & 0.0 \\ \hline
research & 0.5 & 0.0 & 0.0 \\ \hline
1928 & 0.0 & 1.0 & 0.0 \\ \hline
bjarne & 0.0 & 0.0 & 1.0 \\ \hline
founded & 0.0 & 1.0 & 0.0 \\ \hline
second & 0.5 & 0.0 & 0.0 \\ \hline
denmark & 0.5 & 1.0 & 0.0 \\ \hline
stroustrup & 0.0 & 0.0 & 1.0 \\ \hline
aarhus & 0.5 & 1.0 & 1.0 \\ \hline
alumni & 0.0 & 0.0 & 1.0 \\ \hline
\end{tabular}
\end{minipage}
%
\hfill
%
\begin{minipage}[t]{0.3\textwidth}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{minipage}
\end{figure}
\end{document}