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 :
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI 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 :
Three different ways, for three different scenarios.
Step by step:
Add a Figure float, with Insert --> Float --> Figure, or the button on the toolbar.
Add a framebox with Insert --> Box --> Simple frame inside the Figure float.
Right click the box and choose Settings.
Set the Inner box to None, and remove the checkmark from the Width box:
Insert the image inside this box, with Insert --> Graphics or the button on the toolbar.
If the caption should not be inside the frame, go to Document --> Settings --> LaTeX preamble, and add the following:
\usepackage{float}
\floatstyle{boxed}
\restylefloat{figure}
This will make all your figures (added with Insert --> Float --> Figure, or the corresponding button on the toolbar) framed.
If you want the caption a little further away from the frame in this case, replace the three code lines above with
\usepackage{float}
\renewcommand\fs@boxed{\def\@fs@cfont{\bfseries}\let\@fs@capt\floatc@plain
\def\@fs@pre{\setbox\@currbox\vbox{\hbadness10000
\moveleft3.4pt\vbox{\advance\hsize by6.8pt
\hrule \hbox to\hsize{\vrule\kern3pt
\vbox{\kern3pt\box\@currbox\kern3pt}\kern3pt\vrule}\hrule}}}%
\def\@fs@mid{\vspace{\abovecaptionskip}}%
\def\@fs@post{}\let\@fs@iftopcapt\iffalse}
\floatstyle{boxed}
\restylefloat{figure}
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:
\usepackage{float}
\usepackage[framemethod=tikz]{mdframed}
\mdfdefinestyle{myFigureBoxStyle}{tikzsetting={draw=black, line width=1pt}}%
\newcommand\fs@myRoundBox{\def\@fs@cfont{\bfseries}\let\@fs@capt\floatc@plain
\def\@fs@pre{\begin{mdframed}[style=myFigureBoxStyle]}%
\def\@fs@mid{\vspace{\abovecaptionskip}}%
\def\@fs@post{\end{mdframed}}\let\@fs@iftopcapt\iffalse}
\floatstyle{myRoundBox}
\restylefloat{figure}
This will make figures, including the caption, framed.