0

I'm new at LaTEX. I'm learning by myself so this maybe is a beginner problem. I'm getting the warning: underfull \hbox (badness 10000) in paragraph

\documentclass[a4paper, 12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[utf8]{vietnam}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}

\title{\textbf{Tham gia giải bài \\ THÁCH THỨC KỲ NÀY}}
\author{(Tạp chí Pi Tập $5$ - Số $6$ - Tháng $6$ năm $2021$)}
\date{Nguyễn Tấn Phúc}

\begin{document}

    \maketitle
    
    \section{Thông tin cá nhân}
        \begin{flushleft}
            \begin{itemize}
                \item[-] \textit{Họ và tên}: Nguyễn Tấn Phúc
                \item[-] \textit{Lớp}: $8/1$
         
            \end{itemize}
        \end{flushleft}
    
    \section{Giải bài P514 (Mức B)}
        
        \begin{itemize}
            \item \textit{\textbf{Đề bài:}} Đặt $\phi = \dfrac{1 + \sqrt{5}}{2}$. Cho các số nguyên $a, b, c$ thỏa mãn:
            \[ \dfrac{a}{\phi} + \dfrac{b}{\phi^2} + \dfrac{c}{\phi^3} = \phi. \]
            Tính $2a + b + c$. 
                
            \item \textit{\textbf{Lời giải:}} \\
            Ta dễ dàng chứng minh được $\phi^2 - \phi - 1 = 0$, từ đó suy ra \\
            $$\dfrac{1}{\phi} = \phi - 1, \quad \dfrac{1}{\phi^2} = 1 - \dfrac{1}{\phi} = 2 - \phi, \quad \dfrac{1}{\phi^3} = \dfrac{1}{\phi} - \dfrac{1}{\phi^2} = 2\phi - 3$$ \\
            Giả thiết của bài toán tương đương với $a(\phi - 1) + b(2 - \phi) + c(2\phi - 3) = \phi$, hay 
            \[(a - b + 2c - 1)\phi = a - 2b + 3c.\]
            Vì $a - 2b + 3c$ là số hữu tỉ nên $(a - b + 2c - 1)\phi$ cũng là số hữu tỉ. Mà $\phi$ là số vô tỉ và $a - b + 2c - 1$ là số hữu tỉ nên $a - b + 2c = 1$. Do đó $a - 2b + 3c = 0$. Vậy $2a + b + c = 5(a - b + 2c) - 3(a - 2b + 3c) = \textbf{5}$.
                
        \end{itemize}
    
    \section{Giải bài P515 (Mức B)}
        \begin{itemize}
            \item \textit{\textbf{Đề bài:}} Trong hình dưới đây: $ABCD$ là hình vuông cạnh $2$; đường tròn $(O)$ có bán kính $1$ và tiếp xúc với $BC$ tại trung điểm $BC$, $M$ là một điểm di động trên $(O)$. Tìm giá trị lớn nhất của $AM$.
              
            \begin{figure}[ht]
                \label{fig:P515}
                \centering
                \includegraphics[scale = 0.35]{P515}
            \end{figure}
                
            \item \textit{\textbf{Lời giải:}} \\
            Gọi $N$ là trung điểm của đoạn thẳng $AD$. Khi đó ta dễ dàng tính được: \\
            $$AN = \dfrac{1}{2} \cdot AD = \dfrac{1}{2} \cdot 2 = 1$$ 
            $$ON = 2 + 1 = 3$$ \\
            Áp dụng định lí Pythagoras trong tam giác ANO vuông tại N, ta có: 
            $$OA = \sqrt{AN^2 + ON^2} = \sqrt{1^2 + 3^2} = \sqrt{10}$$ \\
            Sử dụng bất đẳng thức tam giác, ta có $AM \leq OA + OM = \sqrt{10} + 1 $. Đẳng thức xảy ra khi $M$ là điểm xa $A$ nhất trong hai giao điểm của $OA$ và $(O)$. Vậy giá trị lớn nhất của AM là $\sqrt{\textbf{10}} + \textbf{1}$.
            
        \end{itemize}     
        
      
\end{document}```


1

2 Answers 2

1

Underfull \hbox normally means that TeX had to stretch things out to fill a line but that's not exactly what's happening in your document. In fact, we can replicate the issue by reducing things to:

\documentclass{article}

\begin{document}
This is a test\\

\end{document}

The problem is that you're sprinkling \\ all over your document when you don't need or want to. \\ Only needs to be used in places where you need to manually specify a line break. Nearly¹ every instance of \\ in your sample document should be removed. In particular, if you put \\ at the end of a paragraph (and right before display math is effectively a paragraph end), LaTeX will try to fill the final line of the paragraph with nothing and give the warning your received.

You would also be well-served to use \[\] instead of $$$$ to indicate display math. You might also want to typeset your pair of displayed equations using

\begin{gather*}
AN = \frac{1}{2} \cdot AD = \frac{1}{2} \cdot 2 = 1\\
ON = 2 + 1 = 3
\end{gather*}

Note that here we use \\ since we have two lines of equations we're displaying. Also, I changed your \dfrac to \frac. You should prefer \frac over \dfrac except in those instances where you want to force a large fraction where you wouldn't ordinarily get one.


  1. Really, every instance should be removed with the possible exception of the one in the title.
3

The usage of \\ followed by empty line is typical mistake in most LaTeX documents. The answer above says that \\ should not be used in this way. I show, what happens at TeX level in detail.

LaTeX defines \\ as \hfil\break by default and it redefines this control sequence in several different context (typically in \halign context it is \cr but it is not the point of our interest now).

The text

... end of paragraph\\
<empty line>

is interpreted by TeX as ... end paragraph\hfil\break<space>\par The \par primitive removes the previous <space> (if exists) and adds \penalty10000\hskip\pafillskip. So, we have:

... end of paragraph\hfil\break\penalty10000\hskip\parfilskip

The \hskip\parfillskip is (by default) a flexible gab inserted at the last line of each paragraph. Now, TeX runs paragraph-breaking routine to create lines of the paragraph. The \break (exactly \penalty-10000) forces breaking. All discardable items after this breaking point are removed, i.e. first \break is accepted and following \penalty10000\hskip\parfillskip are removed. The final internal break is processed which finalizes the paragraph breaking algorithm. We have forced \break fllowed by final break, so there is created an empty line with no material inside and with \hsize width. This is underfull \hbox.

Authors of LaTeX documents are doing this mistake because they typically want to insert \vskip\bigskipamount (vertical space) at this point of typesetting. They realize that the macro \vspace (mentioned in LaTeX manuals) brings more complications because it is defined by \vadjust primitive, i.e. the paragraph is not finalized here. In general: this is bad practice to insert such exceptions of typesetting. If you need something like \vskip\bigskipamount at several (very good defined) places, include it to the typesetting design and create appropriate macros and settings of relevant TeX parameters.

You must log in to answer this question.

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