Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\documentclass[fleqn,12pt,a4paper]{article}
\usepackage{amstext, amsmath}
\newcommand{\lcurly}[1]{$\left\{\begin{array}{l}  #1   \end{array} \right.$}
\newcommand{\rcurly}[1]{$\left. \begin{array}{l}  #1   \end{array} \right  \}$}
\newcommand{\slcurly}[1]{$\left\{   \shortstack{#1} \right.$}
\newcommand{\srcurly}[1]{$\left. \shortstack{#1} \right  \}$}

   \begin{document}
   \lcurly{1 \\ 2} \rcurly{Line 1 \\ Line 2} \vspace{1cm} \\

   \slcurly{1 \\ 2}  \srcurly{Line 1\\ Line 2} \\
   \end{document}

I have a need to create curly brackets, I managed to do that with above shown code. I am attaching a screenshot. When I use array the text is evenly distributed vertically but the bracket appears little bit farther. When I change array to stack the bracket appears closer but the text is not nicely aligned.

I was wondering if there is way to align the text as shown in the top image and make the bracket appear close like shown in the second part of the image. Thanks for your helpalt text

share|improve this question

3 Answers 3

up vote 2 down vote accepted

A quick fix would be to insert just some negative space before respectively after the array:

\newcommand{\lcurly}[1]{$\left\{\hspace{-0.5em}%
  \begin{array}{l}  #1   \end{array} \right.$}
\newcommand{\rcurly}[1]{$\left.
  \begin{array}{l}  #1   \end{array}\hspace{-0.5em}\right  \}$}

In cases such as your second example \vcenter comes handy to vertically center objects:

\newcommand{\slcurly}[1]{$\left\{\vcenter{\hbox{$\shortstack{#1}$}}\right.$}
\newcommand{\srcurly}[1]{$\left.\vcenter{\hbox{$\shortstack{#1}$}}\right \}$}

alt text

share|improve this answer
2  
Why not use \begin{array}{@{}l} and \begin{array}{l@{}}? –  TH. Jan 16 '11 at 4:39
    
@TH.: Why not make an answer out of that? –  Hendrik Vogt Jan 16 '11 at 10:03
    
@Hendrik: It'd be only a minor modification of Stefan's answer. I'm also not really sure I understand the use of this anyway. If the top line for the \lcurly is larger than the top line for the \rcurly, they're not going to match up. Something more like \newcommand\curly[1]{\ensuremath{\left\{\begin{array}{@{}ll@{}}#1\end{array}\ri‌​ght\}}} makes more sense to me. –  TH. Jan 16 '11 at 10:11
    
@TH.: Makes more sense to me, too. Why not write that in your answer :-)? (stortstack even gives bad alignment of the text ...) –  Hendrik Vogt Jan 16 '11 at 10:15

Per Hendrik's prodding =) here's how I would do this.

\documentclass{article}
\usepackage{amsmath}
\newcommand\curly[1]{%
        \ensuremath{%
                \left\{%
                \begin{array}{@{}ll@{}}%
                        #1%
                \end{array}%
                \right\}%
        }%
}
\begin{document}
\curly{1 & \text{Line 1}\\
       2 & \text{Line 2}}
\end{document}

alt text

This has the advantage of keeping the lines aligned even if one part is larger than the others. My picture doesn't show it, but it also lines the vertical center of the array up with about half the x-height of the surrounding text. (TeX by Topic informs me that it's “\fontdimen22 of the font in family 2, the symbol font, in the current style,” just in case you were curious.)

share|improve this answer

This seem to work also:

\documentclass{article}
\usepackage{schemata}
\begin{document}
\Schema[open]{0ex}{2ex}{\schemabox{}}
{\Schema[close]{0ex}{2ex}{\schemabox{1 Line 1\\2 Line 2}}
{}} 
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.