9

Within a text, I would like to emphasize one or two paragraphs by placing a curly brace in the left side margin, and next to it some short text vertically centred around the brace's centre.

The question Adding a large brace next to a body of text shows how to add braces in the main text, maybe that can help as a starting point? A slight modification of the accepted answer there is

\documentclass{report} 
\usepackage{lipsum}

\begin{document}
\lipsum[1]
\noindent$\left\{
\begin{minipage}{\textwidth}
\lipsum[2]
\end{minipage}
\right.$
\lipsum[3]
\end{document}

But this has the drawbacks that

  1. it spills into the right, not the left margin;
  2. I cannot add text to the brace; and that
  3. the line spacing before the braced paragraph is incorrect.

Maybe this can be modified, or a completely different approach should be used? But I wouldn't know which one.

2
  • Andrew Stacey's solution to that linked question is a more promising start of a solution.
    – Seamus
    Nov 7, 2011 at 17:25
  • I have been using the solution from changbars to indicate location of conditional text. This is not a curly brace but enough to make the paragraph stand out. This has the added benefit that you can highlight portions of the text within the paragraph, and also useable within math mode. Nov 7, 2011 at 17:26

5 Answers 5

7

You can use a \makebox to define a new command with two arguments: the first one will contain the text for the brace, and the second one will contain the paragraph text; something along these lines:

\documentclass{report} 
\usepackage{amsmath}
\usepackage{lipsum}

\newcommand\BrText[2]{%
  \par\smallskip
   \noindent\makebox[\textwidth][r]{$\text{#1}\left\{
    \begin{minipage}{\textwidth}
    #2
    \end{minipage}
  \right.\nulldelimiterspace=0pt$}\par\smallskip
}    

\begin{document}
\lipsum[1]
\BrText{Some text}{\lipsum[1]}
\lipsum[1]
\end{document}

enter image description here

1
  • 1
    Instead of guessing the dimension for the \makebox you can say \noindent\makebox[\textwidth][r]{...}; also you should set \nulldelimiterspace=0pt just before the closing $, otherwise a .5pt shift would apppear on the right.
    – egreg
    Nov 7, 2011 at 17:35
2

\psbrace from pstricks-add package can do this. You need to position two nodes, and them connect them with the brace:

\documentclass{article}
\usepackage{pstricks,pstricks-add,lipsum}
\begin{document}
\lipsum[1]
\makebox[0pt]{\makebox[1.5cm][l]{\pnode{A}}}
\lipsum[2]
\makebox[0pt]{\makebox[1.5cm][l]{\pnode{B}}}
\lipsum[3]
\psbrace[rot=180,ref=r, nodesepA=-2ex](A)(B){Text}
\end{document}

enter image description here

8
  • is it intentional that the brace isn't coextensive with the text? i wouldn't have guessed it from the code. Nov 7, 2011 at 19:36
  • You mean the end is below the paragraph? I should put the second node slightly higher...
    – Boris
    Nov 7, 2011 at 19:39
  • and perhaps the first node might be a bit higher as well -- at the top of the first line of that paragraph. raising the height of both beginning and end by the same amount should do it. Nov 7, 2011 at 19:48
  • Surely. These adjustments can be made to taste...
    – Boris
    Nov 7, 2011 at 19:58
  • For simplicity, let P be the paragraph covered by the brace. Am I right when I say that this is the only answer where P is not put inside a box or minipage? If yes, does this mean that this is the only solution where P can be broken in multiple pages? May 21, 2021 at 17:57
2

Here is another approach that utilized the environ package. The two-step procedure boxes the contents (in \savetextbox) in order to get its height. Then it typesets the left brace in the margin, and then the box.

In the following minimal working example, a new environment bracetext is defined. It takes an optional argument which specifies the width of the text block (default is \textwidth). It is possible to modify this environment to take arguments (optional or mandatory) for the text to be displayed on the left-hand side as well.

enter image description here

\documentclass{report}
\usepackage{environ}% http://ctan.org/pkg/environ
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\newbox{\savetextbox}
\NewEnviron{bracetext}[1][\textwidth]{%
  \begin{lrbox}{\savetextbox}%
    \begin{minipage}{#1} \BODY \end{minipage}
  \end{lrbox}%
  \smallskip%
  \noindent\makebox[0pt][r]{$\left\{\rule{0pt}{\ht\savetextbox}\right.$}%
  \usebox{\savetextbox}\par
  \smallskip%
}
\begin{document}
  \lipsum[1]
  \begin{bracetext}
    \lipsum[2]
  \end{bracetext}
  \lipsum[3]
\end{document}​

The lipsum package was used to provide dummy text Lorem Ipsum... style.

Note this one caveat of this approach is that the brace will not split across pages. If you want something that splits across pages, you should consider using mdframed. However, it does not support bracing as you requested.

3
  • sadly, the baselines above and below the braced text aren't the same as elsewhere in the text, and the braced text doesn't have a paragraph indent (maybe that's intentional). Nov 7, 2011 at 19:28
  • The latter was intentional as a consequence of inserting content in a minipage environment. Do you have a suggestion how to fix the former?
    – Werner
    Nov 7, 2011 at 19:31
  • fixing the baseline above the minipage can be done by ending the previous line with a \strut. actually, since you've used \smallskip here, four \struts should do the job instead -- one on the previous line, one at the beginning of the minipage after a \leavevmode, one at the end of the minipage, and the last one after a \leavevmode (or \indent) at the beginning of the line beginning the next paragraph. \struts are your friend; they serve to maintain even baselines much more reliably than \*skips. Nov 7, 2011 at 19:45
1

Another solution: The schemata package.

\documentclass{article}
\usepackage{schemata}
\usepackage{lipsum}
\begin{document}

\lipsum[1]

\hspace{-1cm}\schema{}{\lipsum[2]}

\lipsum[3]

\end{document}

MWE

1

This is a modification of the answer provided by Gonzalo Medina, so that it works for two-column pages:

\documentclass[twocolumn]{article}
\usepackage{amsmath}
\usepackage{lipsum}

\makeatletter
\newcommand\BrLeftText[2]{%
  \par\smallskip
   \noindent\makebox[\columnwidth][r]{$\text{#1}\left\{
    \begin{minipage}{\columnwidth}
    #2
    \end{minipage}
  \right.\nulldelimiterspace=0pt$}\par\smallskip
}    
\newcommand\BrRightText[2]{%
  \par\smallskip
   \noindent\makebox[\columnwidth][l]{$\left.
    \begin{minipage}{\columnwidth}
    #2
    \end{minipage}
  \right\}$\text{#1}\nulldelimiterspace=0pt}\par\smallskip
} 
\newcommand\BrText[2]{
\if@firstcolumn \BrLeftText{#1}{#2} \else \BrRightText{#1}{#2} \fi
}
\makeatother

\begin{document}

\BrText{left}{\lipsum[1]}
\newpage
\BrText{right}{\lipsum[1]}

\end{document}

enter image description here

You must log in to answer this question.

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