3

I am trying to use the theorem environment in my work as Sample Problem.

This is my MWE:

\documentclass{book}

\usepackage{amsthm}

\newtheoremstyle{mythmstyle}
    {}{}{}{}
    {\bf}
    {}
    {\newline}
    {}
\theoremstyle{mythmstyle}
\newtheorem{mythm}{Sample Problem}[chapter]
\setcounter{chapter}{2}

\begin{document}
\chapter{New Chapter}
\begin{mythm}
    Problem statement goes here. But, where does go title?
\end{mythm}
\end{document}

And the output,

enter image description here

Actually, I need something like this,

enter image description here

In other words, my Sample Problem lacks a Title.

How can I include a title within the theorem environment?

Shaqpad
  • 197

2 Answers2

4

Here's a solution with thmtools, which eases defining new theorem styles:

\documentclass{book}
\usepackage[utf8]{inputenc} \usepackage{fourier, erewhon, cabin}
\usepackage[table, x11names]{xcolor} \usepackage{mathtools}
\usepackage{amsthm, thmtools}
\usepackage{microtype} \SetTracking[no ligatures = {f}]{encoding = *}{50}
\declaretheoremstyle[%
headfont=\color{SteelBlue3}\sffamily\bfseries\lsstyle,
within=chapter, headpunct={\medskip}, postheadspace=\newline, notefont=\color{black}\mdseries, notebraces = {\quad}{},spaceabove = 8pt,spacebelow = 8pt]%
{sample}

\declaretheorem[name=Sample Problem, style=sample]{mypb}

\begin{document}

\setcounter{chapter}{3}

\begin{mypb}[Adding vectors in a drawing, orienteering]
  Show the following assertion is true: %
  \begin{equation*}
    a = a
  \end{equation*}
\end{mypb}

\end{document}

enter image description here

Bernard
  • 271,350
  • thmtools package uses more understandable semantics than amsthm. Isn't it? – Shaqpad May 02 '16 at 15:43
  • I agree with you. Amsthm is OK for simple modifications, but it's better to supplement it with thmtools for more complex layouts. Anyway, personally, I use ntheorem, which is also easier to customise and has an automatic placement of end-of-proof symbols. – Bernard May 02 '16 at 15:48
0

The title goes in squared brackets at the beginning of the theorem.

\begin{mythm}[Here goes the title]
Problem statement goes here. But, where does go title?
\end{mythm}

This is what it looks like

It doesn't look exactly what your example picture looks like, but as the "Sample Problem 3.1" text is bold making the title also bold wouldn't benefit readability.

BenjaminH
  • 688