0

Bounding box example

enter image description here

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

6

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: enter image description here

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

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}

enter image description here

1

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

enter image description here

Thanks to samcarter for this code

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.