Graphics, Figures & Tablesm{width} does not work?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Eenzc
Posts: 48
Joined: Thu Jun 26, 2008 2:38 pm

m{width} does not work?

Post by Eenzc »

Hello,

I've got a very simple table with two collumns.

One has a compound name in the next has a picture of it:

I would like the first collumn middle aligned and centered.

Code: Select all

\documentclass[a4paper,oneside,11pt,titlepage]{book}
\usepackage{array} % for m{} in tables
\usepackage[margin=10pt,font=small,labelfont=bf, justification=centering]{caption}
\begin{document}

\chapter{one}
\section{one}

\begin{table}
\centering
\begin{tabular}{|m{4cm}|c|}
\hline
Compound & Structure			\\
\hline
Name		& \includegraphics[width = 6cm]{Picture.png}	\\
\hline
\end{tabular}
\caption{.}
\label{Table:Two_Letter_Code}
\end{table}

\end{document}
This doesn't work.

The column on the left is bottle left aligned and not middle center as intended, its probably something to do with including the graphics.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

m{width} does not work?

Post by Stefan Kottwitz »

Hi,

try:

Code: Select all

\begin{tabular}{|>{\centering\arraybackslash}m{4cm}|c|}
...
Name      & \parbox{6cm}{\includegraphics[width = 6cm]{Picture.png}}   \\
...
The bottom line of the picture would be aligned, that's why I've put \parbox around, its baseline is in its center.

Stefan
LaTeX.org admin
Eenzc
Posts: 48
Joined: Thu Jun 26, 2008 2:38 pm

Re: m{width} does not work?

Post by Eenzc »

Thanks that works, I don't know how or why... but it works and thats the main thing.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

m{width} does not work?

Post by Stefan Kottwitz »

Well, the alignment just depends on where to align. Graphics by \includegraphics will be aligned at their bottom, just like a big letter or normal symbol. That's why we see the effect that the graphic is higher and the other aligned text is set lower. \parbox has an optional parameter that can be used to decide where to align:

t - alignment at the top of the box
b - alignment at the bottom of the box
c - alignment at the vertical center, default, also if this parameter is not used.

Actually \parbox takes up to 5 parameters, 3 of them optional.

Stefan
LaTeX.org admin
Post Reply