1

I am trying to resize the equation font size in math mode:

As This answer suggested :

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\newcommand*{\Scale}[2][4]{\scalebox{#1}{$#2$}}%
\newcommand*{\Resize}[2]{\resizebox{#1}{!}{$#2$}}%
\begin{document}
\[y = \sin^2 x\]
%
\[\Scale[0.5]{y = \sin^2 x}\]
%
\[ \Resize{1cm}{y = \sin^2 x}\]
\end{document}

Where my equation look like this:

\begin{equation}
\begin{aligned}
\mathbf{H_{2}^{(l+1)}=\sigma(\alpha_{22}^{(l)} H_{2}^{(l)} W^{(l)}+\alpha_{21}^{(l)} H_{1}^{(l)} W^{(l)}  \\
 +\alpha_{23}^{(l)} H_{3}^{(l)} W^{(l)}+\alpha_{24}^{(l)} H_{4}^{(l)} W^{(l)} )}
 \end{aligned}
\end{equation}

it's going outside of paper width.

How to reduce the font or use this code to reduce font of equation inside paper width?

Thank you !

enter image description here

  • 2
    Line breaking is preferred over shrinking the font size. – Henri Menke Aug 6 at 8:19
  • If you want to have the whole equation in bold face you could use \boldmath\begin{equation}...\end{equation}\unboldmath, but I don't recommend that at all. Bold face usually carries special semantic meaning in math and therefore cannot be used for emphasis. Better use a different color or put a box around it, see the empheq package. – Henri Menke Aug 6 at 8:31
  • The answer from David in the question you linked to is much better than using some scalebox. – Ulrike Fischer Aug 6 at 8:35
6

Instead of shrinking the font size, it is generally better to use a line break. For that purpose the amsmath package provides the multline environment. From the documentation:

The multline environment is a variation of the equation environment used for equations that don't fit on a single line. The first line of a multline will be at the left margin and the last line at the right margin, except for an indention on both sides in the amount of \multlinegap. Any additional lines in between will be centered independently within the display width (unless the fleqn option is in effect).

\documentclass[twocolumn]{article}
\usepackage{amsmath}
\usepackage{blindtext}
\begin{document}
\blindtext
\begin{multline}
    H_{2}^{(l+1)}
    = \sigma ( \alpha_{22}^{(l)} H_{2}^{(l)} W^{(l)} + \alpha_{21}^{(l)} H_{1}^{(l)} W^{(l)}  \\
    + \alpha_{23}^{(l)} H_{3}^{(l)} W^{(l)} + \alpha_{24}^{(l)} H_{4}^{(l)} W^{(l)} )
\end{multline}
\Blindtext
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.