
我遇到一個問題,\ref 指令排版的數字比對齊方程式應有的數字高 1;方程式編號正確,但引用已關閉。方程式環境運作正常。
\documentclass{pnastwo}
\usepackage[xdvi]{graphicx}
\usepackage{amsmath}
\usepackage{xfrac}
\usepackage{refcount}
\begin{document}
\begin{article}
\begin{align}
vt=d\\\nonumber
\label{eq:1}
\end{align}
\begin{align}
\frac{d}{t}=v\\\nonumber
\label{eq:2}
\end{align}
\begin{equation}
t=\frac{d}{v}\\\nonumber
\label{eq:3}
\end{equation}
Here is the first reference: \ref{eq:1}
And here is the second: \ref{eq:2}
And here is the third: \ref{eq:3}
\end{article}
\end{document}
產生
這是第一個參考:2
這是第二個:??
這是第三個:3
答案1
在或 之\\
類的環境中永遠不應該有尾隨。您也不應該將或用於一行顯示。而且裡面什麼事都不做。align
gather
align
gather
\\
equation
該\label
命令指的是它所在的顯示行;給它之後\nonumber
只會混淆 LaTeX。
\documentclass{pnastwo}
\usepackage{amsmath}
\usepackage{lipsum} % just for the example
\begin{document}
\begin{article}
\lipsum*[1]
\begin{align}
vt &= d \label{eq:1} \\
\frac{d}{t} & =v \label{eq:2}
\end{align}
\lipsum*[3]
\begin{equation}
t=\frac{d}{v} \label{eq:3}
\end{equation}
\lipsum[4]
Here is the first reference: \ref{eq:1}
And here is the second: \ref{eq:2}
And here is the third: \ref{eq:3}
\end{article}
\end{document}
最後的筆記
該lipsum
包僅用於提供文字。不要使用xdvi
for 選項graphicx
:它存在,但只是為了向後相容。如果您不使用諸如 之類的驅動程序dvipdfmx
,則不應給出任何選項。我還刪除了範例中不需要的套件。