27

This happens in the beamer class only. Does anyone know the reason behind this? I fix it by just setting both widths to 0.49\textwidth and this works but I'm still curious why this happens and if I maybe do something wrong.

MWE here:

% !TEX TS-program = pdflatex
% !TEX encoding = UTF-8 Unicode

\documentclass{beamer}
\usetheme{Warsaw}

\begin{document}
\begin{frame}

\begin{minipage}{0.50\textwidth}
asdfasdf
\end{minipage}
\begin{minipage}{0.50\textwidth}
asdfasdf
\end{minipage}

\end{frame}
\end{document}
lockstep
  • 250,273
Philipp
  • 5,078
  • 10
  • 30
  • 32
  • I wrote that already :) But I'm more interested in why this happens and if there is a mistake on my end (misusing the minipage environment e.g.). Also I copy pasted a sligthly altered version of the MWE at first where one width was .5 and the other .49. I'm wondering why .5+0.5 doesn't give me two minipages next to eachother. – Philipp May 02 '12 at 14:31
  • Ah, sorry for not understanding this point right away. As far as I can tell, you're not making a mistake. – Mico May 02 '12 at 14:33
  • 4
    Beamer provides a columns environment that allows to place things next to each other. It might be a cleaner solution for you (see beamer documentation for details). – yo' May 02 '12 at 14:51
  • Didn't know about columns but they indeed are a better solution. – Philipp May 03 '12 at 07:26

1 Answers1

40

There is a space between the two minipages so the total of the line is more than \textwidth. Add a % directly after the first \end{minipage}.

  • 1
    nice, thanks! What does the % do? I assume removing spaces but maybe you can give me an accurate answer? TeXshop also includes a % when inserting a table via menu. – Philipp May 02 '12 at 14:35
  • 2
    % is the standard TeX comment character. It gobbles up anything until the end of the line (including the line end which is normally turned into a space). If that is not known to you I suggest you read some intro document on LaTeX as then you are probably missing a lot useful information. Try lshort.pdf for example or any of its translation into some language. – Frank Mittelbach May 02 '12 at 14:39
  • by the way ... therefore never ever write something like "so 20% of xyz..." because then half of your sentence will be missing in the output. – Frank Mittelbach May 02 '12 at 14:42
  • I knew that % is used for commenting but I didn't know that you could use it for changing the layout as well, which it really does in this case. Thanks – Philipp May 02 '12 at 14:42
  • 1
    it doesn't change the layout, it drops the line end character as part of the commenting so you have one space less and that was the offending one in your example. – Frank Mittelbach May 02 '12 at 14:44
  • 4