1

I would like to define a \case command that acts like a section, meaning that when I type \case{Some Case}, it will:

  1. End the current paragraph if there is one
  2. Write \textsc{Some Case}
  3. End the line and leave some space after it
  4. Make sure that the next paragraph won't be indented, even if I leave a blank line between the command and the paragraph

How can I do this?

  • Welcome to TeX SX! Should it be numbered? – Bernard Jul 15 at 21:47
  • Thanks! No, it doesn't have to be numbered. – user192847 Jul 15 at 21:59
  • Well, use titlesec to format, say \paragraph (the level under \subsection, not the paragraph in the usual sense). – Bernard Jul 15 at 22:02
3

mwe

\documentclass{article}
\usepackage{lipsum} % for dummy text
\makeatletter
\newcommand\case%
{\@startsection {section}{2}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\scshape}}
\makeatother
\begin{document}
\lipsum[1][1-4] % dummy text 
\case*{A case} 
\lipsum[2][1-4]

\lipsum[3][1-4]
\end{document}

Note: The version without the asterisk will be numbered, but using the same counter that \section{} (so do not use both in the same document). But that can be solved using a new counter and some other trick. More complex but the cases can be showed in the index:

\documentclass{article}
\usepackage{lipsum}
\makeatletter
\newcounter{case}
\newcommand\case%
{\@startsection%
{case}%
{2}
{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\scshape}}
\renewcommand*\l@section{\@dottedtocline{1}{0em}{2em}}% for toc
\newcommand*\l@case{\@dottedtocline{1}{3em}{1em}}% for toc
\newcommand{\casemark}[1]{}% for page headers
\makeatother
\begin{document}
\tableofcontents
\section{Foo}   \lipsum[1][1-4] 
\case*{A case}      \lipsum[2][1-4]
\case{Numbered case}        \lipsum[3][1-4]
\case{Another numbered case}        \lipsum[4][1-4]
\section{Bah}   \lipsum[1][1-4] 
\end{document}
1

Would this suit what you need?

\documentclass{article}

\usepackage{noindentafter}
\newcommand{\case}[1]{%
  \par\textsc{#1}\NoIndentAfterThis}

\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\case{Jahyah}

Pellentesque hendrerit volutpat feugiat. Ut purus leo,
pulvinar sit amet vehicula non, pulvinar eu lacus.
Curabitur id mollisligula.
\end{document}

enter image description here

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.