19

How does the resize command work with the equation environment? The following code results in an error.

\begin{equation}\label{model3_coef}
  \resizebox{0.91\hsize}{!}{y_{t}^{3} = -145.071 - 0.003*x_{t-1}^{7} + 0.459*x_{t}^{6} +
  0.001*x_{t-1}^{8} -5.071*x_{t-1}^{9} + 7.322*x_{t-1}^{5} - 0.235*x_{t-1}^{1}  }
\end{equation}
Stefan Kottwitz
  • 231,401

3 Answers3

23

The parameter for \resizebox is in text mode. Thus you need to explicitly go into math mode:

enter image description here

Code:

\documentclass[12pt]{article}
\usepackage{graphicx}

\begin{document} \begin{equation}\label{model3_coef} \resizebox{0.91\hsize}{!}{% $y_{t}^{3} = -145.071 - 0.003 x_{t-1}^{7} + 0.459 x_{t}^{6} + 0.001 x_{t-1}^{8} -5.071 x_{t-1}^{9} + 7.322 x_{t-1}^{5} - 0.235 x_{t-1}^{1}$%
} \end{equation} \end{document}

Peter Grill
  • 223,288
  • @Stan: If the solution worked for you please see How do you accept an answer? and perhaps How does accepting an answer work?. – Peter Grill Jun 10 '15 at 06:21
  • This does not seem to be working for multiple equations in equation environment. – IgotiT Mar 26 '17 at 13:53
  • @IgotiT: Using \resizebox for each equation should work. I would suggest you post a new question and include a fully compilable MWE including \documentclass and the appropriate packages that reproduces the problem and shows what you tried.. – Peter Grill Mar 27 '17 at 08:23
  • @PeterGrill: For resizebox to work for multiple equations in align environment we need put resizebox command before every equation. – IgotiT Mar 28 '17 at 02:35
  • @IgotiT: You probably need separate \resizebox for before and after the align. Instead of describing it here in the comments, I still suggest you post a new question with fully compilable MWE including \documentclass and the appropriate packages that reproduces the problem. You probably won't be the last person to come across this issue so having a separate question specfic to resizing in align would be useful to others as well. – Peter Grill Mar 28 '17 at 05:06
  • @PeterGrill: Posted http://tex.stackexchange.com/questions/360729/resizebox-command-for-equations-in-align-enviroment – IgotiT Mar 28 '17 at 06:22
10

An alternative is package resizegather, which shrinks equations of environment gather of package amsmath to \linewidth, if the equation is too large:

\documentclass{article}
\usepackage{amsmath}
\usepackage{resizegather}

\begin{document}
\hrule % show text width
\begin{gather}\label{model3_coef}
  y_{t}^{3} = -145.071 - 0.003*x_{t-1}^{7} +
  0.459*x_{t}^{6} +
  0.001*x_{t-1}^{8} -5.071*x_{t-1}^{9} + 7.322*x_{t-1}^{5} -
  0.235*x_{t-1}^{1}
\end{gather}
\begin{multline}\label{model3_coef_alt}
  y_{t}^{3} = -145.071 - 0.003*x_{t-1}^{7}  
  + 0.459*x_{t}^{6} + 0.001*x_{t-1}^{8} 
  \\
  - 5.071*x_{t-1}^{9} + 7.322*x_{t-1}^{5} - 0.235*x_{t-1}^{1}
\end{multline}
\hrule % show text width
\end{document}

Result

In this case of the page layout, the equation is still much too large for a pleasant outcome and package resizegather warns, if the scaling factor gets below a threshold (default: 95%, can be configured with option warningthreshold):

Package resizegather Warning: Equation line 1 is too large by 92.86534pt
(resizegather)                in environment `gather' on input line 12.

It should be kept in mind, that the reader should be able to read the equation. Since also the indexes gets scaled down, many readers would need magnifying glasses. Therefore the second equation shows the same equation split in two lines and in its natural size. Package amsmath provides many ways to split an equation.

Heiko Oberdiek
  • 271,626
  • This is really nice. Thanks. Though, is it possible to use this selectively? I.e., apply it only to what ever gather that I wish and not all? – Pouya Nov 12 '18 at 17:09
  • 1
    @Pouya There are options to enable and disable the behavior: \resizegathersetup{enable} and \resizegathersetup{disable}. – Heiko Oberdiek Nov 13 '18 at 22:53
-1

You can use \scalebox as in this example

\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{thmtools}

\begin{document} \begin{equation}
\scalebox{4.0}{$ y=2x+5 $} \end{equation} \end{document}

Mensch
  • 65,388