方程式的定义

方程式的定义

我正在尝试在文档中添加方程式的定义。我知道以前有人问过这个问题,我找到了一个很棒的解决方案。但对我来说,它不起作用。

这就是我发现的

    \documentclass{article}
    \usepackage{amsmath}% http://ctan.org/pkg/amsmath
    \usepackage{array}% http://ctan.org/pkg/array
    \begin{document}
        \begin{gather}
      P_{xi}=\overline{U}_x+\sigma_x
             \frac{\sum_k^{Nu}D_{kx}\times\left(\frac{S_{ki}-\overline{U}_k}{\sigma_k}\right)}
                  {\sum_k^{Nu}D_{kx}},
    \intertext{Where:}
      \begin{tabular}{>{$}r<{$}@{\ :\ }l}
        P_{xi} & is the predicted rate for user~$x$ on item~$i$ \        S_{ki} & is the rate of song~$i$ given by user~$k$ \        D_{kx} & the correlation between user~$x$ and user~$k$ \        \overline{U}_x & the average rate over user~$x$ \        \overline{U}_k & the average rate over user~$k$ \        \sigma_x & is the standard deviation of all the rates of user~$x$
      \end{tabular}\nonumber
    \end{gather}
\end{document}

我尝试这样做:

\begin{gather}
    dN/d(d_{p}) = kd_{p}^{\delta},
\intertext{Where:}
\begin{tabular}{>{$}r<{$}@{\ :\ }l}
 dN  : number of particles per unit water volume in the size range d p  to  [d p +d(d p )] \                                       
 k   :  (= constant) depending on the particle concentration \
 \delta   :   (< 0) descriptor of the distributions' spectral slope.  
\end{tabular}\nonumber
\end{gather}

如果我输入“&”,latex 会告诉我,列数不够。此外,“\”不会显示为红色。我认为问题出在 {>{$}r<{$}@{\ :\ }l} 部分。但我不明白这里面发生了什么。

非常感谢您的帮助。

谢谢

答案1

\\你已经被这个网站臭名昭著的漏洞咬了,看看双反斜杠从代码中消失

您从以下位置复制了代码

https://tex.stackexchange.com/a/53483/4427

受该错误影响。以下是修复后的代码。

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}

\begin{document}

\begin{gather}
      P_{xi}=\overline{U}_x+\sigma_x
             \frac{\sum_k^{Nu}D_{kx}\times\left(\frac{S_{ki}-\overline{U}_k}{\sigma_k}\right)}
                  {\sum_k^{Nu}D_{kx}},
    \intertext{Where:}
      \begin{tabular}{>{$}r<{$}@{\ :\ }l}
        P_{xi} & is the predicted rate for user~$x$ on item~$i$ \\
        S_{ki} & is the rate of song~$i$ given by user~$k$ \\
        D_{kx} & the correlation between user~$x$ and user~$k$ \\
        \overline{U}_x & the average rate over user~$x$ \\
        \overline{U}_k & the average rate over user~$k$ \\
        \sigma_x & is the standard deviation of all the rates of user~$x$
      \end{tabular}\nonumber
    \end{gather}
\end{document}

在此处输入图片描述

您尝试的固定代码应该是

\begin{gather}
    dN/d(d_{p}) = kd_{p}^{\delta},
\intertext{Where:}
\begin{tabular}{>{$}r<{$}@{\ :\ }l}
 dN     & number of particles per unit water volume in the \\
 \multicolumn{1}{c}{} & size range $dp$  to  $[dp+d(dp)]$ \\
 k      & (constant) depending on the particle concentration \\
 \delta & ($<0$) descriptor of the distributions' spectral slope.
\end{tabular}\nonumber
\end{gather}

在此处输入图片描述

答案2

这里有一种方法可能有用:

在此处输入图片描述

使用[t]on 选项tabular可获得更好的间距,tabular如 campa 的评论所述。但是,根据 egreg 的说法,这可能会影响段落间距,但我无法看到此问题,因此发布了:无法复制问题:使用[t]表格选项会影响段落间距

代码:

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\usepackage{array}% http://ctan.org/pkg/array
\begin{document}
\[
    dN/d(d_{p}) = kd_{p}^{\delta},
\]
where:

\begin{tabular}[t]{r@{}l}
 $dN$     &: number of particles per unit water volume in the size range $d p$  to  $[d p +d(d p )]$ \\                                       
 $k$      &: (= constant) depending on the particle concentration \\
 $\delta$ &: $(< 0)$  descriptor of the distributions' spectral slope. 
\end{tabular}
\end{document}

答案3

另一种解决方案,基于frameddescription环境(语义上更令人满意)。另外,我认为d微分的和的d符号d_p有点令人困惑,所以我决定将微分“d”竖起来,使用在这个网站上找到的宏

\documentclass{article}

\renewcommand*{\d}{\mathop{\kern0pt\mathrm{d}}\!{}}

\usepackage{enumitem, framed}
\newenvironment{myleftbar}{%
      \def\FrameCommand{{\hspace{0.8cm}\vrule width 0.5pt}\hspace{6pt}}%\
      \MakeFramed {\advance\hsize-2\width \FrameRestore}\noindent\hspace{- 0.4em}}%
     {\endMakeFramed}
\newenvironment{eqdescription}{%
\myleftbar
\llap{\makebox[1.4cm][l]{where: }}\vspace*{-\dimexpr\baselineskip + \topsep}\strut
\description[font=\normalfont, labelwidth=0.5cm, align=right, leftmargin=!, itemsep=0pt]
}
{%
\enddescription\vspace*{-\topsep}
\endmyleftbar}

\begin{document}
\[
    \d N/\d(d_{p}) = kd_{p}^{\delta},
\]

\begin{eqdescription}
\item[$\d N$:] number of particles per unit water volume\\ in the size range $d_p$ to $[d_p +\d(d_p )]$,
\item[$k$:] (= constant) depending on the particle concentration,
\item[$\delta$:]$(< 0)$ descriptor of the distributions' spectral slope.
\end{eqdescription}

\end{document} 

在此处输入图片描述

相关内容