5

In the following example, is there a way to force the word "environment" to join the previous paragraph, allowing it to bleed into the page margin if necessary?

In other words, I am looking for something like \mbox{} but that will work at the end of a multiple-line paragraph. (If you put the paragraph below in an \mbox{}, the whole paragraph is forced onto one line, rather than just the last line; if you put just the phrase "nontraditional environment" in an \mbox{}, then both words move to the following line.)

enter image description here

%!TEX encoding = UTF-8 Unicode 
\documentclass[11pt, slidestop, compress]{beamer}
\usetheme{CambridgeUS}

\begin{document}

\begin{frame}{Frame}
Spectrum Community School was an alternative high school in Kingston, Washington, United States. It was a part of the North Kitsap School District. The school had been running for over 20 years, and earned two awards of Special Merit from the Grammy Foundation in Los Angeles. The school was designed for students searching for a nontraditional environment.
\end{frame}

\end{document}

I realize that in the contrived example above, there isn't really room for the word "environment" on the line in question, but in my real slideshow, the orphaned word is much shorter and there is room for it. My question is technical (not aesthetic) in nature and I take full responsibility for any ugly typesetting that I produce.

I am not looking for a solution that involves decreasing the letter spacing, text width, and/or font size, whether locally or for the whole presentation. I want just this word to dangle off to the right while maintaining the same text flow in the rest of the paragraph.

\looseness=-1 as suggested here does not work because it alters the letter spacing, and also re-enables hyphenated line breaks which are (rightly, IMO) disabled by default in Beamer.

5
  • 2
    Try \rlap{environment.}. That will make LaTeX think it has no width. May 6, 2022 at 0:50
  • Thank you, that seems to work.
    – Max
    May 6, 2022 at 0:54
  • 8
    The question title sounds strangely cruel… May 6, 2022 at 5:41
  • 2
    @PeterLeFanuLumsdaine 10/10 :D May 6, 2022 at 5:43
  • 2
    Oh lord, what have I done...
    – Max
    May 6, 2022 at 10:29

2 Answers 2

6

A small cheating should be enough (we use only well-known basic commands):

%!TEX encoding = UTF-8 Unicode 
\documentclass[11pt, slidestop, compress]{beamer}
\usetheme{CambridgeUS}

\begin{document}

\begin{frame}{Frame}
Spectrum Community School was an alternative high school in 
Kingston, Washington, United States. It was a part of the North
Kitsap School District. The school had been running for over 20
years, and earned two awards of Special Merit from the Grammy 
Foundation in Los Angeles. The school was designed for students
searching for a \makebox[0pt][l]{nontraditional environment.}
\end{frame}

\end{document}

enter image description here

2

This is probably not the answer that you are after, but nevertheless. I wrote an article for TUGboat about all sorts of different kinds of paragraph shapes (https://tug.org/TUGboat/tb28-2/tb89glister.pdf). One of these was for specifying a paragraph where the last line was "not too short". I used this below.

% paraprob.tex  SE 643183

\documentclass[11pt, slidestop, compress]{beamer}
\usetheme{CambridgeUS}

%%% code from "Glisterings" TUGboat 28:2 2007
\newdimen\parabout
\newdimen\about
\about=2em
\about=0.99\hsize
\newcommand*{\nottooshort}{%
  \parabout=\hsize
  \advance\parabout -\about
  \leftskip=0pt plus 0pt minus 0pt
  \rightskip=\leftskip
  \parfillskip=\parabout minus \parabout
  \parindent=2em}

\begin{document}

\begin{frame}{Frame}

  \nottooshort
  Spectrum Community School was an alternative high school in Kingston,
  Washington, United States. It was a part of the North Kitsap School District.
  The school had been running for over 20 years, and earned two awards of
  Special Merit from the Grammy Foundation in Los Angeles. The school was
  designed for students searching for a nontraditional environment.
\end{frame}

\end{document}

enter image description here

You may wish to consider this as a different approach to your problem.

You must log in to answer this question.

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