\hfill doesn't work for braces in mathmode

Hm, something like this:

\documentclass{article}
\usepackage{lipsum}

\begin{document}
\lipsum[11]
\par\noindent
$\left.\begin{tabular}{@{} p{\linewidth} @{}}
line \\
one more line
\end{tabular}\right\}$
\par
\lipsum[11]
\end{document}

enter image description here


I'd abuse equation* for a couple of reasons:

  1. automatic vertical spacing around the construction;
  2. avoiding page breaks before the construction.

The contents of the braceonright environment is typeset as a tabular and reused for getting the right size of the brace. This is neessary, because \hfill does nothing if inside a \left-\right pair.

\documentclass{article}
\usepackage{amsmath}

\usepackage{lipsum} % for mock text

\newsavebox{\braceonrightbox}
\newenvironment{braceonright}
 {%
  \begin{equation*}% abuse equation* for spacing and other features
  \hspace{0pt}% necessary
  \begin{lrbox}{\braceonrightbox}% save the contents
  \begin{tabular}{@{}l@{}}%
 }
 {%
  \end{tabular}%
  \end{lrbox}%
  \usebox{\braceonrightbox}
  \hspace{1000pt minus 1fil}
  \left.\vphantom{\usebox{\braceonrightbox}}\right\rbrace
  \end{equation*}\ignorespacesafterend
 }

\begin{document}

\lipsum[1][1-6]
\begin{braceonright}
line \\
one more line
\end{braceonright}
\lipsum[2]

\end{document}

The trick is to add a very large space (1000pt) that can be shrinked to the actual width; in order for this to work, there must be some glue (0pt) at the beginning of the “equation”.

enter image description here