2

I am trying to run Asymptote code embedded in a tex file. The pdf generated has no asymptote figure but other latex stuff appear. I get a warning that file "filename-1.pdf" not found. I am using Texmaker 5.0.4 with MikTex 2.9. I ran the command PdfLatex+Asymptote+PdfLatex.

Edit: Since a code snippet was asked, I ran this file that Akira Kakuto suggested as filename.tex and I am still getting an error,

\documentclass{article}
\usepackage{graphicx}
\usepackage{asymptote}
\begin{document}
\begin{figure}[h]
\centering
\begin{asy}
size(200);
pen[] p={red,green,blue,magenta};
path g=(0,0){dir(45)}..(1,0)..(1,1)..(0,1)..cycle;
tensorshade(g,p);
dot(g);
\end{asy}
\immediate\write18{asy \jobname*.asy}
\end{figure}
\end{document}
9
  • would you mind posting what did you try? It is difficult for people to help if they don't know what you tried.
    – bingung
    Commented May 10, 2020 at 11:38
  • @bingung I have now added a code snippet Commented May 11, 2020 at 12:56
  • Run pdflatex --shell-escape twice on the input. You may need to edit your editor preferences to add --shell-escape, or run the command in a terminal window.
    – AlexG
    Commented May 11, 2020 at 13:03
  • @AlexG I did run it that way but it seems to be still giving the same error. The editor preference now looks like this-imgur.com/a/68dCKuj Commented May 11, 2020 at 13:40
  • Editors sometimes break things. Did you try running pdflatex in a terminal (command line window)? (Works for me.)
    – AlexG
    Commented May 11, 2020 at 14:08

2 Answers 2

1

I had this exact problem. For me, the problem was TeXShop not integrating with Asymptote properly. I was able to follow the instructions from Integrating Asymptote and TeXShop for Mac OS X and now it works perfectly.

2
  • But the question is about a different editor on what is almost certainly a different OS ....
    – cfr
    Commented May 20 at 5:20
  • @cfr It still may be worth trying. It's probably something similar that their editor isn't running Asymptote to generate the images. Commented May 20 at 11:39
-1

I'll show an example by using a sample in the version 2.65:

% filename.tex
% Compile twice as:
% pdflatex -shell-escape filename.tex
% pdflatex -shell-escape filename.tex
%
\documentclass{article}
\usepackage{graphicx}
\usepackage{asymptote}
\begin{document}
\begin{figure}[h]
\centering
\begin{asy}
size(200);
pen[] p={red,green,blue,magenta};
path g=(0,0){dir(45)}..(1,0)..(1,1)..(0,1)..cycle;
tensorshade(g,p);
dot(g);
\end{asy}
\immediate\write18{asy \jobname*.asy}
\end{figure}
\end{document}
6
  • Thank you for your reply. It seems I am still getting the same error. Just to clarify in the "For .asy files" section in Texmaker in "Quick build" it reads as "C:/Program Files/MiKTeX 2.9/miktex/bin/x64/asy.exe" -f pdf -noView %.asy|"C:/Program Files/Adobe/Reader 11.0/Reader/AcroRd32.exe" %.pdf. Is this correct? Commented Apr 14, 2020 at 7:49
  • Sorry, I don't use TeXmaker, and I don't know it. I only showed how to compile in command prompt. Commented Apr 16, 2020 at 22:18
  • @cookiemonster The setting in 'Quick Build' ---> 'For .asy files' is not relevant if you run a file with .tex extension; it is only relevant when you run files with .asy extension. When you run filename.tex, is a file called filename-1.asy produced? (using pdflatex only)
    – bingung
    Commented May 11, 2020 at 13:19
  • @bingung Yes, using pdflatex, filename-1.asy is being produced. Commented May 11, 2020 at 13:37
  • @cookiemonster when you open filename-1.asy, is the line defaultfilename="filename-1"; there? if you just compile filename-1.asy with Asymptote, is the pdf file produced?
    – bingung
    Commented May 11, 2020 at 14:05

You must log in to answer this question.

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