4

I want a right brace that spans a few lines of text and is located at the right-most side of page.\

Something like this :

Right brace around text

Related : brackets - Adding a large brace next to a body of text

Here, the following code doesn't seem to work :

$\left.\begin{tabular}{l}
line \\
one more line
\end{tabular}\hfill\right\}$

Are there alternatives for \hfill that will work ?

1
  • Please start by explaining what hvis piece of gode is suppose to do in the first place. Hfill doesnt make much sense here – daleif Nov 8 '20 at 5:49
3

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

1
  • Thanks ! This works exactly how I wanted it to be. – Siddharth Nov 8 '20 at 14:18
3

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

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.