[Tex/LaTex] Horizontal line below figure caption

captionsrules

I would like to draw a horizontal line/rule beneath my multi-line caption to separate the caption more clearly from the rest of the text.

A quick example:

\begin{figure}[tb]
  \begin{center}
    \includegraphics[width=\textwidth]{./fig/test}
  \end{center}
  \caption{`Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
            do eiusmod tempor incididunt ut labore et dolore magna aliqua.
            Ut enim ad minim veniam, quis nostrud exercitation ullamco
            laboris nisi ut aliquip ex ea commodo consequat. Duis aute
            irure dolor in reprehenderit in voluptate velit esse cillum
            dolore eu fugiat nulla pariatur. Excepteur sint occaecat
            cupidatat non proident, sunt in culpa qui officia deserunt
            mollit anim id est laborum`}
  \label{fig:test}
\end{figure}

At the end of the caption I would like to put something like \newline\hrule or something similiar to the suggestions made in a related post:

Best Answer

You can use the caption package to define a new caption format incorporating the rule; something along these lines:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}

\DeclareCaptionFormat{myformat}{#1#2#3\hrulefill}
\captionsetup[figure]{format=myformat}

\begin{document}
\begin{figure}[tb]
  \centering
    \includegraphics[width=\textwidth]{./fig/test}
  \caption{`Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
            do eiusmod tempor incididunt ut labore et dolore magna aliqua.
            Ut enim ad minim veniam, quis nostrud exercitation ullamco
            laboris nisi ut aliquip ex ea commodo consequat. Duis aute
            irure dolor in reprehenderit in voluptate velit esse cillum
            dolore eu fugiat nulla pariatur. Excepteur sint occaecat
            cupidatat non proident, sunt in culpa qui officia deserunt
                mollit anim id est laborum`}
  \label{fig:test}
\end{figure}

\end{document}

Here's the result:

I used the demo option for the graphicx package in order to make my example compilable for everyone; do not include that option in your actual code.