0

(EDIT) I'm trying to use the \animategraphics[]{}{}{}{} command inside a table, to be precise in a \tabularx table.

I have successfully run this :

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{animate}

\title{testing animate package}
\author{JeanValjean}

\date{January 2021}

\begin{document}

\maketitle

\section{Test}
\begin{figure}
        \centering
        \animategraphics[autoplay, loop, width=0.8\textwidth, controls, buttonfg=1:0.4:0.4]{20}{./images/MovingVertices/MovingVertices}{0}{79}
\end{figure}
\end{document}

So, without table, it works like a charm.

But not inside a table :

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{animate}

\title{testing animate package}
\author{JeanValjean}

\date{January 2021}

\begin{document}

\maketitle

\section{Test}
\begin{tabularx}{\textwidth}{@{}m{3cm} X@{}}
something & \animategraphics[autoplay, loop, width=0.8\textwidth, controls, buttonfg=1:0.4:0.4]{20}{./images/MovingVertices/MovingVertices}{0}{79} \\
something else & something else else\\
\end{tabularx}
\end{document}

This error message occur :

You have referenced something which has not yet been labelled. If you have labelled it already, make sure that what is written inside \ref{...} is the same as what is written inside \label{...}.

If I remove "\animategraphics[]{}{}{}{}" in my table, like this :

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{animate}

\title{testing animate package}
\author{JeanValjean}

\date{January 2021}

\begin{document}

\maketitle

\section{Test}
\begin{tabularx}{\textwidth}{@{}m{3cm} X@{}}
something & blabla \\
something else & something else else\\
\end{tabularx}
\end{document}

All is fine.

I also tried to wrap my \animatedgraphics[]{}{}{}{} inside a figure environment, but as I already know, as you do, figure environment doesn't work well inside a tabularx environment :

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{animate}

\title{testing animate package}
\author{JeanValjean}

\date{January 2021}

\begin{document}

\maketitle

\section{Test}
\begin{tabularx}{\textwidth}{@{}m{3cm} X@{}}
   something & \begin{figure}\animategraphics[autoplay, loop, width=0.8\textwidth, controls, buttonfg=1:0.4:0.4]{20}{./images/MovingVertices/MovingVertices}{0}{79}\end{figure}\\
   something else & something else else\\
\end{tabularx}
\end{document}

leads to this error messages :

LaTeX Error: Not in outer par mode

Undefined control sequence. @xfloat ...@fltovf \fi \global \setbox @currbox \color@vbox \normalcolor ... l.20 \end{tabularx} The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., \hobx'), type I' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined.

Missing number, treated as zero. \color@vbox l.20 \end{tabularx} A number should have been here; I inserted 0'. (If you can't figure out why I needed to see a number, look up weird error' in the index to The TeXbook.)

Reference `anim@abspage2' on page 1 undefined on input line 20.

There were undefined references.

Is there a way to perform this?

Thanks a lot

2
  • 5
    Welcome to TeX.SX. Please, provide complete, compilable code, starting with \documentclass... and ending with \end{document}.
    – AlexG
    Jan 26, 2021 at 20:59
  • @Guilhem Escudéro If you already found a solution by your own make a comment, or accept one of the answer posted to close the question or make a follow up question. Jan 28, 2021 at 20:43

2 Answers 2

1

tabularx is somewhat peculiar in that it may typeset its content multiple times in order to adjust widths of individual columns. This may interfere with labelling and referencing commands used within the table. (\animategraphics internally makes use of such commands.)

Therefore, in order to avoid problems, it is advisable to store \animategraphics... in a savebox outside the table and insert the savebox content later on in the table:

\newsavebox\myAnimation

...

\sbox{\animategraphics...}%
\begin{tabularx}...
...
\usebox{\myAnimation}
...
\end{tabularx}
0

I used an animation that I already had.

I didn't find any errors in the compilation with tabularx.

However, the animation doesn't run with tabularx but works fine with tabular*. (using AcrobatReader)

Please test my code with your data. I used acrobat reader to open the pdf file and operate the animation.

UPDATE With tabularx the animation does run using FoxitReader.

n

After some time.

ok

At another time.

b

% !TeX TS-program = pdflatex

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{animate}

\usepackage{tabularx}

\title{testing animate package}
\author{JeanValjean}

\date{January 2021}
\begin{document}
    
%\maketitle 
    
\newcommand{\shipi}{%
    \animategraphics[%
    autoplay, 
    loop,
    controls,
    buttonfg=1:0.4:0.4,
    width=0.8\linewidth,
    ]
    {3}{./animaxiv/frame-}{0}{59}
}
    
\section{Test animation does not work (tabularx)}
\begin{tabularx}{\textwidth}{@{}m{3cm} X@{}}    
    alpha &beta\\
    gamma & \shipi  
\end{tabularx}

\newpage

\section{Test animation  works fine (tabular*) }
\begin{tabular*}{\textwidth}{@{}m{3cm} m{0.8\linewidth}@{}} 
    alpha &beta\\
    gamma & \shipi  
\end{tabular*}  
    
\end{document}
2
  • You can get it working if you use the savebox trick. However, saving with \sbox{...} must be repeated before the second table.
    – AlexG
    Jan 27, 2021 at 15:36
  • @AlexG Thank for your feedback. In both solutions the animation within tabularx runs when using FoxitReader (v. 7.2). I updated my answer. Jan 27, 2021 at 17:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .