Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Jan 24 '12 at 3:08

This question came from our site for professional and enthusiast programmers.

    
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 Jan 24 '12 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 Jan 24 '12 at 5:51
    
You should add keepaspectratio to your \includegraphics statements - otherwise the graphics will get distored. –  Martin Schröder Jan 24 '12 at 11:12

1 Answer 1

up vote 5 down vote accepted

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.

share|improve this answer
    
Ok. It solves problem with width. But height is still wrong. –  citxx Jan 22 '12 at 23:33
    
Using \[-1.2cm] before each new row helps. Not good but acceptable solution. Thank you. –  citxx Jan 22 '12 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 Jan 23 '12 at 6:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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