0

I do not know why \adjustbox seems to scale down an equation, when there is no need to do that, as the equation can fit in the text without scaling.

My understanding is that using \adjustbox{max width=\textwidth} will only make it scale down/resize, if the current size is too large to fit. This is from the manual

enter image description here

So I do not know what Am I doing wrong here. As it is making the equation smaller compared to when not using \adjustbox.

I want \adjustbox to scale the equation only if it is too wide to fit into the textwidth. How to do that?

MWE. ps the actual equations are autogenerated. I just add the adjustbox around them

\documentclass[12pt]{article} \usepackage{amsmath} \usepackage{adjustbox} \usepackage{mleftright} \mleftright \begin{document} \begin{equation*} \adjustbox{max width=\textwidth}{% $y \left(x \right) = \frac{\left(-4 x c_{2}+2 c_{1}\right) \sin \left(2 x \right)-4 \left(c_{1} x +\frac{c_{2}}{2}\right) \cos \left(2 x \right)}{\cos \left(2 x \right) c_{1}+\sin \left(2 x \right) c_{2}}$} \end{equation*} \begin{equation*} \adjustbox{max width=\pagewidth}{% $y \left(x \right) = \frac{\left(-4 x c_{2}+2 c_{1}\right) \sin \left(2 x \right)-4 \left(c_{1} x +\frac{c_{2}}{2}\right) \cos \left(2 x \right)}{\cos \left(2 x \right) c_{1}+\sin \left(2 x \right) c_{2}}$} \end{equation*} \begin{equation*} \adjustbox{max size={\pagewidth}{\pageheight}}{% $y \left(x \right) = \frac{\left(-4 x c_{2}+2 c_{1}\right) \sin \left(2 x \right)-4 \left(c_{1} x +\frac{c_{2}}{2}\right) \cos \left(2 x \right)}{\cos \left(2 x \right) c_{1}+\sin \left(2 x \right) c_{2}}$} \end{equation*} \begin{equation*} y \left(x \right) = \frac{\left(-4 x c_{2}+2 c_{1}\right) \sin \left(2 x \right)-4 \left(c_{1} x +\frac{c_{2}}{2}\right) \cos \left(2 x \right)}{\cos \left(2 x \right) c_{1}+\sin \left(2 x \right) c_{2}} \end{equation*} \end{document} 

I tried few things above. Here is the output, compiled using lualatex

enter image description here

TL 2020 after OCT update. On Linux.

1
  • 1
    It doesn't scale, the y has the same size. But you no longer have a display math frac but inline/textstyle. Commented Nov 26, 2020 at 7:38

1 Answer 1

2

You should look at the output of

\documentclass{article} \usepackage{amsmath} \begin{document} \[ a=\frac{b}{c} \] \[ \mbox{$a=\frac{b}{c}$} \] \end{document} 

enter image description here

What's the difference? Of course that inside \[...\] (or equation, equation* and all other math displays) TeX starts in display math mode. To the contrary, inside $...$ TeX starts in inline math mode.

If you want to strain your readers' eyes with that approach, at least do yourself the favor of defining a suitable shorthand:

\newcommand{\strain}[1]{\adjustbox{max width=\textwidth}{$\displaystyle#1$}} 

With \displaystyle you get back to the display math mode in force at the beginning of the display.

Note that \pagewidth makes little sense, so I used \textwidth.

\documentclass[12pt]{article} \usepackage{amsmath} \usepackage{adjustbox} \usepackage{mleftright} \mleftright \newcommand{\strain}[1]{\adjustbox{max width=\textwidth}{$\displaystyle#1$}} \begin{document} \begin{equation*} y \left(x \right) = \frac{\left(-4 x c_{2}+2 c_{1}\right) \sin \left(2 x \right)-4 \left(c_{1} x +\frac{c_{2}}{2}\right) \cos \left(2 x \right)}{\cos \left(2 x \right) c_{1}+\sin \left(2 x \right) c_{2}} \end{equation*} \begin{equation*} \strain{ y \left(x \right) = \frac{\left(-4 x c_{2}+2 c_{1}\right) \sin \left(2 x \right)-4 \left(c_{1} x +\frac{c_{2}}{2}\right) \cos \left(2 x \right)}{\cos \left(2 x \right) c_{1}+\sin \left(2 x \right) c_{2}} } \end{equation*} \begin{equation*} \strain{ y \left(x \right) = \frac{\left(-4 x c_{2}+2 c_{1}\right) \sin \left(2 x \right)-4 \left(c_{1} x +\frac{c_{2}}{2}\right) \cos \left(2 x \right)}{\cos \left(2 x \right) c_{1}+\sin \left(2 x \right) c_{2}} \frac{\left(-4 x c_{2}+2 c_{1}\right) \sin \left(2 x \right)-4 \left(c_{1} x +\frac{c_{2}}{2}\right) \cos \left(2 x \right)}{\cos \left(2 x \right) c_{1}+\sin \left(2 x \right) c_{2}} \frac{\left(-4 x c_{2}+2 c_{1}\right) \sin \left(2 x \right)-4 \left(c_{1} x +\frac{c_{2}}{2}\right) \cos \left(2 x \right)}{\cos \left(2 x \right) c_{1}+\sin \left(2 x \right) c_{2}} } \end{equation*} \end{document} 

enter image description here

1
  • thanks for the fix. I know the difference between inline vs. display. But because I had both initially inside equation, I thought they will remain as display mode. I just did not realize that adding $$ inside equation makes it go back to inline mode. Commented Nov 26, 2020 at 10:25

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.