Consider this:
\documentclass{article}
\usepackage[framemethod=TikZ]{mdframed}
\begin{document}
\begin{mdframed}[innerrightmargin=0pt]
TEXT\end{mdframed}
\end{document}
This produces a frame that is much wider than its content:

I know this is not a bug: the mdframed documentation mentions a userdefinedwidth parameter that defaults to \linewidth. But how can I get a mdframed frame that has the same width as its content?
(What I actually need is a box with rounded corners and shading options; breaking over multiple pages isn't necessary. mdframed seemed like the easiest way to get the box, but if it's too much hassle to make it size to content, it would be useful to know so I can try pure tikz.)



\linewidtheven if some of the content is white. If you just want a box of natural size then\fbox{TEXT}would work, or others will show you fancy Tikz Boxes:-) – David Carlisle Dec 30 '12 at 16:51tikz. (draw=black!30, fill=gray!4, inner sep = 3mm, outer sep = 3mm, rounded corners=5mm) – Mohan Dec 30 '12 at 16:58