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 have the following document, with several minipages of 12cm width. Each minipage contains a different number of minipages (with a sum of 12cm for all of them). So every *sub*minipages should fit inside its main minipage, but the more minipages there are, the more they're oversized. I see no spaces between the minipages, so i don't understand why i have such a behaviour, especialy since the size is in cm and not in 0.X\linewidth.

Thank you for your lights on this.

Here is my code :

\documentclass[a4paper]{article}
\usepackage{xcolor}
\begin{document}

\fbox{\begin{minipage}[t]{12cm}
\hspace{-1mm}\colorbox{gray}{\begin{minipage}[t]{12cm}12\end{minipage}}%
\end{minipage}}

\fbox{\begin{minipage}[t]{12cm}
\hspace{-1mm}\colorbox{gray}{\begin{minipage}[t]{6cm}6\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{6cm}6\end{minipage}}%
\end{minipage}}

\fbox{\begin{minipage}[t]{12cm}
\hspace{-1mm}\colorbox{gray}{\begin{minipage}[t]{4cm}4\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{4cm}4\end{minipage}}%
\colorbox{gray}{\begin{minipage}[t]{4cm}4\end{minipage}}%
\end{minipage}}

\fbox{\begin{minipage}[t]{12cm}
\hspace{-1mm}\colorbox{gray}{\begin{minipage}[t]{3cm}3\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{3cm}3\end{minipage}}%
\colorbox{gray}{\begin{minipage}[t]{3cm}3\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{3cm}3\end{minipage}}%
\end{minipage}}

\fbox{\begin{minipage}[t]{12cm}
\hspace{-1mm}\colorbox{gray}{\begin{minipage}[t]{3cm}3\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{2cm}2\end{minipage}}%
\colorbox{gray}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{3cm}3\end{minipage}}%
\colorbox{gray}{\begin{minipage}[t]{2cm}2\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\end{minipage}}

\fbox{\begin{minipage}[t]{12cm}
\hspace{-1mm}\colorbox{gray}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{2cm}2\end{minipage}}%
\colorbox{gray}{\begin{minipage}[t]{3cm}3\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\colorbox{gray}{\begin{minipage}[t]{2cm}2\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{3cm}3\end{minipage}}%
\end{minipage}}

\fbox{\begin{minipage}[t]{12cm}
\hspace{-1mm}\colorbox{gray}{\begin{minipage}[t]{2cm}2\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{2cm}2\end{minipage}}%
\colorbox{gray}{\begin{minipage}[t]{2cm}2\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{2cm}2\end{minipage}}%
\colorbox{gray}{\begin{minipage}[t]{2cm}2\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{2cm}2\end{minipage}}%
\end{minipage}}

\fbox{\begin{minipage}[t]{12cm}%
\hspace{-1mm}\colorbox{gray}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\colorbox{gray}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\colorbox{gray}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\colorbox{gray}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\colorbox{gray}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\colorbox{gray}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\colorbox{cyan}{\begin{minipage}[t]{1cm}1\end{minipage}}%
\end{minipage}}
\end{document}

And here is the result : myscreenshot

share|improve this question

1 Answer 1

up vote 7 down vote accepted

\colorbox internally uses \fbox. Thus there two additonal \fboxsep for the left and right side.

share|improve this answer

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.