我如何在 Latex 中创建此列表
这是我的 MW
\documentclass{book}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=Group \arabic*.]
\item
\begin{enumerate}[label=\alph*)]
\item very very very very very very very very very very very very very very long Text 1
\item very very very very very very very long sentence 2
\item very very very very very very very long sentence 3
\item very very very very very very very very very very very very very very long sentence 4
\end{enumerate}
\item
\begin{enumerate}[label=\alph*)]
\item very very very very very very very very very very very very very very very very very very very very very long sentence 1
\item very very very very very very very long sentence 2
\item very very very very very very very long sentence 3
\item very very very very very very very long sentence 4
\end{enumerate}
\end{enumerate}
\end{document}
是否可以在行上方添加文字
答案1
编辑
我的第一个解决方案是破坏枚举项对齐标签和项目文本,所以我做了一些修改,以便现在使用该enumitem
\SetLabelAlign
命令。事实上,这比我以前做的稍微容易一些。
这里有一个不同的方法,我定义了一个新的enumerate
类似环境,称为underrated
-- 因为我们under
在枚举rate
环境中排列:
\newlist{underrated}{enumerate}{1}% define a new eumerate-like environment
\setlist[underrated]{%
before=\let\item\underlineItem, % Set \item -> \underlineItem
align=underline,% use underline "style" above
label=\alph*),
ref=\alph*,
leftmargin=40mm,
labelwidth=42mm,
}
这个想法是定义一种新的“对齐样式” underline
,将线条放在项目标签之前。但是,有一个问题,当有一些文本需要下划线时,比如在underline me
中\item[underline me]
,我们需要将这些文本“传递”\item
回样式underline
。这是通过劫持命令\item
并将其替换为来完成的\underlineItem
:
\let\realItem\item% save the original \item command for later use
\newcommand\underlineItem[1][]{%
\def\underratedText{#1}%
\realItem\ignorespaces%
}
因此,这实际上所做的就是定义\underratedText
,它用于新的标签对齐样式,然后调用 real \item
。要定义这种样式,我们基本上只需在文本下划线,按照手册中的示例enumitem
:
\SetLabelAlign{underline}{\parbox[t]\labelwidth{%
\underline{\hbox to 36mm{\quad\texttt{\underratedText}}}\space#1}%
}
为了更好地衡量,我还为这些组定义了一个新的枚举类环境MyGroup
。通过此设置,代码:
\begin{MyGroup}
\item\mbox{}
\begin{underrated}
\item A lunar eclipse is an omen of a coming disaster
\item Superstitions have been around forever
\item[an answer] People hold many superstitious beliefs about
the moon
\item[another answer] It is made of green cheese
\end{underrated}
\item\mbox{}
\begin{underrated}
\item The history of astronomy is interesting
\item Ice age people recorded the appearance of new moons by
making scratches in animal bones
\item For example, Stonehenge in Britain,m build 3500 years
ago to track the movement of the sun
\item Ancient people observed and recorded lunar and solar
events in different ways
\end{underrated}
\end{MyGroup}
生产
后面\mbox
的 's\item
是强制enumerate
开始新行所必需的;参见在枚举环境中,强制在项目编号后换行。
完整代码如下:
\documentclass{book}
\usepackage{enumitem}
\let\realItem\item% save the original \item command for later use
\newcommand\underlineItem[1][]{%
\def\underratedText{#1}\realItem\ignorespaces%
}
\SetLabelAlign{underline}{%
\parbox[t]\labelwidth{%
\underline{\hbox to 36mm{\quad\texttt{\underratedText}}}%
\space#1%
}%
}
\newlist{underrated}{enumerate}{1}% define a new eumerate-like environment
\setlist[underrated]{%
before=\let\item\underlineItem, % Set \item -> \underlineItem
align=underline,% use underline "style" above
label=\alph*),
ref=\alph*,
leftmargin=40mm,
labelwidth=42mm,
}
\newlist{MyGroup}{enumerate}{1}
\setlist[MyGroup]{
label=\bfseries Group \arabic*:,
style=nextline,
leftmargin=*,
labelsep=2em,
itemsep=2em
}
\begin{document}
\begin{MyGroup}
\item\mbox{}
\begin{underrated}
\item A lunar eclipse is an omen of a coming disaster
\item Superstitions have been around forever
\item[an answer] People hold many superstitious beliefs about
the moon
\item[another answer] It is made of green cheese
\end{underrated}
\item\mbox{}
\begin{underrated}
\item The history of astronomy is interesting
\item Ice age people recorded the appearance of new moons by
making scratches in animal bones
\item For example, Stonehenge in Britain,m build 3500 years
ago to track the movement of the sun
\item Ancient people observed and recorded lunar and solar
events in different ways
\end{underrated}
\end{MyGroup}
\end{document}
答案2
一个版本:
\documentclass{book}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=Group \arabic*.]
\item
\begin{enumerate}[leftmargin=3.75cm,label={\rule{3cm}{.5pt}~\alph*)}]
\item long sentence 1
\item long sentence 2
\item long sentence 3
\item long sentence 4
\end{enumerate}
\item
\begin{enumerate}[leftmargin=3.75cm,label={\rule{3cm}{.5pt}~\alph*)}]
\item long sentence 1
\item long sentence 2
\item long sentence 3
\item long sentence 4
\end{enumerate}
\end{enumerate}
\end{document}
版本 2:
\documentclass{book}
\usepackage{enumitem}
\newcounter{group}
\newenvironment{groupenv}{%
\refstepcounter{group}%
\noindent Group~\thegroup.
\begin{enumerate}[leftmargin=3.75cm,label={\rule{3cm}{.5pt}~\alph*)}]
}{
\end{enumerate}
}
\begin{document}
\begin{groupenv}
\item long sentence 1
\item long sentence 2
\item long sentence 3
\item long sentence 4
\end{groupenv}
\begin{groupenv}
\item long sentence 1
\item long sentence 2
\item long sentence 3
\item long sentence 4
\end{groupenv}
\end{document}
使用简单的覆盖:
\documentclass{book}
\usepackage{enumitem}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\newcounter{group}
\newenvironment{groupenv}{%
\refstepcounter{group}%
\noindent Group~\thegroup.
\begin{enumerate}[leftmargin=3.75cm,label={\rule{3cm}{.5pt}~\alph*)}]
}{
\end{enumerate}
}
\begin{document}
\begin{groupenv}
\item\tikzmark{test1} long sentence 1
\item\tikzmark{test2} long sentence 2
\item\tikzmark{test3} long sentence 3
\item\tikzmark{test4} long sentence 4
\end{groupenv}
\begin{tikzpicture}[overlay,remember picture]
\node at ([xshift=-2.25cm,yshift=.5\baselineskip]pic cs:test1) {this is test};
\node at ([xshift=-2.25cm,yshift=.5\baselineskip]pic cs:test2) {this is tested};
\node at ([xshift=-2.25cm,yshift=.5\baselineskip]pic cs:test3) {this is untested};
\node at ([xshift=-2.25cm,yshift=.5\baselineskip]pic cs:test4) {this is a test};
\end{tikzpicture}
\begin{groupenv}
\item long sentence 1
\item long sentence 2
\item long sentence 3
\item long sentence 4
\end{groupenv}
\end{document}