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}
4
  • Welcome to TeX SE! What are you actually trying to do? That is, what did you hope this code would do?
    – cfr
    Apr 6, 2015 at 3:52
  • Does the code work if you remove the \resizebox? Also, the parameter needs to be put in math mode: \resizebox{<length>}{<height>}{$ math content $}. Apr 6, 2015 at 4:12
  • 1
    it works like \mbox (so takes you out of math mode) but scaling text is always the wrong thing to do Apr 6, 2015 at 8:51
  • Is there a reason you didn't accept any of the answers? Nov 9, 2022 at 20:44

3 Answers 3

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}
6
  • @Stan: If the solution worked for you please see How do you accept an answer? and perhaps How does accepting an answer work?. Jun 10, 2015 at 6:21
  • This does not seem to be working for multiple equations in equation environment.
    – IgotiT
    Mar 26, 2017 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.. Mar 27, 2017 at 8:23
  • @PeterGrill: For resizebox to work for multiple equations in align environment we need put resizebox command before every equation.
    – IgotiT
    Mar 28, 2017 at 2: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. Mar 28, 2017 at 5:06
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.

2
  • 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, 2018 at 17:09
  • 1
    @Pouya There are options to enable and disable the behavior: \resizegathersetup{enable} and \resizegathersetup{disable}. Nov 13, 2018 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}
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .