3

I am unable to fit this large expression under the square root in one line. Is there any option available to do the same?

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\begin{document}
    $\sqrt{49m_1^2 - 6(m_1 + 4)m_2 + 9m_2^2 - 4(7m_1 - 3m_2 + 4)r_1 + 4r_1^2 + 8(7m_1 - 3m_2 - 2r_1 + 4)r_2 + 16r_2^2 + 56m_1 + 16}$
\end{document}

If anyone can help, I will be grateful.

Charlotte
  • 963

2 Answers2

3

As you've discovered, the long square-root expression doesn't fit on a single line; see also the first equation in the screenshot below. (The framelines indicate the width of the textbox.)

One could use \resizebox to force the entire equation to fit on a single line, as is also demonstrated in the screenshot below. However, please don't do it. The resulting equation is so compressed as to become virtually undecipherable, unless you're willing to hand out magnifying glasses to your readers....

Instead, do consider replacing the \sqrt{...} notation with [...]^{0.5} notation and permitting LaTeX to come up with a suitable line break automatically. Your readers will deeply appreciate it.

enter image description here

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc} % that's the default nowadays
\usepackage[T1]{fontenc}
\usepackage{graphicx}  % for '\resizebox' macro
\usepackage{showframe} % draw framelines around textblock
\begin{document}

not good:

\medskip\noindent $\sqrt{49m_1^2 - 6(m_1 + 4)m_2 + 9m_2^2 - 4(7m_1 - 3m_2 + 4)r_1 + 4r_1^2

  • 8(7m_1 - 3m_2 - 2r_1 + 4)r_2 + 16r_2^2 + 56m_1 + 16}$

\bigskip truly awful:

\medskip\noindent \resizebox{\textwidth}{!}{% $\sqrt{49m_1^2 - 6(m_1 + 4)m_2 + 9m_2^2 - 4(7m_1 - 3m_2 + 4)r_1 + 4r_1^2

  • 8(7m_1 - 3m_2 - 2r_1 + 4)r_2 + 16r_2^2 + 56m_1 + 16}$}

\bigskip quite alright:

\medskip\noindent $\bigl[49m_1^2 - 6(m_1 + 4)m_2 + 9m_2^2 - 4(7m_1 - 3m_2 + 4)r_1 + 4r_1^2

  • 8(7m_1 - 3m_2 - 2r_1 + 4)r_2 + 16r_2^2 + 56m_1 + 16

\bigr]^{0.5^{\mathstrut}}$ \end{document}

Mico
  • 506,678
  • Thanks a lot! Why do you use \mathstrut? – Charlotte May 27 '21 at 06:50
  • @Math_Freak - The \mathstrut macro inserts an invisible object that's as tall as a round parenthesis. By writing \bigr]^{0.5^{\mathstrut}} instead of just \bigr]^{0.5}, one can increase the vertical spacing between the two lines of the long formula subtly but effectively. – Mico May 27 '21 at 08:16
3

There are so many options.

You can try to rearrange the expression under the root to make it shorter, if possible, for example like in this particular case a shorter equivalent is

$S=\sqrt{(3m_2+7m_1-2r_1+4r_2+4)^2-24m_2(2m_1+2r_2-r_1+2)}$

or just use an extra symbol, like

$S=\sqrt{T},$
where $T=\dots$

Or omit the root completely, presenting the expression as a square:

$S^2=\dots$

MWE:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\begin{document}

\begin{align} S&=\sqrt{(3m_2+7m_1-2r_1+4r_2+4)^2-24m_2(2m_1+2r_2-r_1+2)} \end{align}

\begin{align} S&=\sqrt{T} ,\ \text{where }\quad T&= 49m_1^2 - 6(m_1 + 4)m_2 + 9m_2^2 \ &- 4(7m_1 - 3m_2 + 4)r_1 + 4r_1^2 \nonumber \ &+ 8(7m_1 - 3m_2 - 2r_1 + 4)r_2 \nonumber \ &+ 16r_2^2 + 56m_1 + 16 \nonumber . \end{align}

\begin{align} S^2&= 49m_1^2 - 6(m_1 + 4)m_2 + 9m_2^2 \ &- 4(7m_1 - 3m_2 + 4)r_1 + 4r_1^2 \nonumber \ &+ 8(7m_1 - 3m_2 - 2r_1 + 4)r_2 \nonumber \ &+ 16r_2^2 + 56m_1 + 16 \nonumber . \end{align}

\end{document}

enter image description here

g.kov
  • 21,864
  • 1
  • 58
  • 95
  • I like your solutions , did you do the calculations by hand and shorten them or used some software? – Charlotte May 27 '21 at 07:24
  • The OP expressed the equation in inline math mode, while you've switched to display math mode. How would you adjust, say, the first solution (the one that uses \sqrt) to inline math mode, in case the equation starts somewhere in the middle of a line rather than at the beginning? – Mico May 27 '21 at 08:21
  • @Math_Freak: Of course, the CAS (Mathematica or any other available) is a proper tool to help with rearranging expressions and checking that the result is the same, but often you need to do some manual rearrangement. – g.kov May 27 '21 at 08:36
  • @Mico:The OP asks specifically to "fit this large expression under the square root in one line", there is nothing in the question that points out that there is anything else in that line, so there is no principal difference between inline and display math mode here. Obviously, the first solution with the root is not a good choice otherwise, that's why the other two are suggested. – g.kov May 27 '21 at 08:46