我在 Latex 中创建了一个 3x3 表格,其中右侧第一行的两个单元格合并在一起。它看起来像这样:
但是,当我导入图像时,右侧的文本(第一行,右侧的两个合并单元格)会向下跳动 4-5 行,导致间距过大。使用了以下代码:
\begin{table}[ht!]
\centering
\begin{tabular}{|l|l|l|}
\hline
\multicolumn{1}{|l}{\includegraphics[width=3.8cm]{logo}} & \multicolumn{2}{c|}{\begin{tabular}[c]{@{}c@{}}\textbf{Something} \\ \\ \textbf{asdsad - random text}\\\textbf{{dasdasd - Random text}}\\ \\ asdasdf - random text \\ \\
\end{tabular}} \\
\hline
\begin{tabular}[c]{@{}l@{}}
{\scriptsize Approved}\\2\end{tabular} & \begin{tabular}[c]{@{}l@{}}{\scriptsize 1}\\2\end{tabular} & \begin{tabular}[c]{@{}l@{}}{\scriptsize 1}\\2\end{tabular} \\
\hline
\begin{tabular}[c]{@{}l@{}} \\2\end{tabular} & \begin{tabular}[c]{@{}l@{}}{\scriptsize 1}\\2\end{tabular} & \begin{tabular}[c]{@{}l@{}}{\scriptsize 1}\\2\end{tabular} \\
\hline
\end{tabular}
\end{table}
有人知道如何将文本重新对齐到单元格顶部且仅留一个空行吗?
答案1
\documentclass{article}
\usepackage[export]{adjustbox} % it also load graphicx
\usepackage{makecell, tabularx}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\begin{document}
\begin{table}[ht!]
\centering
\begin{tabularx}{\linewidth}{ |>{\scriptsize}l|*{2}{>{\scriptsize}X|} }
\hline
\includegraphics[width=3.8cm, valign=c]{example-image-duck}
& \multicolumn{2}{>{\bfseries}c|}{\makecell{Something\\ \\
asdsad - random text\\
dasdasd - Random text\\ \\
asdasdf - random text}} \\
\hline
\makecell[l]{1\\ 2} & \makecell[l]{1\\2 } & \makecell[l]{1\\2 } \\
\hline
\makecell[l]{1\\ 2} & \makecell[l]{1\\2 } & \makecell[l]{1\\2 } \\
\hline
\end{tabularx}
\end{table}
\end{document}
给出
(红线表示文字边框)