答案1
您可以使用标准list
环境。
\documentclass{article}
\usepackage{lipsum}
\newlength{\problemmargin}
\newenvironment{problem}[2][Problem]
{%
\settowidth{\problemmargin}{\hspace{\labelsep}\bfseries #1 #2.}%
\begin{list}{}{\leftmargin=\problemmargin \labelwidth=\leftmargin}
\item[\bfseries #1 #2.]%
}
{\end{list}}
\begin{document}
\lipsum[3]
\begin{problem}{21}
\lipsum[1][1-4]
\end{problem}
\lipsum[4]
\begin{problem}{22}
Solve the following equations
\begin{enumerate}
\item A
\item B
\item C
\end{enumerate}
and check the values.
\end{problem}
\lipsum[4]
\end{document}
答案2
以下是基于description
环境使用`enumitem 工具的解决方案。如您所见,它跨页面中断:
\documentclass{book}
\usepackage{enumitem}
\setlength\parindent{1em}
\newlength{\descrwidth}
\newenvironment{problem}[2][Problem]%
{\settowidth{\descrwidth}{\textbf{#1 #2}\hspace*{2\labelsep}}\begin{description}[font=\bfseries, labelindent=\labelsep, leftmargin =\descrwidth]
\item[#1\hspace*{ \labelsep}#2.]}%
{\end{description}}%
\usepackage{lipsum}
\pagestyle{plain}
\begin{document}
\lipsum[2-6]
\begin{problem}{21}%[noitemsep, labelwidth=\dimexpr\descrwidth, leftmargin =\descrwidth, labelsep=0pt]
\lipsum[11]
\end{problem}
\lipsum[9]
\end{document}