1

Issue: In my custom theorem environment I would like the beginning line of a new paragraph within the theorem environment to immediately follow the line above it and also be indented:

enter image description here

MWE:

\documentclass{book}
\usepackage{amsthm}
\usepackage{enumitem}
\usepackage{xparse}
\usepackage{hyperref}

\usepackage{lipsum}

\newtheoremstyle{fctaylor}% name
  {\topsep}%      Space above
  {\topsep}%      Space below
  {\normalfont}%         Body font
  {}%         Indent amount (empty = no indent, \parindent = para indent)
  {\bfseries}% Thm head font
  {}%        Punctuation after thm head
  {\newline}%     Space after thm head: " " = normal interword space;
  {\makethmhead{#1}{#2}{#3}}

\newlength\fctaylortheoremindent
\AtBeginDocument{\setlength\fctaylortheoremindent{3em}} % <- customize here
\newlength\fctaylorlabelsep
\AtBeginDocument{\setlength\fctaylorlabelsep{1em}} % <- customize here

\makeatletter
\newcommand{\makethmhead}[3]{%
  \gdef\thisthmhead{%
    \makebox[\fctaylortheoremindent][l]{\bfseries#2}%
    {\bfseries#1}%
    \@ifnotempty{#3}{ (#3)}%
    \hspace{\fctaylorlabelsep}%
    \phantomsection%%% THIS LINE ADDED
  }%
}
\makeatother

\newenvironment{fctayloritemize}
 {\list{}{%
    \leftmargin=\fctaylortheoremindent
    \labelwidth=\dimexpr\fctaylortheoremindent-\labelsep\relax
    \itemindent=0pt
  }}
 {\endlist}

\NewDocumentCommand{\newfctaylortheorem}{smomo}{%
  \IfBooleanTF{#1}
   {\newtheorem*{fctaylor@#2}{#4}}
   {\IfNoValueTF{#3}
     {\IfNoValueTF{#5}
       {\newtheorem{fctaylor@#2}{#4}}
       {\newtheorem{fctaylor@#2}{#4}[#5]}}
     {\newtheorem{fctaylor@#2}[fctaylor@#3]{#4}}}%
  \NewDocumentEnvironment{#2}{o}
   {\IfNoValueTF{##1}{\begin{fctaylor@#2}}{\begin{fctaylor@#2}[##1]}%
    \begin{fctayloritemize}\item[\thisthmhead\hfill]}
   {\end{fctayloritemize}\end{fctaylor@#2}}%
}

\theoremstyle{fctaylor}
\newfctaylortheorem{thm}{Theorem}[section]
\newfctaylortheorem*{defn}{Definition}

\begin{document}
\section{One}

\begin{defn}
\lipsum*[2]
\end{defn}

\begin{thm}\label{A}
\lipsum*[2]
\end{thm}

\begin{thm}[Somebody]\label{B}
Something that should show how the text is split across line boundaries
and is correctly indented. And some equivalent conditions:
\begin{enumerate}[label=\upshape(\alph*),ref=(\alph*)]
\item a condition
\item another
\item and another
\end{enumerate}
which show the point made.

\indent\textbf{This line, which begins a new paragraph, should immediately follow the above line but be indented.}
\end{thm}

Here are the references: \ref{A} and \ref{B}.

\end{document}

My work: I tried mimicking one answer to a similar question as best I knew how by making the change from

\newtheoremstyle{fctaylor}% 
  {\topsep}%
  {\topsep}%
  {\normalfont}%
  {}%
  {\bfseries}%
  {}%
  {0pt}%     Space after thm head: " " = normal interword space;
  {\makethmhead{#1}{#2}{#3}}

to

\newtheoremstyle{fctaylor}% 
  {\topsep}%
  {\topsep}%
  {\normalfont}%
  {}%
  {\bfseries}%
  {}%
  {\newline}%     The one thing I changed which seemed to work in the other answer
  {\makethmhead{#1}{#2}{#3}}

Any ideas how to accomplish what I am seeking to do? (I just tried modifying the line in question by adding \indent, but this did nothing.)

1

You’re essentially putting your theorems/definitions in a list and displaying their headers as description items. The way you set up this format is seemingly convoluted, and I doubt this is the best way to achieve your goal.

But, based on your current code, what you need is simply \listparindent. However, I made some additional adjustments as well:

  • There’s no need to use \phantomsection.
  • I added \relax to \itemindent=0pt, just before the crucial line \listparindent=\parindent.
  • I removed \hfill in \item[\thisthmhead\hfill].
  • Since I don’t fully understand your request about \newline, I added \strut\par immediately after \item[\thisthmhead]. This will cause the text after the header to be typeset in a new paragraph (and will make \fctaylorlabelsep useless, of course). If this isn’t what you want, simply remove \strut\par.

Again, I wonder if better code exists for your format.

\documentclass{book}
\usepackage{amsthm}
\usepackage{enumitem}
\usepackage{xparse}
\usepackage{hyperref}

\usepackage{lipsum}

\newtheoremstyle{fctaylor}% name
  {\topsep}%      Space above
  {\topsep}%      Space below
  {\normalfont}%         Body font
  {}%         Indent amount (empty = no indent, \parindent = para indent)
  {\bfseries}% Thm head font
  {}%        Punctuation after thm head
  {\newline}%     Space after thm head: " " = normal interword space;
  {\makethmhead{#1}{#2}{#3}}

\newlength\fctaylortheoremindent
\AtBeginDocument{\setlength\fctaylortheoremindent{3em}} % <- customize here
\newlength\fctaylorlabelsep
\AtBeginDocument{\setlength\fctaylorlabelsep{1em}} % <- customize here

\makeatletter
\newcommand{\makethmhead}[3]{%
  \gdef\thisthmhead{%
    \makebox[\fctaylortheoremindent][l]{\bfseries#2}%
    {\bfseries#1}%
    \@ifnotempty{#3}{ (#3)}%
    \hspace{\fctaylorlabelsep}%
    %\phantomsection%%% THIS LINE ADDED% <-- This line commented out
  }%
}
\makeatother

\newenvironment{fctayloritemize}
 {\list{}{%
    \leftmargin=\fctaylortheoremindent
    \labelwidth=\dimexpr\fctaylortheoremindent-\labelsep\relax
    \itemindent=0pt\relax% <-- \relax added
    \listparindent=\parindent% <-- What you missed
  }}
 {\endlist}

\NewDocumentCommand{\newfctaylortheorem}{smomo}{%
  \IfBooleanTF{#1}
   {\newtheorem*{fctaylor@#2}{#4}}
   {\IfNoValueTF{#3}
     {\IfNoValueTF{#5}
       {\newtheorem{fctaylor@#2}{#4}}
       {\newtheorem{fctaylor@#2}{#4}[#5]}}
     {\newtheorem{fctaylor@#2}[fctaylor@#3]{#4}}}%
  \NewDocumentEnvironment{#2}{o}
   {\IfNoValueTF{##1}{\begin{fctaylor@#2}}{\begin{fctaylor@#2}[##1]}%
    \begin{fctayloritemize}\item[\thisthmhead]\strut\par}% <-- \hfill removed.
   {\end{fctayloritemize}\end{fctaylor@#2}}%
}

\theoremstyle{fctaylor}
\newfctaylortheorem{thm}{Theorem}[section]
\newfctaylortheorem*{defn}{Definition}

\begin{document}
\section{One}

\begin{defn}
\lipsum*[2]
\end{defn}

\begin{thm}\label{A}
\lipsum*[2]
\end{thm}

\begin{thm}[Somebody]\label{B}
Something that should show how the text is split across line boundaries
and is correctly indented. And some equivalent conditions:
\begin{enumerate}[label=\upshape(\alph*),ref=(\alph*)]
\item a condition
\item another
\item and another
\end{enumerate}
which show the point made.

\indent\textbf{This line, which begins a new paragraph, should immediately follow the above line but be indented.}
\end{thm}

Here are the references: \ref{A} and \ref{B}.

\end{document}

With \strut\par

With strut and par

Without \strut\par

Without strut and par

  • Thank you. I see my real issue was in dealing with how the list was defined. Adding \setlength{\parsep}{0pt} solved my concern about unwanted paragraph separation (I realize that was rather unclear by my question.) Also, phantomsection was added to make the hyperlinks work correctly. This answer showed why that was necessary. Appreciate the help! – Jessica Jul 21 '18 at 20:30
  • @Jessica I see. I hope the \setlength{\parsep}{0pt} is global. If so, for your nested list inside theorem, you may want \begin{enumerate}[label=\textup{(\alph*)},ref=(\alph*),noitemsep] or \begin{enumerate}[label=\textup{(\alph*)},ref=(\alph*),nosep]. Better yet, use \setlist to do it globally (see the enumitem manual for more details). Please note that you should use \textup instead of \upshape. – Ruixi Zhang Jul 21 '18 at 21: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.