我正在尝试创建一个自定义描述环境(使用enumitem
),以便我可以描述方程的项。我想要的是定义默认为内联数学模式的项目标签,并将列表水平对齐到所述项目的右侧,如本例所示(不带冒号):
我知道给出的解决方案这里(事实上,我从那篇文章中提取了图片),但我需要使用enumitem
(而不是使用tabular
、array
等等),而enumitem
解决方案并不能完全满足我的要求。
那么,我该如何定义这样的自定义描述列表呢?我尝试使用包的文档,但无法做到。
答案1
这样可以吗?
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{enumitem}
\SetLabelAlign{myright}{\hss\llap{$#1$}}
\newlist{where}{description}{1}
\setlist[where]{labelwidth=2cm,labelsep=1em,
leftmargin=!,align=myright,font=\normalfont}
\begin{document}
\[ P_{xi}=\overline{U}_{x}+\sigma_{x}\frac{\sum^{Nu}_{k}D_{kx}\times
\left( \frac{S_{ki}-\overline{U}_{k}}{\sigma_{k}}\right)}{\sum^{Nu}_{k}D_{kx}} \]
Where:
\begin{where}
\item [P_{xi}] is the predicted rate for user $x$ on item $i$
\item [S_{ki}] is the rate of song $i$ given by user $k$
\item [\overline{U}_{x}] is the average rate of user $x$
\item [\overline{U}_{k}] is the average rate of user $k$
\item [\sigma_{x}] is the standard deviation of all the rates of user $x$
\end{where}
\end{document}
答案2
您可以使用scrextend
和paralist
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{scrextend}
\usepackage{paralist}
\usepackage{enumitem}
\usepackage{blindtext}
\begin{document}
\blindtext
\begin{equation}
\label{eq:mylabel}
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}},
\end{equation}
Where:
\begin{addmargin}[4em]{1em}
\begin{compactitem}
\item [$P_{xi}$]: is the predicted rate for user $x$ on item $i$
\item [$S_{ki}$]: is the rate of song $i$ given by user $k$
\item [$\overline{U_{x}}$]: is the average rate of user $x$
\item [$\overline{U_{k}}$]: is the average rate of user $k$
\item [$\sigma_{x}$]: is the standard deviation of all the rates of user $x$
\end{compactitem}
\end{addmargin}
\blindtext
\end{document}
和这关于 的优秀答案indentation
。