# How to create new blocks for theorems

I was trying to create two different blocks: one for 'Quiz' and other for 'Homework'. The following MWE looks quite OK:

\documentclass{beamer}
\usepackage{thmtools}

\newcounter{qzcounter}
\newcounter{hwcounter}

\declaretheoremstyle[
title = Quiz \arabic{qzcounter} ,
]{qzstyle}

\declaretheoremstyle[
title = Homework \arabic{hwcounter} ,
]{hwstyle}

\declaretheorem[style=qzstyle]{qz}
\declaretheorem[style=hwstyle]{hw}

\begin{document}

\begin{frame}
\begin{qz}
Q 1
\end{qz}

\begin{qz}
Q 2
\end{qz}

\begin{hw}
HW 1
\end{hw}

\begin{qz}
Q 3
\end{qz}

\begin{hw}
HW 2
\end{hw}

\begin{qz}
Q 4
\end{qz}

\end{frame}

\end{document}


But, the two things I failed to do:

1. Automatic numbering for the quizzes and homeworks separately
2. Changing the block type (say, exampleblock for 'Homework' and alertblock for 'Quiz')
• you need to add \stepcounter{qzcounter} before \arabic{qzcounter} – John Kormylo Oct 8 '14 at 19:45
• If the quiz/homework environments should be referencable, then \refstepcounter{qzcounter} is to be used – user31729 Oct 8 '14 at 20:30
• \stepcounter does not work as it is in the mwe given by the OP, maybe the thmtools package has its own way of dealing with counters. – Old Nick Oct 8 '14 at 20:33

You're using beamer and beamer provides its own mechanism to declare new theorem environments. It's explained in beameruserguide, section 12.4.

The main command is:

\newtheorem{<environment name>}[<numbered as>]{<head text>}[<number within>]


which in your case could be

\newtheorem{qz}[qzcounter]{Quiz}
\newtheorem{hw}[hwcounter]{Homework}


with qzcounter and hwcounter previously declared. By default, beamer doesn't show numbers in theorem headers, but \setbeamertemplate{theorems}[numbered] will do it.

\documentclass{beamer}
%\usepackage{thmtools}

\newcounter{qzcounter}
\newcounter{hwcounter}

\newtheorem{qz}[qzcounter]{Quiz}
\newtheorem{hw}[hwcounter]{Homework}

\setbeamertemplate{theorems}[numbered]

\begin{document}

\begin{frame}
\begin{qz}
Q 1
\end{qz}

\begin{qz}
Q 2
\end{qz}

\begin{hw}
HW 1
\end{hw}

\begin{qz}
Q 3
\end{qz}

\begin{hw}
HW 2
\end{hw}

\begin{qz}
Q 4
\end{qz}

\end{frame}

\end{document}


This solves 1. Let me some time to try to solve 2. ;-)

I don't see why you're using any theorem package if you're bypassing the numbering mechanisms… beamer suggests that if you define theorems with theoremstyle X active, it will try to put it into a Xblock environment instead of plain block, but it will only do that for example. We seem to have split that into a separate question now.

\documentclass{beamer}
\usepackage{thmtools}
\setbeamertemplate{theorems}[numbered]

\declaretheorem[title=Quiz]{qz}

\theoremstyle{example}
\declaretheorem[title=Homework]{hw}

\begin{document}

\begin{frame}
\begin{qz}Q 1\end{qz}
\begin{qz}Q 2\end{qz}
\begin{hw}HW 1\end{hw}
\begin{qz}Q 3\end{qz}
\begin{hw}HW 2\end{hw}
\begin{qz}Q 4\end{qz}
\end{frame}

\end{document}