![如何证明子图子浮点数的合理性?](https://linux22.com/image/243101/%E5%A6%82%E4%BD%95%E8%AF%81%E6%98%8E%E5%AD%90%E5%9B%BE%E5%AD%90%E6%B5%AE%E7%82%B9%E6%95%B0%E7%9A%84%E5%90%88%E7%90%86%E6%80%A7%EF%BC%9F.png)
我有三个子浮点数,我想让它们与整个对齐\textwidth
,无论它们的尺寸是多少(当然小于页面的三分之一)。
我有以下设置:
\begin{figure} %
\centering
\subfloat[subcaption 1]{%
\includegraphics[width=0.2\textwidth]{image1}} %
%
\subfloat[subcaption 2]{%
\includegraphics[width=0.2\textwidth]{image2}} %
%
\subfloat[subcaption 3]{%
\includegraphics[width=0.2\textwidth]{image3}} %
\caption{%
\label{fig:trans_actions} %
Some caption text here. This is the full textwidth.}
\end{figure}
如何让图像与文本的整个宽度对齐?
答案1
只需添加\hfill
以展开图形,即可添加可根据需要水平拉伸和收缩的橡胶长度。
[showframe]
包装选项用于geometry
显示图形和边距的位置。
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage[demo]{graphicx}% Remove demo option in real document
\usepackage{caption}
\usepackage{subfig}
\begin{document}
\begin{figure}
\centering
\subfloat[subcaption 1]{\includegraphics[width=0.2\textwidth]{image1}}
\hfill
\subfloat[subcaption 2]{\includegraphics[width=0.2\textwidth]{image2}}
\hfill
\subfloat[subcaption 3]{\includegraphics[width=0.2\textwidth]{image3}}
\caption{\label{fig:trans_actions}
Some caption text here. This is the full textwidth.}
\end{figure}
\end{document}
正如 Werner 指出的那样,上述解决方案将图形的边缘与边距对齐。如果您还想在图形和边距之间留出间距,请\null\hfill
在左侧和\hfill\null
右侧添加。
\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage[demo]{graphicx}% Remove demo option in real document
\usepackage{caption}
\usepackage{subfig}
\begin{document}
\begin{figure}
\centering
\null\hfill
\subfloat[subcaption 1]{\includegraphics[width=0.2\textwidth]{image1}}
\hfill
\subfloat[subcaption 2]{\includegraphics[width=0.2\textwidth]{image2}}
\hfill
\subfloat[subcaption 3]{\includegraphics[width=0.2\textwidth]{image3}}
\hfill\null
\caption{\label{fig:trans_actions}
Some caption text here. This is the full textwidth.}
\end{figure}
\end{document}