如何使较长的数学方程式变得美观且小巧,以适合一行?

如何使较长的数学方程式变得美观且小巧,以适合一行?

我正在编写一份乳胶报告,我必须使用一个方程式,但该方程式足够长,只能放在一行中,如果我使用mathbf{}它,它看起来会很奇怪。

以下是代码:

\documentclass[a4paper,twoside]{article}

\usepackage{epsfig}
\usepackage{subcaption}
\usepackage{calc}
\usepackage{amssymb}
\usepackage{amstext}
\usepackage{amsmath}
\usepackage{amsthm}


\usepackage[justification=centering]{caption}

\usepackage{multicol}
\usepackage{pslatex}
\usepackage{apalike}
\usepackage{SCITEPRESS}     % Please add other packages that you may need BEFORE the SCITEPRESS.sty package.


\begin{document}
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

\begin{equation}
\begin{aligned}
\mathbf{H_{2}^{(l+1)}} = \mathbf{ReLU (\alpha_{22}^{(l)} H_{2}^{(l)} W^{(l)}+\alpha_{21}^{(l)} H_{1}^{(l)} W^{(l)}} \\
 \mathbf{+\alpha_{23}^{(l)} H_{3}^{(l)} W^{(l)}+\alpha_{24}^{(l)} H_{4}^{(l)} W^{(l)} )}
 \end{aligned}
\end{equation}
\end{document}

它看起来像这样:

在此处输入图片描述

我怎样才能让它在一行中显示出来并且看起来更好?或者如果我必须拆分,那么如何让它在拆分模式下看起来更好?

谢谢

答案1

我认为你应该考虑对这个等式做一些改变。

  1. 你的方程式一行就已经足够了,为什么还要把它写成两行呢?
  2. 将所有东西都加粗可能不是一个好主意,所以你至少可以减少使用的粗体量。如果你想要直立的数学符号,你可以使用命令\mathrm
  3. 在书写l数学符号时,我们常常会混淆符号是“l”还是“1”,因此使用\ell输出草书“l”符号的命令可能是一个更好的主意。
  4. 您可以放置​​更大的括号,因为它们之间的内容有点大。

总而言之,我建议以下选项(5)或(6)。

\documentclass[a4paper,twoside]{article}

\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{bm}
\usepackage{pslatex}

\begin{document}

Original:
\begin{equation}
\begin{aligned}
\mathbf{H_{2}^{(l+1)}} = \mathbf{ReLU (\alpha_{22}^{(l)} H_{2}^{(l)} W^{(l)}+\alpha_{21}^{(l)} H_{1}^{(l)} W^{(l)}} \\
 \mathbf{+\alpha_{23}^{(l)} H_{3}^{(l)} W^{(l)}+\alpha_{24}^{(l)} H_{4}^{(l)} W^{(l)} )}
 \end{aligned}
\end{equation}

On one line:
\begin{equation}
\mathbf{H_{2}^{(l+1)}} = \mathbf{ReLU (\alpha_{22}^{(l)} H_{2}^{(l)} W^{(l)}+\alpha_{21}^{(l)} H_{1}^{(l)} W^{(l)}} \mathbf{+\alpha_{23}^{(l)} H_{3}^{(l)} W^{(l)}+\alpha_{24}^{(l)} H_{4}^{(l)} W^{(l)} )}
\end{equation}

On one line, with $\ell$ and bigger parentheses:
\begin{equation}
\mathbf{H_{2}^{(\bm{\ell}+1)}} = \mathbf{ReLU \Bigl( \alpha_{22}^{(\bm{\ell})} H_{2}^{(\bm{\ell})} W^{(\bm{\ell})}+\alpha_{21}^{(\bm{\ell})} H_{1}^{(\bm{\ell})} W^{(\bm{\ell})}}
 \mathbf{+\alpha_{23}^{(\bm{\ell})} H_{3}^{(\bm{\ell})} W^{(\bm{\ell})}+\alpha_{24}^{(\bm{\ell})} H_{4}^{(\bm{\ell})} W^{(\bm{\ell})} \Bigr)}
\end{equation}

On two lines, with $\ell$ and bigger parentheses:
\begin{multline}
\mathbf{H_{2}^{(\bm{\ell}+1)}} = \mathbf{ReLU \Bigl( \alpha_{22}^{(\bm{\ell})} H_{2}^{(\bm{\ell})} W^{(\bm{\ell})}+\alpha_{21}^{(\bm{\ell})} H_{1}^{(\bm{\ell})} W^{(\bm{\ell})}} \\
\mathbf{+\alpha_{23}^{(\bm{\ell})} H_{3}^{(\bm{\ell})} W^{(\bm{\ell})}+\alpha_{24}^{(\bm{\ell})} H_{4}^{(\bm{\ell})} W^{(\bm{\ell})} \Bigr)}
\end{multline}

On one line, with $\ell$, bigger parentheses, and less bold:
\begin{equation}
\mathbf{H}_2^{(\ell+1)} = \mathbf{ReLu}\Bigl( \alpha_{22}^{(\ell)} \mathbf{H}_2^{(\ell)} \mathbf{W}^{(\ell)} + \alpha_{21}^{(\ell)} \mathbf{H}_1^{(\ell)} \mathbf{W}^{(\ell)} + \alpha_{23}^{(\ell)} \mathbf{H}_3^{(\ell)} \mathbf{W}^{(\ell)} + \alpha_{24}^{(\ell)} \mathbf{H}_4^{(\ell)} \mathbf{W}^{(\ell)} \Bigr)
\end{equation}

On one line, with $\ell$, bigger parentheses, and \texttt{mathrm} instead of \texttt{mathbf}:
\begin{equation}
\mathrm{H}_2^{(\ell+1)} = \mathrm{ReLu}\Bigl( \alpha_{22}^{(\ell)} \mathrm{H}_2^{(\ell)} \mathrm{W}^{(\ell)} + \alpha_{21}^{(\ell)} \mathrm{H}_1^{(\ell)} \mathrm{W}^{(\ell)} + \alpha_{23}^{(\ell)} \mathrm{H}_3^{(\ell)} \mathrm{W}^{(\ell)} + \alpha_{24}^{(\ell)} \mathrm{H}_4^{(\ell)} \mathrm{W}^{(\ell)} \Bigr)
\end{equation}

\end{document}

相关内容