如何避免在环境开始时出现换行符enumerate
?我注意到定理风格的环境可以成功做到这一点。我正在使用该enumitem
包,我的具体示例是:
\textbf{Example:} % don't want a line break here!
\begin{enumerate}
\item test1
\item test2
\end{enumerate}
我尝试将其包装起来enumerate
但这vbox
只是将整个列表向上移动了......
答案1
以下是模仿 AMS 类的定理环境的尝试:
\documentclass{article}
%\makeatletter
\newenvironment{myexample}
{\trivlist \item[\hskip\labelsep\textbf{Example:}]}
% {\trivlist \item[]\setbox\@labels\hbox{\textbf{Example: }}}
{\endtrivlist}
%\makeatother
\begin{document}
\thispagestyle{empty}
Here's some text. Here's some text. Here's some text. Here's some
text. Here's some text. Here's some text. Here's some text. Here's
some text. Here's some text. Here's some text. Here's some
text. Here's some text. Here's some text. Here's some text.
\begin{myexample}
\begin{enumerate}
\item Test 1
\item Test 2
\end{enumerate}
\end{myexample}
Here's some text. Here's some text. Here's some text. Here's some
text. Here's some text. Here's some text. Here's some text. Here's
some text. Here's some text. Here's some text. Here's some
text. Here's some text. Here's some text. Here's some text.
\end{document}
答案2
你可以欺骗第一个项目标签,让它排版成你想要的任何格式。像这样:
\documentclass{article}
\newcommand*\fixitem[1]{\item[]
\refstepcounter{enumi}\hskip-\labelwidth\hskip-\labelsep
#1 \labelenumi}
\begin{document}
\noindent\textbf{Example:} don't want a line break here, see below!
\begin{enumerate}
\fixitem{\textbf{Example:}} test1
\item test2
\end{enumerate}
\end{document}
结果是: