Discussion:
Vertical Space in Minipages
(too old to reply)
Pietro
2008-04-07 05:01:49 UTC
Permalink
Whats the deal with vertical spaces in minipages?

When I use stuff like \vspace{\stretch{1}} in a minipage, it seems to
be doing its calculations relative to the height of the whole page,
not just the minipage (even when I specify the height of the minipage
when I construct it). Also \flushbottom doesnt seem to work in
minipages.

Can anyone explain or send a url? I am trying to do things like define
minipages of fixed heights, vertically center stuff inside them, etc.
For example I had hoped that the following would give me a minipage
that is half the height of the page, which contains two minipages side
by side (each half the page wide) and an image below them.

% Half height of page, full width
begin{minipage}[t][0.49\textheight]{\textwidth}
% Full height of outer minipage, half width
\begin{minipage}[t][\textheight]{.49\textwidth}
content ...
\end{minipage}
% Full height of outer minipage, half width
\begin{minipage}[t][\textheight]{.49\textwidth}
\includegraphics[width=\textwidth]{foo}}
\end{minipage}

\includegraphics[width=\textwidth]{bar}}
\end{minipage}

What I would like is for the bar image to be at the bottom of the
outer minipage, for the 2 inner minipages to fill up the remaining
space above it, and for the foo image to be vertically centered in its
minipage. I cant figure it out tho ...

Thanks.
Ulrike Fischer
2008-04-07 07:16:47 UTC
Permalink
Post by Pietro
Whats the deal with vertical spaces in minipages?
When I use stuff like \vspace{\stretch{1}} in a minipage, it seems to
be doing its calculations relative to the height of the whole page,
not just the minipage (even when I specify the height of the minipage
when I construct it). Also \flushbottom doesnt seem to work in
minipages.
Can anyone explain or send a url? I am trying to do things like define
minipages of fixed heights, vertically center stuff inside them, etc.
For example I had hoped that the following would give me a minipage
that is half the height of the page, which contains two minipages side
by side (each half the page wide) and an image below them.
Make a complete running example that demonstrates your problem. Replace
graphics by \rule-commands. Your example doesn't show a
\vspace{\stretch{1}} or a \flushbottom.

Btw: \textheight is not changed inside a minipage:

\documentclass{article}

\begin{document}
\showthe\textheight\showthe\textwidth
\begin{minipage}[t][0.2\textheight]{.2\textwidth}
text\showthe\textheight\showthe\textwidth
\end{minipage}
\end{document}
--
Ulrike Fischer
Pietro
2008-04-07 10:13:56 UTC
Permalink
Post by Ulrike Fischer
Post by Pietro
Whats the deal with vertical spaces in minipages?
When I use stuff like \vspace{\stretch{1}} in a minipage, it seems to
be doing its calculations relative to the height of the whole page,
not just the minipage (even when I specify the height of the minipage
when I construct it). Also \flushbottom doesnt seem to work in
minipages.
Can anyone explain or send a url? I am trying to do things like define
minipages of fixed heights, vertically center stuff inside them, etc.
For example I had hoped that the following would give me a minipage
that is half the height of the page, which contains two minipages side
by side (each half the page wide) and an image below them.
Make a complete running example that demonstrates your problem. Replace
graphics by \rule-commands.Your example doesn't show a
\vspace{\stretch{1}} or a \flushbottom.
\documentclass{article}
\begin{document}
\showthe\textheight\showthe\textwidth
\begin{minipage}[t][0.2\textheight]{.2\textwidth}
text\showthe\textheight\showthe\textwidth
\end{minipage}
\end{document}
--
Ulrike Fischer
This is the problem, I dont know what de code should look like. I only
included that code to show that I was using nested minipages as I
thought that would probably be relevant.

Let me explain again what I want to achieve.

I want my page to be divided in half vertically, hence

\begin{minipage}[t][0.49\textheight]{\textwidth}
\end{minipage}

\begin{minipage}[t][0.49\textheight]{\textwidth}
\end{minipage}

In the top half I want to have an image of arbitrary height aligned to
the bottom of the minipage. So I thought something like

\begin{minipage}[t][0.49\textheight]{\textwidth}
\flushbottom
\includegraphics[width=\textwidth]{foo}
\end{minipage}

\begin{minipage}[t][0.49\textheight]{\textwidth}
\end{minipage}

The rest of the space in the top half I want to be divided in two
horizontally, hence

\begin{minipage}[t][0.49\textheight]{\textwidth}
\flushbottom

\begin{minipage}[t]{0.49\textwidth}
\end
\begin{minipage}[t]{0.49\textwidth}
\end

\includegraphics[width=\textwidth]{foo}
\end{minipage}

\begin{minipage}[t][0.49\textheight]{\textwidth}
\end{minipage}

These two new minipages should occupy all the vertical space in the
top half left over after displaying the image. This is something I
cant figure out.

Finally within one of these two new minipages I want to put an image
that is vertically centered, hence I thought

\begin{minipage}[t][0.49\textheight]{\textwidth}
\flushbottom

\begin{minipage}[t]{0.49\textwidth}
\vspace{\strecth{1}}
\includegraphics[width=\textwidth]{bar}
\vspace{\strecth{1}}
\end
\begin{minipage}[t]{0.49\textwidth}
\end

\includegraphics[width=\textwidth]{foo}
\end{minipage}

\begin{minipage}[t][0.49\textheight]{\textwidth}
\end{minipage}

but that doesnt work either.

Clear enough? Can this be done without hardcoding some heights?
Ulrike Fischer
2008-04-07 10:51:00 UTC
Permalink
Post by Pietro
This is the problem, I dont know what de code should look like. I only
included that code to show that I was using nested minipages as I
thought that would probably be relevant.
Let me explain again what I want to achieve.
No don't try long explanations. Make as I already said a complete
minimal examples. I don't want to have to assemble your code snippets.
Do as best as you can and mark the points where you have problems or
want to replace hardcoded values.
Post by Pietro
These two new minipages should occupy all the vertical space in the
top half left over after displaying the image. This is something I
cant figure out.
Get the height of the image and store it in a length register with
\settoheight and then substract it.
Post by Pietro
\begin{minipage}[t][0.49\textheight]{\textwidth}
\flushbottom
\begin{minipage}[t]{0.49\textwidth}
\vspace{\strecth{1}}
\vspace*
--
Ulrike Fischer
vvvv
2008-04-07 12:26:55 UTC
Permalink
If you have specific text that you want to go above the picture, and
if I assume that there is more than a few lines of text, then you
probably want to put the entire block (text plus picture) into one
float. LaTeX will then decide where to put the float. Perhaps you
could make it a full page float. If you want the image to go all the
way to the edge of the paper, then that is a different issue.


\documentclass{article}

\usepackage{graphicx}
\begin{document}
Your regular text goes here. If you want specific text to go above a
float, you should put it all in the same table, other wise the text
might move to another page when you edit the document.
\begin{table}[p]

\vfil% this will push your text down so that it is near the image
\vbox to.5\textheight{%
\vfil
\begin{minipage}[b]{\hsize}
you can put your regular text here. You might not even need a
minipage. blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah blah blah blah blah blah blah blah blah blah blah
blah blah blah blah
\end{minipage}
}%end vbox
\vskip2\baselineskip% optional spacing above the picture
\includegraphics[height=.45\textheight,width=\textwidth]{/Examples/
MyPicture.png}
\end{table}
\end{document}

Loading...