1

I'm a beginner with latex and would have liked to make a recipe book. Each recipe would be framed in a tcolorbox as shown on the screenshot below:

example of a recipe frame

The problem is that the boxes don't break if there isn't enough place for the complete box on the page. For an example, see this page:

enter image description here

What I would like to obtain is something like this (I arranged the previous picture with Gimp):

enter image description here

Here's my code:

\documentclass[a4paper,12pt]{book}

\usepackage{indentfirst} %package qui sert à avoir un alinéa au premier paragraphe de chaque section

\usepackage{url} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[french]{babel} \usepackage{appendix} \usepackage{geometry} \geometry{hmargin=2cm,vmargin=2cm} \usepackage{moreverb} \usepackage{verbatimbox} \usepackage[skins, many]{tcolorbox} %[skins, many] \usepackage{fancyvrb} \usepackage{graphicx} \usepackage{mdframed} \usepackage{lipsum}

\def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]} \let\endchangemargin=\endlist %https://tex.stackexchange.com/questions/588/how-can-i-change-the-margins-for-only-part-of-the-text

\newmdenv[ topline=false, bottomline=false, rightline=false, linewidth=1.5pt, skipabove=\topsep, skipbelow=\topsep ]{siderules} %https://tex.stackexchange.com/questions/86381/adding-vertical-lines-to-each-side-of-a-paragraph

\newtcolorbox{ficherecette}{enhanced jigsaw, colback=white, enforce breakable, nobeforeafter}

\newcommand{\nomrecette}[1]{\newpage \addcontentsline{toc}{subsection}{#1}\begin{center} \begin{Large} \textbf{#1} \end{Large} \end{center}}

\newcommand{\descriptionrecette}[1]{\hspace{1cm} \textit{#1}\}

%\newcommand{\infosrecette}[4]{\\textbf{Informations pratiques~:}\begin{itemize} \item[•] Nombres de personnes~: #1 \item[•] Préparation~: #2 minutes \item[•] Cuisson~: #3 minutes \item[•] Repos~: #4 minutes\ \end{itemize}}

\newcommand{\infosrecette}{\\textbf{Informations pratiques~:}\begin{itemize}} \newcommand{\quantite}[1]{\item[•] Quantité~: #1} %/!\ajouter l'unité \newcommand{\tpsprepa}[1]{\item[•] Temps de préparation~: #1 minutes} \newcommand{\tpsprepassmin}[1]{\item[•] Temps de préparation~: #1} %tps e prépa sans minutes. ex.: rapide \newcommand{\tpscuisson}[1]{\item[•] Cuisson~: #1 minutes} \newcommand{\tpsrepos}[1]{\item[•] Repos~: #1} \newcommand{\fininfosrecette}{\ \end{itemize}}

\newcommand{\ingredients}{\textbf{Ingrédients~:} \begin{itemize}} \newcommand{\itemingredient}[1]{\item[•] #1} \newcommand{\finingredients}{\\end{itemize}}

\newcommand{\matos}{\textbf{Matériel spécifique~:} \begin{itemize}} \newcommand{\itemmatos}[1]{\item[•] #1} \newcommand{\finmatos}{\\end{itemize}}

\newcommand{\conseil}[1]{\end{itemize}\begin{changemargin}{2cm}{2cm} \begin{siderules}\begin{minipage}{11.7cm}\textit{\textbf{Conseil pratique~:} #1}\end{minipage}\end{siderules}\end{changemargin}\begin{itemize}} \newcommand{\dernierconseil}[1]{\end{itemize}\begin{changemargin}{2cm}{2cm} \begin{siderules}\begin{minipage}{11.7cm}\textit{\textbf{Conseil pratique~:} #1}\end{minipage}\end{siderules}\end{changemargin}} \newcounter{compteuretapes} \newcommand{\etapes}{\textbf{Préparation~:}\setcounter{compteuretapes}{1}\begin{itemize}} \newcommand{\itemetape}[1]{\item[\textbf{\arabic{compteuretapes}.}] #1\stepcounter{compteuretapes}} \newcommand{\finetapes}{\end{itemize}} %------------------------------------------------------------------------------------- \begin{document} \title{My recipe book} \author{Myself} \date{2023} \clearpage\maketitle \thispagestyle{empty} \newpage \tableofcontents \chapter{Entrées} \chapter{Soupes} \chapter{Plats principaux} \chapter{Desserts} \begin{ficherecette} \nomrecette{Pudding à la vanille} \descriptionrecette{Pudding traditionnel transmit de mère en fille...} \infosrecette{} \quantite{5 ramequins et 3 mini-ramequins} \tpsprepa{15} \tpscuisson{10} \tpsrepos{le temps que ça refroidisse à notre goût} \fininfosrecette{} \ingredients{} \itemingredient{1 l de lait} \itemingredient{55 g de sucre} \itemingredient{60 g de pudding-powder} \finingredients{} \etapes{} \itemetape{Dans une casserole, mélanger le sucre avec le lait et la poudre de pudding.} \conseil{Au four à micro-ondes ? Mélanger les ingrédients dans un bol prévu à cet effet.} \itemetape{Faire bouillir le lait pendant au minimum 1~min.} \conseil{Au four à micro-ondes ? Programmer 10~min à 1000~W en retirant 3 fois ou plus pour remuer.} \itemetape{Verser immédiatement dans les bols.} \finetapes{} \end{ficherecette} \begin{ficherecette} \nomrecette{Pudding à la vanille} \descriptionrecette{Pudding traditionnel transmit de mère en fille...} \infosrecette{} \quantite{5 ramequins et 3 mini-ramequins} \tpsprepa{15} \tpscuisson{10} \tpsrepos{le temps que ça refroidisse à notre goût} \fininfosrecette{} \ingredients{} \itemingredient{1 l de lait} \itemingredient{55 g de sucre} \itemingredient{60 g de pudding-powder} \finingredients{} \etapes{} \itemetape{Dans une casserole, mélanger le sucre avec le lait et la poudre de pudding.} \conseil{Au four à micro-ondes ? Mélanger les ingrédients dans un bol prévu à cet effet.} \itemetape{Faire bouillir le lait pendant au minimum 1~min.} \conseil{Au four à micro-ondes ? Programmer 10~min à 1000~W en retirant 3 fois ou plus pour remuer.} \itemetape{Verser immédiatement dans les bols.} \finetapes{} \end{ficherecette} \begin{ficherecette} \nomrecette{Pudding à la vanille} \descriptionrecette{Pudding traditionnel transmit de mère en fille...} \infosrecette{} \quantite{5 ramequins et 3 mini-ramequins} \tpsprepa{15} \tpscuisson{10} \tpsrepos{le temps que ça refroidisse à notre goût} \fininfosrecette{} \ingredients{} \itemingredient{1 l de lait} \itemingredient{55 g de sucre} \itemingredient{60 g de pudding-powder} \finingredients{} \etapes{} \itemetape{Dans une casserole, mélanger le sucre avec le lait et la poudre de pudding.} \conseil{Au four à micro-ondes ? Mélanger les ingrédients dans un bol prévu à cet effet.} \itemetape{Faire bouillir le lait pendant au minimum 1~min.} \conseil{Au four à micro-ondes ? Programmer 10~min à 1000~W en retirant 3 fois ou plus pour remuer.} \itemetape{Verser immédiatement dans les bols.} \finetapes{} \end{ficherecette} \end{document}

I tried the breakable option on my tcolorbox but it doesn't work... I also saw this post [https://tex.stackexchange.com/questions/319355/tcolorbox-breakable-option-not-working] but I didn't understand how it has been resolved and I'm not shure it's the same problem as mine.

Can somebody please help me ?

Thanks in advance

0 Answers0