1

Is there a command \commandname, such that if you write

\begin{frame}
Latex code 1
\commandname{mylabel}
Latex code 2
\end{frame}
\begin{frame}
Latex code 3
\commandname{mylabel}
Latex code 4
\end{frame}

it forces that "Latex Code 2" and "Latex Code 4" start at the same vertical position, no matter how much vertical space "Latex Code 1-4" needs?

This would make some \only \uncover ... constructs way easier.

3
  • 1
    Beamer frames are vertically centered, but with option \begin{frame}[t] or \documentclass[t]{beamer} this frame resp. all frames are top aligned. Apr 10, 2021 at 20:30
  • Yes, but "Latex code 1" and "Latex code 3" maybe need different amounts of space Apr 10, 2021 at 20:33
  • Ok, what about a TikZ picture of fixed height, which holds all stuff and can show things one by one? Apr 10, 2021 at 20:40

2 Answers 2

1

Does it have to be a \command{}, or can it be an \begin{environment}? Allowing environments, you can just use columns passing the [T] optional parameter:

\documentclass[utf8]{beamer}
\usepackage{lipsum}


\begin{document}
\begin{frame}{Sample frame}
  \begin{columns}[T]
    % column 1
    \begin{column}{.24\textwidth}
      \lipsum[2-5]
    \end{column}
    % column 2
    \begin{column}{.24\textwidth}
      I'm vertically aligned!
    \end{column}
    % column 3
    \begin{column}{.24\textwidth}
      \lipsum[2-5]
    \end{column}
    % column 4
    \begin{column}{.24\textwidth}
      I'm vertically aligned!
    \end{column}
\end{columns}
\end{frame}

\end{document}

enter image description here

1
  • \begin{environment} is also fine, but I need multiple slides, not just multiple columns. Apr 10, 2021 at 21:19
1

With tabularray you can set the table row height.

You can write your pieces of text as table cell text.

\documentclass{beamer}
\usepackage{tabularray}

\begin{document}
    \begin{frame}
        \begin{tblr}{colspec={*2{X[h]}},rows={ht=.6\textheight}}
            \LaTeX\ code 1 could be longer and longer and longer \LaTeX\ code 1 could be longer and longer and longer
            &
            \LaTeX\ code 2
        \end{tblr}
    \end{frame}
    \begin{frame}
        \begin{tblr}{colspec={*2{X[h]}},rows={ht=.6\textheight}}
            \LaTeX\ code 3
            &   
            \LaTeX\ code 4 longer than \LaTeX\ code 3
        \end{tblr}
    \end{frame}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .