# A compatibility problem between the fontspec package and asymptote

Has anyone run across a compatibility issue between the fontspec package and asymptote?

In the MWE below, commenting out the \usepackage{fontspec} allows for proper compilation and embedding of the 3D asymptote manipulative.

Without commenting out the fontspec package, I receive errors like

"Latex Error: ./untitled-1.tex:1 LaTeX Error: Can be used only in preamble.

Latex Error: ./untitled-1.tex:9 Undefined control sequence."


and while the manipulative is embedded in the output, there's the word everypage embedded as well.

\documentclass{article}
\usepackage{fontspec}
%\setmainfont[ItalicFont={Calibri Italic}]{Cambria}
\usepackage{asymptote}
\begin{document}
\section{Basic Definitions}
\begin{center}
\begin{asy}
import solids;
import three;
import graph3;
size(14cm,0);
currentlight=Viewport;
currentprojection=perspective(4,-4,3);
material Gray=material(heavygray+opacity(0.75),emissivepen=heavygray,ambientpen=heavygray);
material Blue=material(blue+opacity(0.75),emissivepen=blue);
surface y=shift((-.5,0,0))*unitplane;
draw(scale3(6)*y,Gray);
draw((0,3,2)--(2,3,0),linewidth(2));
surface r=shift((0,3,1))*unitsphere;
draw(surface(r),Blue,render(merge=true));
\end{asy}
\end{center}
\end{document}

• This appears to be a problem with XeLaTeX+asymptote; I get the same error without the fontspec package. – Will Robertson Aug 5 '14 at 2:20
• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – cfr Aug 5 '14 at 2:56
• Will, do you have any idea what the issue is between XeLaTeX and the asymptote package? Will it occur with LUaLaTeX? – Tim Aug 10 '14 at 6:25