width=\linewidth
is acceptable input option to \includegraphics
, but is not acceptable as input to minipage
. What can we replace X
with so that \begin{minipage}{X}
has a similair width setting to \includegraphics[width=\linewidth]{file_name}
?
The following code is meant to create a framed figure. It almost works except that I do not want the width of the minipage to be hard-coded in to be 12 cm.
\documentclass{article}
\usepackage{graphicx}
\begin{document}\begin{figure}[htbp]
\centering
\fbox{
\begin{minipage}{12 cm}
\includegraphics[width=\linewidth]{solution_count_satisfiability}
\caption{caption}
\label{label}
\end{minipage}
}
\end{figure}
\end{document}
Best Answer
Not sure what your question is about, simply changing
12cm
with\linewidth
does it, and, as David already pointed out, you need to subtract the separation and line width of\fbox
from it, otherwise the box will be larger then the line width. Also\fbox{<linebreak>
will cause a space be added, which will push the image a little to the left, so you need to mask it with a comment:\fbox{%
.The simplest way would be using
adjustbox
:As Mico stated already, the centering (here done with the
center
key) is not really needed if the content is already as wide as the line. I added it for good measure as you might change the width later.