4

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

\documentclass{beamer}
\usetheme{Madrid}
\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
  • 1
    \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. – Nico Boni Oct 8 '14 at 20:33
2

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}
\usetheme{Madrid}
%\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}

enter image description here

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

1

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}
\usetheme{Madrid}
\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}

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.