![列表环境的对齐](https://linux22.com/image/239659/%E5%88%97%E8%A1%A8%E7%8E%AF%E5%A2%83%E7%9A%84%E5%AF%B9%E9%BD%90.png)
我似乎在处理列表的两个环境中遇到了麻烦。这两个环境是
\begin{description} \begin{problemlist}
..... ......
\end{description} \end{problemlist}
问题在于,文本与文档正文无法正确对齐,就像其他列表环境一样,例如
\begin{enumerate} \begin{itemize}
..... ......
\end{enumerate} \end{itemize}
下面提供了一个 mwe:
\documentclass[12pt]{article}
\usepackage{enumerate}
\oddsidemargin=0pt
\topmargin=1pt
\evensidemargin=0pt
\headheight=15pt
\headsep=15pt
\textwidth=6.2truein
\marginparsep=0pt
\textheight=8.75truein
\pagestyle{empty}
\begin{document}
\begin{description}
\item[Problem 1.] The sky is a very nice blue color. The sky is a very nice
blue color. The sky is a very nice blue color. The sky is a very nice blue color. The
sky is a very nice blue color. The sky is a very nice blue color. The sky is a very
nice blue color. The sky is a very nice blue color. The sky is a very nice blue color.
The sky is a very nice blue color. The sky is a very nice blue color. The sky is a very
nice blue color. The sky is a very nice blue color. The sky is a very nice blue color.
The sky is a very nice blue color.
\bigskip
\hspace{1.4cm} \textbf{\underline{Solution:}}
\vspace{0.15in}
\hspace{1.42cm}
The sky is a very nice blue color. The sky is a very nice blue color. The sky is a very
nice blue color. The sky is a very nice blue color. The sky is a very nice blue color.
The sky is a very nice blue color. The sky is a very nice blue color. The sky is a very
nice blue color. The sky is a very nice blue color. The sky is a very nice blue color.
The sky is a very nice blue color. The sky is a very nice blue color. The sky is a very
nice blue color. The sky is a very nice blue color. The sky is a very nice blue color.
\end{description}
\end{document}
您将看到每段中第一个句子之后的句子与第一个句子不对齐。将环境更改为enumerate
或时,itemize
您将看到自动对齐。
有没有什么办法可以解决这个问题?
答案1
您可以使用该软件包,enumitem
它更舒适,enumerate
并且具有更多功能。
您还应该使用包装geometry
来代替手动操作长度。
编辑1:使用geometry
编辑2:newlist
我用和扩展了示例setlist
。现在您可以使用环境了problemdescript
。
**编辑3:参见评论——我将标签的格式更改为“问题1””。
\documentclass[12pt]{article}
\usepackage{enumitem}
\usepackage{geometry}
\geometry{textwidth=6.2truein,textheight=8.75truein}
\geometry{showframe}
\pagestyle{empty}
\newlist{problemdescript}{enumerate}{1}
%\setlist[problemdescript]{font=\sffamily\bfseries,label={Problem~\arabic*.},leftmargin=2.5cm}
\setlist[problemdescript]{label={\textbf{Problem}~\arabic*.},leftmargin=2.5cm}
\begin{document}
\begin{problemdescript}
\item The sky is a very nice blue color. The sky is a very nice
blue color. The sky is a very nice blue color. The sky is a very nice blue color. The
sky is a very nice blue color. The sky is a very nice blue color. The sky is a very
nice blue color. The sky is a very nice blue color. The sky is a very nice blue color.
The sky is a very nice blue color. The sky is a very nice blue color. The sky is a very
nice blue color. The sky is a very nice blue color. The sky is a very nice blue color.
The sky is a very nice blue color.
\bigskip
\hspace{1.4cm} \textbf{\underline{Solution:}}
\vspace{0.15in}
\hspace{1.42cm}
The sky is a very nice blue color. The sky is a very nice blue color. The sky is a very
nice blue color. The sky is a very nice blue color. The sky is a very nice blue color.
The sky is a very nice blue color. The sky is a very nice blue color. The sky is a very
nice blue color. The sky is a very nice blue color. The sky is a very nice blue color.
The sky is a very nice blue color. The sky is a very nice blue color. The sky is a very
nice blue color. The sky is a very nice blue color. The sky is a very nice blue color.
\end{problemdescript}
\begin{description}[font=\sffamily\bfseries,leftmargin=2.5cm,style=sameline]
\item[Problem 1.] The sky is a very nice blue color. The sky is a very nice
blue color. The sky is a very nice blue color. The sky is a very nice blue color. The
sky is a very nice blue color. The sky is a very nice blue color. The sky is a very
nice blue color. The sky is a very nice blue color. The sky is a very nice blue color.
The sky is a very nice blue color. The sky is a very nice blue color. The sky is a very
nice blue color. The sky is a very nice blue color. The sky is a very nice blue color.
The sky is a very nice blue color.
\bigskip
\hspace{1.4cm} \textbf{\underline{Solution:}}
\vspace{0.15in}
\hspace{1.42cm}
The sky is a very nice blue color. The sky is a very nice blue color. The sky is a very
nice blue color. The sky is a very nice blue color. The sky is a very nice blue color.
The sky is a very nice blue color. The sky is a very nice blue color. The sky is a very
nice blue color. The sky is a very nice blue color. The sky is a very nice blue color.
The sky is a very nice blue color. The sky is a very nice blue color. The sky is a very
nice blue color. The sky is a very nice blue color. The sky is a very nice blue color.
\end{description}
\end{document}