# How to add a continuous line at the end of every caption?

I am new to lyx. I would like to know what should i write in the LaTeX preamble of the document to add a continuous line at the end of each caption and another line to separate the foot from the text (Just like the line that appears to separate the header from the body text when you use fancy option in page style).

Welcome to TeX.SE! This answer is based on this answer, and both are using the caption package.

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}

\DeclareCaptionTextFormat{myformat}{#1\hrulefill}
\captionsetup[figure]{textformat=myformat}

\begin{document}
\begin{figure}[tb]
\centering
\includegraphics[width=\textwidth]{example-image-duck}
\caption{I'm a caption.}
\label{fig:test}
\end{figure}

\begin{figure}[tb]
\centering
\includegraphics[width=\textwidth]{example-image-duck}
\caption{I'm a very long caption. Normally one should try to avoid long
captions but this here is to illustrate that it works also if the text runs
over several lines.}
\label{fig:testlong}
\end{figure}

\end{document}


• Your code worked well, just like you showed in your images. How ever the best coding for my question is the one you cited in your answer: \usepackage{caption} \DeclareCaptionFormat{myformat}{#1#2#3\hrulefill} \captionsetup[figure]{format=myformat} – Martín Feb 3 '19 at 13:43