0

enter image description hereI have an example which is 3 slides long, as shown in the figure. I would like to have all 3 boxes green and have the same number This is my code, basically i changed everywhere to "example"

\documentclass{beamer}
\usetheme{Warsaw}
\usepackage{lipsum}

\makeatletter
\newenvironment<>{examples}[1][\proofname]{%
    \par
    \def\insertexamplename{#1\@addpunct{.}}%
    \usebeamertemplate{example begin}#2}
  {\usebeamertemplate{example end}}
\makeatother

\begin{document}

\begin{frame}
\begin{examples}
\lipsum[1]
\end{examples}
\end{frame}

\begin{frame}
\begin{examples}[\proofname\ (Cont.)]
\lipsum[1]
\end{examples}
\end{frame}

\begin{frame}
\begin{example}[\examplename\ (Cont.)]
\lipsum[1]
\end{example}
\end{frame}
  • 2
    Your code is not compilable. The definition of \examplename and the \end{document} are missing. – Skillmon Apr 9 '17 at 17:46
  • 1
    Also your code does produce only one box for me. And this one box is green. And what is the meaning of #2 in the definition of your newenvironment? And the \usebeamertemplate{example begin} doesn't seem to do anything. If I change all your \begin{examples}...\end{examples} to use {example} I do get three green boxes. And what do you mean with "same number"? They don't have any number as far as I can tell. – Skillmon Apr 9 '17 at 17:56
  • 1
    You could reduce the counter which is used inside the environments (which were used for the picture, but not in your MWE) between your uses, to have it show the same number using \addtocounter{<insert counter name here>}{-1} – Skillmon Apr 9 '17 at 18:08
  • @Skillmon I saw this code: \documentclass{beamer} \usetheme{Warsaw} \usepackage{lipsum} \makeatletter \newenvironment<>{proofs}[1][\proofname]{% \par \def\insertproofname{#1\@addpunct{.}}% \usebeamertemplate{proof begin}#2} {\usebeamertemplate{proof end}} \makeatother \begin{document} \begin{frame} \begin{proofs} \lipsum[1] \end{proofs} \end{frame} \begin{frame} \begin{proofs}[\proofname\ (Cont.)] \lipsum[1] \end{proofs} \end{frame} \begin{frame} \begin{proof}[\proofname\ (Cont.)] \lipsum[1] \end{proof} \end{frame} \end{document} – user146120 Apr 9 '17 at 20:36
  • @Skillmon I found that code and I tried to recreate it using the word "example" instead. You are right the code does not function, I checked myself. I wish that this example will be split in multiple frames. I tried to use [allowframebreaks] but it didn't work too. I appreciate a lot for your help, regards – user146120 Apr 9 '17 at 20:40
2

If I get your question right (I hope so) the following could work. It uses tcolorbox and not the default proof-boxes from beamer. I don't know how to do this with beamer. For that, you might have a look at the beamer documentation.

\documentclass{beamer}
\usetheme{Warsaw}
\usepackage{lipsum}
\usepackage[skins]{tcolorbox}

\definecolor{proofhead}{HTML}{006000}
\definecolor{proofbody}{HTML}{e6efe6}
\newcounter{proofs}
\newtcolorbox{myproofbox}[1][]{%
    beamer,%
    colback=proofbody,%
    colframe=proofhead,%
    boxsep=0pt,
    top=3pt,
    bottom=5pt,
    left=4pt,%
    right=4pt,%
    fuzzy shadow={1mm}{-1mm}{0mm}{0.1mm}{black!50!white},%
    #1%
}

\newenvironment<>{myproof}[1][]{%
    \refstepcounter{proofs}
    \begin{myproofbox}[%
        adjusted title=\normalfont{\proofname~\theproofs~#1},% you might change this line to set a default title
    ]}
    {\end{myproofbox}}

\begin{document}
    \begin{frame}
        This is how it should look like:
        \begin{example}
            \lipsum[2]
        \end{example}
    \end{frame}
    \begin{frame}
        This is how my code looks like:
        \begin{myproof}
            \lipsum[2]
        \end{myproof}
    \end{frame}
    \begin{frame}
        \addtocounter{proofs}{-1}% This reduces the counter so it's the same number
        \begin{myproof}[(Cont.)]
            \lipsum[2]
        \end{myproof}
    \end{frame}
\end{document}

To set a complete custom title you can also use the following instead of \begin{myproof}...\end{myproof}:

\begin{myproofbox}[adjusted title=\normalfont{<Insert your Title here>}]
    <Insert the content of the box here>
\end{myproofbox}

Note that this doesn't step the counter. To step the counter in a way that you can label the box you should use \refstepcounter{proofs}. To use the counter value (e.g. in your title) you can use \theproofs or something like \roman{proofs} for other formatting of the number.

  • thanks for your reply its almost what I wanted but instead of having Proof 1 and Proof 1 Cont in the 2nd and 3rd slide respectively I would like "Example Cont" on both slides – user146120 Apr 10 '17 at 21:07
  • With or without numbering? So the first title (of the frames using myproof) should be 'Example 1' and the second 'Example 1 (Cont.)'? To change the word 'Proof' to 'Example' you might use adjusted title=\normalfont{Example~\theproofs~#1},% in the definition of myproof. – Skillmon Apr 11 '17 at 7:40
  • @user146120 you might look at my edit for some additional information. – Skillmon Apr 11 '17 at 7:49

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.