3
\PassOptionsToPackage{dvipsnames}{xcolor} 
\documentclass[dvipsnames]{article}
\usepackage[skins]{tcolorbox}
\usepackage{animate}

\providecommand{\actiontext}{Attention}
\newtcolorbox{achtungbox}[1][]{%
  enhanced,
  colframe=white,
  natural height,
  colback=black!10,
  coltitle=black,
  fonttitle=\bfseries\large,
  boxrule=0.3mm,arc=0mm,boxsep=0pt,left=2mm,width=\linewidth,
  leftrule=13mm,
  title={\small{\actiontext}},
  attach title to upper={\par\smallskip},
  underlay={
    \node[inner sep=0pt] (logo) at ([xshift=6mm,yshift=-6mm]frame.north west) {\ifpdf\includegraphics[width=10mm]{warning}\fi};
  },
  #1
}

\providecommand{\achtung}[1]{
\begin{achtungbox}
#1
\end{achtungbox}
}

\begin{document}

\animategraphics[trim=4.75cm 17cm 3.5cm 4.0cm, poster=last,autoplay=false,autoresume=true,autopause=true,loop=false,controls=true,scale=0.75]{8}{pdstestg-pics}{}{}
\achtung{AAA}
% \newpage
\animategraphics[trim=4.75cm 17cm 3.5cm 4.0cm, poster=last,autoplay=false,autoresume=true,autopause=true,loop=false,controls=true,scale=0.75]{8}{pdstestg-pics}{}{}

\achtung{I would expect the same figure in both animates at the start, but it does not. Sure, this is not the real case, but timeline options enables me to start animatens from different frames, this is currently impossible, seems to me. timeline option is not used here..., wanted to show a special animation at the intro of lectorenotes and later at the chapter.}

\end{document}

Seems to me that I am able to hunt bugs very successfully...

I would expect to see identical figures before starting animation.

Download warning.pdf and pdstestg-pics.pdf at https://www.dropbox.com/sh/5y5rgralnw1pj8h/AABxTyDrCDUqo80ZtRF_rVTba?dl=0

  • The culprit is the underlay in the achtungbox, but I can't say why this is causing problems – user31729 Feb 14 '16 at 11:05
  • That's clearly a bug of the animate package (though it is unrelated to tcolorbox). I'll have a look into it. – AlexG Feb 15 '16 at 13:02
  • A bug fix is on the way to CTAN (animate v. [2016/02/15]) – AlexG Feb 15 '16 at 13:08
  • Seems, that one problem is solved. (figure is seen as the workaround) but only the second animation can be played, the first wont be played clicking on the play button. Can anyone confirm? – Peter Ebelsberger Feb 17 '16 at 23:39
  • No, both play nicely on my end. – AlexG Feb 20 '16 at 17:06
3

The inclusion of the graphic file seems to upset animate -- however, if the graphic file is put into a box, the whole compilation runs and the desired feature is shown.

\PassOptionsToPackage{dvipsnames}{xcolor} 
\documentclass[dvipsnames]{article}
\usepackage[most]{tcolorbox}
\usepackage{animate}

\newsavebox{\mybox}
\savebox{\mybox}{\includegraphics[width=10mm]{warning}}

\providecommand{\actiontext}{Attention}
\newtcolorbox{achtungbox}[1][]{%
  enhanced,
  colframe=white,
  natural height,
  colback=black!10,
  coltitle=black,
  fonttitle=\bfseries\large,
  boxrule=0.3mm,arc=0mm,boxsep=0pt,left=2mm,width=\linewidth,
  leftrule=13mm,
  title={\small{\actiontext}},
  attach title to upper={\par\smallskip},
  underlay={
    \node[inner sep=0pt] (logo) at ([xshift=6mm,yshift=-6mm]frame.north west) {%
      \ifpdf
      \usebox{\mybox}%
      \fi
  };
  },
  #1
}

\providecommand{\achtung}[1]{
\begin{achtungbox}
#1
\end{achtungbox}
}

\begin{document}

\animategraphics[trim=4.75cm 17cm 3.5cm 4.0cm, poster=last,autoplay=false,autoresume=true,autopause=true,loop=false,controls=true,scale=0.75]{8}{pdstestg-pics}{}{}

\achtung{AAA}
% \newpage
\animategraphics[trim=4.75cm 17cm 3.5cm 4.0cm, poster=last,autoplay=false,autoresume=true,autopause=true,loop=false,controls=true,scale=0.75]{8}{pdstestg-pics}{}{}

\achtung{I would expect the same figure in both animates at the start, but it does not. Sure, this is not the real case, but timeline options enables me to start animatens from different frames, this is currently impossible, seems to me. timeline option is not used here..., wanted to show a special animation at the intro of lectorenotes and later at the chapter.}

\end{document}

enter image description here

  • 1
    You were minutes faster than me. I also found that the \includegraphics caused the problem, but you also found a way to circumvent the problem :-) – Thomas F. Sturm Feb 14 '16 at 11:18
  • @ThomasF.Sturm: Yes, I found a way to circumvent, but not the cause. I assume it's the boxing features of tcolorbox, but I leave this to the experts -- do you know one, by chance? ;-) – user31729 Feb 14 '16 at 11:19
  • No, it has nothing to do with tcolorbox. The same problem arises, if all tcolorboxes are removed and you place a naked \includegraphics[width=10mm]{warning} between the animations. – Thomas F. Sturm Feb 14 '16 at 11:21
  • @ThomasF.Sturm: Ah -- I did not remove the tcolorboxes so far. Well, it's a feature (as David Carlisle would say, others call it a bug ;-)) of animate then? – user31729 Feb 14 '16 at 11:22
  • Yes, I think so. I'm not familiar with the animate package, but, maybe, it's a known problem with a known solution? – Thomas F. Sturm Feb 14 '16 at 11:27
1

Based on the solution above I have improved this one to be used including storebox.

\PassOptionsToPackage{dvipsnames}{xcolor} 
\documentclass[dvipsnames]{article}
\usepackage[skins]{tcolorbox}
\usepackage{animate}

% \usepackage{storebox}
% \AtBeginDocument{{}} % see [2]

\providecommand{\newstorebox}[1]{\newsavebox{#1}} % <- fallback is no storebox is used
\providecommand{\storebox}[1]{\savebox{#1}}  % <- fallback is no storebox is used
\providecommand{\usestorebox}[1]{\usebox{#1}}  % <- fallback is no storebox is used

\newstorebox{\myboxgnA}     

\AfterEndPreamble{%
    \storebox{\myboxgnA}{\includegraphics[width=10mm]{warning}} 
} % see [1]


\providecommand{\actiontext}{Attention}
\newtcolorbox{achtungbox}[1][]{%
  enhanced,
  colframe=white,
  natural height,
  colback=black!10,
  coltitle=black,
  fonttitle=\bfseries\large,
  boxrule=0.3mm,arc=0mm,boxsep=0pt,left=2mm,width=\linewidth,
  leftrule=13mm,
  title={\small{\actiontext}},
  attach title to upper={\par\smallskip},
  underlay={
    \node[inner sep=0pt] (logo) at ([xshift=6mm,yshift=-6mm]frame.north west) {\ifpdf\usestorebox{\myboxgnA}\fi};
  },
  #1
}

\providecommand{\achtung}[1]{
\begin{achtungbox}
#1
\end{achtungbox}
}

\begin{document}

\animategraphics[trim=4.75cm 17cm 3.5cm 4.0cm, poster=last,autoplay=false,autoresume=true,autopause=true,loop=false,controls=true,scale=0.75]{8}{pdstestg-pics}{}{}
\achtung{AAA}
% \newpage
\animategraphics[trim=4.75cm 17cm 3.5cm 4.0cm, poster=last,autoplay=false,autoresume=true,autopause=true,loop=false,controls=true,scale=0.75]{8}{pdstestg-pics}{}{}

\achtung{I would expect the same figure in both animates at the start, but it does not. Sure, this is not the real case, but timeline options enables me to start animatens from different frames, this is currently impossible, seems to me. timeline option is not used here..., wanted to show a special animation at the intro of lectorenotes and later at the chapter.}

\end{document}

Now may use storebox now, but you don't have to.

references are:

[1] storebox doesn't work before begin{document} like normal savebox (thanks to egreg)

[2] Problems combining tikz and storebox: Missing number, treated as zero. With animate, page shipped out with text `graphicx`, (thanks to egreg)

Without egreg it would not be possible to provide this solution to the TeX.SE.

  • I don't see the point of the wrappers at all.... – user31729 Feb 14 '16 at 17:58
  • Maybe I am wrong, but storebox saves the content only once? – Peter Ebelsberger Feb 15 '16 at 10:06
  • Yes,but why the wrappers? If you don't need the box more than once you don't need this extra setup,in my point of view – user31729 Feb 15 '16 at 11:14
  • I have tested once more. You are absolutley right. You cannot understand this, because you are thinking the right way. Thanks for your advice. Should I delete this example? – Peter Ebelsberger Feb 15 '16 at 12:52
  • No. Just keep it as a more 'general' way instead of using a direct box name – user31729 Feb 15 '16 at 12:56

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.