9

I have this strange issue with 3d asymptote diagrams. Without labels they act as a normal figure, but when I add label, the diagram moves to the edge off the page...

MWE:

\documentclass[12pt,a4paper,addpoints]{exam}

\usepackage{asymptote}

\begin{document}
\begin{figure}
\begin{asy}
import solids;
import three;

size(5cm);

currentprojection=orthographic(0,-5,3);

triple start = (0,0,1);
real length = 5;
real radius = 1;
triple ax = (0,0,1);
revolution r = cylinder(start,radius,length,ax);
draw(r,black);

revolution downcone=cone(Z,1,-3);
draw (downcone,black);

draw((-1,0,7)--(1,0,7),Arrows3);

draw((1.5,0,1)--(1.5,0,6),Arrows3);

draw((1.5,0,1)--(1.5,0,-2),Arrows3);


\end{asy}
%label("2m",(0,0,7),N);
%label("5m",(1.5,0,3.5),E);
%label("3m",(1.5,0,-0.5),E)
\caption{Graansilo}
\end{figure}
\end{document}

When I add the commented label lines to the asy-environment, things start to go wrong... the diagram is no longer centered (or at least in the visible area of the page), but moves to the edge...
When trying with multiple diagrams on a page, they even appear on top of each other...
I tried altering the label-lines (adding $, numbers only, letters only), tried changing the perspective.

still no clue...

compiling .asy gives 'illegal token "\"', but that's all i have...

2 Answers 2

3

Replace the line

\usepackage{asymptote}

in your preamble with

\usepackage[inline]{asymptote}
5

enter image description here

Try this:

\documentclass[12pt,a4paper,addpoints]{exam}
\usepackage{asymptote}
\begin{document}
\begin{figure}
\centering
\begin{asy}
import settings;
settings.prc=false;
settings.render=0;
import solids;
import three;

size(5cm);

currentprojection=orthographic(0,-5,3);

triple start = (0,0,1);
real length = 5;
real radius = 1;
triple ax = (0,0,1);
revolution r = cylinder(start,radius,length,ax);
draw(r,black);

revolution downcone=cone(Z,1,-3);
draw (downcone,black);

draw((-1,0,7)--(1,0,7),Arrows3);
draw((1.5,0,1)--(1.5,0,6),Arrows3);
draw((1.5,0,1)--(1.5,0,-2),Arrows3);

label("2m",(0,0,7),N);
label("5m",(1.5,0,3.5),E);
label("3m",(1.5,0,-0.5),E);

\end{asy}

\caption{Graansilo}
\end{figure}
\end{document}

Edit Changes to the OP's code:

  • labels uncommented and moved inside the asy environment;
  • added a ; missed at the end of the third label statement, which most probably was the reason of troubles.

  • added settings to get a vector output (noprc+render=0) from 3D drawing:

import settings;

settings.prc=false;

settings.render=0;

4
  • Can you add pointers to the changes you made to the OP's code?
    – egreg
    May 25, 2013 at 16:26
  • @egreg: comments added.
    – g.kov
    May 25, 2013 at 17:04
  • I'm afraid this didn't solve my problem, but it made me (more) aware how subtle a typo influences the output... Found a few other mistakes (in other diagrams) by your help...
    – long tom
    May 26, 2013 at 7:49
  • Note that the line import settings; is redundant here. The purpose of this line is to allow you to write e.g. render=0; rather than settings.render=0;. May 26, 2013 at 12:52

You must log in to answer this question.

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