2

I want to place two boxes side by side and one box below both of them such that the are aligned. I thought of using columns, but then the alignment does not match.

Here my minimal example:

\documentclass[t,aspectratio=169]{beamer}
\usetheme{boxes}
\usecolortheme{rose}

\begin{document}
\begin{frame}
  \frametitle{test}
  \begin{columns}
    \begin{column}{0.5\linewidth}
      \begin{block}{left}
        text
      \end{block}
    \end{column}
    \begin{column}{0.5\linewidth}
      \begin{block}{right}
        text
      \end{block}
    \end{column}
  \end{columns}
  \begin{block}{middle}
    text
  \end{block}
\end{frame}
\end{document}

with output:

enter image description here

But I would like to get something like this:

enter image description here

What is the best practice for this problem?

While I am writing this the algorithm of this website suggested me some similar posts and in one of these post there was the optional parameter onlytextwidth for the columns environment. But this leads to two touching Blocks. then I can reduce the size of the columns to e.g. 0.48\textwidth which surprisingly works. I expected that then the two blocks don't align on the right hand side.

the column documentation doesn't really tell me how it arranges the columns.

So even though I found kind of a solution I am wondering how the "best" solution looks like.

4
  • Try adding \vphantom{g} to the title of the left box
    – Willoughby
    Commented Jun 5, 2022 at 10:47
  • 1
    Your solution with onlytextwidth is good, what's the problem?
    – Ignasi
    Commented Jun 5, 2022 at 17:23
  • @Ignasi it is good but i thought that there might be a better solution. espacially because i have to guess a good distance with 0.48\textwidth. and when i don't use onlytextwidth there is automatically a little distance in between Commented Jun 6, 2022 at 9:41
  • 1
    I not sure to understand the problem. If you don't use onlytextwidth columns are distributed over a wider space. So if you want to keep the alignment with a one column box, you need to add this option. And about distribution, if I'm not wrong columns are aligned to the left and right exterms with the available space in between. You don't need to guess a good distance, but you have to use widths which sum is inferior to textwidth.
    – Ignasi
    Commented Jun 6, 2022 at 13:46

1 Answer 1

1

onlytextwidth is the best solution.

That being said, that's how beamer creates columns:

  • without the onlytextwidth option, beamer does not apply left/right margins to the columns and instead uses an \hfill:

    <left margin> normal text <right margin>
    < \hfill > | column 1 | < \hfill > | column 2 | < \hfill >
    

    this means that even if your columns sum up to the whole \textwidth, there will still be space in the middle, but the margins are wrong

  • with the onlytextwidth option:

    <left margin> normal text <right margin>
    <left margin> | column 1 | < \hfill > | column 2 | < right margin >
    

    this means if your columns sum up to the whole \textwidth, there is no room left in the middle which \hfill could fill

You must log in to answer this question.

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