3

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).

3

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}

enter image description here

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.