答案1
将字幕格式定义为
\usepackage{xcolor}
\usepackage[labelfont=bf]{caption}
\newcommand\myhrulefill[1]{\leavevmode\leaders\hrule height#1\hfill\kern0pt}
\DeclareCaptionFormat{myformat}{{\color[RGB]{152,204,204}\myhrulefill{0.08em}}\\#1#2#3}
\captionsetup[figure]{format=myformat}
您的代码中缺少的只是 之后的行尾\hrulefill
。 的参数\myhrulefill
是线的粗细。
\documentclass{article}
\usepackage{graphicx,xcolor}
\usepackage[labelfont=bf]{caption}
\newcommand\myhrulefill[1]{\leavevmode\leaders\hrule height#1\hfill\kern0pt}
\DeclareCaptionFormat{myformat}{{\color[RGB]{152,204,204}\myhrulefill{0.08em}}\\#1#2#3}
\captionsetup[figure]{format=myformat}
\begin{document}
\begin{figure}
\centering
\includegraphics[width=0.5\textwidth]{example-image}
\caption{Schematic diagram to visualise the flow of the experiment bla bla bla bla bla bla bla bla bla bla bla bla bla}
\end{figure}
\end{document}