1

Why do I get output like this ?

Why is the alignment varying if I embed the special characters like lambda and eta ?

code sample 1:

\begin{gather}
\label{eq:Highest spatial frequency}
\frac{2 \text{ }\eta \text{ }\sin (\alpha )}{\lambda }\\
\shortintertext{where}
\begin{aligned}
&\lambda \text{is the wavelength of the monochromatic light used}\\
&\eta \text{refers to the refractive index of the immersion fluid}\\
&\alpha \text{acceptance angle of the objective}
\end{aligned}\notag
\end{gather}

output:

1

and ,

code snippet 2:

\begin{gather}
\label{eq:Highest spatial frequency}
\frac{2 \text{ }\eta \text{ }\sin (\alpha )}{\lambda }\\
\shortintertext{where}
\begin{aligned}
&$\lambda$ \text{is the wavelength of the monochromatic light used}\\
&$\eta$ \text{refers to the refractive index of the immersion fluid}\\
&$\alpha$ \text{acceptance angle of the objective}
\end{aligned}\notag
\end{gather}

Output: 2

  • In math mode spacing is determined by TeX. If you want a space you should leave on at within the start and end of the \text{} macro. So it should be \text{ is the wavelength of the monochromatic light used} – Peter Grill Apr 29 '13 at 2:31
  • The second example should give you a bunch of error messages as you are already inside a math environment and then switch back to text with $ but then use a math-mode-only command (the Greek letters). The following space (between the second $ and \text) is in fact in text-mode and thus shows up. – Qrrbrbirlbel Apr 29 '13 at 2:44
4

Spacing in math mode is controlled by TeX. If you want spacing between the math and text you should leave a space within the text{} macro:

enter image description here

Notes:

  • You should not be using \text{ } to add space in math mode. There is a reason why TeX produces the spacing it does in math mode. For instance look at the output produced by $-x-y$, and you will notice a different amount of spacing between the unary "negative" and the binary "minus" operator.

  • Not sure how you are getting your second example to compile, as it does not compile for me. One of the reasons why it is always best to post a fully compilable MWE including \documentclass and the appropriate packages.

Code:

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\begin{gather}
\label{eq:Highest spatial frequency}
\frac{2 \eta \sin (\alpha)}{\lambda }\\
\shortintertext{where}
\begin{aligned}
&\lambda \text{ is the wavelength of the monochromatic light used}\\
&\eta \text{ refers to the refractive index of the immersion fluid}\\
&\alpha \text{ acceptance angle of the objective}
\end{aligned}\notag
\end{gather}
\end{document}
  • 2
    &\text{$\lambda$ is the ...}\\ is clearer. – egreg Apr 29 '13 at 9:27
0

Thank you and another way it can be done which I just figured out is the below (by using ~ ) :

\begin{gather}
\label{eq:Highest spatial frequency}
%f_c=\frac{2. \eta \text{ } .(  \text{Sin($\alpha$)})}{\lambda }\\
\frac{2 \text{ }\eta \text{ }\sin (\alpha )}{\lambda }\\
\shortintertext{where}
\begin{aligned}
    &\lambda ~\text{is the wavelength of the monochromatic light used}\\
    &\eta ~\text{refers to the refractive index of the immersion fluid}\\
    &\alpha ~\text{acceptance angle of the objective}
\end{aligned}\notag
\end{gather}

image1

  • 1
    Don't type 2\text{ }\eta\text{ }\sin: the output is wrong. A thin space will automatically appear between 'eta' and 'sin', but no space is wanted between '2' and 'eta'. – egreg Apr 29 '13 at 9:26

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.