我想產生一個「目標」(1、2、3...等)清單作為標籤\item
,目標文字位於相鄰(帶有\hspace{Xmm}
)。對於超過該行寬度的項目,第二行的對齊方式是不可取的。我希望它是齊平的。
這是我到目前為止所擁有的:
\documentclass{article}
\usepackage{enumitem}
\usepackage[top=1in, bottom=1.5in, left=1in, right=1in]{geometry}
\begin{document}
\begin{itemize}[leftmargin=*,align=left]
\item[Aim 1] \hspace{10mm} This aim fits nicely on to a single line.
\item[Aim 2] \hspace{10mm} Unfortunately, the details of this aim are such that they will not fit on to a single line. Instead, the text aligns strangely beneath the "Aim 2" item label :(
\end{itemize}
\end{document}
我之前嘗試過使用tabbing
,它非常接近所需的輸出,但是第二個目標不會換行到頁面寬度:
\documentclass{article}
\usepackage{enumitem}
\usepackage[top=1in, bottom=1.5in, left=1in, right=1in]{geometry}
\begin{document}
\begin{tabbing}
\= \hspace{20mm} \= \\
\> {\bf Aim 1:} \> This aim fits nicely on to a single line.\\[10pt]
\> {\bf Aim 2:} \> Unfortunately, the details of this aim are such that they willnot fit on to a single line. Instead, the text aligns strangely beneath the "Aim 2" item label :(
\end{tabbing}
\end{document}
非常感謝您的任何幫助/指示。
答案1
另一個選擇是使用enumitem
套件來定義具有所需佈局的新清單(選項showframe
僅用geometry
作視覺指南):
\documentclass{article}
\usepackage{enumitem}
\usepackage[showframe]{geometry}
\newlist{aims}{enumerate}{1}
\setlist[aims,1]{
label={Aim~\arabic*},
leftmargin=*,
align=left,
labelsep=10mm,
itemindent=\dimexpr\labelsep+\labelwidth+7pt\relax
}
\begin{document}
\begin{aims}
\item This aim fits nicely on to a single line.
\item The details of this aim are such that they will not fit on to a single line. Now the text aligns with the margin.
\item This aim fits nicely on to a single line.
\item The details of this aim are such that they will not fit on to a single line. Now the text aligns with the margin.
\end{aims}
\end{document}
由於我不確定所需的對齊方式,因此還有另一種可能性:
\documentclass{article}
\usepackage{enumitem}
\usepackage[showframe]{geometry}
\newlist{aims}{enumerate}{1}
\setlist[aims,1]{
label={Aim~\arabic*},
leftmargin=*,
align=left,
labelsep=10mm,
}
\begin{document}
\begin{aims}
\item This aim fits nicely on to a single line.
\item The details of this aim are such that they will not fit on to a single line. Now the text aligns with the margin.
\item This aim fits nicely on to a single line.
\item The details of this aim are such that they will not fit on to a single line. Now the text aligns with the margin.
\end{aims}
\end{document}
答案2
我不確定你到底想要什麼,但這是一個嘗試:
\documentclass{article}
\newcounter{myenumi}
\renewcommand{\themyenumi}{(\roman{myenumi})}
\newenvironment{myenumerate}{%
% stuff for beginning of environment goes here
\setlength{\parindent}{0pt}% don't indent paragraphs
\setcounter{myenumi}{0}% restart numbering
\bigskip% skip a line
\renewcommand{\item}{% new definition of item
\par% start a new line
\refstepcounter{myenumi}% advance counter
\makebox[2.5em][l]{\themyenumi}% print counter to width of 3em, aligned to left
}% end of definition of item
}{% at end of environment
\par% start new paragraph
\bigskip% skip a line
\noindent% don't indent new paragraph
\ignorespacesafterend% ignore spaces after environment
}
\pagestyle{empty}
\begin{document}
\noindent Here is some regular text, and I'm going to go on a bit just to see where it wraps and all that.
\begin{myenumerate}
\item Here is the first item which goes on a bit so we can see how it wraps, and it still needs to be longer.
\item Here is another item.
\item Here is yet another item.
\item And this item is going to be much much longer so we can see another example of one that wraps.
\end{myenumerate}
Here is some more regular text, and let's go on a bit here too, just in case it's important how that looks too.
\end{document}
PS 我不記得我最初從哪裡得到這個代碼,但它不是我自己的。 (如果您認出這是您寫的或知道誰寫的,請告訴我;然後我將刪除我的答案並讓您發布。)