I have written the following latex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\renewcommand{\P}{\mathcal{P}}
\date{May 2019}
\begin{document}
\begin{align*}
&H_{n + 1}= \\
&-\sum_{x_{n + 1}} \P(x_{n + 1} | x_n) \sum_{x_1, x_2, \dots, x_{n}} \P(x_1, x_2, \dots, x_n) \log(\P(x_1, x_2, \dots, x_n)\P(x_{n + 1} | x_n)) =\\
&-\sum_{x_{n + 1}} \P(x_{n + 1} | x_n) \sum_{x_1, x_2, \dots, x_{n}} \P(x_1, x_2, \dots, x_n) (\log(\P(x_1, x_2, \dots, x_n)) + \log(\P(x_{n + 1} | x_n))) =\\
&-\sum_{x_{n + 1}} \P(x_{n + 1} | x_n) H_n - \sum_{x_1, x_2, \dots, x_{n + 1}} \P(x_1, x_2, \dots, x_{n + 1}) \log(\P(x_{n + 1} | x_n))) =
\end{align*}
\end{document}
This gives me an overfull hbox warning. Is there a way to automatically shrink each line so that it fits inside the hbox?
Note: I am willing to accept a solution that tells me how to shrink everything in the align contents, but I would greatly prefer an answer that automatically shrinks each line dynamically, and I would love an answer that explains how to do both.
&
at the beginning of the first line is automatically forcing everything to the right, though not by very much. Themultline*
environment ofamsmath
would be more appropriate, although it still won't reduce the width of the second line. It's not clear what\P
is defined to be, and it's not possible to know what the output is without knowing that. Please make your example a complete compilable example, starting with\documentclass
and ending with\end{document}
; that way potential helpers will have something to experiment with.mathtools
. For more than 381pt, there must be something else.