我使用subcaptionbox
来对齐图像和标题,因为我的标题长度不同。但是,我无法缩小图像的尺寸。如果我更改宽度,标题宽度也会更改。我想保持相同的宽度,但图像要小一些。
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\subcaptionbox{person, shirt
\label{fig:shirtperson}}
{\includegraphics[width=.24\linewidth]
{figures/shirtperson}}
\hfill
\subcaptionbox{person, shirt, jacket
\label{fig:shirtjacketperson}}
{\includegraphics[width=.24\linewidth]
{figures/shirtjacketperson}}\hfill
\subcaptionbox{person, shirt, jacket, glasses\label{fig:shirtjacketglassesperson}}
{\includegraphics[width=.24\linewidth]
{figures/shirtjacketglassesperson}}
\hfill
\subcaptionbox{person, stripedshirt
\label{fig:stripedshirtperson}}
{\includegraphics[width=.24\linewidth]
{figures/stripedshirtperson}}
\caption{Image product variants}
\label{fig:imageproductvariants}
\end{figure}
\end{document}
答案1
您可以使用以下\includegraphics
设置包围\makebox
宽度\makebox[<width>][<alignment>]{\includegraphics[<options>]{<image>}}
:
\documentclass[]{article}
\usepackage{subcaption}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\subcaptionbox{person, shirt
\label{fig:shirtperson}}
{\makebox[0.24\linewidth][c]{\includegraphics[width=.1\linewidth]
{example-image-a}}}
\hfill
\subcaptionbox{person, shirt, jacket
\label{fig:shirtjacketperson}}
{\includegraphics[width=.24\linewidth]
{example-image-b}}\hfill
\subcaptionbox{person, shirt, jacket, glasses\label{fig:shirtjacketglassesperson}}
{\includegraphics[width=.24\linewidth]
{example-image-a}}
\hfill
\subcaptionbox{person, stripedshirt
\label{fig:stripedshirtperson}}
{\includegraphics[width=.24\linewidth]
{example-image-b}}
\caption{Image product variants}
\label{fig:imageproductvariants}
\end{figure}
\end{document}
答案2
我更愿意使用可选参数 '[⟨width⟩]' \subcaptionbox
:
\subcaptionbox[⟨list entry⟩]{⟨heading⟩}[⟨width⟩][⟨inner-pos⟩]{⟨contents⟩}
以下是代码:
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\subcaptionbox{person, shirt
\label{fig:shirtperson}}
[.24\linewidth]
{\includegraphics[width=.5\linewidth]
{example-image}}
\hfill
\subcaptionbox{person, shirt, jacket
\label{fig:shirtjacketperson}}
{\includegraphics[width=.24\linewidth]
{example-image-a}}\hfill
\subcaptionbox{person, shirt, jacket, glasses\label{fig:shirtjacketglassesperson}}
{\includegraphics[width=.24\linewidth]
{example-image-b}}
\hfill
\subcaptionbox{person, stripedshirt
\label{fig:stripedshirtperson}}
{\includegraphics[width=.24\linewidth]
{example-image-c}}
\caption{Image product variants}
\label{fig:imageproductvariants}
\end{figure}
\end{document}
其实在子标题的文档中已经有了对此的详细描述: