列表环境的对齐

列表环境的对齐

我似乎在处理列表的两个环境中遇到了麻烦。这两个环境是

\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}

答案2

我建议使用enumitem包而不是包enumerate。它提供了许多自定义边距和对齐方式的方法。enumitem您可以使用它创建自己的自定义列表。查看文档

相关内容