我有一个描述列表。在这个列表中,我有标签名称,其下方应该有一个分数(例如,在一个带有彩色背景的框中)。然后旁边应该是描述。到目前为止,我已经能够正确对齐事物并制作彩色分数框。但是,我不知道如何移动此框以使其显示在标签下方。正确的方法是什么?以下是 MWE 和所需结果的屏幕截图:
\documentclass{article}
\usepackage{enumitem}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\begin{document}
\begin{description}[style=multiline,leftmargin=3cm]
\item[First item]
\fcolorbox{orange}{orange}{\LARGE 2}
Here is information. This is a multiline description. We will copy
these lines a few times. Here is information. This is a multiline description.
We will copy these lines a few times. Here is information. This is a multiline
description. We will copy these lines a few times. Here is information. This is
a multiline description. We will copy these lines a few times.Here is
information. This is a multiline description. We will copy these lines a few
time.
\item[Second item]
\fcolorbox{orange}{orange}{\LARGE 8}
Here is information. This is a multiline description. We will copy
these lines a few times. Here is information. This is a multiline description.
We will copy these lines a few times. Here is information. This is a multiline
description. We will copy these lines a few times. Here is information. This is
a multiline description. We will copy these lines a few times.Here is
information. This is a multiline description. We will copy these lines a few
time.
\item[Third item]
\fcolorbox{orange}{orange}{\LARGE 6-10}
Here is information. This is a multiline description. We will copy
these lines a few times. Here is information. This is a multiline description.
We will copy these lines a few times. Here is information. This is a multiline
description. We will copy these lines a few times. Here is information. This is
a multiline description. We will copy these lines a few times.Here is
information. This is a multiline description. We will copy these lines a few
time.
\item[And here is the fourth]
\fcolorbox{orange}{orange}{\LARGE 4}
Here is information. This is a multiline description. We will copy
these lines a few times. Here is information. This is a multiline description.
We will copy these lines a few times. Here is information. This is a multiline
description. We will copy these lines a few times. Here is information. This is
a multiline description. We will copy these lines a few times.Here is
information. This is a multiline description. We will copy these lines a few
time.
\end{description}
\end{document}
答案1
快速试用,需要改进...
允许\item[...]
在其可选参数中使用换行符,因此可以将彩色框放置在该参数的换行符之后。
下面也是一个具有tcolorbox
而非 的诸多特点的例子fcolorbox
。
\documentclass{article}
\usepackage{enumitem}
\usepackage[usenames,table]{xcolor}
\usepackage{tcolorbox}
\begin{document}
\begin{description}[style=multiline,leftmargin=3cm]
\item[First item\\
\fcolorbox{orange}{orange}{\LARGE 2}]
Here is information. This is a multiline description. We will copy
these lines a few times. Here is information. This is a multiline description.
We will copy these lines a few times. Here is information. This is a multiline
description. We will copy these lines a few times. Here is information. This is
a multiline description. We will copy these lines a few times.Here is
information. This is a multiline description. We will copy these lines a few
time.
\item[Second item\\
\fcolorbox{orange}{orange}{\LARGE 8}]
Here is information. This is a multiline description. We will copy
these lines a few times. Here is information. This is a multiline description.
We will copy these lines a few times. Here is information. This is a multiline
description. We will copy these lines a few times. Here is information. This is
a multiline description. We will copy these lines a few times.Here is
information. This is a multiline description. We will copy these lines a few
time.
\item[Third item\\
\fcolorbox{orange}{orange}{\LARGE 6-10}]
Here is information. This is a multiline description. We will copy
these lines a few times. Here is information. This is a multiline description.
We will copy these lines a few times. Here is information. This is a multiline
description. We will copy these lines a few times. Here is information. This is
a multiline description. We will copy these lines a few times.Here is
information. This is a multiline description. We will copy these lines a few
time.
\item[And here is the fourth\\
\fcolorbox{orange}{orange}{\LARGE 4}]
Here is information. This is a multiline description. We will copy
these lines a few times. Here is information. This is a multiline description.
We will copy these lines a few times. Here is information. This is a multiline
description. We will copy these lines a few times. Here is information. This is
a multiline description. We will copy these lines a few times.Here is
information. This is a multiline description. We will copy these lines a few
time.
\end{description}
\tcbset{colback=orange,width=0.05\labelwidth,left=2pt,right=2pt,boxsep=0pt,boxrule=0pt,arc=0pt,auto outer arc}
\begin{description}[style=multiline,leftmargin=3cm]
\item[{First item\\[0.8ex]
\tcbox{%
\centering
\LARGE 2
}}
]%
Here is information. This is a multiline description. We will copy
these lines a few times. Here is information. This is a multiline description.
We will copy these lines a few times. Here is information. This is a multiline
description. We will copy these lines a few times. Here is information. This is
a multiline description. We will copy these lines a few times.Here is
information. This is a multiline description. We will copy these lines a few
time.
\end{description}
\end{document}