3

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}
\includegraphics[scale=0.7]{\visualizadordeperfil apontador.png}
&
Apontador
&
Seleciona track, finaliza algumas ações como: identificador de pontos editar marcadores, criar camadas, zoom vertical.
\\
\hline
\includegraphics[scale=0.7]{\visualizadordeperfil indentidicadordepontos.png}
&
Identificador de pontos
&
Selecione e passe sobre o perfil, e etiquetas com informações serão mostradas.
\\
\hline
\rowcolor{gray!35}
\includegraphics[scale=0.7]{\visualizadordeperfil localizador.png}
& 
Localizador
&
Apresenta o valor da escala do perfil e da profundidade no perfil da amostragem.
\\
\hline
\includegraphics[scale=0.7]{\visualizadordeperfil zoomvertical.png}
&
Zoom vertical
&
Aumenta verticalmente, selecione e clique no topo e na base de onde deseja aumentar o zoom.
\\
\hline
\rowcolor{gray!35}
\includegraphics[scale=0.7]{\visualizadordeperfil zoommenos.png}
&
Zoom -
&
Clique para diminuir ou retirar o zoom vertical.
\\
\hline
\includegraphics[scale=0.7]{\visualizadordeperfil visaoglobal.png}
&
Visão global
&
Volta ao tamanho normal de apresentação do dado.
\\
\hline
\rowcolor{gray!35}
\includegraphics[scale=0.7]{\visualizadordeperfil editordemarcadores.png}
&
Editor de marcadores
&
Cria pontos de informação no registro, ligado a uma profundidade.
\\
\hline
\includegraphics[scale=0.7]{\visualizadordeperfil editordecamadas.png}
&
Editor de camadas
&
Cria pontos ligados a topo de base de um intervalo.
\\
\hline
\rowcolor{gray!35}
\includegraphics[scale=0.7]{\visualizadordeperfil gerenciarcolunas.png}
&
Gerenciar colunas
&
Apresenta os perfis existentes e está ligado aos ícones inserir ou remover track e gerenciador de Perfis.
\\
\hline
\includegraphics[scale=0.7]{\visualizadordeperfil gerenciarperfis.png}
&
Gerenciar perfis
&
Através de uma caixa de diálogos ajuda a inserir ou remover perfis de uma mesma track.
\\
\hline
\rowcolor{gray!35}
\includegraphics[scale=0.7]{\visualizadordeperfil configurarperfis.png}
&
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
\includegraphics[scale=0.7]{\visualizadordeperfil inserirtrack.png}
&
Inserir track
&
Possui combo box  com diferentes tipos de tracks: perfis, litologia, ihc,  marcadores, imagens, bioestratigrafia e camadas.
\\
\hline
\rowcolor{gray!35}
\includegraphics[scale=0.7]{\visualizadordeperfil removertrack.png}
&
Remover Track
&
Remove a track selecionada.
\\
\hline
\includegraphics[scale=0.7]{\visualizadordeperfil moverparaesquerdaeparadireita.png}
&
Mover para a esquerda e para a direita
&
Move a track selecionada para esquerda e para a direita.
\\
\hline
\rowcolor{gray!35}
\includegraphics[scale=0.7]{\visualizadordeperfil setarposicaodepocos.png}
&
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
\includegraphics[scale=0.7]{\visualizadordeperfil desenhodascamadas.png}
&
Desenho das camadas
&
Para Desenha as camadas correlatas entre poços.
\\
\hline
\rowcolor{gray!35}
\includegraphics[scale=0.7]{\visualizadordeperfil definirdatum.png}
&
Definir datum
&
Para a múltipla visualização ajusta as profundidades dos poços para visualização de datum, selecionado pelo usuário.
\\
\hline
\includegraphics[scale=0.7]{\visualizadordeperfil dadomedido.png}
&
Dado medido
&
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}
\includegraphics[scale=0.7]{\visualizadordeperfil salvarimagem.png}
&
Salvar imagem
&
Salva uma cópia da imagem em diretório formatos  diferentes de arquivo, mas por default é .png.
\\
\hline
\includegraphics[scale=0.7]{\visualizadordeperfil salvartemplate.png}
&
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.}
\label{tab:tabeladeferramentasperfil}
\end{longtable} 

Here is an Image part of my longtable

Any sugestions on how to make it look better?

4
  • And if someone knows, how to put the image on the center, vertical and horizontal.
    – Guilherme
    Nov 20, 2014 at 11:35
  • I would use cm{3cm}m{8cm} (i. e. use m instead of p).
    – Bernard
    Nov 20, 2014 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, 2014 at 11:48
  • @Bernard Do you know how to align the images to the center verticaly too?
    – Guilherme
    Nov 20, 2014 at 11:48

3 Answers 3

2

enter image description here

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:

enter image description here

1
  • tks =]] that help a lot!
    – Guilherme
    Nov 20, 2014 at 12:31
1

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

Then include your images as

\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}
\usepackage[export]{adjustbox}

\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}
\fbox{\includegraphics[width=1cm,valign=t]{apontador.png}}
&
Apontador
&
Seleciona track, finaliza algumas ações como: identificador de pontos editar marcadores, criar 
camadas, zoom vertical.
\\
\hline
\fbox{\includegraphics[width=1cm,valign=t]{apontador.png}}
&
Identificador de pontos
&
Selecione e passe sobre o perfil, e etiquetas com informações serão mostradas.
\\
\hline
\end{longtable}

\end{document}

enter image description here

3
  • 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, 2014 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, 2014 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, 2014 at 12:53
0

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}

\newcommand\myincludegraphics[2][]{ \raisebox{-0.5\height}{\includegraphics[#1]{#2}}} \begin{document} \begin{longtable}{|Sc|m{3cm}|m{8cm}|} \endhead \endfirsthead \endfoot \multicolumn{3}{c}{}\ \caption{Tabela de ferramentas para Perfis.} \label{tab:tabeladeferramentasperfil} \endlastfoot

\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}
&
Apontador
&
Seleciona track, finaliza algumas ações como: identificador de pontos editar marcadores, criar camadas, zoom vertical.
\\
\hline
\myincludegraphics[scale=0.5]{sendak.png}
&
Identificador de pontos
&
Selecione e passe sobre o perfil, e etiquetas com informações serão mostradas.
\\
\hline
\rowcolor{gray!35}

\myincludegraphics[scale=0.5]{sendak.png} & Localizador & Apresenta o valor da escala do perfil e da profundidade no perfil da amostragem. \ \hline \myincludegraphics[scale=0.5]{sendak.png} & Zoom vertical & Aumenta verticalmente, selecione e clique no topo e na base de onde deseja aumentar o zoom. \ \hline \rowcolor{gray!35} \myincludegraphics[scale=0.5]{sendak.png} & Zoom - & Clique para diminuir ou retirar o zoom vertical. \ \hline \end{longtable} \end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .