我使用以下设置在文档中的图像下方获得一条水平线。
\documentclass[12pt,twoside,openright]{book}
\usepackage[table,xcdraw]{xcolor}
\definecolor{mygray}{gray}{0.8}
\usepackage{graphicx}
\usepackage{mwe}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[CE,CO]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.4pt}
\fancypagestyle{plain}{\pagestyle{fancy}}
\usepackage{subcaption}
\DeclareCaptionFormat{myfigformat}{#1#2#3{\color{mygray}\hrulefill}}
\captionsetup[figure]{format=myfigformat}
\begin{document}
\begin{figure}[ht]
\centering
\includegraphics[width=\linewidth,keepaspectratio]{example-image-a}
\caption{The caption.}
\end{figure}
\lipsum[2-3]
\begin{figure}[ht]
\centering
\includegraphics[width=\linewidth,keepaspectratio]{example-image-a}
\caption{The caption.}
\end{figure}
\lipsum[5-7]
\begin{figure}[ht]
\centering
\includegraphics[width=0.7\linewidth,keepaspectratio]{example-image-a}
\caption{The caption.}
\end{figure}
\end{document}
当图像是页面上的最后一项时,如何确保图像下方没有水平线?在此处给出的示例中,图 3 下方不应有线条。