3

In a tabular environment, I would like to align text vertically at the top of one cell while placing an Asymptote image in an adjacent cell. There are numerous posts on vertical alignment with images in a tabular environment with "normal" image placement using \includegraphics. See here for instance:

Vertical alignment of text and figures in a table

However, the two most commonly suggested techniques -- using \raisebox or \adjustbox -- don't seem to work with asymptote images. Here is a minimal example showing the effect I would like to get, and what actually happens when I use an asymptote image:

\documentclass{article}
\usepackage{mwe}
\usepackage{asymptote}

\begin{document}
\begin{tabular}{c c}
Text &
\raisebox{-.9\height}{\includegraphics[scale=0.25]{example-image}}

\\ Text &
\begin{asy}
import graph;
unitsize(1inch);
draw((0,0)--(1,0)--(1,1)--(0,1)--(0,0));
\end{asy}
\end{tabular}
\end{document}

Any idea how to get top-aligned text next to an asymptote image?

4

With adjustbox it's really easy:

\documentclass{article}
\usepackage{adjustbox}
\usepackage{asymptote}

\begin{document}
\begin{tabular}{c c}
Text &
  \adjustbox{valign=t}{\includegraphics[scale=0.25]{example-image}} \\
Text &
  \begin{adjustbox}{valign=t}
  \begin{asy}
  import graph;
  unitsize(1inch);
  draw((0,0)--(1,0)--(1,1)--(0,1)--(0,0));
  \end{asy}
  \end{adjustbox}
\end{tabular}
\end{document}

I used the “command form” in the first case, because it's handier. Around the asy environment it's better instead using the “environment form”.

enter image description here

  • 1
    Thanks! I was only aware of the \adjustbox command form, not the environment form. That makes all the difference! – Chad Feb 20 '14 at 18:03

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.