1

I'm trying to create a table with 5 columns and 2 rows. The first row should shows images and the second row shows the according text. In my main tex-file I have following code to import the table \input{chapter3/buttonTable}. My buttonTable.tex File has following code in it:

\begin{table}[b]
\begin{tabularx}{\textwidth}{ |X|X|X|X|X| }
    \hline
    \includegraphics{./images/buttons/Windows-Buttons.png}
    & 
    \includegraphics{./images/buttons/MacOSX-Buttons.png}
    & 
    \includegraphics{./images/buttons/Gnome-Buttons.png}
    & 
    \includegraphics{./images/buttons/iOS-Buttons.png}
    & 
    \includegraphics{./images/buttons/Android-Buttons.png}
    \\ \hline
    Windows 7 & Mac OS X & Gnome & iOS & Android \\
    \hline
\end{tabularx}
\end{table}

This is the output: http://i47.tinypic.com/1z5r8ys.jpg

Basically I have two questions:

  1. Why do the images get bigger and bigger and how can I avoid it?
  2. How can I center the text in the table?
  • 1
    you can avoid it by using the parameter width and height of includegraphics includegraphics[width=2cm,height=1cm,keepaspectratio]{...} – susis strolch Jan 4 '13 at 15:48
  • 1
    just a guess: the size of the images are different(!) and includegraphics is not changing them. – susis strolch Jan 4 '13 at 15:54
  • Thank you for your answer. Unfortunately your suggested solution does not work. I have added includegraphics[width=2cm,height=1cm,keepaspectratio] to every image but they still scale up. – Flying Rocket Jan 4 '13 at 15:55
  • The images are nearly the same size (between 75x50 and 99 x 71 pixels) – Flying Rocket Jan 4 '13 at 15:56
  • As susius said try the width argument, but I'd say don't use cm instead make it dependend from your tablewidth, so for example try: \includegraphics[width=0.15\textwidth]{<name>} or you could also try to scale the images. (e.g. [scale=0.5]) – rtzll Jan 4 '13 at 15:57
1

I set up a demo and was unable to recreate the problem. Start with this minimal example and expand it until your problem starts to show.

\documentclass{article}

\usepackage{graphicx}

\begin{document}

\begin{table}
\begin{tabular}{|c|c|c|c|c|}
    \hline
    \includegraphics[height=1cm]{./images/buttons/splash.png}
    & 
    \includegraphics[height=1cm]{./images/buttons/splash.png}
    & 
    \includegraphics[height=1cm]{./images/buttons/splash.png}
    & 
    \includegraphics[height=1cm]{./images/buttons/splash.png}
    & 
    \includegraphics[height=1cm]{./images/buttons/splash.png}
    \\ \hline
    Windows 7 & Mac OS X & Gnome & iOS & Android \\
    \hline
\end{tabular}
\caption{tablecaption}
\label{tablelabel}
\end{table}

\end{document}
| improve this answer | |
  • Thank you for your answer Johannes. The limiting of the height does work. Previous user also have suggested this workaround. PS: I am going to have multiple tables just like the one I posted. How can I make sure, that the columns are all having the same width? Furthermore I want the table to have the same width as \textwidth. PPS: Is an image scaled up if it is smaller than 1cm or is this the maximum height? – Flying Rocket Jan 4 '13 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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