67

I would like to split a frame into 2 parts side by side by minipage. But it seems that the following code puts one on top of the other:

\begin{minipage}[t]{0.48\linewidth}
left part
\end{minipage}\hfill
\begin{minipage}[t]{0.48\linewidth}
right part
\end{minipage}

Could anyone tell me how to do that, and if it is correct to set 0.48\linewidth?

SoftTimur
  • 19,767
  • 7
    The fact that you say "frame" and have tagged this "beamer" makes me think that this is part of a presentation. Since many things are set up slightly differently for presentations than for ordinary articles, a minimum working example is really important here. Please add a full example including preamble. – Andrew Stacey Aug 29 '11 at 10:04
  • could you add more context to your question? Like for example you wrote beamer but you never reference it in the details, could you explain how your question relates to beamer please? – Charlie Parker Nov 07 '16 at 18:12
  • I found your question useful. The {.48\textwidth} determines the width of each column and you can modify it to make one column wider than the other. Probably you already that, but it seemed to me that that was your question, many years ago. – Clara Jul 10 '21 at 05:06

2 Answers2

103

A minipage or a parbox or a box in general need a \noindent to prevent the indention at the beginning of a paragraph.

\documentclass{article}
\begin{document}
\fboxsep=0pt
\noindent\fbox{%
\begin{minipage}[t]{0.48\linewidth}
left part
\end{minipage}}%
\hfill%
\fbox{%
\begin{minipage}[t]{0.48\linewidth}
right part
\end{minipage}
}

\end{document} 

I am sure that Raphink knows the answer but you don't provide a minimal example to show the problem.

I used the command \frame to demonstrate the left and right part.

enter image description here

EDIT: How Andrew Stacey commented here the solution with beamer. beamer provides additional features / environments like columns which is used in the minimal example. For more details have a look at the documentation.

\documentclass{beamer}
\begin{document}
\begin{frame}
\begin{columns}[T] % align columns
\begin{column}{.48\textwidth}
\color{red}\rule{\linewidth}{4pt}

Left Part
\end{column}%
\hfill%
\begin{column}{.48\textwidth}
\color{blue}\rule{\linewidth}{4pt}

Right Part
\end{column}%
\end{columns}
\end{frame}
\end{document}

enter image description here

ajmartin
  • 167
Marco Daniel
  • 95,681
14

You should add a \hfill between the two minipages.

Using 0.48\textwidth is indeed a correct way of splitting the page.

raphink
  • 31,894