2

I have the following simple code

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{enumitem}
\begin{document}

\begin{description}[leftmargin=0.5cm,font=\normalfont\it\bfseries\underline]
\item[Case $1$.] 
\item[Case $2$.] 
\vskip 10pt
\item[]  According to Case $1$ and Case $2$, we must have $\pi_\mathbb{Q}(K)\neq 0$ 
 and $\pi_{\mathbb{Z}_p}(K) \neq 0$ which we consider in the following case.

\vskip 10pt
\item[Case $3$.] 
\end{description}
\end{document}

I need the following behaviour: I need the letter A of 'According' to be aligned with the letter C of 'Case'. When you run this code it seems that the paragraph is shifted a little bit to the right and that the second line of the paragraph is itself shifted to the right. How can I change this?

Another question: As a sort of abbreviation, is it possible to define the item as an option to be 'Case #N' where $N$ counts on positive integers?

1
  • Off-topic: (a) Please replace \it (Plain-TeX syntax) with \itshape (LaTeX syntax). (b) the \bfseries directive is redundant.
    – Mico
    Commented May 30 at 23:31

2 Answers 2

1

You want to define your own environment for this job.

\documentclass[12pt,a4paper]{article}
%\usepackage[utf8]{inputenc}% no longer needed
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{enumitem}

\usepackage{showframe}

\newcounter{casedesc}
\newenvironment{casedesc}{%
  \setcounter{casedesc}{0}%
  \begin{description}[style=nextline,leftmargin=0pt,labelsep=0pt]
}{\end{description}}
\newcommand{\case}{%
  \stepcounter{casedesc}%
  \item[\normalfont\itshape\bfseries\underline{Case \textup{\thecasedesc}}]
}

\begin{document}

\begin{casedesc}
\case Some text for this case
\case Some text for this case

According to Case~1 and Case~2, we must have $\pi_\mathbb{Q}(K)\neq 0$ 
and $\pi_{\mathbb{Z}_p}(K) \neq 0$ which we consider in the following case.

\case Some text for this case
\end{casedesc}

\end{document}

I used showframe to see precisely what happens with the margins, remove it for your production version.

enter image description here

For variable representation of the case numbers, you can modify like below.

\documentclass[12pt,a4paper]{article}
%\usepackage[utf8]{inputenc}% no longer needed
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{enumitem}

\usepackage{showframe}

\newcounter{casedesc}
\newenvironment{casedesc}[1][\arabic]{%
  \setcounter{casedesc}{0}%
  \let\casenumbering#1\relax
  \begin{description}[style=nextline,leftmargin=0pt,labelsep=0pt]
}{\end{description}}
\newcommand{\case}{%
  \stepcounter{casedesc}%
  \item[\normalfont\itshape\bfseries\underline{Case \textup{\casenumbering{casedesc}}}]
}

\begin{document}

\begin{casedesc}
\case Some text for this case
\case Some text for this case

According to Case~1 and Case~2, we must have $\pi_\mathbb{Q}(K)\neq 0$ 
and $\pi_{\mathbb{Z}_p}(K) \neq 0$ which we consider in the following case.

\case Some text for this case
\end{casedesc}

\begin{casedesc}[\Alph]
\case Some text for this case
\case Some text for this case

According to Case~1 and Case~2, we must have $\pi_\mathbb{Q}(K)\neq 0$ 
and $\pi_{\mathbb{Z}_p}(K) \neq 0$ which we consider in the following case.

\case Some text for this case
\end{casedesc}

\end{document}

enter image description here

After seeing the result, you'll hopefully realize that boldface plus italics plus underlining plus newline is quadruple emphasis.

Here's a version I'd prefer. I also add cleveref to see that you can refer to cases in a simpler way. Apart from \cref and the \label commands, the code hasn't changed.

\documentclass[12pt,a4paper]{article}
%\usepackage[utf8]{inputenc}% no longer needed
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{enumitem}

\usepackage{showframe}

\usepackage{hyperref,cleveref}

\newlist{casedesc}{enumerate}{1}
\setlist[casedesc]{
  wide=0pt,
  label=\textbf{\textit{Case} \arabic*.},
  ref=\arabic*,
}
\crefname{casedesci}{Case}{Cases}
\newcommand{\case}{\item}

\begin{document}

\begin{casedesc}
\case\label{cone} Some text for this case
\case\label{ctwo} Some text for this case

According to \cref{cone,ctwo}, we must have $\pi_\mathbb{Q}(K)\neq 0$ 
and $\pi_{\mathbb{Z}_p}(K) \neq 0$ which we consider in the following case.

\case Some text for this case
\end{casedesc}

\end{document}

enter image description here

For variable representation:

\documentclass[12pt,a4paper]{article}
%\usepackage[utf8]{inputenc}% no longer needed
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{enumitem}
\usepackage{microtype}

\usepackage{showframe}

\usepackage{hyperref,cleveref}

\newlist{casedesclist}{enumerate}{1}
\setlist[casedesclist]{
  wide=0pt,
}
\newenvironment{casedesc}[1][\arabic]{%
  \casedesclist[label=\textbf{\textit{Case} #1*.},ref=#1*,]%
}{\endcasedesclist}
\crefname{casedesclisti}{Case}{Cases}
\newcommand{\case}{\item}

\begin{document}

\begin{casedesc}
\case\label{cone} Some text for this case
\case\label{ctwo} Some text for this case

According to \cref{cone,ctwo}, we must have $\pi_\mathbb{Q}(K)\neq 0$ 
and $\pi_{\mathbb{Z}_p}(K) \neq 0$ which we consider in the following case.

\case Some text for this case
\end{casedesc}

\begin{casedesc}[\Alph]
\case\label{cthree} Some text for this case
\case\label{cfour} Some text for this case

According to \cref{cthree,cfour}, we must have $\pi_\mathbb{Q}(K)\neq 0$ 
and $\pi_{\mathbb{Z}_p}(K) \neq 0$ which we consider in the following case.

\case Some text for this case
\end{casedesc}

\end{document}

enter image description here

4
  • This is pretty cool. But I need the label to be dynamic, meaning that in some lists I use 'Case 1, Case 2, ...' and in some lists I use 'Case A, Case B, ...' . Is it necessary to redefine the description environment for the second list style? Another question: Why 1 in \newlist{casedesc}{enumerate}{1}? What is its usage? Commented May 31 at 15:17
  • @HusseinEid I added the changes. The 1 means that you just want one level.
    – egreg
    Commented May 31 at 15:22
  • Thanks alot for your help. Commented May 31 at 15:29
  • Excuse me. I have one more requirement please about this great solution. I need the option nosep to be optional. i.e., I add it when I need it like \begin{casedesc}[nosep]. But I do not need it to be the default behaviour. How can I achieve this? Commented Jun 7 at 12:25
2

I need the letter A of 'According' to be aligned with the letter C of 'Case'.

Since you employ the enumitem package, I suggest you start the description environment with the options style=nextline and leftmargin=0cm.

enter image description here

\documentclass[12pt,a4paper]{article}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage[normalem]{ulem} % for '\uline' macro

\begin{document}

\begin{description}[style=nextline,
                    leftmargin=0cm,
                    font=\itshape\uline]
\item[Case \upshape 1.]  
bla bla

\item[Case \upshape 2.] 
According to Case $1$ and Case $2$, we must have 
$\pi_\mathbb{Q}(K)\neq 0$ and $\pi_{\mathbb{Z}_p}(K) 
\neq 0$, which we consider in the following case.

\item[Case \upshape 3.] 
blu blu

\end{description}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .