2

When I create a minipage to insert an operating mode in front of an image, I obtain a warning with an Underfull \hbox (badness 1748) in paragraph at lines 75--75 I can't understand what is causing this warning.

As I have received this warning several times, I would like to understand it to avoid repeating it. THANKS

PS: my code returns an error on overleaf but not when compiling on my "real" file

\RequirePackage{fix-cm}
\documentclass{book}

\usepackage[T1]{fontenc}
\usepackage{inputenc} 
\usepackage[french]{babel}
\usepackage[left=1.5cm, right=1.5cm, top=1.5cm, bottom=1.5cm]{geometry}

\usepackage{enumitem}  %pour l'option [resume] qui permet de reprendre la numérotation
\usepackage{pifont}
\usepackage{tabularray}
\UseTblrLibrary{amsmath,booktabs,counter,diagbox,siunitx,varwidth}
\usepackage{tikz} 

\usepackage{titlesec}
\usepackage{caption}
\usepackage{amsmath}
\usepackage{amssymb}

\usepackage{mathtools}

\newcommand{\ofg}[1]{\og{}#1\fg{}}

\newcommand{\itemmanip}{\begin{itemize}[label=\ding{45}]}

\def\before@cadre{\par\medskip}
\def\after@cadre{\par\medskip}
        

%cadre simple
  \newcommand{\cadremanip}[1]{\before@cadre
\tikzstyle{mybox} = [draw=gray, fill=gray!15, very thick,
    rectangle, rounded corners, inner sep=10pt, inner ysep=10pt]
\tikzstyle{fancytitle} =[fill=gray!5, text=black]

\begin{tikzpicture}
\node [mybox] (box){%
    \begin{minipage}{0.9\textwidth}
   #1
            \end{minipage}
};
\node[fancytitle, right=10pt] at (box.north west) {Partie expérimentale};
%\node[fancytitle, rounded corners] at (box.east) {$\clubsuit$};
\end{tikzpicture}
\after@cadre}%
%fin cadre simple
        
\begin{document}

\subsection{Méthode de suivi pHmétrique}
\subsubsection{Dispositif expérimental}
\cadremanip{
\begin{minipage}{0.65\textwidth}
\itemmanip{}
    \item on rince la burette graduée à l'eau distillée puis avec la solution titrante;
    \item on rince le bécher de prélèvement avec la solution à doser ;
    \item on rince la pipette, munie d'une propipette, avec la solution à doser ;
    \item on remplit la burette avec la solution titrante en veillant à dépasser un peu la graduation zéro;
    \item on ajuste le zéro en ouvrant doucement le robinet de manière à ce que le bas du ménisque soit à la graduation zéro;
    \item on étalonne le pHmètre ;
    \item on prélève le volume de solution à doser (pipette + propipette) que l'on verse dans un bécher haut;
    \item on plonge l'électrode combinée dans la solution;
    \item si la sonde ne plonge pas  suffisamment dans la solution, on ajoute un volume d'eau distillée $V_0$ à l'aide d'une éprouvette graduée (ce volume n'a pas besoin d'être précis);
    \item on mesure le pH pour chaque volume de solution titrante : il est possible de le faire mL par mLloin de l'équivalence et de resserer aux alentours de l'équivalence afin d'obtenir un \ofg{beau} saut de pH;
\end{itemize}
\end{minipage}
\hfill
\begin{minipage}{0.3\textwidth}
    \center
    \includegraphics[width=0.7\textwidth]{example-image}
    \captionsetup{type=figure}
    \captionof{figure}{Montage dosage pHmétrique}%
    \label{montage_dosage_phmetrique}%
\end{minipage}
}

\end{document}
9
  • \center is an internal command part of the definition of \begin{center} do not use as a command use \centering (unrelated to your question) Commented Jun 23 at 8:37
  • Suggestion: replace the picture file with example-image.pdf and uncomment the style definition line for fancytitle
    – Stephen
    Commented Jun 23 at 8:40
  • I edited as @Stephen said (and deleted my earlier comment, which only had half the fix) Commented Jun 23 at 8:43
  • as I specified, the error that appears does not appear in my original document but I understand that this could complicate my request. With the update I still get the hbox warning
    – Nicolas
    Commented Jun 23 at 8:46
  • @Nicolas yes that is exactly the point, the update alows people to run the example and see the warning you are asking about. Are you sure you don't get the pgf error on overleaf, no red error count at the top of the pdf view? Commented Jun 23 at 8:50

2 Answers 2

3

"Badness" is a measure of how much white space has been stretched. There are user-settable tolerances on this and if you look at the caption

enter image description here

You can see its first line has been over-stretched to justify the paragraph.

You have a relatively narrow text block for captions and complicated technical long words that probably don't hyphenate well with the standard French hyphenation rules.

You could ignore it (it is not an error), you could increase hbadness so that you only got warned about lines that are stretched more than this, you could allow more hyphenation eg

\captionof{figure}{Montage dosage pH\-métrique}%

has no warning and produces

enter image description here

Or you could use caption package to configure captions to use an unjustified ragged right format or some other style choice that you may pick.

See also

Do I have to care about bad boxes?

3

Underfull or overfull box issues are most commonly solved by rewording.

In your case, “Montage dosage pHmétrique” has no really good place for line breaking is a very narrow column. In my opinion, two nouns next to each other don't make for good language: the caption is under a picture that describes a device for doing something:

Montage pour le dosage pHmétrique

might be better and avoids the issue. You also avoid the issue with

\caption{Montage dosage pH\-métrique}

that allows (but doesn't force) hyphenation after “pH”. Take your pick.

Meanwhile, there are some improvements for your code.

  1. I'd define a manip environment, rather than beginning with a command and ending with \end{itemize}.

  2. I'd use \linewidth throughout, for relative lengths.

  3. \tikzstyle has been deprecated for several years. I modified for using \tikzset and I also moved it outside the definition of \cadremanip, because there's no point in redoing each time the work of defining the styles.

  4. Instead of \par\medskip, I suggest \par\addvspace{\medskipamount}, so spaces won't cumulate in case of consecutive objects that do \addvspace. It's the case of \subsubsection followed by \cadremanip, for instance.

\RequirePackage{fix-cm}
\documentclass{book}

\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage[left=1.5cm, right=1.5cm, top=1.5cm, bottom=1.5cm]{geometry}

\usepackage{enumitem}
\usepackage{pifont}
\usepackage{tabularray}
\UseTblrLibrary{amsmath,booktabs,counter,diagbox,siunitx,varwidth}
\usepackage{tikz}

\usepackage{titlesec}
\usepackage{caption}
\usepackage{amsmath}
\usepackage{amssymb}

\usepackage{mathtools}

\newcommand{\ofg}[1]{\og{}#1\fg{}}

\newenvironment{manip}{\begin{itemize}[label=\ding{45}]}{\end{itemize}}

%cadre simple
\tikzset{
  mybox/.style={
    draw=gray,
    fill=gray!15,
    very thick,
    rectangle,
    rounded corners,
    inner sep=10pt,
    inner ysep=10pt,
  },
  fancytitle/.style={
    fill=gray!5,
    text=black,
  },
}

\newcommand{\cadremanip}[1]{%
  \par\addvspace{\medskipamount}
  \begin{tikzpicture}
    \node[mybox] (box){\parbox{0.9\linewidth}{#1}};
    \node[fancytitle, right=10pt] at (box.north west) {Partie expérimentale};
    %\node[fancytitle, rounded corners] at (box.east) {$\clubsuit$};
  \end{tikzpicture}
  \par\addvspace{\medskipamount}
}
%fin cadre simple
        
\begin{document}

\subsection{Méthode de suivi pHmétrique}

\subsubsection{Dispositif expérimental}

\cadremanip{%
  \begin{minipage}{0.65\linewidth}
  \begin{manip}
    \item on rince la burette graduée à l'eau distillée puis avec la solution titrante;
    \item on rince le bécher de prélèvement avec la solution à doser ;
    \item on rince la pipette, munie d'une propipette, avec la solution à doser ;
    \item on remplit la burette avec la solution titrante en veillant 
          à dépasser un peu la graduation zéro;
    \item on ajuste le zéro en ouvrant doucement le robinet de manière à ce que le bas 
          du ménisque soit à la graduation zéro;
    \item on étalonne le pHmètre ;
    \item on prélève le volume de solution à doser (pipette + propipette) que l'on verse 
          dans un bécher haut;
    \item on plonge l'électrode combinée dans la solution;
    \item si la sonde ne plonge pas  suffisamment dans la solution, on ajoute un volume 
          d'eau distillée $V_0$ à l'aide d'une éprouvette graduée (ce volume n'a pas 
          besoin d'être précis);
    \item on mesure le pH pour chaque volume de solution titrante : il est possible 
          de le faire mL par mLloin de l'équivalence et de resserer aux alentours de 
          l'équivalence afin d'obtenir un \ofg{beau} saut de pH;
  \end{manip}
  \end{minipage}\hfill
  \begin{minipage}{0.3\linewidth}
    \centering
    \includegraphics[width=0.7\linewidth]{example-image}
    \captionof{figure}{Montage dosage pH\-métrique}%
    \label{montage_dosage_phmetrique}%
  \end{minipage}
}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .