0

Possible Duplicate:
How to align picture top left in a table?

I want to display an image and some lines of monospaced text with line breaks (as far as I know, lstlisting is the only option). The upper bounds of both image and text should both be aligned at the top of the row, but I always result in either the image or the monospace text at the wrong position. As I don't understand whats wrong I haven't got any clue how to fix this.

\documentclass[10pt]{article}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{verbatim}
\begin{document}
\lstset{
    breaklines     = true
}
\begin{tabular}{|p{3cm}|p{10cm}|}
\hline
\includegraphics{/Users/jenserat/Downloads/test.png} & \begin{lstlisting}
Some listing.
Some listing. Some lines can get quite long and should be wrapped.
Some listing.
Some listing.
Some listing.
Some listing.
Some listing.
Some listing.
\end{lstlisting} \\
\hline
\end{tabular}

\end{document}

I tried using different combinations of tabular, tabularx, graphics, graphicsx, minipages without luck. I want to avoid some ugly hacks using vspace as this latex code should be generated by some script which probably will get distributed.

I'd like to use a table, but am not bound to one. I do not mind using tabularx and do not mind what column style I use (as long as the code is left-aligned).

Wrong display with hint how it should look like

David Carlisle
  • 757,742
Jens Erat
  • 103
  • I'd be tempted to use minipages with the optional alignment argument, either t, b, or c – cmhughes Jan 26 '12 at 23:49
  • Succeeded with adjustbox as proposed by @MartinScharrer - thanks a lot! \begin{minipage}[t]{...}...\end{minipage} didn't work in this case. – Jens Erat Jan 27 '12 at 00:33
  • I will close as a duplicate, as suggested, especially because the solution of the answer to the linked question has solved this problem too, confirmed by the OP. – Stefan Kottwitz Jan 27 '12 at 07:42
  • @MartinScharrer: FYI your comment has been automatically deleted when closing, probably automatism because of the link to the dupe. – Stefan Kottwitz Jan 27 '12 at 07:43
  • @StefanKottwitz: Thanks. I will post two separate comments next time. – Martin Scharrer Jan 27 '12 at 08:20

0 Answers0