3

I am just copied/pasted the solution posted for the following question.

how to get a newline in \fbox?

My problem is that box does not appear in the center of frame.

Below is the snap shot of my code along with its pdf version

enter image description here

NAASI
  • 2,809
  • Try an empty line after \centering –  Aug 07 '15 at 15:30
  • 2
    Try leaving a blank line between \end{varwidth}} and \end{frame}. – Gonzalo Medina Aug 07 '15 at 15:30
  • @ Christian....that didnt work. @ Gonzalo .... it worked. But can you please comment if it is a good practice to leave empty line after every command? – NAASI Aug 07 '15 at 15:33
  • 2
    @NAASI This indicates that your version of beamer is outdated. The problem is that \centering needs an end of paragraph to work properly; old versions of beamer had this problem and an explicit end of paragraph (a blank line) was required. This is not the case in newest versions. You should really update your LaTeX installation. – Gonzalo Medina Aug 07 '15 at 15:36

1 Answers1

4

The code in the linked solution works as expected. The problem in your case is that you are using an old version of beamer in which an explicit end of paragraph was needed before \end{frame} for commands such as \centering to have effect. Add an explicit end of paragraph (a blank line or \par) before \end{frame}:

\documentclass{beamer}
\usepackage{vietnam}
\usepackage{varwidth}

\begin{document}

\begin{frame}
\centering
\fbox{\begin{varwidth}{\textwidth}
\centering
One billion searches per second $\Rightarrow$ 36 yrs  \\ All this to recover only $10$ bits !
\end{varwidth}}

\end{frame}

\end{document}

I'd suggest you to update your LaTeX system.

Gonzalo Medina
  • 505,128