Text FormattingStrech braces around enumerate environment

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
revberaldo
Posts: 9
Joined: Sat Feb 13, 2010 3:37 pm

Strech braces around enumerate environment

Post by revberaldo »

I am trying to do something simitar to what I saw in this post.

Well, I've tried

Code: Select all

{$\left.\begin{enumerate}
         \item fnord
         \item fnord
         \end{enumerate}\right\rbrace$}
But pdflatex gives me an error:

Code: Select all

(/usr/share/texmf-dist/tex/latex/base/omscmr.fd) [1{/usr/share/texmf-var/fonts/
map/pdftex/updmap/pdftex.map}]
./aulas.tex:60: Missing $ inserted.
<inserted text> 
                $
l.60 {$\left.\begin{enumerate}
                              
? 
So, I would be very useful if I could put braces or brackets around enumerate or itemize environment. Is there any other way?

Is there any way to put braces under words and more text under the brace I would have just created?

Thank you all.

Edit: This is more or less what I am trying to reproduce:
Image

I haven't asked about how to do the text in red because I think I just have to use the tabular environment.
Last edited by revberaldo on Tue May 11, 2010 11:47 pm, edited 3 times in total.
Blog (in Portuguese)
Twitter (almost completely in Portuguese, eventually in English or Esperanto)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Strech braces around enumerate environment

Post by gmedina »

Hi,

one possible solution would be to use something along these lines:

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{multirow}
\usepackage{xcolor}

\newcounter{mycount}

\begin{document}

\begin{tabular}{>{\stepcounter{mycount}\themycount.}ll@{\ }l@{\ }l}
  & fnord & \multirow{3}{*}{$\left.\vphantom{\rule{0pt}{16pt}}\right\rbrace$} &\\
  & fnord & &\textcolor{red}{apscal}\\
  & fnord &&
\end{tabular}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
revberaldo
Posts: 9
Joined: Sat Feb 13, 2010 3:37 pm

Strech braces around enumerate environment

Post by revberaldo »

gmedina wrote:Hi,

one possible solution would be to use something along these lines:

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{multirow}
\usepackage{xcolor}

\newcounter{mycount}

\begin{document}

\begin{tabular}{>{\stepcounter{mycount}\themycount.}ll@{\ }l@{\ }l}
  & fnord & \multirow{3}{*}{$\left.\vphantom{\rule{0pt}{16pt}}\right\rbrace$} &\\
  & fnord & &\textcolor{red}{apscal}\\
  & fnord &&
\end{tabular}

\end{document}
Hey,

Well, it works very well but is kind of complex. I'll use several braces and words etc. I was hoping that the braces stretched themselves automatically.
Blog (in Portuguese)
Twitter (almost completely in Portuguese, eventually in English or Esperanto)
torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

Strech braces around enumerate environment

Post by torbjorn t. »

Another possible solution, is to use Tikz, but this also has its drawbacks. Note that you have to compile twice to get the brace in the correct place:

Code: Select all

\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calc}
\tikzstyle{every picture}+=[remember picture]

\begin{document}
\begin{enumerate}
  \item \tikz \node[coordinate] (a) {};
        This is a line of text. 
  \item More text.
  \item And yet much more text. 
        \tikz \node[coordinate] (b) {};
\end{enumerate}

\begin{tikzpicture}[overlay,decoration={brace,amplitude=5}]
  \draw [thick,decorate] ($(a-|b)+(0,1.5ex)$)  --node[right=1ex,red]{apscal} ($(b)+(0,-.3ex)$);
\end{tikzpicture}
\end{document}
One problem with this is the horizontal position of the brace. If the last line isn't the longest of them, you have to add horiosontal space between the text of the last item and

Code: Select all

        \tikz \node[coordinate] (b) {};
otherwise the brace will be placed above the text of the longer line.

Also, the way I've made the brace fully enclose the text is not the most elegant I think. I'd welcome suggestions for better solutions.

revberaldo wrote:Is there any way to put braces under words and more text under the brace I would have just created?
In mathmode there is an underbrace-command, that combined with a subscript will do this.

Code: Select all

\documentclass[a4paper]{article}
\usepackage{amsmath}  % Provides the \text-command

\begin{document}
$ \underbrace{\text{Text above brace}}_{\text{Text below brace}} $
\end{document}
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Strech braces around enumerate environment

Post by gmedina »

Yet another option would be to use a minipage to enclose the enumerate environment (now you only have to set the minipage's width):

Code: Select all

\documentclass{report}

\begin{document}

$\left.\begin{minipage}{3cm}
\begin{enumerate}
\item First item
\item Second item
\end{enumerate}
\end{minipage}\right\rbrace$ Some comment

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
revberaldo
Posts: 9
Joined: Sat Feb 13, 2010 3:37 pm

Strech braces around enumerate environment

Post by revberaldo »

gmedina wrote:Yet another option would be to use a minipage to enclose the enumerate environment (now you only have to set the minipage's width):

Code: Select all

\documentclass{report}

\begin{document}

$\left.\begin{minipage}{3cm}
\begin{enumerate}
\item First item
\item Second item
\end{enumerate}
\end{minipage}\right\rbrace$ Some comment

\end{document}
This is a very nice idea indeed!

Thank you all!
Blog (in Portuguese)
Twitter (almost completely in Portuguese, eventually in English or Esperanto)
Post Reply