[Tex/LaTex] How to resize font of displayed formulas to automatically fit column width?


Is there a way, in LaTeX, to automatically resize font of displayed equations to fit column width (241 pt, here)?

Any ideas would be appreciated.

You can see my equation below; note that I use \fontsize{4pt}{4pt}\selectfont to resize the font, but I need the font to be resized automatically every time.

{x}_{j}(t)-{x}_{i}(t)-{\Delta }_{ij}^{q}\Vert 
{x}_{j}(t)-{x}_{i}(t)-{\Delta }_{ij}^{q}\Vert 
{x}_{j}(t)-{x}_{i}(t)-{\Delta }_{ij}^{q}\Vert 

Best Answer

The adjustbox package is handy. You put the contents inside adjustbox environment as

\begin{adjustbox}{max width=241pt}

then if the contents are wider than 241pt, then only they are resized otherwise not.


\noindent A\hfill Z
\begin{adjustbox}{max width=241pt}
  \varphi_{ij}^q(t) =
    e^{ -(\Vert x_j(t) - x_i(t) - \Delta_{ij}^q\Vert^2/L_a^2)}
    - \dfrac{S_r}{L_r^2}
    e^{ -(\Vert x_j(t) - x_i(t) - \Delta_{ij}^q\Vert^2/L_r^2)}
    + \left( \dfrac{S_r}{L_r^2} + \dfrac{S_r}{L_a^2} \right)
    e^{(- 1/L_r^2 + 1/L_a^2)
       (\Vert x_j(t) - x_i(t) - \Delta_{ij}^q\Vert^2)}

enter image description here