![如何制作水平列表?](https://linux22.com/image/279516/%E5%A6%82%E4%BD%95%E5%88%B6%E4%BD%9C%E6%B0%B4%E5%B9%B3%E5%88%97%E8%A1%A8%EF%BC%9F.png)
这似乎是一个非常简单的问题,但是将普通的垂直列表变成水平列表的最简单方法是什么?
答案1
该enumitem
包有一个inline
选项,它使用基本列表环境的星号版本来实现标准列表的内联版本。与其他enumitem
列表一样,可以使用键值设置标签和(水平)间距,也可以为列表项之间的元素(通常是标点符号)设置自定义设置。
\documentclass{article}
\usepackage[inline]{enumitem}
\begin{document}
Text before list.
\begin{enumerate*}
\item My first in list.
\item My second in list.
\end{enumerate*}
Text after list.
\end{document}
答案2
如果你使用 enumitem 包,你可以传递选项 [inline]。这样做可以启用与生成内联列表的常规环境相对应的星号环境(\begin{enumerate*}
等\begin{itemize*}
):
\documentclass{article}
\usepackage[inline]{enumitem}
\begin{document}
Text before list.
\begin{enumerate*}[label=(\roman*)]
\item My first in list.
\item My second in list.
\end{enumerate*}
Text after list.
\end{document}
此包可让您对枚举、项目化和描述环境的格式进行大量控制,并允许您全局或本地控制它们的样式,以基于默认值创建自定义环境,并轻松指定一系列格式选项。上面的示例生成一个内联枚举列表,其标签形式为 (i)。我实际上所做的是为此设置一个自定义环境,以便我可以随意使用它:
\newlist{mylist}{enumerate*}{1}
\setlist[mylist]{label=(\roman*)}
那我就只能说
\begin{mylist}
\item My first in list.
\item My second in list.
\end{mylist}
如果需要,我可以轻松地全局更改配置。mylist
例如,通过更改 的定义,您可以将使用此环境的所有列表从垂直列表切换为内联列表。
答案3
解决方案打包任务Clemens Niederberger 著,网址:维基百科/Latex
\documentclass{article}
\usepackage{tasks}
\usepackage{amssymb}
\begin{document}
\settasks{label-format={\color{green!70!black}\large\bfseries}, label-align=center, label-offset={10mm}, label-width={10mm}, item-indent={5mm}, item-format={\scshape\small}, column-sep={3mm}, after-item-skip=-1mm, after-skip={3mm}
}
\bfseries Horizontal list with the same look as enumerate.\normalfont
\begin{tasks}[style=enumerate, item-format={\normalfont\tiny}, after-item-skip=4mm](6)
\task One
\task Two
\task Three
\task Four
\task Five
\task Six
\task Seven
\task Eight
\task Nine
\task Ten
\end{tasks}
\bfseries Horizontal list: 1 = arabic \normalfont
\begin{tasks}[counter-format={tsk[1].}, label-align=left, label-offset={0mm}, label-width={5mm}, item-indent={5mm}, label-format={\bfseries}, column-sep=10mm](4)
\task One One One One One One
\task Two Two Two Two Two Two
\task Three Three Three Three
\task Four Four Four Four Four Four
\task Five
\task Six
\task Seven
\task Eight
\end{tasks}
\bfseries Horizontal list: r= roman \normalfont
\begin{tasks}[counter-format={(tsk[r])}, label-align=left, label-offset={10mm}, label-width={10mm}, label-format={\bfseries}](4)
\task One
\task Two
\task Three
\task Four
\task Five
\task Six
\task Seven
\end{tasks}
\bfseries Horizontal list: R = Roman \normalfont
\begin{tasks}[counter-format={(tsk[R])}, label-align = right, label-width = {10mm}, label-offset={10mm}, label-format = {\bfseries}, after-skip={10mm}](4)
\task One
\task Two
\task Three
\task Four
\task Five
\task Six
\task Seven
\end{tasks}
\bfseries Horizontal list: a = alphabetical \normalfont
\begin{tasks}[counter-format={tsk[a].}, label-format={\bfseries}](6)
\task One
\task Two
\task Three
\task Four
\task Five
\task Six
\task Seven
\task Eight
\task Nine
\task Ten
\end{tasks}
\bfseries Horizontal list: A = Alphabetical \normalfont
\begin{tasks}[counter-format={(tsk[A])}, label-offset={10mm}, label-width={10mm}, label-format={\bfseries}](4)
\task One
\task Two
\task Three
\task Four
\task Five
\task Six
\task Seven
\end{tasks}
\bfseries Horizontal list with the default look.\normalfont
\begin{tasks}[after-skip={10mm}](6)
\task One
\task Two
\task Three
\task Four
\task Five
\task Six
\task Seven
\task Eight
\task Nine
\task Ten
\end{tasks}
\bfseries Horizontal list with the same look as itemize.\normalfont
\begin{tasks}[style=itemize, column-sep=-35mm, label-align=left, label-offset={0mm}, label-width={3mm}, item-indent={0mm}](6)%
\task One
\task Two
\task Three
\task Four
\task Five
\task Six
\task Seven
\task Eight
\task Nine
\task Ten
\end{tasks}
\bfseries Horizontal list with the same look as multiplechoice.\normalfont
\begin{tasks}[style=multiplechoice](6)
\task One
\task Two
\task Three
\task Four
\task Five
\task Six
\task Seven
\task Eight
\task Nine
\task Ten
\end{tasks}
\bfseries Horizontal list with custom bullets "@@@".\normalfont
\begin{tasks}[label={@@@}, label-offset={10mm}, label-width={10mm}](4)
\task One
\task Two
\task Three
\task Four
\task Five
\task Six
\task Seven
\task Eight
\end{tasks}
\bfseries Horizontal list with variable formatting.\normalfont
\begin{tasks}[label=\textcolor{red}{$\bullet\bullet\bullet$}, label-format={\color{blue!80!black}\large\bfseries}, label-align=left, label-offset={5mm}, label-width={10mm}, item-indent={15mm},
% text aligned if item-indent = label-offset + label-width
item-format={\itshape\small}, column-sep={8mm}, after-item-skip=1mm, after-skip={1cm}](3)
\task Item
\task Item
\task Item
\task Item Item Item Item Item Item
\task Item Item Item Item Item Item
\task Item Item Item Item Item Item
\vglue5mm%
% parbox: 1st parameter = vertical position = bottom (b), center (c), top (t)
% parbox: 2nd parameter = height of parbox
% parbox: 3rd parameter = content position = center, top, bottom or spread
\task \parbox[b][0em][b]{3cm}{Item Item \\ Item Item \\Item}
\task \parbox[c][0em][c]{3cm}{Item Item \\ Item Item \\Item}
\task \parbox[t][0em][t]{3cm}{Item Item \\ Item Item \\Item}
\vglue5mm
\task* task* spans more than one column.
\task Item
\task[\small$\blacksquare\textcolor{orange}{\blacksquare}\blacksquare$] Item
\task[\normalsize$\blacksquare\textcolor{orange}{\blacksquare}\blacksquare$] Item
\task[$\blacksquare\otimes\blacksquare$] Item
\task Item
\task! task! spans all columns in any case.
\task[$\otimes\otimes\otimes$] Item
\task! task! spans all columns in any case.
\task[\small$\blacksquare\textcolor{green}{\blacksquare}\blacksquare$] Item
\task[\small$\blacksquare\textcolor{orange}{\blacksquare}\blacksquare$] Item
\task*(3) task*(3) takes max. of 3 of remaining columns.
\task*(2) task*(2) takes max. of 2 of remaining columns.
\task Item
\task*(3) task*(3) takes max. of 3 of remaining columns.
\task Item
\task[\small$\blacksquare\textcolor{blue}{\blacksquare}\blacksquare$] Item
\task[\small$\blacksquare\textcolor{pink}{\blacksquare}\blacksquare$] Item
\task[\small$\blacksquare\textcolor{orange}{\blacksquare}\blacksquare$] Item
\task startnewitemline starts... \startnewitemline
\task Item
\task Item
\task Item
\end{tasks}
\end{document}
答案4
带有 LaTeX 列表环境 + 多列的水平列表
\documentclass{article}
\usepackage{xcolor}
\usepackage{amssymb}
\usepackage{multicol}
\begin{document}
\def\PreText{ In-line list of items. \color{blue!80!black}\scshape}
\def\PosText{\color{black}\normalfont In-line list of items.\vglue5mm}
%...........................
\vglue10mm\hrule\vglue5mm
\bfseries LaTeX list environments + multicols\normalfont\\
\begin{enumerate}
%
\item ITEMIZE
\begin{multicols}{4}
\begin{itemize}
\item Item1
\item Item2
\item Item3
\item Item4
\item Item5
\item Item6
\item Item7
\item Item8
\item Item9
\item Item10
\item Item11
\item Item12
\end{itemize}
\end{multicols}
%
%
\item ENUMERATE
\raggedcolumns%
\raggedright%
\begin{multicols}{3}
\begin{enumerate}
\item Item1Item1 Item1 Item1Item1
\item Item2
\item Item3
\item Item4Item4Item4 Item4Item4 Item4 \columnbreak
\item Item5
\item Item6
\item Item7
\item Item8
\item Item9 Item9Item9 Item9Item9Item9
\item Item10
\item Item11Item11 Item11Item11
\item Item12
\end{enumerate}
\end{multicols}
%
%
\item DESCRIPTION
\begin{multicols}{2}
\begin{description}
\item[CustomLabel1] Item
\item[CustomLabel2] Item
\end{description}
\columnbreak
\begin{description}
\item[First label] Item
\item[Second label] Item
\end{description}
\end{multicols}
%
%
\end{enumerate}
\end{document}