2

I switched from a proof environment to a custom one, if I begin the custom environment with an enumerate, there is a linebreak that I'd like to prevent. The MWE shows the difference between the proof environment and ex. I tried playing with spacings, and /nobreak, to no avail.

\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}
zuggg
  • 442

2 Answers2

1

Is this an acceptable solution? The line is not being broken after the item in the trivlist (actually, the solution is stolen from the 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}
Fedxa
  • 325
1

If you invoke the inline option to enumitem, then using enumerate* instead of enumerate gives you inline lists:

enter image description here

Code:

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

Peter Grill
  • 223,288
  • This would be a good workaround if the items are small, but in my case (which I did not specify), they are not. Also, I'd prefer for the following items to be on a new line rather than inline. Sorry for not being specific enough. – zuggg Nov 21 '14 at 19:30