我从环境切换proof
到自定义环境,如果我以 开始自定义环境enumerate
,则会出现我想避免的换行符。 MWE 显示了proof
环境和之间的差异ex
。我尝试使用空格和/nobreak
,但无济于事。
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amsfonts}
%% Packages
\usepackage{amsmath,amsfonts}
\usepackage{amsthm}
\usepackage[matha,mathb]{mathabx}
\usepackage[shortlabels]{enumitem}
\usepackage[french]{babel} % load last
%% Custom environments/macros
\newcounter{exnum}[section]
\newenvironment{ex}
{\stepcounter{exnum}\paragraph{Exercice \thesection.\theexnum.}}
{\hfill\(\Box\)}
\begin{document}
\section{Section 1}
\begin{ex}
\begin{enumerate}[(a),wide=0pt]
\item foo
\end{enumerate}
\end{ex}
\begin{proof}
\begin{enumerate}[(a),wide=0pt]
\item foo
\end{enumerate}
\end{proof}
\end{document}
答案1
这是一个可以接受的解决方案吗?trivlist 中的项目后面的行没有被打破(实际上,解决方案是从 amsthm 中偷来的)
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amsfonts}
%% Packages
\usepackage{amsmath,amsfonts}
\usepackage{amsthm}
\usepackage[matha,mathb]{mathabx}
\usepackage[shortlabels]{enumitem}
\usepackage[french]{babel} % load last
%% Custom environments/macros
\newcounter{exnum}[section]
\newenvironment{ex}
{\stepcounter{exnum}%
\trivlist\item[\bfseries Exercice \thesection.\theexnum.]\ignorespaces}
{\hfill\(\Box\)\endtrivlist}
\begin{document}
\section{Section 1}
\begin{ex}
\begin{enumerate}[(a),wide=0pt]
\item foo
\end{enumerate}
\end{ex}
\end{document}
答案2
如果您调用inline
选项enumitem
,则使用enumerate*
而不是会为enumerate
您提供内联列表:
代码:
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amsfonts}
%% Packages
\usepackage{amsmath,amsfonts}
\usepackage{amsthm}
\usepackage[matha,mathb]{mathabx}
\usepackage[shortlabels,inline]{enumitem}
\usepackage[french]{babel} % load last
%% Custom environments/macros
\newcounter{exnum}[section]
\newenvironment{ex}
{\stepcounter{exnum}\paragraph{Exercice \thesection.\theexnum.}}
{\hfill\(\Box\)}
\begin{document}
\section{Section 1}
\begin{ex}
\begin{enumerate*}[(a),wide=0pt]
\item foo
\end{enumerate*}
\end{ex}
\begin{proof}
\begin{enumerate}[(a),wide=0pt]
\item foo
\end{enumerate}
\end{proof}
\end{document}