# Irregular bounding box for text in LaTeX

Bounding box example

Can you tell me the package to use to make the irregular shape for bounding the text, as in the example just above ?

The example image is from the page 16 of the French initiation to LaTeX by Stéphane Pasquet.

The source of the PDF is not available. But his mathbook class, available on his website, has on pages 12-14 of the documentation a similar border with the mathbook class environment demonstration.

The code of mathbook.cls is available in this zipped file, and for the demonstration environment, precisely in the file commandes.tex.

You could then see that the author uses the TikZ package and the decorations.pathmorphing tikzlibrary, with random steps.

With this code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\begin{document}

\tikz\node[draw,thick,inner sep=0.25cm,decorate,decoration={random steps,segment length=3pt, amplitude=1pt}] {{\Large Mon texte en Large} et maintenant en taille normale.};

\end{document}


you will obtain:

• Very clear and precise answer. Thank you – Idefix Jun 20 '19 at 0:43

You can also draw the randomized box with MetaFun.

\documentclass{article}
\pagestyle{empty}
\usepackage{luamplib}
\mplibsetformat{metafun}
\mplibtextextlabel{enable}
\begin{document}

\begin{mplibcode}
input rboxes ;

beginfig(0) ;
numeric amplitude, segment_length, n ;
path p, q ;

amplitude := 1pt ;
segment_length := 3pt ;

boxit.a("{\Large Mon texte en Large} et maintenant en taille normale.");
drawunboxed(a);
p := bpath a ;
n := arclength p / segment_length ;
q := for i = 0 upto n: point (i/n) along p -- endfor cycle;
draw q randomized amplitude ;
endfig ;
\end{mplibcode}

\end{document}


So at the end of it

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}

\newcommand\randombox[1]{%
\tikz{%
\node[inner sep=1em,text width=.85\linewidth,align=flush left] (A) {#1};
\draw[decoration={random steps,segment length=0.4cm,amplitude=.1cm},decorate]
(A.north west) -- (A.north east) -- (A.south east) -- (A.south west) -- cycle;
}}

\begin{document}
\randombox{%
{\Large Mon text en large} mon text
}

\end{document}


Which gives the result

Thanks to samcarter for this code

https://texnique.fr/osqa/users/1702/samcarter