1

I want to have parts of my beamer slide to be aligned to the top of the slide. The rest should still align automatically to the middle.

MWE:

\documentclass{beamer}

\usepackage{tcolorbox}

\begin{document}

\begin{frame}{Title}
\begin{tcolorbox}
align to top
\end{tcolorbox}

align to middle
\end{frame}

\end{document}

Like in Different alignment for frame content in beamer solution. (If this is a good/right solution). But is it able, to define tcolorbox or a new environment such that the [t] option is added to the frame and the \vfill after the environment (which seems to be the easy part)

  • thew simplest way is add to frames, which contain tcolorbox option [t] and then consider answer for which you provide link. this answer can be improved on the way, as i show (now erased) answer (which you not liked) ... – Zarko Nov 6 '17 at 1:45
  • This is exactly the solution from the link. I was wondering if it's possible to define a new environment which contains something like \addtoframe{option}{t} and of course \vfill in the closing part – Ben Nov 6 '17 at 1:49
  • maybe, but i don't know if it possible test frame content, if it contain tcolorbox and than change it from \begin{frame}\frametitle{...} ... to \begin{frame}[t]\frametitle{...} .... this is not trivial task and i'm curious, if some of "beamer" wizard provide a solution. – Zarko Nov 6 '17 at 1:55
  • (I believe) One doesn't need to test frame content. The \begin{mytopcolorbox}... maybe can set a frame option. – Ben Nov 6 '17 at 2:06
  • 1
    option [t] at start of frame ... and see, that it is needed when latex find tcolorbox is already to late or you fall in loop giving error "sorry capacity is ...". anyway, wait on experts for beamer what they will say :-) – Zarko Nov 6 '17 at 2:16
1

You could make the tcolorbox ride piggy back of the frametitle:

\documentclass{beamer}

\usepackage{tcolorbox}

\begin{document}

{
\addtobeamertemplate{frametitle}{}{%
    \begin{tcolorbox}
    align to top
    \end{tcolorbox}
}
\begin{frame}{Title}
align to middle
\end{frame}
}

{
\addtobeamertemplate{frametitle}{}{%
    \begin{tcolorbox}
    align to top
    \end{tcolorbox}
}
\begin{frame}{\mbox{}}
align to middle
\end{frame}
}

\end{document}

Drawback: you'll have to have something non-empty in your frametitle. Worst case, you can use something invisible if the frame should not have a title.

| improve this answer | |
  • I don't think that this saves any writing than the solution here – Ben Nov 6 '17 at 15:37
1

edit:

reading samcarter answer gives me the following idea:

\documentclass{beamer}
\usepackage{tcolorbox}

\newcommand\mytcolorbox[1]{%
    \framesubtitle{\medskip%
        \centerline{\begin{tcolorbox}[width=\textwidth]
                    #1
                    \end{tcolorbox}}}
                        }

\begin{document}
\begin{frame}{Title}
\mytcolorbox{align to top}
align to middle
\end{frame}

\begin{frame}{Title}
align to middle
\end{frame}

\end{document}

pros: simple in working :-)

cons: yin the same time you can't use \framesubtitle, it will be overwritten by \mytcolorbox

enter image description here

| improve this answer | |
  • The global alignment should still be middle. Only if there is a tcolorbox, it and only it, should be aligned to the top (Actually your code doesn't produce this output ;) ) – Ben Nov 6 '17 at 1:24
  • well, than you should wait on better answer (i will erase mine soon) ... the simplest solution is write option [t] when necessary, but you are not wiling to do this ... :-( – Zarko Nov 6 '17 at 1:31
  • good idea!!!!!! – samcarter_is_at_topanswers.xyz Nov 6 '17 at 11:27
1

The following new command, \totop, should add its content to the top of the frame without interfering with the global frame centering. The only drawback is choosing the right value by which you raisebox that content, I chose .35\textheight in the example.

\documentclass{beamer}
\usepackage{lmodern,tcolorbox}

\newcommand{\totop}[1]{\vbox to 0pt{\raisebox{.35\textheight}[\height][0pt]{#1}}\vspace{-\baselineskip}}

\begin{document}    
\begin{frame}{Title}

\totop{%
\begin{tcolorbox}
    align to top
\end{tcolorbox}
}

align to middle

\end{frame}    
\end{document}

enter image description here

| improve this answer | |

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.