I use Lyx 2.1. I want to frame the figures. I inserted a simple box and I put the figure inside it.

But, I encountered these errors :

enter image description here

  • 1
    As I asked in the other question, should the caption be included in the frame? Also, LyX is being useless here, so it is totally impossible to know exactly what causes those errors from your screenshot. Create a LyX document that contains only such a figure, export it to LaTeX, and edit your question to include the LaTeX code. Jun 14, 2014 at 16:54
  • Also, should the frame be the width of the text, or just enclose the image? Jun 14, 2014 at 16:58
  • If I remove the frame, the errors will be deleted. just enclose the image and his legend.
    – GoldRay
    Jun 14, 2014 at 18:18

1 Answer 1


Three different ways, for three different scenarios.

1. Frame tightly enclosing image

Step by step:

  1. Add a Figure float, with Insert --> Float --> Figure, or the enter image description here button on the toolbar.

  2. Add a framebox with Insert --> Box --> Simple frame inside the Figure float.

  3. Right click the box and choose Settings.

  4. Set the Inner box to None, and remove the checkmark from the Width box:

    enter image description here

  5. Insert the image inside this box, with Insert --> Graphics or the enter image description here button on the toolbar.

enter image description here

2. Just image inside frame, frame width of the text

If the caption should not be inside the frame, go to Document --> Settings --> LaTeX preamble, and add the following:


This will make all your figures (added with Insert --> Float --> Figure, or the corresponding button on the toolbar) framed.

enter image description here

If you want the caption a little further away from the frame in this case, replace the three code lines above with

    \moveleft3.4pt\vbox{\advance\hsize by6.8pt
      \hrule \hbox to\hsize{\vrule\kern3pt


3. Both caption and image inside frame

You can use Peter Grill's answer to Rounded corner colored box around figure. For a simple black frame, and add this code to the LaTeX preamble:


\mdfdefinestyle{myFigureBoxStyle}{tikzsetting={draw=black, line width=1pt}}%



This will make figures, including the caption, framed.

enter image description here

  • How can I put the caption below the frame?
    – GoldRay
    Jun 14, 2014 at 18:31
  • @user1936895 Answer edited. Anything missing? Jun 14, 2014 at 19:02
  • Thank you very much. I want the caption be farthest from the frame
    – GoldRay
    Jun 14, 2014 at 19:39
  • @user1936895 What do you mean? Further away from the frame? For which of the three cases? Jun 14, 2014 at 19:42
  • 1
    @user1936895 I thought that was what you meant, so I edited my answer three hours ago, adding a solution for this. See the code block just after the screenshot under part 2. (By the way, 'farthest' means 'most far', you wanted to say 'further'.) Jun 14, 2014 at 23:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .