2

I have a document in "book" format (strictly speaking, in an environment defined by the book publisher I am using, the details of which are way beyond my comprehension), and I very much want to have certain paragraphs labeled with the same running count as for theorems, lemmas, etc. but with the numerical label appearing as boldface within the text and not set off on its own line.

For example, between Theorem 2.3.7 and Theorem 2.3.9 within section 2.3 of Chapter 2, I'd like to be able to make some intermediate paragraph of my choosing begin with either "2.3.8" in boldface (and ordinary-size font), or perhaps "2.3.8 Blah-blah" in boldface (and ordinary-size font). It is also very important for this command to allow the possibility of using a \label command associated to that numerical label "2.3.8" for cross-referencing purposes.

In order to increase the chances of a solution being usable by the book publisher (whose typesetting staff has been unable to provide me with a solution), please try to make answers as simple as possible.

Although I cannot reproduce the publishers proprietary documentclass here (it is much too large, and incomprehensible to me), here is a test .tex file that I tried based on the comment below suggesting to use the command \paragraph:

\documentclass{book}

\begin{document}

\chapter{A class of groups}

Let $G$ be a group.

\section{A class of subgroups}

Let $H$ be a subgroup.

\paragraph{Refinements}\label{refined} This can be refined.

In \ref{refined} we saw something.

\end{document}

The output that I get does not make any numerical label appear in front of "Refinements", and the cross-reference to it at the end produces the numerical label for the section, so it fails miserably. I want that labelled paragraph to begin with "1.1.1. Refinements" in boldface, and the cross-reference at the end should appear as "In 1.1.1 we saw something".

I should also point out that a version (given to me long ago from a source I cannot remember) does work within the amsart environment, where the hierarchy shifts by one: instead of \chapter, \section, \subsection it is \section, \subsection, \subsubsection, and the following gives exactly what I seek as a subsubsection (but the publisher told me that they cannot adapt it; hmm, maybe I should specifically ask them to try replacing "subsubsection" with "subsection" below, in case they didn't try that?).

\makeatletter

\def\@seccntformat#1{\@ifundefined{#1@cntformat}%

{\csname the#1\endcsname\quad}% default

{\csname #1@cntformat\endcsname}% individual control

}

\def\subsubsection@cntformat{{\rm{\textbf{\thesubsubsection.}}}}

\makeatother
5
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – user31729
    Aug 27, 2014 at 12:14
  • With other words, you do want a \subsection between two theorems, having the number 2.3.8?
    – user31729
    Aug 27, 2014 at 12:15
  • Yes, I should have said that the command \subsection barely fails in my situation precisely because I want the subsection label to appear within the text itself (at the start of a specified paragraph) and not on its own line. The reason I am unable to provide a MWE is that everything has to work with the publisher's TeX code, and their topmatter is so huge that I am unsure what to extract from it.
    – BCnrd
    Aug 27, 2014 at 12:20
  • Basically, you need a \paragraph rather than subsection, if the label number should be a leadin
    – user31729
    Aug 27, 2014 at 12:24
  • I added a suggested solution, however, for lack of time, I could not incorporate your MWE in the meantime
    – user31729
    Aug 27, 2014 at 12:47

2 Answers 2

2

Define a new theorem environment.

\documentclass{book}

\usepackage{amsthm}
\newtheorem{thm}{Theorem}[section]

\theoremstyle{definition}
\newtheorem{interthm}[thm]{\ignorespaces}% theorem label is empty

\begin{document}

\chapter{A class of groups}

Let $G$ be a finite group.

\section{A class of subgroups}

Let $H$ be a subgroup of $G$.

\begin{thm}\label{lagrange}
The order of $H$ divides the order of $G$.
\end{thm}

\begin{interthm}\label{lagrange-comment}
Theorem~\ref{lagrange} is credited to Lagrange and can be
inverted for abelian groups.
\end{interthm}

\begin{thm}\label{inverse-lagrange}
If $G$ is abelian and $k$ is a divisor of the order
of $G$, then $G$ has a subgroup of order $k$.
\end{thm}

In \ref{lagrange-comment} we saw something.

\end{document}

enter image description here

You can make it into a command by using an \everypar trick; use it only at the outer level.

\documentclass{book}

\usepackage{amsthm}
\newtheorem{thm}{Theorem}[section]

\newcommand{\interthm}{%
  \par\refstepcounter{thm}%
  \everypar{{\setbox0=\lastbox}\textbf{\thethm.} \everypar{}}%
}

\begin{document}

\chapter{A class of groups}

Let $G$ be a finite group.

\section{A class of subgroups}

Let $H$ be a subgroup of $G$.

\begin{thm}\label{lagrange}
The order of $H$ divides the order of $G$.
\end{thm}

\interthm\label{lagrange-comment}
Theorem~\ref{lagrange} is credited to Lagrange and can be
inverted for abelian groups.

\begin{thm}\label{inverse-lagrange}
If $G$ is abelian and $k$ is a divisor of the order
of $G$, then $G$ has a subgroup of order $k$.
\end{thm}

In \ref{lagrange-comment} we saw something.

\end{document}

Note that, in this case, no additional vertical space below the numbered paragraph can be set automatically.

7
  • Awesome, this seems to do the trick! Let me fiddle around with it for some time. Strictly speaking, I'd love to have one slightly "better" feature, in the spirit of \subsection: can the command be designed to not require a \begin{...} and \end{...} part, just a single command right at the spot where I want the numerical label to appear, and not needing to select an \end{...} location? (The reason I ask is that I am going to have to tell the publisher what to do, and to the extent I can minimize what they have to do it will be better.)
    – BCnrd
    Aug 27, 2014 at 21:24
  • @BCnrd: you could wrap the environment in another macro ;-)
    – user31729
    Aug 27, 2014 at 21:28
  • @BCnrd I added an alternative solution
    – egreg
    Aug 27, 2014 at 21:42
  • @egreg: Thanks very much! I'll give it a try in the morning (right now I am tired after a long day).
    – BCnrd
    Aug 28, 2014 at 2:19
  • @egreg: The last line of the output reads as "1.1.3. In 1.1.2 we saw something" with 1.1.3 showing there in boldface (and without indentation). I then duplicated the final line of .tex code (before \end{document}) and there appears a repetition of the same line of text at the end of the output except without the "1.1.3" repeated in front and with an indentation. Is there a way to fix this bug? Also, my original .tex code used \newtheorem{thm}[section]{Theorem}, but that doesn't work with the solution; is there a way to make it work with that (to minimize what the publisher must change)?
    – BCnrd
    Aug 28, 2014 at 11:00
2

This provides an environment called \intertheoremremark similar to paragraph (which is not an environment at all, of course), just with a subsection like label and a bold font heading leadin. \label works for this.

This uses the assoccnt package, which provides a master counter, driving other counters, when stepped, in this case, the mytheorem counter.

However, a master counter cannot be driven by another counter, which is driven by the master.

\documentclass{scrbook}


\usepackage{blindtext}
\usepackage{amsmath}
\usepackage{amsthm}%
\usepackage{assoccnt}%




\newcounter{intertheoremremark}


\renewcommand{\theintertheoremremark}{\thesection.\arabic{intertheoremremark}}

\newenvironment{intertheoremremark}[2][]{%
\setcounter{intertheoremremark}{\number\value{mytheorem}}%
\setlength{\parindent}{0pt}%
\refstepcounter{intertheoremremark}%
\large  \textbf{\theintertheoremremark~#2}~
}{}%




\newtheorem{mytheorem}{Theorem}

\renewcommand{\themytheorem}{\thesection.\arabic{mytheorem}}

\DeclareAssociatedCounters{intertheoremremark}{mytheorem}%



\begin{document}

\chapter{Number one}

\section{First section}
\blindtext

\section{Second section}
\blindtext

\begin{mytheorem}{On Brontosaurs} \label{theorem::brontosaurs}
\blindtext
\end{mytheorem}


\begin{intertheoremremark}{Remarks to Theorem \ref{theorem::brontosaurs}} \label{firstremark}%
\blindtext
\end{intertheoremremark}%


\begin{mytheorem}{Other theory on  Brontosaurs} \label{theorem::brontosaurs2}
\blindtext
\end{mytheorem}


\begin{intertheoremremark}{Remarks to Theorem \ref{theorem::brontosaurs2}}%
This is a follow up remark to \ref{firstremark} 
\blindtext
\end{intertheoremremark}%

\end{document}

enter image description here enter image description here

Edit

I should add, that I am the author of assoccnt package, which is still in a rudimentary version available on CTAN and TeXlive 2014

Updated version with \paragraph coupled to mytheorem etc.

This does not use the assoccnt package, but uses paragraph instead of intertheoremremark environment. The behaviour of stepcounter is slightly changed, as assoccnt would do. The screen shots are nearly the same as in the version above.

\documentclass{book}

\usepackage{etoolbox}%

\usepackage{blindtext}
\usepackage{amsmath}
\usepackage{amsthm}%
\usepackage{remreset}%


\newtheorem{mytheorem}{Theorem}%


\makeatletter
\@removefromreset{paragraph}{subsubsection}
\@addtoreset{paragraph}{chapter}%
\@addtoreset{mytheorem}{chapter}%
\makeatother




\setcounter{secnumdepth}{4}%


\let\standardstepcounter\stepcounter

\renewcommand{\stepcounter}[1]{%
  \ifstrequal{#1}{paragraph}{%
    \standardstepcounter{mytheorem}%
  }{  \ifstrequal{#1}{mytheorem}{%
      \standardstepcounter{paragraph}%
    }{}}%
  \standardstepcounter{#1}%
}%



\renewcommand{\themytheorem}{\thesection.\arabic{mytheorem}}

\renewcommand{\theparagraph}{\thesection.\arabic{paragraph}.}%





\begin{document}

\chapter{Number one}

\section{First section}
\blindtext

\section{Second section}
\blindtext

\begin{mytheorem}{On Brontosaurs} \label{theorem::brontosaurs}
\blindtext
\end{mytheorem}


\paragraph{Remarks to Theorem \ref{theorem::brontosaurs}} \label{firstremark}%
\blindtext

\begin{mytheorem}{Other theory on  Brontosaurs} \label{theorem::brontosaurs2}
\blindtext
\end{mytheorem}


\paragraph{Remarks to Theorem \ref{theorem::brontosaurs2_again}}%
This is a follow up remark to \ref{secondremark}%
\blindtext


\chapter{Number Two}

\section{First section}
\blindtext

\section{Second section}
\blindtext

\begin{mytheorem}{On Brontosaurs} \label{theorem::brontosaurs_again}
\blindtext
\end{mytheorem}


\paragraph{Remarks to Theorem \ref{theorem::brontosaurs_again}} \label{secondremark}%
\blindtext

\begin{mytheorem}{Other theory on  Brontosaurs} \label{theorem::brontosaurs2_again}
\blindtext
\end{mytheorem}


\paragraph{Remarks to Theorem \ref{theorem::brontosaurs2}}%
This is a follow up remark to \ref{firstremark} 
\blindtext


\end{document}
8
  • Thanks! I am hoping for a procedure which is sufficiently robust that it works even without any Theorems present, just like \subsection. That is, if I want section 2.3 to begin with a subsection 2.3.1 (say after a few introductory sentences) and there is no "Theorem" in the picture at all, I'd still like to be able to make a paragraph that begins with "2.3.1" in boldface at the start (not on its own line), and works with \label. My publisher may frown if I insist on them using a rudimentary version of a package (e.g., assoccnt), so I'll wait to see what other ideas emerge. Thanks again.
    – BCnrd
    Aug 27, 2014 at 13:31
  • @BCnrd: The solution just uses one feature of the package. It can be done without the package.
    – user31729
    Aug 27, 2014 at 13:54
  • I have tried it with the lines for \DeclareAssociatedCounters and \usepackage{assoccnt} removed, but it doesn't then make the numbering synced properly (as subsection would); not sure what causes that. The output is also somewhat bigger font size than the regular text; would be best to be same size as regular text, just like for \subsection.
    – BCnrd
    Aug 27, 2014 at 14:12
  • @BCnrd: The font size can be changed. I provided another version, without assoccnt, using \paragraph.
    – user31729
    Aug 27, 2014 at 19:25
  • @BCnrd: Did you see my other version at all?
    – user31729
    Aug 27, 2014 at 21:29

You must log in to answer this question.

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