我正在尝试构建自己的自定义列表环境,这将对解决下面的问题有很大帮助。
我想要一个列表环境,它采用强制参数,将文本显示为标签,到目前为止我有这个
\newenvironment{mylist}[1]
{
\begin{itemize}[label=#1]
}{
\end{itemize}
}
到目前为止,这种方法是可行的,但当单个列表项中的文本溢出到下一行时,它看起来像这样
Example: aaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaa
但我希望它看起来像这样
Example: aaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaa
第二行和后续行上的文本与页面左边距(或当前环境的左边缘,无论其是什么)保持可定义的距离。
我尝试使用enumitem
带有选项的包itemindent
,但似乎只能将第二行相对于其缩进位置向左移动。我想要做的是将第二行从非缩进位置向右移动。
編輯:a mwe
\documentclass[a4]{article}
\usepackage{enumitem}
%Used in my LaTeX document that I'm preparing, just in case there is some conflict between this and any proposed solution
\setlist{topsep=0mm,partopsep=0mm,parsep=0mm,itemsep=0.1mm,leftmargin=*}
\newenvironment{mylist}[1]
{
\begin{itemize}[label=#1]
}{
\end{itemize}
}
\begin{document}
\begin{mylist}{Example:}
\item Some text just to illustrate what happens when there is too much text and it overflows onto the next line.
\end{mylist}
\end{document}
答案1
以下 MWE 将帮助您解决问题:
\documentclass[a4paper]{article}
\usepackage{enumitem}
\usepackage{lipsum}
%Used in my LaTeX document that I'm preparing, just in case there is some conflict between this and any proposed solution
\setlist[itemize]{wide,topsep=0mm,partopsep=0mm,parsep=0mm,itemsep=0.1mm,labelindent=0pt,leftmargin=0pt}
\newenvironment{mylist}[1]
{
\begin{itemize}[label=#1]
}{
\end{itemize}
}
\begin{document}
\lipsum[1]
\begin{mylist}{Example:}
\item Some text just to illustrate what happens when there is too much text and it overflows onto the next line.
\item Some text just to illustrate what happens when there is too much text and it overflows onto the next line.
\end{mylist}
\lipsum[1]
\end{document}
我现在已经\setlist
从以下改变:
\setlist{topsep=0mm,partopsep=0mm,parsep=0mm,itemsep=0.1mm,leftmargin=*}
到
\setlist[itemize]{wide,topsep=0mm,partopsep=0mm,parsep=0mm,itemsep=0.1mm,labelindent=0pt,leftmargin=0pt}
您可以leftmargin=<dimension>
从第二行开始调整左边距。