包 animate 與 tcolorbox 衝突

包 animate 與 tcolorbox 衝突
\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}

在我看來,我能夠非常成功地尋找錯誤...

我希望在開始動畫之前看到相同的人物。

下載warning.pdfpdstestg-pics.pdfhttps://www.dropbox.com/sh/5y5rgralnw1pj8h/AABxTyDrCDUqo80ZtRF_rVTba?dl=0

答案1

圖形檔案的包含似乎令人不安animate- 然而,如果將圖形檔案放入一個盒子中,整個編譯就會運行並顯示所需的功能。

\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}

在此輸入影像描述

答案2

基於上面的解決方案,我改進了這個解決方案,包括儲存箱。

\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}

現在可以使用 storebox,但您不必這樣做。

參考文獻是:

[1]storebox 在 begin{document} 之前無法像普通 savebox 一樣運作(感謝egreg)

[2]tikz 和 storebox 結合出現問題:缺少數字,視為零。使用 animate,頁面會附帶文字“graphicx”,(感謝egreg)

如果沒有egreg,就不可能向TeX.SE 提供此解決方案。

相關內容