如何在同一行放置带有不同编号的多个公式?
嘿,刚好处理过类似的需求!要把多个短公式塞进同一行还各自带独立编号,用LaTeX的话可以这么搞:
方案1:用minipage包裹单个equation环境(自动编号)
这是最稳妥的自动编号方法,通过minipage把每个公式限制在固定宽度的盒子里,让它们并排显示,每个equation环境会自动生成独立编号——完全符合你要的效果:
\usepackage{amsmath} % *必须加载amsmath包*,否则equation环境和minipage的排版会出问题 \begin{document} % 调整minipage的宽度,确保所有盒子能在一行放下(根据公式长度灵活调整) \begin{minipage}{0.22\textwidth} \begin{equation} a = b \end{equation} \end{minipage} \begin{minipage}{0.22\textwidth} \begin{equation} c = d \end{equation} \end{minipage} \begin{minipage}{0.22\textwidth} \begin{equation} d = e \end{equation} \end{minipage} \begin{minipage}{0.22\textwidth} \begin{equation} e = f \end{equation} \end{minipage} \end{document}
编译后就能得到你想要的展示:$a = b$ (1) $c = d$ (2) $d = e$ (3) $e = f$ (4),而且编号是自动递增的,后续修改公式顺序也不用手动改编号。
方案2:手动控制编号(适合极短公式)
如果公式特别短,也可以用行内公式结合编号命令手动生成编号(不过还是推荐方案1,自动编号更省心):
\usepackage{amsmath} \begin{document} $a = b$ \refstepcounter{equation} (\theequation) \quad $c = d$ \refstepcounter{equation} (\theequation) \quad $d = e$ \refstepcounter{equation} (\theequation) \quad $e = f$ \refstepcounter{equation} (\theequation) \end{document}
这里\refstepcounter{equation}会让公式编号自动加1,\theequation显示当前编号,\quad用来控制公式之间的间距,避免挤在一起。
小技巧:
- 调整
minipage宽度时留一点余量(比如用0.22而非0.25),避免因为公式长度或页边距意外换行; - 如果想让公式在一行里均匀分布,可以在
minipage之间加\hfill,比如:
\begin{minipage}{0.2\textwidth}...\end{minipage}\hfill \begin{minipage}{0.2\textwidth}...\end{minipage}\hfill ...
内容的提问来源于stack exchange,提问作者Huzhenyu
相关产品推荐
相关产品推荐

