6

This part C\frac{1}{\sqrt{G}}\sqrt{\rho} doesn't seem to be on the same height as this part \sqrt{b}\sqrt{l} when compiled. What am I doing wrong?

\begin{flalign*}
T=C\frac{1}{\sqrt{G}}\sqrt{\rho}\sqrt{b}\sqrt{l} &&
\end{flalign*}

migrated from stackoverflow.com Dec 4 '13 at 7:25

This question came from our site for professional and enthusiast programmers.

12

You're not doing anything wrong, you're just wanting something that is not the default. The reason for the different \sqrts is because \rho and b (and l) have different height and depth, which \sqrt accommodates.

Here are some alternatives (non-exhaustive) that tried to show you what is possible:

enter image description here

\documentclass{article}
\usepackage{mathtools}% http://ctan.org/pkg/mathtools
\begin{document}
\begin{flalign*}
  T &= C\frac{1}{\sqrt{G}}\sqrt{\rho}\sqrt{b}\sqrt{l} \\
  T &= C\frac{1}{\sqrt{G}}\sqrt{\vphantom{b}\rho}\sqrt{b}\sqrt{l} \\
  T &= C\frac{1}{\sqrt{G}}\sqrt{\mathrlap{\smash{\mkern-2mu\rho}}\phantom{b}}\sqrt{b}\sqrt{l} \\
  T &= C\frac{1}{\sqrt{G}}\sqrt{\vphantom{b}\mkern-2mu\rho\mkern2mu}\sqrt{b}\sqrt{l} \\
  T &= C\frac{1}{\sqrt{G}}\sqrt{\rho b l} \\
  T &= C\frac{1}{\sqrt{G}}\sqrt{\rho\,b\,l} \\
  T &= C\frac{1}{\sqrt{G}}\sqrt{\mkern-2mu\rho\,b\,l}
\end{flalign*}
\end{document}

Options include

  • horizontal adjustment of \rho using \mkern (math kerning);
  • removal of depth (and height) using \smash;
  • vertical struts using \vphantom;
  • overlapping (math right overlap) with \phantom content to provide similar horizontal spacing/placement.

Many other options also exist, including moving \sqrt{rho} to form part of the \frac.

7

Don't use flalign for left aligning displays; this is a job for the fleqn option.

The problem is that a lonely \sqrt{\rho} shouldn't have too much space between the bar and the rho, but this obviously gives asymmetric results when square roots appear together like in

$\sqrt{a}+\sqrt{b}$

There are several tricks for equalizing square root symbols, each with its pros and its cons.

A couple of adjustments are to be made anyway: the \rho under the square root should be backspaced a little, to avoid a hole; between two consecutive square roots a thin space should be added.

In order to solve the main problem, two strategies are possible: the first one is easier, as it consists in adding \mathstrut under the square roots; the second strategy is to remove the depth from \rho and adding a phantom b.

Which one to choose depends on many factors; leave these decisions to the final revision of your document. A change in notation might make obsolete one of these constructions.

\documentclass[fleqn]{article}
\usepackage{amsmath}
\usepackage{lipsum} % just for the example
\begin{document}
\lipsum*[2]
\[
T=C\frac{1}{\sqrt{G}}\sqrt{\!\rho\mathstrut}\,\sqrt{b\mathstrut}\,\sqrt{l\mathstrut}
\]
\lipsum*[2]
\[
T=C\frac{1}{\sqrt{G}}
  \vphantom{\rho}\sqrt{\!\smash[b]{\rho}\vphantom{b}}\,\sqrt{b}\,\sqrt{l}
\]
\lipsum*[2]
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.