我真的不明白这段代码有什么问题:
\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
当我尝试构建并运行时,出现一堆错误,包括:
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}
如您所知,第 11 行是:\end{align}
答案1
您可能希望实现这一点:
\text
第一次你应该使用哪个\parbox
选项来写两行文本。之后你需要用花括号来清理解决方案:
\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}
附录:
考虑到 Andrew Swann 的评论,使用siunitx
单位并使用包使文本宽度稍微宽一些,geometry
我获得:
\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}
编辑:
看来这个因子\sin{...}
必须放在分母中。我纠正了我对给定 MWE 的误解。上面的我的 MWE 和方程式图像现已更正。
答案2
一种稍微不同的方法(除了使用\parbox
),通过应用更通用的\genfrac
命令并将其用于\textfrac
。
根据 Tobi 的上述评论,OP 提供的方程式在 的位置方面存在错误\sin
。
我也用它siunitx
来显示角度值。
\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
答案3
您不能\newline
在 中使用\text
。左侧的两行描述符可以用 完成tabular
,因此您不必猜测宽度。这里我使用居中,您可以选择左对齐。
\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}