2

I am writing my thesis in TexniCenter and I have the following problem. I want all my figures to have a border. So I use :

\usepackage{float}
\floatstyle{boxed} 
\restylefloat{figure}

in the beginning.

However, every figure after that has a border with width equal to text width, even it is much smaller. For example I use the following code to include an image:

\begin{figure}[h]
  \centering
  \includegraphics [width=0.5\textwidth] {myfigure.png}
  \caption[myfigure]%
  {myfigure}
  \label{myfigure}
\end{figure}

I want to have a figure with width half the text width. The border though remains full width size. Could you help me please.

lockstep
  • 250,273

2 Answers2

4

You may use the floatrow package and its \ffigbox command with the optional argument \FBwidth:

\documentclass{article}

\usepackage{floatrow}
\floatsetup[figure]{style=boxed} 

\begin{document}

\begin{figure}
\ffigbox[\FBwidth]{%
\rule{5cm}{1cm}% placeholder for image
}{%
\caption{A figure}%
}
\end{figure}

\begin{figure}
\ffigbox[\FBwidth]{%
\rule{3cm}{1cm}% placeholder for image
}{%
\caption{A figure}%
}
\end{figure}

\begin{figure}
\rule{3cm}{1cm}% placeholder for image
\caption{A figure}
\end{figure}

\end{document}

Boxed figures

Werner
  • 603,163
lockstep
  • 250,273
1

Try with:

\begin{figure}
  \centering
  \begin{tabular}{|c|}
    \hline
    \rule{0.5\linewidth}{0pt}\vspace{-10pt}\\
    \includegraphics{figure} \\
    \hline
  \end{tabular}
\end{figure}
David Carlisle
  • 757,742
jankos
  • 201