How does the asymptote and asypictureB packages determine the output file and working directories? I tried to use asypictureB and TeXLive to produce my files and put all the output files to a different directory. For pdflatex, this can be done by the -output-directory=dir option, and the *.asy files are in the dir folder. but then asy.exe cannot find this file. I tried to let TeX know the working directory by following this post: Asymptote Files and tried all the options

\asysetup{dir= xxx}

none of them seemed to affect the working directory. I also tried to use TexStudio to change the asymptote command to be asy.exe dir/filename.asy, or include the -cd dir after asy.exe, but none of these work. asy.exe keeps searching for the files under the current directory.

Under mac, I found a workaround by revising the pdflatex command in TexStudio to include a series of bash commands:

sh -c "cp %.tex ~/asytmp/%.tex
& cd ~/asytmp/ && pdflatex -shell-escape -synctex=1 -interaction=nonstopmode 
&& cd - && cp ~/asytmp/%.pdf %.pdf
&& cd ~/asytmp && find . \! -name '1' -delete"

but when I followed the same way and tried under Windows by using cmd /C "... | ... | ..." it does not work because the cd dir command doesn't work under windows and everything seems to be still executed under the current directory.

any thoughts on how to get this to work? Is it possible to revise the ~/.asy/config.asy file? I don't even know if the asymptote and asypictureB packages use this config file.


I tried again and the /asydir command seems to interfere with how pdflatex proccesses the *.asy file and I got the error "cannot write on the file dir/*-noname-1.asy".

It turns out that the workaround in MacOS described above works in windows. just need to keep using "&" instead of "|" between the different codes.

cmd /C "@echo off && pushd .
&& copy %.tex C:\localtexmf\tmp\%.tex & cd C:\localtexmf\tmp
&& pdflatex.exe --shell-escape -synctex=1 -interaction=nonstopmode %.tex
&& asy.exe *.asy
&& pdflatex.exe --shell-escape -synctex=1 -interaction=nonstopmode %.tex
&& popd
&& copy C:\localtexmf\tmp\%.pdf %.pdf"
| txs:///view

NOTE: I formatted these codes to be multi-lines for readability, but it should be made sure that all the things are written in one line in TeXStudio.

| improve this answer | |

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.