# Making fancy frames around a textblock

I'm aware of the question and of the replies about borders around a textblock from the textpos package. This works but produces "very square" boxes...

I was wondering if there was a way to make those boxes more fancy with, for example with round borders, non rectangular shape (I was thinking about cartoon bubbles), or to add a title, itself in a fancy box, in one step.

I tried to play with tikz but I didn't manage to have a common coordinate system for the tikz and for the textpos and, moreover, as the height of the textblock is variable, I'm not sure to be able to draw the border properly around the textblock.

• Packages mdframed and tcolorbox, very easy to use, the second one being my personal favorite, both highly configurable and with breaking-box-feature (both use TikZ in the background, actually) – user31729 Dec 30 '16 at 13:04

The OP's question leaves wide latitude, so I opted to make a fancy frame using those clipart frame corners you can find on the web. Once you have downloaded such a frame, which I called corner_299-282.png, use my macro

\cframe{<frame-image-file>}{<offset-factor>}{<content>}


One additional parameter is \frameprop, which is the proportion of the content's width/height minimum to make the frame.

Here is the MWE. During the early part of the page, \frameprop is set to .45 (i.e., 45%). The first row shows the raw frame. The second row shows it applied to square content, but changing the offset-factor from 0 to .2. The 3rd row shows it applied to rectangular content, also varying the offset-factor. The last row shows it applied to a text \parbox, with the offset at .35 and \frameprop revised to .6 (60%).

EDITED to allow <content> to contain multi-paragraphs.

\documentclass{article}
\usepackage{graphicx,stackengine}
\newlength\framewidth
\def\frameprop{.45}
\newcommand\cframe[3]{%
\setbox0=\hbox{#3}%
\ifdim\wd0>\dimexpr\ht0+\dp0\relax\relax%
\setlength\framewidth{\frameprop\dimexpr\ht0+\dp0\relax}\else%
\setlength\framewidth{\frameprop\wd0}\fi%
\savestack\corner{\includegraphics[width=\framewidth]{#1}}%
\hspace{#2\framewidth}%
\setbox0=\hbox{#3}%
\stackinset{l}{-#2\framewidth}{t}{}{\corner}{%
\stackinset{r}{-#2\framewidth}{t}{-#2\framewidth}{\rotatebox{-90}{\corner}}{%
\stackinset{l}{-#2\framewidth}{b}{}{\rotatebox{90}{\corner}}{%
\stackinset{r}{-#2\framewidth}{b}{-#2\framewidth}{\rotatebox{180}{\corner}}{%
\copy0}}}}%
\hspace{#2\framewidth}%
}
\parskip1ex
\begin{document}
\includegraphics[width=1in]{corner_299-282}\par
\cframe{corner_299-282}{0}{\includegraphics[width=1cm,height=1cm]{example-image}}
\cframe{corner_299-282}{.2}{\includegraphics[width=2cm,height=2cm]{example-image}}\par
\cframe{corner_299-282}{0}{\includegraphics[width=2in,height=1in]{example-image}}
\cframe{corner_299-282}{.2}{\includegraphics[width=1in,height=2in]{example-image}}\par
\def\frameprop{.6}
\cframe{corner_299-282}{.35}{\parbox{2.4in}{
{\centering\scshape A LIMERICK\par}
The lemmings get set for their race.\\
With one step and two steps they pace.\\

Note: \cframes can be nested: