3

Using the theorem style as in the example below, a new paragraph is produced after the Remark. Can I prevent this? (and using the amsthm package at the same time)?

\documentclass[english]{scrartcl}  

\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}

 \usepackage{amsthm}

\usepackage{blindtext}

\newtheorem{rem}{Remark} 

\begin{document}


\begin{rem}
\blindtext
\end{rem}
\blindtext  % I want that the text begins aligned left, i.e. no new 
 % paragraph


\end{document} 

Example of the problem

Carlos
  • 155
  • That's a precise choice: theorem-like environments are always separated from the context by vertical space and a new paragraph is supposed to start after them. I can't see reasons for changing the behavior. – egreg Mar 01 '19 at 15:23
  • 1
    A simple solution would be to use \noindent. – MahiPai Mar 01 '19 at 15:31
  • Without amsthm ist works. However, without amsthm I lose a lot of advantages. @MahiPai: Thanks, \noindent works! Since I need this only for one specific case the solution is appropriate. – Carlos Mar 01 '19 at 15:34
  • @Carlos... my answer had \noindent but you said it doesn't work for you... Anyway... Happy TeXing! – koleygr Mar 01 '19 at 15:46
  • Are you sure you want to make Latin-9 encoded documents in 2019? – egreg Mar 01 '19 at 16:42
  • @koleygr: ok, i overlooked!! So, the question is definitely answered. Thanks. – Carlos Mar 01 '19 at 20:20
  • No problem @Carlos... Just keep in mind that the solution of egreg works without the need of \noindent (So it is better if you want to use multiple times this environment) and also consider about his comment on Latin-9 encoding... – koleygr Mar 01 '19 at 20:38

3 Answers3

3

It's not difficult to do it, but you should think twice. A remark set in evidence within a rem environment is a paragraph (or more of them) on its own, so the text after it should be a new paragraph.

\documentclass{article}

\usepackage{amsthm}

\newtheorem{reminner}{Remark}

\makeatletter
\newenvironment{rem}
  {\reminner}
  {\endreminner\@endpetrue}
\makeatother

\begin{document}

\begin{rem}
A remarkable text.
\end{rem}
Some text that shouldn't start a new paragraph. But why not?

\begin{rem}
Another remarkable text.
\end{rem}

Some text that will start a new paragraph.

\end{document}

enter image description here

egreg
  • 1,121,712
2

Not sure what exactly you are looking for, but this could help you

\documentclass[english]{scrartcl}  

\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}

 \usepackage{amsthm}

\usepackage{blindtext}


\newtheoremstyle{mystyle}
  {\topsep} % Space above
  {0pt} % Space below
  {\itshape} % Body font
  {} % Indent amount
  {\bfseries} % Theorem head font
  {.} % Punctuation after theorem head
  {.5em} % Space after theorem head
  {} % Theorem head spec (can be left empty, meaning `normal')

\theoremstyle{mystyle}
\newtheorem{rem}{Remark} 

\begin{document}


\begin{rem}
\blindtext
\end{rem}
\noindent\blindtext


\end{document}

PS: Used theoremstyle from here

koleygr
  • 20,105
2

The behavior occurs because amsthm.sty explicitly includes \@endpefalse in its definition of \@endtheorem: it has \def\@endtheorem{\endtrivlist\@endpefalse }. In a May 7, 1996 post on comp.text.tex, Mark Wooding gave a solution,

\expandafter\let\csname @endtheorem\endcsname\endtrivlist

and then wrote: "A more robust method would be to say

\makeatletter
\toks@\expandafter{\@endtheorem\@endpetrue}
\edef\@endtheorem{\the\toks@}
\makeatother

in case [...] someone else changes the original macro further." This solution is working for me (in 2023). The code should come between \usepackage{amsthm} and \newtheorem{...}{...}, as pointed out later in that thread by Tom Scavo quoting Young U. Ryu (who offered \makeatletter\def\@endtheorem{\endtrivlist}\makeatother as a solution).

  • A more modern approach would be to load the experimental regexpatch package and then replace all instances of \@endpefalse in \@endtheorem with \@endpetrue by using \xpatchcmd*{\@endtheorem}{\@endpefalse}{\@endpetrue}{}{}. As of now, the * ("replace all") is not needed since there is currently only one instance of \@endpefalse in \@endtheorem. Alternatively, one might be able to use the similar \xpatchcmd command of the xpatch package, or the \patchcmd command of the etoolbox package. – Gabriel A. Lozada Jul 03 '23 at 00:07