3

I frequently put a graphic into a raisebox, like:

\raisebox{1cm}{\includegraphics{myfigure}}

Is it possible to do this with something like

\begin{asy}
size(1cm);
draw((0,0)--(1,1)); 
\end{asy} 

environment in place of \includegraphics{myfigure}? If you directly substitute you get an error, which I think is because you can't have asy environments as arguments of TeX commands. I don't want to use includegraphics because I want to take advantage of asymptote's 3D PRC graphics.

  • 1
    Since asymptote is running as an external program, it is at best fragile. What can you fit it into? Can you get it into a minipage or a savebox? (MikTeX user here. No asymptote.) – John Kormylo Jun 6 '17 at 16:29
  • 1
    Can you provide a complete minimum example of what you tried? – Steven B. Segletes Jun 6 '17 at 16:41
3

Define a box bin:

\documentclass{article}
\usepackage{asymptote}

\newsavebox{\myasybox}

\begin{document}

Normal
\begin{asy}
size(1cm);
draw((0,0)--(1,1));
\end{asy}
Normal

Raised
\begin{lrbox}{\myasybox}
\begin{asy}
size(1cm);
draw((0,0)--(1,1));
\end{asy}
\end{lrbox}\raisebox{-.5\height}{\usebox{\myasybox}}
Raised

\end{document}

enter image description here

2

You are correct that you can't have asy environments as arguments of TeX commands. But there are a couple other options:

  1. Usually you can add an invisible line or point in the asy drawing to get you extra whitespace on the bottom. Unfortunately this concept does not apply very well to interactive prc graphics, because the invisible point/line would rotate with the rest of the graphic.
  2. You can actually put an asy environment inside a tikz node. (TikZ "works some magic" so that \node commands behave like environments.) So, something like this (not tested):

    \begin{tikzpicture}
    \draw [white] (0,0) (0,1) node [above right] {%
    \begin{asy}
    size(1cm);
    draw((0,0)--(1,1)); 
    \end{asy}
    };
    \end{tikzpicture}
    
  • Thanks--the TikZ trick is very cool. I will keep that in mind. – user2366158 Jun 6 '17 at 21:00

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.