0

A few years ago I use Asymptote in LaTeX to produce an interactive 3d graph (interactive in Acrobat Reader). Unfortunately, when I compile the same code today, it compile but it does not produce a .prc file. So, the 3d graph is visible in the .pdf file, but it is not interactive. I compile with PdfLaTeX - Asymptote - PdfLaTeX. My text editor is Texmaker et my LaTeX distribution is Miktex (both are up to date). I use Acrobat to open the .pdf file.

Does anybody could tell me why?

\documentclass{article}
\usepackage[inline]{asymptote}

\begin{document}

\begin{asy}
import graph3;
size(9cm, 7cm, IgnoreAspect);

currentprojection=perspective(4,2,2);

draw(Label("$y$",1),(0,0,0)--(0,3,0),black,Arrow3);
draw(Label("$x$",1),(0,0,0)--(3,0,0),black,Arrow3);
draw(Label("$z$",1),(0,0,0)--(0,0,3),black,Arrow3);

path3 P = (0,0,2)
--(3,0,2)
--(3,3,2)
--(0,3,2)
--cycle;

draw(surface(P), lightblue+opacity(0.8), light=nolight);
\end{asy}
\end{document}

1 Answer 1

1

You need to set prc and embed to true explicitly:

\documentclass{article}
\usepackage[inline]{asymptote}

\begin{document}

\begin{asy}
settings.prc=true;
settings.embed=true;
import graph3;
size(9cm, 7cm, IgnoreAspect);

currentprojection=perspective(4,2,2);

draw(Label("$y$",1),(0,0,0)--(0,3,0),black,Arrow3);
draw(Label("$x$",1),(0,0,0)--(3,0,0),black,Arrow3);
draw(Label("$z$",1),(0,0,0)--(0,0,3),black,Arrow3);

path3 P = (0,0,2)
--(3,0,2)
--(3,3,2)
--(0,3,2)
--cycle;

draw(surface(P), lightblue+opacity(0.8), light=nolight);
\end{asy}
\end{document}

Result after rotating a bit:

enter image description here

4
  • The quality of the screenshot is rather bad but I think that is caused by my 10 year old version of Adobe Reader (the last one that is available for Ubuntu).
    – Marijn
    Nov 30, 2022 at 17:33
  • I thought it was something like that. Thanks But now I get the "filename.-1.pdf not found" error. The filename-1.asy is created.
    – sipaq11
    Nov 30, 2022 at 17:57
  • I'm not sure what TeXmaker does exactly, I compiled on the command line using pdflatex filename.tex, then asy filename-1, then pdflatex filename.tex again. This doesn't generate errors, only a warning on the first run that filename-1.tex is not found (because that file is generated during the asy run).
    – Marijn
    Nov 30, 2022 at 18:04
  • I was using asy.exe that comes with MikTex. I installe asymptote and now it is working.
    – sipaq11
    Nov 30, 2022 at 18:55

You must log in to answer this question.

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