3

I want to make a table from images of specific size (2cm) in PDF format. But in case of using article document class I got larger images. I tried to use minimal class and got right sizes, but invisible table borders.

There is my code:

\documentclass[a4paper]{minimal}

\usepackage[a4paper]{geometry}
\usepackage{graphicx}

\newcommand{\ABTile}{\includegraphics[height=2cm, width=2cm]{./AB.png}}
\newcommand{\AvTile}{\includegraphics[height=2cm, width=2cm]{./Av.png}}

\begin{document}
    \begin{tabular}{|p{\tileSize}|p{\tileSize}|}
        \hline
        \ABTile    & \ABTile \\
        \AvTile    & \AvTile \\
        \hline
    \end{tabular}
\end{document}

Result with article class (pdf)

Result with minimal class (pdf)

Is there any way to make table with right size?

3
  • Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question.
    – Werner
    Commented Jan 24, 2012 at 5:44
  • It may be that your images have additional whitespace at the top/bottom, causing you to use something like \\[-1.2cm].
    – Werner
    Commented Jan 24, 2012 at 5:51
  • You should add keepaspectratio to your \includegraphics statements - otherwise the graphics will get distored. Commented Jan 24, 2012 at 11:12

1 Answer 1

5

There is a special column descriptor (@{}) which can be used in the tabular definition. It replaces the spacing with whatever you put inside the curly braces (so leave blank to have no space). Try replacing

\begin{tabular}{|p{\tileSize}|p{\tileSize}|}

with

\begin{tabular}{|@{}c@{}|@{}c@{}|}

That is, wrap the c or p with @{} on either side to make 0 space on both sides.

3
  • Ok. It solves problem with width. But height is still wrong.
    – citxx
    Commented Jan 22, 2012 at 23:33
  • Using \[-1.2cm] before each new row helps. Not good but acceptable solution. Thank you.
    – citxx
    Commented Jan 22, 2012 at 23:46
  • 2
    @citxx Try putting \renewcommand{\arraystretch}{0.5} before the tabular environment. You can change the number (0.5) to fine tune the spacing. It's a bit more elegant (and simple) of a solution I think...
    – Magnesium
    Commented Jan 23, 2012 at 6:45

You must log in to answer this question.

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