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}
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}
  • Yes, this works very well. I should've looked for the source code of the proof environment. There seems to be quite a bit to do with trivlists, especially when defining custom theorem-like environments. Thanks! – zuggg Nov 21 '14 at 19:25
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}
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.