我想列出一些方程式,但它们没有与项目符号出现在同一行。
以下是代码示例
\documentclass[11pt,a4paper]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\begin{document}
\begin{description}
\item[i) ] foo foo foo foo
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
\item[ii)]
\begin{equation}
x^2 + y^2 = z^2
\end{equation}
\end{description}
\end{document}
是否可以将第二个等式写在描述旁边,使其看起来像这样:
ii) x^2 + y^2 = z^2 (等式 2 的个数)
答案1
基于这个答案经过海科·奥伯迪克,您可以使用\inlineequation
:
\documentclass[11pt,a4paper]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\makeatletter
\newcommand*{\inlineequation}[2][]{%
\begingroup
% Put \refstepcounter at the beginning, because
% package `hyperref' sets the anchor here.
\refstepcounter{equation}%
\ifx\\#1\\%
\else
\label{#1}%
\fi
% prevent line breaks inside equation
\relpenalty=10000 %
\binoppenalty=10000 %
\ensuremath{%
% \displaystyle % larger fractions, ...
#2%
}%
\hfill\@eqnnum
\endgroup
}
\makeatother
\usepackage{hyperref}
\begin{document}
\begin{description}
\item[i) ] foo foo foo foo \inlineequation{a^2 + b^2 = c^2}
\item[ii)] \inlineequation{x^2 + y^2 = z^2}
\end{description}
\end{document}
答案2
这里有一种方法:
\documentclass[11pt,a4paper]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\begin{document}
\begin{description}
\item[i) ] foo foo foo foo
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
\item[ii)]\leavevmode\vspace*{-\baselineskip}
\begin{equation}x^2 + y^2 = z^2 \end{equation}
\end{description}
\end{document}