# longtable Alignment

I'm using a long table with image and lots of text. The alignment of it is wrong for me. I'd like to know how to make the text start on top of the box, near the line. Here is my code for the longtable

\begin{longtable}{|c|p{3cm}|p{8cm}|}

\hline
\rowcolor{blue!35}
Ícone & Barra de ferramentas perfis & Ações
\\
\hline
\rowcolor{gray!35}
&
&
\\
\hline
&
&
Selecione e passe sobre o perfil, e etiquetas com informações serão mostradas.
\\
\hline
\rowcolor{gray!35}
&
&
Apresenta o valor da escala do perfil e da profundidade no perfil da amostragem.
\\
\hline
&
Zoom vertical
&
Aumenta verticalmente, selecione e clique no topo e na base de onde deseja aumentar o zoom.
\\
\hline
\rowcolor{gray!35}
&
Zoom -
&
Clique para diminuir ou retirar o zoom vertical.
\\
\hline
&
Visão global
&
Volta ao tamanho normal de apresentação do dado.
\\
\hline
\rowcolor{gray!35}
&
&
\\
\hline
&
&
Cria pontos ligados a topo de base de um intervalo.
\\
\hline
\rowcolor{gray!35}
&
Gerenciar colunas
&
Apresenta os perfis existentes e está ligado aos ícones inserir ou remover track e gerenciador de Perfis.
\\
\hline
&
Gerenciar perfis
&
Através de uma caixa de diálogos ajuda a inserir ou remover perfis de uma mesma track.
\\
\hline
\rowcolor{gray!35}
&
Configurar perfis
&
Apresenta uma caixa de diálogos onde poderá manusear as informações e estilos dos perfis. Editar nome, escala, unidades, grids, cores e preenchimento entre perfis.
\\
\hline
&
Inserir track
&
Possui combo box  com diferentes tipos de tracks: perfis, litologia, ihc,  marcadores, imagens, bioestratigrafia e camadas.
\\
\hline
\rowcolor{gray!35}
&
Remover Track
&
\\
\hline
&
Mover para a esquerda e para a direita
&
Move a track selecionada para esquerda e para a direita.
\\
\hline
\rowcolor{gray!35}
&
Setar posição dos poços
&
Para a múltipla visualização, ajusta os poços a uma distancia que pode ser editada pelo usuário.
\\
\hline
&
&
Para Desenha as camadas correlatas entre poços.
\\
\hline
\rowcolor{gray!35}
&
Definir datum
&
Para a múltipla visualização ajusta as profundidades dos poços para visualização de datum, selecionado pelo usuário.
\\
\hline
&
&
O dado medido é definido nas \textbf{propriedades} do poço na aba de \textbf{Datum Vertical} e podem ser alterados pelo usuário.
\\
\hline
\rowcolor{gray!35}
&
Salvar imagem
&
Salva uma cópia da imagem em diretório formatos  diferentes de arquivo, mas por default é .png.
\\
\hline
&
Salvar template
&
Se salva como \textbf{Template}, um formato de visualização padrão de perfis, gráficos etc., definido pelo usuário ou padrão da indústria.
\\
\hline

\caption{Tabela de ferramentas para Perfis.}
\end{longtable}


Here is an Image

Any sugestions on how to make it look better?

• And if someone knows, how to put the image on the center, vertical and horizontal. – Guilherme Nov 20 '14 at 11:35
• I would use cm{3cm}m{8cm} (i. e. use m instead of p). – Bernard Nov 20 '14 at 11:41
• The m{8cm} was amazing, but the c{3cm} give me this error ! Class memoir Error: Illegal pream-token (3cm): c' used. – Guilherme Nov 20 '14 at 11:48
• @Bernard Do you know how to align the images to the center verticaly too? – Guilherme Nov 20 '14 at 11:48

The tex model of table layout doesn't really allow for vertically centering within the space of a cell, each cell has a base reference point and these are aligned. l, c, r columns it is the baseline of the text p columns it is the baseline of the top row. and for m columns it is that cell's centre and b it is that cells bottom line. The baseline of an image is on its bottom edge. Note that m does not place the cell content in the centre of the space finally allocated to that cell, it simply puts the baseline of the content on that content's vertical centre.

So you get the layout in the first example.

You can change the reference point of the image to be roughly one line's worth below the top with

\raisebox{10pt-\height}{\includegraphics....


That will give a layout like the second image, but the first column it is not centred, if there is a lot of text in the third column, the image will still be aligned on its top row.

If you want centred appearance you need to center the third column. If that used m rather than p its reference point would be in its centre, then you can put the reference point of the image in the centre with

\raisebox{-.5\height}{\includegraphics....


and the alignment will be:

• tks =]] that help a lot! – Guilherme Nov 20 '14 at 12:31

Type \usepackage[export]{adjustbox} to your document preamble immediately above \usepackage{graphicx}.

\includegraphics[scale=0.7,valign=t]{\visualizadordeperfil apontador.png}


This will shift the picture vertically, so that its height is just like the height of a line of text.

Here's an example, I used \fbox around \includegraphics to show the precise bounding box.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[portuguese]{babel}
\usepackage[table]{xcolor}
\usepackage{longtable}

\setlength{\fboxsep}{-.5\fboxrule}% just for the example

\begin{document}

\begin{longtable}{|c|p{3cm}|p{8cm}|}

\hline
\rowcolor{blue!35}
Ícone & Barra de ferramentas perfis & Ações
\\
\hline
\rowcolor{gray!35}
&
&
Seleciona track, finaliza algumas ações como: identificador de pontos editar marcadores, criar
\\
\hline
&
&
Selecione e passe sobre o perfil, e etiquetas com informações serão mostradas.
\\
\hline
\end{longtable}

\end{document}


• This valign=t sometimes put the image in the middle and sometimes to low. almost at the end of the box. I'm trying to padronize it. do you have any idea how? like, every image on top, or on middle, or botton. I'm trying to see how it fit if the images stay on middle. – Guilherme Nov 20 '14 at 12:06
• I saw somewhere to use the T instead of T, it make all the figures on the botton. I kind of like it, but I would like to know if there is a way to put in the top. – Guilherme Nov 20 '14 at 12:16
• @Guilherme Doesn't happen to me and I confirm that valign=t is the option for doing what you seem to want. – egreg Nov 20 '14 at 12:53

You can centre the images with a simple \raisebox{-0.5\height}{…}. As the vertical spacing in tables is very tight, you can introduce some more with the cellspace package: it ensures a minimal spacing between a cell and the above and below cells in columns that have an S prespecifier.

Here is an example, using one of my favourite images. In order to have a shorter code, I define a \myincludegraphics command:

\documentclass[a4paper,12pt,]{article}

\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage[vmargin=2cm, hmargin=2.5cm]{geometry}
\usepackage{array, colortbl}
\usepackage{cellspace}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}


\hline
\rowcolor{blue!35}
Ícone & Barra de ferramentas perfis & Ações
\\
\hline
\rowcolor{gray!35}
%\raisebox{-0.5\height}{\includegraphics[scale=0.5]{sendak.png}}
\myincludegraphics[scale=0.5]{sendak.png}
&
&
`