如何让两张图片顶对齐

2019-10-18 19:06发布

图片我两张高度不同的图片,希望能够顶对齐,不知道怎么弄了,minipage加[t]也没起作用 ```tex \documentclass{article} \usepackage{graphicx} ...

图片我两张高度不同的图片,希望能够顶对齐,不知道怎么弄了,minipage加[t]也没起作用 ```tex \documentclass{article} \usepackage{graphicx} \begin{document} \begin{minipage}[t]{0.45\linewidth} \includegraphics[width=\textwidth]{1.png} \end{minipage} \begin{minipage}[t]{0.45\linewidth} \includegraphics[width=\textwidth]{2.jpg} \end{minipage} \end{document} ``` 下面是测试图片,也可以随便截取![](https://wenda.latexstudio.net/data/attach/191018/pDVjbBO9.jpg)![](https://wenda.latexstudio.net/data/attach/191018/AuGgOHB9.png) 希望得到下面效果 ![](https://wenda.latexstudio.net/data/attach/191018/kh7jUFtB.png)
4条回答
论坛 github.com/C
2019-10-19 12:49 .采纳回答
`minipage` 环境的 `[t]` 选项,是指按照环境内容的第一行基线对齐。对应的,`[b]` 是在末一行对齐。你的内容里只有一行,所以无论用 `[t]` 还是 `[b]`,效果是相同的。 从便利的角度,可以使用 `graphbox` 宏包。它给 `\includegraphics[]{}` 增加了几个选项,其中就有控制纵向对齐的 `align=t|c|b` 选项。 ```tex \documentclass{article} %\usepackage{graphicx} \usepackage{graphbox} % loads graphicx \usepackage{mwe} \begin{document} \newcommand{\test}[1]{% xx \includegraphics[height=3cm, #1]{example-image} \includegraphics[height=2cm, #1]{example-image} xx\par } \test{} \test{align=t} \test{align=c} \end{document} ``` ![](https://wenda.latexstudio.net/data/attach/191019/h4JZQBsP.png) `adjustbox` 可以认为是 `graphbox` 的进阶版,可配置项众多,有时会有副作用。

一周热门 更多>