7

I am trying to highlight pieces of a formula with some text on the side, but one of those pieces is multiple lines. The solution that I came up with was to use braces in an array to highlight the groups.

Unfortunately, the result doesn't look very good because the small brace is much narrower and has a different weight than the big brace. How can I fix this so it doesn't look so strange?

One option is to find a different kind of brace that doesn't vary in width when it varies in height. I hoped that ] would do this, but indeed it varies in width.

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

\begin{document}
\begin{align*}
\begin{array}{ll@{}l}
  w & \}                       & \textrm{one element} \\
  x & \multirow{2}{*}{\bigg\}} & \multirow{2}{*}{\textrm{two elements}} \\
  y &                          & \\
  z & \}                       & \textrm{another element} 
\end{array}
\end{align*}
\end{document}

Here is the result of the code. I would like for the left and right edges of all three braces to be aligned. Here the gap between the brace and one element is much larger than the gap between the brace and two elements.

strange width of braces

1

The scalerel package allows one to stretch glyphs to fit the size of a second item. Also, I used a TABstack to create the assembly. If you wish the vertical spacing to be the same as your original, edit \setstackgap{S}{1pt} to be 0pt. I just thought that the small extra gap looked better.

\documentclass{article}
\usepackage{tabstackengine}
\usepackage{scalerel}
\begin{document}
\[
\setstackgap{S}{1pt}
\alignShortstack{%
\strut$w\mkern-1mu$\quad\}& one element\\
\stretchleftright{.}{\stackanchor{\strut$x$}{\strut$y$}\quad}{\}}& two elements\\
\strut$z$\quad\}& another element
}
\]
\end{document}

enter image description here

  • Thank you for this suggestion. Unfortunately it doesn't look quite right. The stretched symbols look different from the unstretched symbols. Additionally, I have no familiarity with TABstack, which confuses the answer, I think. Your comment about more space is absolutely correct, however. Thank you. – Arlen Cox Feb 23 '14 at 0:15
1

I adapted this using the suggestions of Claudio in Add a curved arrow and a bracket to a table to my purposes. The advantage of using tikz over stretching symbols is that tikz produces a uniform look for all of the braces by actually generating an arbitrarily sized brace. By setting the amplitude parameter in the code below I am able to control how wide a brace is.

It is also possible to solve this problem by placing markers in the table, but this solution seemed easier.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{multirow}
\usepackage{amsmath}

\newcommand{\vcenteredbox}[1]{\begingroup
\setbox0=\hbox{#1}\parbox{\wd0}{\box0}\endgroup}

\newcommand{\braceone}{%
  \vcenteredbox{\tikz{%
      \draw[decorate,decoration={brace,amplitude=2pt},xshift=0pt, yshift=0pt] (0,0) -- (0,-1em);
  }}
}
\newcommand{\bracetwo}{%
  \vcenteredbox{\tikz{%
      \draw[decorate,decoration={brace,amplitude=2pt},xshift=0pt, yshift=0pt] (0,0) -- (0,-2em);
  }}
}


\begin{document}
\begin{align*}
\begin{array}{ll@{}l}
  w & \braceone                  & \textrm{one element} \\
  x & \multirow{2}{*}{\bracetwo} & \multirow{2}{*}{\textrm{two elements}} \\
  y &                            & \\
  z & \braceone                  & \textrm{another element} 
\end{array}
\end{align*}
\end{document}

Correctly aligned braces

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.