0

I started using rather large Beamer-based template. Everything is good except title vertical align - for default font size it looks ok:

enter image description here

But when I change the fontsize to, e.g. 9pt like this:

\documentclass[lualatex,hyperref={pdfencoding=auto},9pt]{beamer}

The gets shifted upwards

enter image description here

As far as I found out, the vertical alignment is set up with this code:

    \setbeamertemplate{frametitle}
    {   
        \nointerlineskip
        \begin{beamercolorbox}[sep=0.3cm,ht=1.8em,wd=\paperwidth]{frametitle}
            \vbox{}\vskip-2ex
            \strut\insertframetitle\strut
            \hfill
            \raisebox{-0.25\height}{\includegraphics[height=1.35em]{\proj@TightSignFileName}}
            \vskip-0.8ex%
        \end{beamercolorbox}
    }  

Is there any way, how to do the vertical alignment "dynamically", so that the whole title would be positioned in the middle, no matter the font size?

I've tried valign from adjustbox package as mentioned in How to vertically center text with an image in the same row of a table , but it doesn't seem to work really well in this case:

enter image description here

    \setbeamertemplate{frametitle}
    {   
        \nointerlineskip
        \begin{beamercolorbox}[sep=0.3cm,ht=1.8em,wd=\paperwidth]{frametitle}
            \vbox{}\vskip-2ex
            \strut\insertframetitle\strut
            \hfill
            \includegraphics[valign=m,height=1.35em]{\vsb@TightSignFileName}
            \vskip-0.8ex%
        \end{beamercolorbox}
    } 

Download link

Due to the large number of necessary files and images I uploaded complete MWE onto this link:

https://gofile.io/?c=2d0D8O

  • Please give a fully compilable code. – AndréC Feb 18 at 10:55
  • 1
    @AndréC The whole template is divided into several pretty long codes, but I'll try to choose the necessary ones and upload them here. – Eenoku Feb 18 at 10:59
  • 1
    @AndréC I uploaded minimalized version to the permanent link added into the question - I was not able to remove all the dependencies now and putting all the code here would be confusing, I believe. – Eenoku Feb 18 at 11:18
  • Note that we generally do not like following external links as they tend to rot over time and thus your example is unusable for others in the future. – daleif Feb 18 at 11:39
  • @daleif I'm aware of that - I'll try to improve this one over time. – Eenoku Feb 18 at 11:41
0

You could bracket your code in:

\vspace*{\fill}
  % Your stuff here
\vspace*{\fill}

This adds vertical space (\vspace) unconditionally (*), the space to be added is "as long as will fit" (\fill). Both \fill fight for space, each gets half. If you want uneven space top/bottom, use \stretch{n}:

\vspace*{\stretch{2}}
  % Your stuff here
\vspace*{\stretch{3}}

This will give 2/5 of the space above. Can use the same idea horizontally, BTW.

| improve this answer | |
  • It seems, that \vspace gets completely ignored. On the other hand, \vskip still has effect.. – Eenoku Feb 18 at 17:56

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.