![如何在投影機中左對齊一些(不是全部)單行標記方程式?我嘗試了“fleqn”,但它出現了問題](https://rvso.com/image/472333/%E5%A6%82%E4%BD%95%E5%9C%A8%E6%8A%95%E5%BD%B1%E6%A9%9F%E4%B8%AD%E5%B7%A6%E5%B0%8D%E9%BD%8A%E4%B8%80%E4%BA%9B%EF%BC%88%E4%B8%8D%E6%98%AF%E5%85%A8%E9%83%A8%EF%BC%89%E5%96%AE%E8%A1%8C%E6%A8%99%E8%A8%98%E6%96%B9%E7%A8%8B%E5%BC%8F%EF%BC%9F%E6%88%91%E5%98%97%E8%A9%A6%E4%BA%86%E2%80%9Cfleqn%E2%80%9D%EF%BC%8C%E4%BD%86%E5%AE%83%E5%87%BA%E7%8F%BE%E4%BA%86%E5%95%8F%E9%A1%8C.png)
equation
我正在使用 Beamer 進行演示,並且在兩種情況下使用該環境:
- 僅包含數學表達式的行,位於兩行文字之間,且水平居中(幾乎是標準情況,請參見下面 MWE 中的第一個方程式)
- 與方程式並列的一些文本段落(數學環境之外)(如下面 MWE 中的第二個和第三個方程式)
為了實現後者,我利用了minipage
環境。我曾經使用過該columns
環境,但調整到正確的視覺對齊方式要困難得多。
這樣做的動機是文本段落給出了其側面出現的公式的描述或定義。然而,簡單地將文本和\begin{equation}
[...]\end{equation}
放在相鄰的minipage
s 中會導致中間出現一個間隙,我覺得這個間隙很難看並且我想填充- 更準確地說,我希望文本和公式更接近每個其他靠近幻燈片中心(請參閱下面 MWE 中第二個和第三個方程式之間的差異)。
我發現這可以透過將文字放入flushright
環境中並將equation
環境封閉到環境中fleqn
(載入nccmath
包)來實現。請注意,我不想全部方程式在左側對齊,所以我沒有\usepackage[fleqn]{amsmath}
在序言中使用(無論如何,它在投影機中不起作用,因為它會引發選項衝突錯誤)。
我沒有使用flalign
或類似的,因為它們似乎無法達到單行方程式所需的結果,但僅在兩行或更多行上的方程式需要左對齊時才起作用。
問題:一切工作正常,直到我嘗試交叉引用方程式。事實上,如果我給環境\label
中的一個方程式賦予afleqn
並嘗試在其他地方引用它\ref{}
,則後者會導致方程式本身附近顯示的數字不同。
我已經看到了類似問題的幾個答案,但很少有人關注投影機(因此出現了問題fleqn
),並且沒有一個解決了我的問題。
非常歡迎任何幫助!
這是一個 MWE:
\documentclass[aspectratio=169]{beamer}
\usetheme{Antibes}
\usepackage{nccmath}
\begin{document}
\begin{frame}[fragile]
An equation outside of the \verb|fleqn| environment. I give it the label: \verb|\label{eq1}|.
\begin{equation}\label{eq1}
F = ma
\end{equation}
\begin{minipage}{0.5\linewidth}
\begin{flushright}
Text on the side equation in \verb|fleqn| \\
(the equation has label: \verb|\label{eq2}|)
\end{flushright}
\end{minipage}
\hspace{0.5em}
\begin{minipage}{0.45\linewidth}
\begin{fleqn}
\begin{equation}\label{eq2}
\delta q = {\rm d}u + P\,{\rm d}v
\end{equation}
\end{fleqn}
\end{minipage}\\
\vspace{1.5em}
\begin{minipage}{0.5\linewidth}
\begin{flushright}
Text on the side equation without \verb|fleqn| \\
(the equation has label: \verb|\label{eq3}|)
\end{flushright}
\end{minipage}
\hspace{1em}
\begin{minipage}{0.45\linewidth}
\begin{equation}\label{eq3}
\frac{\partial\rho}{\partial t} + \nabla\cdot\left(\rho\vec{v}\right) = 0
\end{equation}
\end{minipage}\\
\vspace{1em}
Note, in the latter case, the space between text and equation, that I'd like to fill.
\begin{itemize}
\item Here I reference the first equation, using \verb|\ref{eq1}|: Eq.~\ref{eq1}.
\item Here I reference the second equation, using \verb|\ref{eq2}|: Eq.~\ref{eq2}.
\item Here I reference the third equation, using \verb|\ref{eq3}|: Eq.~\ref{eq3}.
\end{itemize}
\end{frame}
\end{document}
答案1
使用該套件的不同方法varwidth
(這將使整個文字+方程式塊居中):
\documentclass[aspectratio=169]{beamer}
\usetheme{Antibes}
\usepackage{varwidth}
\begin{document}
\begin{frame}[fragile]
An equation outside of the \verb|fleqn| environment. I give it the label: \verb|\label{eq1}|.
\begin{equation}\label{eq1}
F = ma
\end{equation}
\begin{equation}
\text{\begin{varwidth}{.4\textwidth}
\raggedleft
Text on the side equation in \\
(the equation has label: )
\end{varwidth}\quad
}
\delta q = {\rm d}u + P\,{\rm d}v
\label{eq2}
\end{equation}
Note, in the latter case, the space between text and equation, that I'd like to fill.
\begin{itemize}
\item Here I reference the first equation, using \verb|\ref{eq1}|: Eq.~\ref{eq1}.
\item Here I reference the second equation, using \verb|\ref{eq2}|: Eq.~\ref{eq2}.
\end{itemize}
\end{frame}
\end{document}
如果您喜歡固定寬度的小型頁面(這將使等式的左邊緣居中):
\documentclass[aspectratio=169]{beamer}
\usetheme{Antibes}
\begin{document}
\begin{frame}[fragile]
An equation outside of the \verb|fleqn| environment. I give it the label: \verb|\label{eq1}|.
\begin{equation}\label{eq1}
F = ma
\end{equation}
\begin{equation}
\text{\begin{minipage}{.48\textwidth}
\raggedleft
Text on the side equation in \\
(the equation has label: )
\end{minipage}\quad
}
\delta q = {\rm d}u + P\,{\rm d}v
\hskip \textwidth minus \textwidth
\label{eq2}
\end{equation}
Note, in the latter case, the space between text and equation, that I'd like to fill.
\begin{itemize}
\item Here I reference the first equation, using \verb|\ref{eq1}|: Eq.~\ref{eq1}.
\item Here I reference the second equation, using \verb|\ref{eq2}|: Eq.~\ref{eq2}.
\end{itemize}
\end{frame}
\end{document}