Automatically vertically center content in a Beamer slide

Hello,

Is there a way to automatically vertically center the content of each slide in a Beamer presentation ?

Have a nice day.

The only possibility I see is to create a table with the vertical size of the slide and then to center vertically its content.

1 Like

Thanks for your kind answer.:+1:

Excuse me if it’s trivial for you, but if I understand you correctly it’s not possible to do this automatically in a style package for example, but one has to do it manually for each slide.

Thanks.

I am not aware of a way to do that in a style file. It would be a nice feature.

Actually, it seems you could redefine the <shown> tag.

Sorry for the misinformation, this doesn’t work any more if you add a title.

What about defining a command to add automatically the table when one adds a new slide?

Latex has the \vfill{} command.
Is there something equivalent in TeXmacs ?

It could be useful to see how Joris deals with this problem. He has a lot of presentations on his webpage: http://www.texmacs.org/joris/main/talks.html maybe some tricks could be reusable. :slight_smile: I would be interested in finding a way to obtain the vertical centering.

Referring to the above question by @fbob, there is an analogous of \hfill command in TeXmacs (htab, did not check the details, it might work differently from \hfill in some of them). But I did not find an analogous of \vfill.

I’m not sure what could be a good solution to this problem. A fast solution is to use the following macro

<assign|center-box|<\macro|body>
  <\wide-tabular>
    <tformat|<twith|table-vmode|max>|<cwith|1|1|1|1|cell-height|>|<cwith|1|1|1|1|cell-vmode|auto>|<twith|table-min-rows|1>|<twith|table-min-cols|1>|<twith|table-max-rows|1>|<twith|table-max-cols|1>|<twith|table-height|1gpag>|<twith|table-valign|c>|<cwith|1|1|1|1|cell-valign|c>|<table|<row|<\cell>
      <arg|body>
    </cell>>>>
  </wide-tabular>
</macro>>

To work you have to be in “beamer mode” (in the “page rendering mode” of the document). It seem to work for me, with or without titles the height adapts to the available height in the page. I’m not sure what “1gpag” means however… One can use also “1pag” but this seems to be measures in units of the current page height. Note that “1par” is the current paragraph width.

This idea, refined (I used 0.8pag instead of calculating with page margins, and did not take into account the spacing of lines) and turned into a macro (so that the box height of the argument is used), could give the vertical centering.

<hspace|0pt>

test<vspace|<minus|0.4pag|<times|<look-up|<box-info|test|h>|0>|1tmpt>>><vspace*|<minus|0.4pag|<times|<look-up|<box-info|test|h>|0>|1tmpt>>>

<hspace|0pt>

Edit - thinking twice, do not see how to get the height of a multi-paragraph document. box-info maybe works only for content that fits in typesetting boxes (did not check it in the code).

Second edit: one can get information about multi-paragraph constructs as well

<box-info|<extern|(lambda () '(document "a" "b"))>|h>

I do not know how to write the same thing using only TeXmacs tags, and I also do not have clear in my mind whether this way could bring to a good solution.

@pireddag is not my macro working well enough? Or maybe I do not understand what was the original goal?

I should have written

:wink:

Your macro works nicely in the one test that I did!

Sorry I already have the feeling that my question is stupid but here we go …
Why on eart I’m unable to correctly copy and past your macro in the preamble of the edited document ?
I’ve got something like this see screenshot:

How to proceed to include macro in the preamble of the document for example.

Any way many thanks @mgubi and @pireddag for the helpful answers you’ve made.

After you have copied from the webpage, paste into the preamble with Paste from -> TeXmacs.
It should then appear highlighted as code.

@mgubi maybe we put this and other helpful small pieces of information in a pinned post :slight_smile:

2 Likes

Very useful it works like a charm now.
Many thanks !

1 Like

I’m not sure pinning this kind of informations would be useful. People arriving the first time do not even know what are you talking about and after that they will not pay any more attention, until they get hit by the problem.