[Tex/LaTex] Automatically resize equations

ebookequationsresize

I want to know if there is a tool to automatically resize the equations if they are longer than \pagewidth.

The whole story is that I am compiling my thesis in b5paper, but I want to also produce a pdf that is more ebook-size-friendly. Therefore, I am compiling the source documents again with a smaller paper size. Long equations that are correctly displayed in b5paper go over the margin in the new smaller paper.
I tried to use the breqn package, but as soon as I load it, the compiler never ends compiling.

Any other idea?

Thanks in advance

Best Answer

Scaling elements which contain text is usually a bad idea, see Why not scale elements that contain text

I suggest to use a smaller font size or split the equations over multiple lines instead.

\begingroup
    \scriptsize%
    \begin{equation}
     x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
    \end{equation}
\endgroup

If you must scale them, you could try \resizebox:

\documentclass{article}

\usepackage{graphicx}

\begin{document}

\begin{equation}
\resizebox{.9\textwidth}{!}{
     x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
}
\end{equation}


\end{document}

Or if you also want to apply it to short equations which don't need to be scaled:

\documentclass{article}

\usepackage{adjustbox}

\begin{document}

\begin{equation}
\adjustbox{max width=.9\textwidth}{
     x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
}
\end{equation}


\begin{equation}
\adjustbox{max width=.9\textwidth}{
     x x x x x x x x x x x x x x x x x x x x 
}
\end{equation}

\end{document}
Related Question