9

I really don't understand what's the problem with this piece of code:

\documentclass[a4paper,11pt]{article}

\usepackage{amsmath} % declares a predefined package for math

\begin{document} %starts document

\begin{align} %starts a formula block
\text{Number of looks in\newline azimuth direction 
    &= \frac{\text{Pixel spacing slant range}}{\text{Pixel spacing azimuth}}\times \sin (\text{Incidence angle})}\\
    &= \frac{9.3685143}{3.5448059\times \sin (23.871\circ)}
\end{align} %ends formula block

\end{document} %ends document  

When I try to build and run, I get a bunch of errors, including:

line 11: Misplaced alignment tab character &. \end{align}
line 11: Missing $ inserted. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Misplaced alignment tab character &. \end{align}
line 11: Missing $ inserted. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Misplaced alignment tab character &. \end{align}
line 11: Missing $ inserted. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Misplaced alignment tab character &. \end{align}
line 11: Missing $ inserted. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Misplaced alignment tab character &. \end{align}
line 11: Misplaced \omit. \end{align}
line 11: Misplaced \cr. \end{align}
line 11: Misplaced \noalign. \end{align}
line 11: Missing $ inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing $ inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing $ inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing $ inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing $ inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing { inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing { inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing { inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Missing \cr inserted. \end{align}
line 11: Missing { inserted. \end{align}
line 11: Missing { inserted. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Missing $ inserted. \end{align}
line 11: Missing } inserted. \end{align}
line 11: Misplaced alignment tab character &. \end{align}
line 11: Misplaced \omit. \end{align}
line 11: Misplaced \cr. \end{align}
line 11: Misplaced \cr. \end{align}
line 11: Extra }, or forgotten \endgroup. \end{align}
line 11: Extra }, or forgotten \endgroup. \end{align}
line 11: Missing number, treated as zero. \end{align}
line 11: Illegal unit of measure (pt inserted). \end{align}
line 11: Missing number, treated as zero. \end{align}
line 11: Illegal unit of measure (pt inserted). \end{align}
line 11: Improper \halign inside $$'s. \end{align}
line 11: Misplaced alignment tab character &. \end{align}
line 11: Missing $ inserted. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Misplaced alignment tab character &. \end{align}
line 11: Missing $ inserted. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Misplaced alignment tab character &. \end{align}
line 11: Missing $ inserted. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Misplaced alignment tab character &. \end{align}
line 11: Missing $ inserted. \end{align}
line 11: Extra }, or forgotten $. \end{align}
line 11: Extra }, or forgotten $. \end{align}  

As you know, line 11 is: \end{align}

3
  • 3
    \text can't span over a & column. You have to use a different approach. As well, use the siunitx package for a proper formatting of the angle within \sin
    – user31729
    Aug 12, 2016 at 6:28
  • 3
    shouldn’t the sin in the second line be a product and not below the fraction bar?
    – Tobi
    Aug 12, 2016 at 6:42
  • @Tobi Congratulations, nobody noticed so far :-)
    – Johannes_B
    Aug 12, 2016 at 6:43

3 Answers 3

10

Probably you like to achieve this:

enter image description here

Instead of \text in first occasion you should use \parbox which enable to write two line text. After than you need to clean-up remedy with curly braces:

\begin{document} %starts document

\begin{align} %starts a formula block
\parbox{8.5em}{Number of looks in\\ azimuth direction}
    &= \frac{\text{Pixel spacing slant range}}
            {\text{Pixel spacing azimuth}}\times \sin (\text{Incidence angle})\\
    &= \frac{9.3685143}{3.5448059\times \sin (23.871^\circ)}
\end{align} %ends formula block

\end{document}

Addendum: Considering Andrew Swann comment, use siunitx for units and make text width a bit wider with geometry package I obtain:

enter image description here

\documentclass[a4paper,11pt]{article}
\usepackage[showframe]{geometry} % show page layout and make text width wider ...
                                 % in final use option "showframe" had to be removed
\usepackage{amsmath} % declares a predefined package for math
\usepackage{siunitx}

\begin{document} %starts document

\begin{align} %starts a formula block
\parbox{8.3em}{\centering Number of looks in\\ azimuth direction}
    &= \frac{\text{Pixel spacing slant range}}
            {\text{Pixel spacing azimuth}\times \sin (\text{Incidence angle})}\\[1ex]
    &= \frac{9.3685143}{3.5448059\times \sin (\SI{23.871}{\degree})}
\end{align} %ends formula block

\end{document}

Edit: It seems that factor \sin{...} had to be in the denominator. I correct this my misunderstanding of given MWE. Above mine MWE and image of equation is now corrected.

4
  • 1
    You might consider adding \centering to the parbox. Aug 12, 2016 at 6:55
  • @AndrewSwann, you have right, with centering of text in the parbox the equation looks better :-)
    – Zarko
    Aug 12, 2016 at 7:16
  • ok, thanks. but the second equation's right. I mean \sin should be in the denominator. But the problem is solved. I guess I should add the documentation for all those packages to my notes. :-) Aug 12, 2016 at 7:29
  • @sepideh, sorry I didn't figured out from you MWE .. I will correct this immediately.
    – Zarko
    Aug 12, 2016 at 7:36
7

A slightly different approach (other than using \parbox), by applying the more general \genfrac command and using it for \textfrac.

According to Tobi's comment above, the equations provided by the O.P. contained an error regarding the position of the \sin.

I also used siunitx for the display of the angular value.

\documentclass[a4paper,11pt]{article}

\usepackage{siunitx}
\usepackage{amsmath} % declares a predefined package for math

\newcommand{\textfrac}[2]{\genfrac{}{}{0pt}{0}{\text{#1}}{\text{#2}}}
\begin{document} %starts document


\begin{align} %starts a formula block
  \textfrac{Number of looks}{in azimuth direction}
    &= \frac{\text{Pixel spacing slant range}}{\text{Pixel spacing azimuth}\times \sin \left(\text{Incidence angle}\right)}\\
    &= \frac{9.3685143}{3.5448059\times \sin (\SI{23.871}{\degree})}
\end{align} %ends formula block

\end{document} %ends document

enter image description here

3

You can't use \newline in \text. The two-line descriptor on the left-hand side can be done with tabular, so you don't have to guess a width. Here I use centering, you can choose left alignment.

\documentclass[a4paper,11pt]{article}
\usepackage{amsmath}

\begin{document}

\begin{align}
\begin{tabular}{@{}c@{}}
  Number of looks in\\
  azimuth direction
\end{tabular}
    &= \frac{\text{Pixel spacing slant range}}
            {\text{Pixel spacing azimuth}\times\sin (\text{Incidence angle})} \\
    &= \frac{9.3685143}{3.5448059\times \sin (23.871^\circ)}
\end{align}

\end{document}

enter image description here

4
  • I'm using TexStudio integrated with MikTEX 2.9 and you know while debugging, it doesn't give you much information. Maybe if I was using a better IDE, I was better in LaTEX codes. TexStudio is good and comfortable. The only problem I the debugging. Do you know of any other good IDE for LaTEX which can be used on a Win7x64 machine? Aug 12, 2016 at 7:58
  • 1
    @sepideh Sorry, I use neither an IDE nor Windows. Debugging an align is a question of (1) using the right syntax to begin with; (2) commenting out all rows but one and check.
    – egreg
    Aug 12, 2016 at 8:02
  • so how do you code in latex without any IDE? Aug 12, 2016 at 9:21
  • 1
    @sepideh I use a text editor; for longer projects I use Aquamacs (Emacs for Mac OS X), for snippets nano from the terminal.
    – egreg
    Aug 12, 2016 at 9:22

You must log in to answer this question.

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