0
$\begingroup$

Is there a process of embedding Manipulate output into .pdf document, or alternatively creating a link of the Manipulate output, which can be added into .pdf.

For example, I would like to add the output of

Manipulate[Plot[Sin[n x], {x, 0, 2 Pi}], {n, 1, 20}]

into lecture notes to demonstrate effect of varying parameter for angular frequency.

Kind regards, Richard

$\endgroup$
5
  • $\begingroup$ Embedding it directly into the PDF will not be possible. For creating a link to an interactive version, see CloudPublish (note that published stuff may not remain accessible forever depending on your account type) $\endgroup$
    – Lukas Lang
    Commented Nov 30, 2022 at 14:15
  • $\begingroup$ Thank you, Lukas, for prompt reply. I will investigate the idea and see if I can manage to get this concept working. $\endgroup$
    – RichD
    Commented Nov 30, 2022 at 14:37
  • 1
    $\begingroup$ You can embed Mathematica video into a PDF file using the animate package which has it's own animation controls. If you're interested how let me know and I'll post an example. $\endgroup$
    – josh
    Commented Nov 30, 2022 at 15:00
  • 1
    $\begingroup$ Dear Josh, I am very interested to see your example. Kind regards, R $\endgroup$
    – RichD
    Commented Dec 2, 2022 at 6:56
  • $\begingroup$ @Josh I would be very much interested! Tahnks $\endgroup$
    – aprendiz
    Commented Apr 5, 2023 at 16:32

1 Answer 1

1
$\begingroup$

Sorry, didn't see the first request for an example and just saw aprendiz request also. Here it is:

First create frames of the video in Mathematica and save as png type:

 SetDirectory[NotebookDirectory[]];
videoFrameData = Table[Plot[Sin[a + x], {x, 0, 10}], {a, 20}];
Export["d:\\NewFunctionFolder2\\pdfVideoTestFile.png", videoFrameData,
   "VideoFrames"];

Now create the latex code with the animate package shown below. I use TeXnic Center and included the lstlisting package to include a listing of the Mathematica code in the PDF file for reference. Now compile it into a PDF file and run it. It will show a frame of the video and a Manipulate-like GUI for running the animation.

    \documentclass[12pt,reqno]{amsart}
\usepackage{animate}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{xcolor}

\lstdefinestyle{myMathematica}{
frame=tb,
  language=Mathematica,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  basicstyle={\ttfamily},
  numbers=none,
  numberstyle=\tiny\color{gray},
  keywordstyle=\color{blue},
  commentstyle=\color{mauve},
  stringstyle=\color{dkgreen},
  breaklines=true,
  breakatwhitespace=true,
    morekeywords={AsymptoticSolve},
  tabsize=3
 }

\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}




\begin{document}

This is a test of imbeding Mathematica video into PDF file using animate package.  First create the video frames and save in directory of this TeXnicCenter latex file:

    \begin{center}
    \begin{minipage}{0.85\linewidth}
    \begin{lstlisting}[title={Mathematica Code},style=myMathematica,
    frame=single,
    label=code2]
    SetDirectory[NotebookDirectory[]];
    videoFrameData = Table[Plot[Sin[a + x], {x, 0, 10}], {a, 20}];
    Export["d:\\NewFunctionFolder2\\pdfVideoTestFile.png", videoFrameData, "VideoFrames"];
    
        \end{lstlisting}
        \end{minipage}
        \end{center}
    
    
    \begin{center}
    \animategraphics[controls,loop,width=3in]{3}{pdfVideoTestFile}{1}{20}
    \end{center}
    
    
    
    \end{document}
$\endgroup$
3
  • $\begingroup$ Your Mathematica code and LaTeX frame ranges differ (both file names and number of frames). This might confuse copy/paste users. $\endgroup$
    – Acus
    Commented Apr 5, 2023 at 18:13
  • $\begingroup$ @Acus: Ok thanks. I updated the code and also better defined both the video data and video data file names to make more clear. $\endgroup$
    – josh
    Commented Apr 5, 2023 at 18:41
  • $\begingroup$ Thank you very much $\endgroup$
    – RichD
    Commented Apr 7, 2023 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.