5

Consider the following MWE. Sorry, I cannot provide the simpler one.

% spiral.tex
\documentclass[preview]{standalone}
\usepackage[inline]{asymptote}

\begin{document}
\begin{asy}    
settings.tex="pdflatex";
settings.prc=false;
settings.render=0;

import graph3;
import math;
size(200);
size3(150,180,100);
defaultpen(fontsize(10pt));

currentprojection=orthographic(camera=(8,6,4),up=Z,target=O,zoom=1);

real x(real t) {return t*cos(2pi*t*3);}
real y(real t) {return t*sin(2pi*t*3);}
real z(real t) {return t;}

real xMax=3, yMax=3, zMax=4;

path3 p=graph(x,y,z,0,2.735,operator ..);
triple P=relpoint(p,0.986);
triple Q=(P.x,P.y,0);

pen spiPen=deepcyan+1.2bp;
draw(p,spiPen,Arrow3(size=3));
dot(P);
label("$P$",P,Z+X);

guide3 h=P--Q;
guide3 rho=O--1.2Q; 

draw(h,  dashed+0.7bp);
draw(rho,dashed+0.7bp);

real arcd=1.5;
guide3 garc=arc(O,arcpoint(O--X,arcd),arcpoint(rho,arcd));
draw(garc,gray,Arrow3(size=3));

label("$z$",h,E);
label("$\rho$",rho,SW);
label("$\phi$",garc,NE);

pen xyzPen=darkblue+1bp;
xaxis3(0,xMax,xyzPen,Arrow3(size=3));
zaxis3("",0,zMax,xyzPen,Arrow3(size=3));

label("$Z$",zMax*Z,SW);
shipout(bbox(Fill(lightyellow)));
\end{asy}
\end{document}

Compiling with Asymptote.bat spiral produces the following.

enter image description here

where my batch Asymptote.bat is defined as follows.

rem Asymptote.bat
echo off

rem %1 TeX input filename without extension

if exist "%~1.pdf" del "%~1.pdf"

if exist "%~1.tex" pdflatex "%~1.tex"

if exist "%~1-*.asy" asy -f pdf %~1-*.asy

if exist "%~1.tex" pdflatex "%~1.tex"

for %%x in (pdf tex asy pre) do (if exist "%~1-*.%%x" del "%~1-*.%%x")

for %%x in (aux log pre) do (if exist "%~1.%%x" del "%~1.%%x")

I noticed that the characters in PDF output are not searchable because of conversion. Can we make them still searchable?

Bonus question:

I CAN use asy -f pdf %~1-*.asy and why can't I use double quotes in asy command, i.e., asy -f pdf "%~1-*.asy"?

  • Have you tried asy -f pdf %~n1-*.asy? – g.kov Sep 14 '13 at 3:40
  • To get searchable text, 3d-labels have to be replaced with projected 2d-labels, like label("$Z$",project(zMax*Z),SW); instead of label("$Z$",zMax*Z,SW);. – g.kov Sep 14 '13 at 4:20
  • Yes, the "%~n1" means the file name w/o extension. You can use asy command with double quoted file names as asy -f pdf "%~n1-"*.asy. – g.kov Sep 14 '13 at 13:26
  • Exactly, while using "%~n1" there is no need to to remove extension manually, it can be invoked as batch.bat filename.tex. – g.kov Sep 14 '13 at 13:46
4

To get searchable text, 3d-labels have to be replaced with projected 2d-labels, like label("$Z$",project(zMax*Z),SW) instead of label("$Z$",zMax*Z,SW).

asy command with double quoted file names can be used as asy -f pdf "%~n1-"*.asy, here "%~n1" means the file name w/o extension, hence there is no need to to remove extension manually, it can be used as batch.bat filename.tex or batch.bat "filename.tex".

  • But filename with spaces is not possible. – kiss my armpit Sep 14 '13 at 14:27
  • batch.bat "file name.tex" – g.kov Sep 14 '13 at 14:30
  • I have to invoke batch.bat "file name" rather than batch.bat "file name.tex" because extension is deliberately not allowed in my batch for the sake of simplicity. – kiss my armpit Sep 14 '13 at 14:33

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.