Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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...

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Replace the line

\usepackage{asymptote}

in your preamble with

\usepackage[inline]{asymptote}
share|improve this answer
add comment

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;

share|improve this answer
    
Can you add pointers to the changes you made to the OP's code? –  egreg May 25 '13 at 16:26
    
@egreg: comments added. –  g.kov May 25 '13 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 '13 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;. –  Charles Staats May 26 '13 at 12:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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