3

I'd like to create an environment for enumerating different cases. Something that would look like \itemize but instead of printing a "-" symbol at the begining of each item, prints (for the first item) "Case 1:" (eventually in a big font) and then line breaks , "Case 2:" and then line breaks for the second item, etc. Moreover I'd like not to have any margin after the break line, I'd like to have everything I write after "Case 1:" to begin at the same spot as the rest of my domcument.
I'd also like that the different cases can have "names", for example somthing like the \theorem environment where you can put the name of the author in brackets. Is there any command that already does what I want? Otherwise can somebody help me to create such environment?

Edit:

Thanks a lot I managed to do something close to what I wanted but I still can't make Latex break line after "Case"... This is what I wrote:

\documentclass[10pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[francais]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{enumitem}

\newlist{cases}{enumerate}{10}
\setlist[cases]{label=\textbf{Cas \arabic* :}, itemindent=*,leftmargin=0pt}

But when I try to add in the setlist argument breakline or \\ I only get errors...
Also do you have any idea to add an argument to this new list so that it prints a title in backets and then break a line?

2

I fudged it with a \trlap from stackengine package. EDITED to add listparindent specifier.

\documentclass[10pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[francais]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{enumitem}
\usepackage{lipsum}
\usepackage{stackengine}
\renewlist{cases}{enumerate}{10}
\setlist[cases]{label=%
  \trlap{\textbf{\kern5pt Cas \arabic* :}}, itemindent=0pt,leftmargin=0pt,
  listparindent=1.5em}
\begin{document}
\begin{cases}
\item \lipsum[1]

\lipsum[4]

\item \lipsum[4]
\end{cases}
\end{document}

enter image description here

  • What you've done is very close to what I wanted but I'd also like to have an indent Inside the "case" environement every time I skip a line in the source. – WrabbitW May 28 '14 at 20:05
  • @WrabbitW I added a listparindent specifier. Is that what you had in mind? – Steven B. Segletes May 28 '14 at 23:00
  • Hi, thanks for letting me know the listparindent command! I did not quite well get the effects of trlap and kern5pt... Could you quickly explain it to me? – WrabbitW May 29 '14 at 11:48
  • @WrabbitW \trlap is a "top-right" lap, that is it adds a notation above and to the right of the current location. The notation has height (so it won't overwrite what is above), but is perceived to have no width, so it doesn't move the current location to the right (see pp. 9, 15 of stackengine documentation, ctan.org/pkg/stackengine). The \kern shifts the item left(-), right(+). It should not have been needed, but for some reason, without it, it caused the header to not align. So it's a "fix." – Steven B. Segletes May 29 '14 at 11:55
  • Thank's I'm a beginner in the Tex world so I don't get the subtilities of heigh and width but I'll get there! I also wanted some cases to have a "title" that is on the same line as "Cas 1:" but written in italic. To do that I used te answer of SlX64 but if had an itemize environment inside the case environment I can't write anything after the "-", exept if I enter this line in the argument of the item but then it's in italic too... – WrabbitW May 29 '14 at 13:49
1

Do you need something like this?

\documentclass[10pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[francais]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{enumitem}
\usepackage{blindtext}

 \newenvironment{case}{%
 \let\olditem\item% 
 \renewcommand\item[1][]{\olditem \textbf{##1} \\}%
 \begin{enumerate}[label=\textbf{Case \arabic*:},itemindent=*,leftmargin=0em]}{\end{enumerate}%
 }

\begin{document}

\blindtext

 \begin{case}
  \item[Title of my first item] \blindtext
\end{case}

\blindtext 

\end{document}

  • Yes that's quite exactly what I wanted, exept that I'd like to break a line after "Title of my first item"... Moreover I's like to have an indent Inside the "case" environement every time I skip a line in the source. – WrabbitW May 28 '14 at 20:03
  • I've edited my answer. – SLx64 May 28 '14 at 20:17
  • Thanks, we are really close : I'll just add listparindent=1.5em in the arguments of the new enumerate environment to do exactly what I wanted! – WrabbitW May 29 '14 at 8:00

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.