1

Something fundamental is missing from my understanding of scalebox. The following appears to me to conform to the instructions and examples I have found. Can someone please explain why it tosses up

Latex error: Something's wrong -- perhaps a missing \item

and how to make it right?

If you comment out the line containing 'scalebox' and the matching right brace, it compiles fine.

\documentclass{beamer}
\begin{document}
\begin{frame}

\scalebox{1.5}{
Happy\\
Birthday
}

\end{frame}
\end{document}

2

\scalebox is like \mbox and takes horizontal mode (LR mode) material. So you can not have \\

To get paragraph material you need \scalebox{2}{\parbox{5cm}{hello\\world}}

  • Horizontal mode! Ha! Thanks. Now I have some reading to do. – Robert Bruner Jul 26 at 18:00
1

It could be another wrong thing (or not) beside that you cannot break lines in horizontal mode (+1), let's say that is more related with best-practices: use \scalebox when you simply want a larger/smaller font.

In this example, almost exactly the same results is obtained with simply:

\parbox{3cm}{\LARGE Happy Birthday} 

With de advantage that this text will be consistent with any other \LARGE font in the document, whilst scaling here and there you could end with a lot of irregular font sizes (typical blunder when people try to fit a lot of tables tables using \scalebox or \resizebox).

Note also that with a reasonable width or the \parbox, there are not need of break the line with \\ to obtain the same result:

\documentclass{beamer}
\begin{document}
\begin{frame}
\scalebox{1.5}{\parbox{2cm}{Happy\\ Birthday}}
\parbox{3cm}{\LARGE Happy Birthday}
\end{frame}
\end{document}

enter image description here

  • My MWE left out several things I wanted to do, so it inadvertently left open alternative, easier solutions. Also consistency was irrelevant, as there is nothing else it needs to match. Pointing me toward understanding horizontal mode is exactly what I needed. Thanks. What did you mean by (+1) though? – Robert Bruner Jul 26 at 17:59
  • @RobertBruner Alternatives approaches are risky because sometimes help, specially when the questioner (or other people interested in that question) have really a XY problem and sometimes not. Hopefully , answer X( when really you want only Y) could help to others that search solutions for X. By (+1) I mean that I upvoted the David's answer pointing to the horizontal mode (that is, solving Y) in spite of make an alternative answer after suspecting a X. – Fran Jul 27 at 0:24
1

You don't need \scalebox; if you want to use it, then use varwidth in order not to have to guess the width.

\documentclass{beamer}
\usepackage{varwidth}

\begin{document}
\begin{frame}

\scalebox{1.5}{\begin{varwidth}{\textwidth}
  Happy\\
  Birthday
  \end{varwidth}%
}

{\LARGE
Happy\\
Birthday\\}

\end{frame}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.