2

I have the package \usepackage[inline]{asymptote} and I am trying to display the following Asymptote figure:

\begin{asy}
size(200);
pair A,B,C,D;
A=(0,0);
B=(200,0);
C=(200,150);
D=(0,150);
draw(A--B--C--D--cycle);
label("A",A,(-1,0));
label("D",B,(0,-1));
label("C",C,(1,0));
label("B",D,(0,1));
label("E",(200,85),(1,0));
dot((200,85));
draw((0,0)--(200,85));
draw((0,150)--(200,85));
label("$\ \ \ \ \ \ \ 30^\circ$",anglemark((200,85),D,C),SE);
label("$80^\circ \ \ \ $",anglemark(A,(200,85),D),W);
\end{asy}

I'm just getting a blank. No error messages but it's showing nothing. I'm using TeXShop on a Mac, if that helps any. Any help would be highly appreciated!

Update: Torbjørn T. was nice enough to help me figure out why nothing was showing. Now, I am getting a figure without the desired anglemarks, which is a bit annoying. My code is as is in the OP. Does anybody know what's going on with the angle marks?


For Torbjørn T.

Here is a screenshot of what I am getting:

Screenie

I have already following the steps that you told me about earlier.

11
  • Did you run asy on the generated file? Aug 19 '13 at 21:01
  • Sorry, what do you mean by "run asy"? My brain is not doing well today, sorry about that! Aug 19 '13 at 21:02
  • When you compile a document containing an asymptote figure such as that, it generates a separate file containing Asymptote code called e.g. filename-1.asy. You have to compile this with the Asymptote program, by issuing asy filename-1.asy in a terminal, which generates the figure, and then run pdflatex again, to place it in the document. Aug 19 '13 at 21:07
  • Ah, okay, I do see a .asy file in the same folder as the .tex file. Now, when I open it, it just shows the Asy code with a few extra stuffages. From here, what do you mean by "issuing asy filename-1.asy in the terminal? Aug 19 '13 at 21:15
  • Are you familiar with the command line? Aug 19 '13 at 21:19
5

Asymptote part

The first thing you need for that Asymptote code is a module called olympian, that can be downloaded here: http://www.artofproblemsolving.com/Forum/viewtopic.php?f=519&t=165767 This adds support for anglemark and more.

It is the file attached to the first post in that thread. Save it as olympian.asy in the same folder as your .tex file. To use the module, add import olympian; to the Asymptote code.

Next, you want to draw the arcs, so instead of having the anglemark within the labels, it seemed necessary to have it in a draw command, so

draw(anglemark(E,D,C));
draw(anglemark(D,E,A));
label("$\ \ \ \ \ \ \ 30^\circ$",D,SE);;
label("$80^\circ \ \ \ $",E,W);

E is the point (200,85).

The default size of the arc is quite small, it can be increased by adding

markscalefactor=3;

Adjust the value to your needs.

I don't know what is the best to label angles, but I've added a suggestion:

label("\small$30^\circ$",shift(35*dir(-7))*D);

This label is placed at D, but shifted 35 units in the direction -7 degrees. The \small command makes the font a little smaller. Perhaps not necessary, but it was a bit cramped in the top left corner.

Complete code:

\documentclass{standalone}
\usepackage[inline]{asymptote}
\begin{document}

\begin{asy}
import olympiad;
size(200);
pair A,B,C,D,E;
A=(0,0);
B=(200,0);
C=(200,150);
D=(0,150);
E=(200,85);
draw(A--B--C--D--cycle);
label("A",A,(-1,0));
label("D",B,(0,-1));
label("C",C,(1,0));
label("B",D,(0,1));
label("E",E,(1,0));
dot(E);
draw(A--E--D);
markscalefactor=3;
draw(anglemark(E,D,C));
draw(anglemark(D,E,A));
label("\small$30^\circ$",shift(35*dir(-7))*D);
label("\small$80^\circ$",shift(35*dir(180))*E);
\end{asy}
\end{document}

Compilation

When compiling the above with pdflatex, a file called <filename>-1.asy is generated. To generate the image, this has to be compiled with the Asymptote program, so run

asy <filename>-1.asy

from a command line/terminal. Compile your .tex file again with pdflatex and the image should be included in your document.

You could also open the .asy in TeXshop file and compile it with the Asymptote engine, mentioned by Alan Munn in a comment.

Finally, it should be possible to do this compilation automatically with latexmk, but I wasn't successful in my attempts (I probably did something wrong).

Output of above code

enter image description here

6
  • 3
    In TeXShop there is an Engine for asymptote so you don't need to do anything from the command line. You can simply put % !TEX TS-program = Asymptote in your .asy file and typeset the file. The Asymptote engine needs to be in the ~/Library/TeXShop/Engines folder (move it there from the Inactive folder if it's not active.) You will need to restart TeXShop for the change to show up in the Typeset menu.
    – Alan Munn
    Aug 19 '13 at 22:35
  • I can't thank you enough for your help, Torbjørn! I have put a well-deserved green check next to your response. But due to my ignorance, this is still not working. I downloaded the olympiad file on the AoPS site in the correct folder, then copied your code, and I get this error: Undefined Control Sequence. Aug 20 '13 at 0:38
  • @AhaanRungta That is a TeX-error. What more does it say, i.e. what is the undefined control sequence? Aug 20 '13 at 6:59
  • @TorbjørnT. Since I cannot post screenshots as comments, I have posted it as an answer. Aug 20 '13 at 15:07
  • @AhaanRungta I got that error one time last night, but I cannot remember what I did to fix it. Try deleting all the generated files (e.g. <filename>-1.asy, <filename>-1.tex, and any other files) and recompile. Aug 20 '13 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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