# To embed PDF animation in latex document

I have created an animation by latex with \usepackage{animate}. I added this PDF-animation to another latex file by \includegraphics{} or \includepdf{}, but it is invisible in new file.

This is a simplified sample of my code:

\documentclass[landscape,a4paper]{article}
\usepackage{animate}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
%\usepackage{xepersian}
%\setlatintexfont[scale=1.0]{Times New Roman}
\begin{document}
\begin{animateinline}[controls,poster=first,loop]{1}

\begin{tikzpicture}
\draw (0,0) rectangle (4,5);
\end{tikzpicture}

\newframe
\begin{tikzpicture}
\draw (1,1) rectangle (3,6);
\end{tikzpicture}

%...

\end{animateinline}
\end{document}


My problem is only "to embed PDF animation in another latex document". You asked a minimal code, so I made a simple code for you. It is not XY-Problem. The result of above code is a PDF file. I want to add this file in my next file. the second file has \usepackage{xepersian}. I added those three inactive lines to show you the error of using animation codes in my final file.

\documentclass{article}
\usepackage{pdfpages}
\usepackage{xepersian}
\settexfont[scale=1.0]{Yas}

\begin{document}
\includepdf{BC.pdf}
\end{document}


Actually this is my second code. When I run second code with final file of first code (BC.pdf) I have a white blank paper. But I have a result, if I replace another PDF file.

• Please post a minimal example for us to reproduce your problem. Apr 16 '18 at 6:39
• As is, you are trying to solve an ↗XY-Problem. Your code does not compile for some reason (original problem X). You are trying to work around the problem using another method which fails too (problem Y) and you ask for help solving Y. Could you please reformulate your question to clearly state the original problem X, adding the error message you get (mentioned in your first comment below the answer)? Apr 17 '18 at 8:28
• Your actual problem X is: How to use animate in a document using the xepersian package. Your attempt to work around this problem is to embed a PDF with animation produced without xepersian into a secondary document using xepersian. It is giving rise to problem Y, because such kind of PDF doesn't seem to leave the animation intact. Apr 17 '18 at 11:45
• The command \setlatintexfont doesn't seem to be defined. At least not by the packages loaded. Apr 17 '18 at 11:46
• The command \settexfont of the second code isn't defined either. Apr 17 '18 at 11:54

This is an ↗XY Problem:

• Secondary, Y Problem: Embedding a PDF with an animate-generated animation into another document as an attempt to work around the actual problem X below.

Any interactivity in the included PDF, such as animate-generated animations, gets lost. The same happens to hyperref-generated links and bookmarks, to PDF layers, embedded files, multimedia etc.

To transfer an animation, just copy the original code for building the animation into the LaTeX source of the destination document.

• Actual, X Problem: A document using packages animate and xepersian at the same time does not compile, but produces an error:

Package ifthen Error: Boolean @anim@morejs undefined.


Solution to original Problem X:

You should use an up-to-date TeX installation and packages. With TeXLive 2017 (frozen1), there is no problem using animate and xepersian in the same document:

(I put Yas.ttf into the current directory for compilation with xelatex):

\documentclass{article}
\usepackage[landscape,a6paper]{geometry}

\usepackage{animate}
\usepackage{tikz}

\usepackage{xepersian}
\settextfont{Yas.ttf}

\begin{document}\Huge\centering
این طرحنما میآزماید نگاره و اندازه و شکل را

\begin{animateinline}[controls,poster=first,loop]{1}
\begin{tikzpicture}
\node[draw,fill=red] {1};
\end{tikzpicture}
\newframe
\begin{tikzpicture}
\node[draw,fill=green] {2};
\end{tikzpicture}
\newframe
\begin{tikzpicture}
\node[draw,fill=blue] {3};
\end{tikzpicture}
\end{animateinline}
\end{document}


1 As of 5th March 2018, TeXLive-2017 does not get package updates anymore; versions of installed packages may lag behind the versions on CTAN. TeXLive-2018 is to be released to the public on 30th April 2018, allowing the user to update packages via its package manager tlmgr again, either via command line (tlmgr update --self --all) or via the graphical user interface. Package updates are started manually and should be carried out regularly to take advantage of bug fixes and new features of installed packages, as well as of new packages that appear on CTAN.

• I cannot copy the code. It is impossible because when I use \usepackage{xepersian} and \usepackage{animate} both together, TexStudio shows this error: package ifthen error: Boolean
– AliM
Apr 16 '18 at 12:24
• Please add a minimal example, as suggested by @Henri . In doubt, follow the link in his comment on how to set up an MWE. Apr 16 '18 at 13:29
• \documentclass[landscape,a4paper]{article} \usepackage{animate} \usepackage{tikz} \usepackage[utf8]{inputenc} \usepackage{xepersian} \setlatintexfont[scale=1.0]{Times New Roman} \begin{document} \begin{animateinline}[controls,poster=first,loop]{1} \newframe \begin{tikzpicture} \drow (0,0) rectangle (4,5); \end{tikzpicture} ... \end{animateinline} \end{document}
– AliM
Apr 17 '18 at 5:23
• This is my sample code. If you hide xepersian and set text font, it is correct and will be run. But when you use xepersian to write Farsi, you will see those errors.
– AliM
Apr 17 '18 at 5:28
• Why didn't you insert the code into the question? Apr 17 '18 at 6:40