Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a problem with a table. Since I am a day zero newbie in latex, please bare with me.

This is what I did:

\begin{table}[h]
\begin{tabular}{|l|p{0.5\textwidth}|}
\hline
\includegraphics[width=0.48\textwidth]{Constraints/FacesX.png}
& 
dsadasd
\\
\hline
\end{tabular}
\end{table}

I added the \hline and | so I can see what is happening, but I do not need them.

This is what I get:

result

dsadasd is at the bottom of the cell instead of at the top. What am I doing wrong?

share|improve this question
    
My gut reaction is "why are you using a table", but it might be justified. –  You Jun 18 '12 at 15:27
add comment

2 Answers

up vote 2 down vote accepted

The reason is, that the picture is is not aligned at the top. So you may use the following approach to create a point, where the stuff can be aligned:

\documentclass{article}
\usepackage{graphicx}

\newcommand{\BildTop}[1]{\vtop{\null\hbox{#1}}}

\begin{document}
\begin{tabular}{lp{0.5\textwidth}}
 \BildTop{\includegraphics[width=0.48\textwidth]{TestPdf}} & dsadasd 
\end{tabular}
\end{document}

The macro \BildTop creates a vertical box (\vbox) with nothing in it (\null) in the first line and the other material e.g. your picture in the second line (\hbox{#1})

enter image description here

share|improve this answer
    
Thanks! That solved my problem. –  BCartolo Jun 18 '12 at 15:54
    
a p column is already a vtop internally so actually you just need a \null (or \vspace{0pt} before the \includegrapics. –  David Carlisle Jun 18 '12 at 15:59
add comment

Use the package adjustbox, which adds many facilities for managing boxes and images:

\documentclass{article}
\usepackage[export]{adjustbox}
\begin{document}
\begin{tabular}{|l|p{0.5\textwidth}|}
\hline
\includegraphics[valign=t,width=0.48\textwidth]{example-image-a}
&
dsadasd
\\
\hline
\end{tabular}

\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.