1

I want to have an empty page such that the body is centered. Next I want to have two minipage's each half the width of the body and of its height, such that they will vertically split the body. Here is an illustration of what I want:

|-------------------|
| P                 |
| |---------------| |
| |  B1   | B2    | |
| |---------------| |
|                   |
|-------------------|

where P denotes the page and B1 and B2 are the two boxes whose union is exactly the body.

Here is how far I got:

\documentclass{article}
\usepackage[%
showframe,paper=a4paper,noheadfoot,nomarginpar,vmargin=4cm,hmargin=2cm
]%
{geometry}
\begin{document}
\pagestyle{empty}
\vbox{
  \noindent
  \fbox{
    \begin{minipage}[c][\textheight][c]{0.5\textwidth}
      Block 1
    \end{minipage}
  }
  \fbox{
    \begin{minipage}[c][\textheight][c]{0.5\textwidth}
      Block 2
    \end{minipage}
  }
}
\end{document}

However, this is not perfect... It seems like \textwidth is too big, and therefore, the total width of the minipages is too big. Furthermore, the total height (\textheight) seems to be too big as well.

How can I fix the code?

2
\fbox{
    \begin{minipage}[c][.5\textheight][c]{0.5\textwidth}
      Block 1
    \end{minipage}
  }

You have a word-space either side of the minipage inside the box and \fbox adds \fboxsep padding and a rule of \fboxrule wide to either side.

You have two such boxes with another word space in between.

So you need % at the end of lines and use

\begin{minipage}[c][\textheight][c]{\dimexpr 0.5\textwidth-2\fboxrule-2\fboxsep\relax}

Note that assumes no space between the minipages, so the two fbox rules will touch If you want to add space between them you need to reduce the width of each box by half that space

| improve this answer | |
  • Where should I put the \dimexpr? – Dror Apr 25 '14 at 13:58
  • Thanks! How can I accurately solve the vertical/height issue? The boxes are still too high. – Dror Apr 25 '14 at 14:02
  • @Dror \vspace*{\fill} at the top and bottom of the page is usual way to vertically centre, is that what you mean? Also I reduced the vertical extent to .5\textheight as for the same reason you can't put an fbox around something that is already textheight heigh. – David Carlisle Apr 25 '14 at 14:03
  • I want the minipages to be of the same height as the body. I thought \textheight will do the trick, but it is too big. – Dror Apr 25 '14 at 14:06
  • If I disable the \fboxs, can I be sure that the minipages will be filling the body as I expect? I added the \fboxs to verify this and then things became uglier... – Dror Apr 25 '14 at 14:19

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.