我想将每个单元格(第一列)的内容对齐到顶部。这里介绍的方法不适用。也许这与表格环境有关?
\begin{figure}[ht!]
\begin{center}
\begin{tabular}{cccc}
\textbf{(a)} & \begin{tabular}[t]{l} \includegraphics[width=16pc]{example-image1.jpeg} \end{tabular}&\hspace*{-4mm}
\textbf{(b)} & \begin{tabular}[t]{l} \includegraphics[width=16pc]{example-image2.jpeg} \end{tabular}\\
\textbf{(c)} & \begin{tabular}[t]{l} \includegraphics[width=16pc]{example-image3.jpeg} \end{tabular}&\hspace*{-4mm}
\textbf{(d)} & \begin{tabular}[t]{l} \includegraphics[width=16pc]{example-image4.jpeg} \end{tabular}\\
\end{tabular}
\end{center}
\caption{COSMIC-2.}
\label{fig:sec21}
\end{figure}
答案1
像这样?
编辑:
呃,第一列应该在单元格顶部,而不是中间。抱歉造成混淆...
但简化并完成了您的代码片段,MWE是:
\documentclass{article}
\usepackage{array}
\usepackage[export]{adjustbox} % it loads graphicx too
\begin{document}
\begin{table}
\centering
\adjustboxset{width=16pc,
margin=1pt, valign=t % <---
}
\begin{tabular}{@{} >{\bfseries}c cc @{}}
(a) & \adjincludegraphics{example-image-duck} \\
(b) & \adjincludegraphics{example-image-duck} \\
(c) & \adjincludegraphics{example-image-duck} \\
(d) & \adjincludegraphics{example-image-duck}
\end{tabular}
\caption{Test}
\label{test}
\end{table}
\end{document}
答案2
根据@David Carlisle 的建议,我得到了答案
\begin{figure}[ht!]
\begin{center}
\begin{tabular}{cc}
\textbf{(a)}\includegraphics[width=18pc, keepaspectratio=true, valign=t, trim=230 50 100 50, clip]{fig1.jpeg}&\hspace*{-4mm}
\textbf{(b)}\includegraphics[width=18pc, keepaspectratio=true, valign=t, trim=230 50 100 50, clip]{fig2.jpeg}\\
\textbf{(c)}\includegraphics[width=18pc, keepaspectratio=true, valign=t, trim=230 50 100 50, clip]{fig3.jpeg}&\hspace*{-4mm}
\textbf{(d)}\includegraphics[width=18pc, keepaspectratio=true, valign=t, trim=230 50 160 50, clip]{fig4.jpeg}\\
\end{tabular}
\end{center}
\end{figure}
谢谢
答案3
这个想法valign=t
很好,但还可以改进很多。
\documentclass{article}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{booktabs}
\begin{document}
\begin{figure}[!htp]
\centering
\begin{tabular}{@{}ll@{}}
\textbf{(a)} &
\includegraphics[width=18pc, trim=0 100 0 0, clip, valign=t]{example-image} \\
\addlinespace
\textbf{(b)} &
\includegraphics[width=18pc, trim=0 100 0 0, clip, valign=t]{example-image} \\
\addlinespace
\textbf{(c)} &
\includegraphics[width=18pc, trim=0 100 0 0, clip, valign=t]{example-image} \\
\addlinespace
\textbf{(d)} &
\includegraphics[width=18pc, trim=0 100 0 0, clip, valign=t]{example-image} \\
\end{tabular}
\end{figure}
\end{document}
注意\centering
,不是center
环境,而是两列表格,两边都没有填充(用 获得@{}
)。p
还应将 添加到选项中figure
(并且\caption
基本上是强制性的)。
我使用了不同的值进行修剪,因为我不了解您的图片。无需添加keepaspectratio=true
,因为您只指定了宽度。