3

Within my thesis I am attempting to number the studies listed throughout.

I have used a custom theorem style for this:

\newtheorem{study}{Study}

First Issue

I then want to use this within my section headings, so that a section heading will look something like 5.2 Study 1. This is a test

To achieve this, I am using the following code

\section[This is a test]{\protect\begin{study}This is a test\protect\end{study}}

This is both messy, and means that the Study number does not show up in my ToC. Is there a better way to include a theorem in a section heading?

Second Issue

The theorem class puts breaks above and below the study, meaning the formatting of the heading has a line break after the section number, like so:

5.2

Study 1. This is a test

I have attempted to fix this by altering the theoremstyle, but has not worked. I want it to stop linebreaking, and to bold the text after Study 1. The code I am using to attempt that is below

\newtheoremstyle{study2}
  {0} % Space above
  {0} % Space below
  {} % 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{study2} \newtheorem{study}{Study}

How can I remove this line break, and how can I make the whole section heading bold?

Thank you very much in advance for any advice you can give.

Working Example

\documentclass{report}
\usepackage{amsthm}

\newtheoremstyle{study2}
  {0} % Space above
  {0} % Space below
  {} % 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{study2} \newtheorem{study}{Study}


\begin{document}
\section[This is a test]{\protect\begin{study}This is a test\protect\end{study}}
\end{document}

Desired Outcome Mock-up

Desired Outcome mockup

SOLUTION

I have ended up using the following code:

 \newenvironment{study}
  {\enskip\refstepcounter{studyish}\textbf{Study~\thestudyish:\space}}% \begin{shortthm}
  {\enskip}% \end{shortthm}
\makeatother

 \newtheorem{studyish}{Study}

This fixes the line breaking problem. And allows for the Study number to be listed in the ToC. The new section headings look like this:

\section{\protect\begin{study}\label{study:FirstStudy}This is a test\protect\end{study}}
4
  • This is difficult to comprehend. Wouldn't it be enough to put the number of the study into the section heading? However, please give a minimal working example.
    – Keks Dose
    Sep 14, 2014 at 12:30
  • Could you post a graphic mock-up of what you want to achieve? Sep 14, 2014 at 12:45
  • if all of your studys are used as section headings, and if you are using amsthm you can use \swapnumbers and use [section] as the controlling counter: \swapnumbers \newtheorem[section]{study}{Study}. or if only some of them are at the section level, you could define a second version, say secstudy and tinker with counters to keep them in synch. Sep 14, 2014 at 12:46
  • I've just added the working example, and the desired outcome mock-up. Hopefully that makes my question clearer. I am still unsure about the order of the studies, hence trying to use the Theorem solution. However, if there is no easy way of doing this, I will just hard code it and write it in by hand. I had just assumed there'd be a more "LaTeX-y" way of doing it. Thanks for input so far.
    – SarahW
    Sep 14, 2014 at 13:03

1 Answer 1

5

You're on the wrong track. ;-) Just setup a new counter and use it.

\documentclass{book}
\usepackage{xparse}

\newcounter{study}
\NewDocumentCommand{\study}{om}{%
  \refstepcounter{study}\IfValueT{#1}{\label{#1}}%
  \section{Study \thestudy: #2}%
}

\begin{document}
\frontmatter
\tableofcontents

\mainmatter
\chapter{Title}

\section{A regular section}\label{sec:reg}

We'll see in study~\ref{st:first} (see section~\ref{sec:st})
that we're doing interesting things.

\study[st:first]{This is a test}\label{sec:st}

Whatever.

\end{document}

The label for the study number is given as optional argument to \study.

Table of contents

enter image description here

First page

enter image description here

You must log in to answer this question.

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