Latex: text should automatically fill the frame in Beamer slides
Asked Answered
S

2

5

In beamer frames I want the contents to be spread out evenly across the frame.

Using option \documentclass[slidestop]{beamer} I can easily specify the contents to be top/center aligned but when I have only few bullets on a slide they get clustered together at the top, I want beamer to decide the spacing between them automatically to spread them evenly.

Is this possible without putting vspace by trial and error?

Seriocomic answered 12/7, 2010 at 12:31 Comment(1)
Could you post a minimal example?Benelux
S
8

I think using \vfill would reduce the trial and error part. One \vfill between each bullet should guarantee even spacing. Try \vfill before and/or after bullets to get separation from preceding text or from bottom of page. I don't use or know Beamer, but I suspect there's a way to put the \vfill commands into the Beamer template.

\documentclass{article}
\begin{document}
\begin{itemize}
\vfill\item This is text of first item
\vfill\item This is text of second item
\vfill\item This is text of third item
\end{itemize}
\end{document}

Per your comment, here's one way you could define vfill to be automatically used in main list items but have no vfill in subitems. THis way lets you use same \item command regardless of whether you're in main list or in nested list, but requires you to define or redefine environments, and to be aware of when you're adding a main (i.e, vfilled) list and when you're adding a non-vfilled (i.e, nested) list:

\documentclass{article}

\newenvironment{novfillenum}{\begin{enumerate}\let\item\olditem}%
{\end{enumerate}}
\newenvironment{vfilleditems}{\begin{itemize} \let\olditem\item \renewcommand\item{\vfill\olditem}}%
{\end{itemize}}

\begin{document}
\begin{vfilleditems}
\item Item One 
   \begin{novfillenum}
        \item subitem1
        \item s2
        \item s3
    \end{novfillenum}
\item Item Two 
   \begin{novfillenum}
        \item subitem1
        \item s2
        \item s3
    \end{novfillenum}
\item item three
   \begin{novfillenum}
        \item subitem1
        \item s2
        \item s3
    \end{novfillenum}
\end{vfilleditems}

\end{document}
Selfdetermination answered 12/7, 2010 at 15:18 Comment(7)
No this doesn't help the purpose. I want the spacing to be automatically decided. What I want is to avoid using vfill. I want LaTeX/Beamer to detect the height of frame and spread the bullets evenly.Seriocomic
@thequark: Well, I would say it does help some, since the suggested fix is much better than using \vspace. In fact, using \vfill does det4ect the height of the frame and automatically adjusts space evenly to match. Instead of using \item just use \vfill\item for each of your items. That should get you 90% - 99% of where you want to go. You could define macro to make even simpler, but \vfill\item seems pretty simple to me.Selfdetermination
Thanks Herbert, I tried and it works for me. Now I have a lot of items in my presentations so instead of manually inserting \vfill everywhere can we redefine the itemize command? I tried following: \let\olditem\item \renewcommand\item{\olditem \vfill} it works fine but i require something else for it. I require the top level bullets to have vfill not the "sub-items". Is this possible through renewcommand?Seriocomic
I don't think there's any easy way to automatically have it figure out whether an item is a 'item' or a 'subitem' (i.e, no way to easily have '\item' behave differently merely depending on whether it's in nested environment, though I could be wrong). There has to be some distinction added by you. If \vfill\item is a little too verbose you could define new item command: 'newcommand\fillitem{\vfill\item}' or just '\newcommand\fitem{\vfill\item}'. Search and replace should make it trivial to switch items back and forth.Selfdetermination
@thequark: in post above I added a code sample showing a different way to do what you were asking with items and subitems.Selfdetermination
@Herbert: Thanks for the help, it works now. However I was wondering if there is a solution where user doesn't has to change the structure of document, instead of using new and different environments for itemize, can we renew itemize itself? I read about renewing labeli, labelii to get different bullets for different levels. Is such a thing possible for vfill? If such a solution is possible then user doesn't have to bother using different environment for items and subitems.Seriocomic
@thequark: yes the label changing also struck me as a possibility, but I was doubtful that vfill would work in a label. If vfill works in a label then changing the label should work for what you want. I'll give it a try. . .Selfdetermination
S
2

Adding another sample here because first answer getting too crowded. Tested altering the label commands and, what do you know, it seems to work, sort of. It gives errors, though, which I'm sure are related to having the \vfill as part of the label construct. I'm surprised it does seem to create the desired output, but the method would need some tweaking to get it to work without errors:

\begin{document}

\let\oldlabelitemi\labelitemi
\renewcommand{\labelitemi}{\vfill\oldlabelitemi{\hspace{1ex}}}

\begin{itemize}

\item Item One 
    \begin{itemize}
    \item subone
    \item subtwo
    \item subthree
    \end{itemize}
\item Item Two 
   \begin{itemize}
        \item subitem1
        \item s2
        \item s3
    \end{itemize}
\item item three
   \begin{itemize}
        \item subitem1
        \item s2
        \item s3
    \end{itemize}
\end{itemize}

\end{document}
Selfdetermination answered 17/7, 2010 at 15:38 Comment(12)
@Herbert Sitz: I am very impressed by your answers and all your effort to find a solution and help thequack. I am taking note of all you are saying :)Helper
@Herbert: I had tried such an approach earlier and when I try your example I get following error (same as what i used to get in my attempts): 9 error| Missing } inserted. } \item I tem OneSeriocomic
@quark: Yes, I don't think it's a good solution. I'm sure it's because putting \vfill in the label causes the problem; the label is supposed to be just a character(s), not page formatting info.Selfdetermination
@Vivi: Thanks, I'm trying to learn LaTeX and, like a lot of us on SO, some problems catch my fancy more than others. BTW, if you're an academic using Emacs, I would suggest that you use Org-mode. http:\\org-mode.org. It's a mind-blowing addition to Emacs with a lot of benefits for outlining, note-taking, footnotes, BibTeX, publishing to LaTeX or LaTeX/Beamer, integration with R, etc. It's a big Emacs subcommunity with many users who are academics like yourself, not people who use Emacs primarily for coding, so help is probably easier to get. If you haven't already, check it out.Selfdetermination
@Herbert Sitz : I know of it, and I did have that 5-10 min look, but as I haven't been using Emacs for long, it all just seemed too much. I invested quite a bit of time to start using Emacs, and I haven't done much "thesis" work in the last 3 months or so. I know org-mode will be worthwhile, but I just can't pay the fixed cost of learning it right now. It is on my list, though :)Helper
@Vivi: I understand your thinking, but still think org-mode would be most efficient next-step for you. Emacs is great for coders, for general writing use not so much. For someone wanting to do basic writing tasks I would say they should start Emacs using org-mode from very beginning. Org-mode could just as easily be called "Emacs for writing". Org may appear complex when you read about it, if you actually run it you find it simplifies things. For example, for stuff like publishing in LaTeX, Org automatically adds most LaTeX markup for you (plus markup doesn't clutter your doc).Selfdetermination
@Herbet: I just found out renewing labelitemi doesn't work with beamer document class. For customizing elements of the presentation one should use command: \setbeamertemplate{itemize subitem}{\textendash} now this just changes the label to dash (-) instead of the regular bullets, which I wanted to do. Lets check out the definition of \setbeamertemplate to find if there is something more possible.Seriocomic
@quark: A quick look around and at Beamer docs didn't reveal anything I saw as helpful. Other than the wrapper around label setting I think Beamer leaves formatting in list environment to regular LaTeX, but I'm not sure. You might want to ask at LaTeX Community FOrum: latex-community.org , but a search there didn't reveal much, either, other than that people use \vfill to alter Beamer spacing in less automated way than we've done here. I'm sure there is way to create new list env that would do what you want, but would require lower level hacking.Selfdetermination
@quark: One workaround to your problem could be to write simple script in your editor (or perhaps use a regexp extension) to distinguish between main and nested environments, then use your editor to make document wide changes. Seems to me like this gets you most of what you want. You might want to make this into new SO question, would depend on specific editor you use.Selfdetermination
@Herbert Sitz: Just to give you an idea, I am now resorting to pencil and paper, and avoiding Emacs/latex for a while. I spent way too much time on it already, I need to do a bit of work and then I can go back to it. When I do, org-mode will be the first thing on my list.Helper
@Vivi: Whoa, pencil and paper sounds pretty extreme. MS Word or OO Writer really aren't that bad when used correctly. Emacs/LaTeX (or LyX) is good, but as you've found you definitely want to avoid anything that turns into time waster.Selfdetermination
@Herbert Sitz: I refuse to use LyX, I really don't like it. LaTeX has to be LaTeX! The pencil and paper thing is just because I am not writing anything final now, I am just working out the equations, reading papers and making notes, etc. I had been doing that on Emacs, but that bit really need not be typed. When I decide to finally type my stuff, it will certainly be in LaTeX using Emacs.Helper

© 2022 - 2024 — McMap. All rights reserved.