I have been using Asymptote to make pictures that can be included in Latex documents. I recently discovered that Org mode plays well with Asymptote


I was able to successfully compile a Latex document with embedded Asymptote code as follows.

#+TITLE: Test Document
#+AUTHOR: A. U. Thor
#+latex_class_options: [10pt]
#+LATEX_HEADER: \usepackage[margin=0.5in]{geometry}            
#+LATEX_HEADER: \usepackage{parskip} 
#+LATEX_HEADER: \usepackage{graphicx}                         
#+LATEX_HEADER: \usepackage{asymptote}
#+OPTIONS:      toc:nil 

#+BEGIN_SRC asymptote :file test.pdf
include graph;

This generates the document as in the screenshot below. enter image description here

How can I adjust the instructions in the header of the code-chunk above, to be able to manipulate the size and placement (left/right/center) of the image? Right now the image is just too big.

Note: If it helps, the generated \LaTeX source file, exported from the Org file looks like this

% Created 2019-04-13 Sat 15:26
% Intended LaTeX compiler: pdflatex
\author{A. U. Thor}
\title{Test Document}
 pdfauthor={A. U. Thor},
 pdftitle={Test Document},
 pdfcreator={Emacs 26.1 (Org mode 9.1.9)}, 


If you include this answer based on "#+ATTR_LATEX" between your #+END_SRC and #+RESULTS block, you should be able to resize the image through LaTeX export. Your code would look like this.

#+BEGIN_SRC asymptote :file test.pdf
<<Your Asymptote code here.>>

#+ATTR_LATEX: :width 0.2\textwidth
<<The image Asymptote generated here.>>

Note that the "0.2" factor happened to work well with the document I was just working on; you might have to adjust it for your own use.

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