我刚刚进入 Latex,我必须制作一些图表等,我用 Tikz 制作了三个具有不同高度的图表,并尝试使用以下代码将它们放入我的主文档中,但是所有三个图表都位于底部,但我希望它们的中心位于同一高度,所以它看起来不像楼梯,有什么方法可以为单个子图的底部添加边距吗?
\documentclass{article}
\usepackage{subfigure}
\usepackage{tikz}
\begin{document}
\textbf{Beispiel:}
\begin{figure}
\centering
\subfigure[a]{\includegraphics\[height=300, width=.40\textwidth\]{example-image-a}}\hfill
\subfigure[b]{\includegraphics\[height=200, width=.30\textwidth\]{example-image-b}}\hfill
\subfigure[c]{\includegraphics\[height=100, width=.15\textwidth\]{example-image-c}}\hfill
\caption{BLIPBLUP}
\end{figure}
\end{document}
答案1
以下是该软件包的解决方案floatrow
:
\documentclass{article}
\usepackage{mwe}
\usepackage{subcaption}
\usepackage{floatrow}
\usepackage{tikz}
\begin{document}
\textbf{Beispiel:}\bigskip
\centering\floatsetup{heightadjust=object, valign=c, floatrowsep=qquad}%
\renewcommand\subfloatrowsep{\hskip 4em}
\ffigbox{\begin{subfloatrow}[3]
\ffigbox[\FBwidth]{\caption{}}{\includegraphics[height=300pt, width=.40\textwidth]{example-image-a}}\hfill
\ffigbox[\FBwidth]{\caption{}}{\includegraphics[height=200pt, width=.30\textwidth]{example-image-b}}\hfill
\ffigbox[\FBwidth]{\caption{}}{\includegraphics[height=100pt, width=.15\textwidth]{example-image-c}}\hfill
\end{subfloatrow}}{\caption{BLIPBLUP}}
\end{document}
答案2
正如 Zarko 在评论中提到的,您可以使用包subfigure
中的环境。环境中的subcaption
可选参数将所有图像对齐到中心。[c]
subfigure
\documentclass{article}
\usepackage[german]{babel}
\usepackage{subcaption}
\usepackage{tikz}
\begin{document}
\textbf{Beispiel:}
\begin{figure}[htbp]
\begin{subfigure}[c]{0.4\textwidth}
\includegraphics[height=300pt, width=\textwidth]{example-image-a}
\end{subfigure}
\hfill
\begin{subfigure}[c]{0.3\textwidth}
\includegraphics[height=200pt, width=\textwidth]{example-image-b}
\end{subfigure}
\hfill
\begin{subfigure}[c]{0.15\textwidth}
\includegraphics[height=100pt, width=\textwidth]{example-image-c}
\end{subfigure}
\caption{BLIPBLUP}
\end{figure}
\end{document}
如果需要为每个子图添加标题,则可以使用环境\caption
内的命令subfigure
。
\documentclass{article}
\usepackage[german]{babel}
\usepackage{subcaption}
\usepackage{tikz}
\begin{document}
\textbf{Beispiel:}
\begin{figure}[htbp]
\begin{subfigure}[c]{0.4\textwidth}
\includegraphics[height=300pt, width=\textwidth]{example-image-a}
\caption{Caption A}\label{fig:a}
\end{subfigure}
\hfill
\begin{subfigure}[c]{0.3\textwidth}
\includegraphics[height=200pt, width=\textwidth]{example-image-b}
\caption{Caption B}\label{fig:b}
\end{subfigure}
\hfill
\begin{subfigure}[c]{0.15\textwidth}
\includegraphics[height=100pt, width=\textwidth]{example-image-c}
\caption{Caption B}\label{fig:c}
\end{subfigure}
\caption{BLIPBLUP}
\end{figure}
\end{document}
答案3
像这样?
图像及其子标题以表格形式组织。表格使用tabularray
包进行组织,图像的垂直对齐基线移至中心。
\documentclass{article}
\usepackage[export]{adjustbox}
\usepackage[skip=0.5ex, font=small, labelfont=bf]{caption}
\usepackage{subcaption}
\usepackage{tabularray}
\UseTblrLibrary{counter,varwidth} % <===
\begin{document}
\begin{figure}[ht]
\centering
\captionsetup[subfigure]{skip=-1.5ex, belowskip=-2.5ex}
\begin{tblr}{colspec={Q[wd=.40\textwidth] Q[wd=.30\textwidth] Q[wd=.15\textwidth]},
measure = vbox} % <===
\includegraphics[height=3cm, width=\linewidth, valign=m]{example-image-a}
& \includegraphics[height=2cm, width=\linewidth, valign=m]{example-image-b}
& \includegraphics[height=1cm, width=\linewidth, valign=m]{example-image-c} \\
\subcaption{} & \subcaption{} & \subcaption{}
\end{tblr}
\caption{BLIPBLUP}
\end{figure}
\end{document}