# Size of { in my equations

I write some code to get the above equation. However, I would like to make the first "{" to have the same size as the last "}". Does anyone know how to do it? I am attaching my code in the following

\begin{align}
\mathbf{Q}=\text{diag}&\left\{\text{diag}\left\{\underbrace{\mathbf{m}_1, \ \mathbf{m}_2,\ \ldots, \ \mathbf{m}_K}_{K}\right\}\right., \ \ldots\notag\\
&\quad \left.\underbrace{\ldots, \ \text{diag}\left\{\underbrace{\mathbf{m}_1, \ \mathbf{m}_2,\ \ldots, \ \mathbf{m}_K}_{K}\right\}}_{N_x}\right\}
\label{eq:Q}
\end{align}

• – Werner Sep 10 '14 at 23:41
• Do you really need to inform user that m_1,\dots,m_K makes K elements? IMHO it's a bit ridiculous. If you get rid of these inner \underbraces, you'll be fine then, won't you? – yo' Sep 10 '14 at 23:57

Here, I \smashed the outer \underbrace of the 2nd line and added \vphantom of the same size as the inner \underbrace. That way, the \right\} picks up on the \vphantom height.

Note that because the outer \underbrace was \smashed, you will likely have to add a small \vspace after the equation to make up for the space taken up by the outer \underbrace, as shown in my MWE.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
\mathbf{Q}=\text{diag}&\left\{\text{diag}\left\{\underbrace{\mathbf{m}_1, \
\mathbf{m}_2,\ \ldots, \ \mathbf{m}_K}_{K}\right\}\right., \ \ldots\notag\\
\left\{\underbrace{\mathbf{m}_1, \ \mathbf{m}_2,\ \ldots, \
\mathbf{m}_K}_{K}\right\}}_{N_x}}\vphantom{\underbrace{m_1}_{N_x}}\right\}
\label{eq:Q}
\end{align}

\vspace{\baselineskip}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\end{document}


To follow up on a comment by the OP, if one wanted the braces on the inner diag arguments to be smaller, one could use the same technique I used on the outer diag. However, in this case, I think I would use something like \bigg\{ ... \bigg\}, which I show in the first line of the MWE below, or else \big\{ ... \big\}, which I show in the second line.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
\mathbf{Q}=\text{diag}&\left\{\text{diag}\bigg\{\underbrace{\mathbf{m}_1, \
\mathbf{m}_2,\ \ldots, \ \mathbf{m}_K}_{K}\bigg\}\right., \ \ldots\notag\\
%
\big\{\underbrace{\mathbf{m}_1, \ \mathbf{m}_2,\ \ldots, \
\mathbf{m}_K}_{K}\big\}}_{N_x}}\vphantom{\underbrace{m_1}_{N_x}}\right\}
\label{eq:Q}
\end{align}

\vspace{\baselineskip}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\end{document}


• Thank you for your answer. It is pretty nice. In order to keep the consistency, do you know how to change the inner diag{} part in the same way as outside diag{}. – HeyMan Sep 11 '14 at 1:18
• @user2270626 If I understand your question properly, I would not use \left\{ ... \right\} for the inner braces, but rather \{\, ... \,\}, which would use normal size braces for the inner diag arguments. – Steven B. Segletes Sep 11 '14 at 1:29
• Yes. That's what I mean. If you can make the inner under brace and "K" lower than {} in the same way as the outer, that would be great for me. Thank you again. – HeyMan Sep 11 '14 at 1:30
• @user2270626 See my more recent comment. I can post an MWE, if it would help. – Steven B. Segletes Sep 11 '14 at 1:30
• @user2270626, ...or, alternately, you could use \big\{ ... \big\}, or else \bigg\{ ... \bigg\}, or even \Bigg\{ ... \Bigg\}. – Steven B. Segletes Sep 11 '14 at 1:33

A classic TeX method -- "classic" in the sense that it's mentioned explicitly in Knuth's TeXbook -- for achieving your objective is to repeat the material from the second line that's causing the closing curly brace to be so large inside a \vphantom macro on the first line. A \vphantom ("vertical phantom") is an invisible object that's as tall as its argument. In the code below, I've simplified your setup a bit by defining an auxiliary macro called \bigblock (sorry, not very creative) that's used twice -- first as the argument of \vphantom on the first line, then as itself on the second line. Additionally, I've defined another auxiliary macro named \smallblock that's an important building block (pun intended) of \bigblock.

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\diag}{diag}
%% define to auxiliary macros: \smallblock and \bigblock
\newcommand\smallblock{\diag\left\{\underbrace{\mathbf{m}_1, \
\mathbf{m}_2,\ \ldots, \ \mathbf{m}_K}_{K}\right\}}
\newcommand\bigblock{ \underbrace{\ldots, \ \smallblock}_{N_x} }

\begin{document}
\begin{align}
\mathbf{Q}=\diag
&\left\{ \vphantom{\bigblock} \smallblock \right., \ \ldots \notag\\
\end{align}
\end{document}


You don't really need two lines for this formula, and the mathtools package allows to define a \diag command that includes the variable sized braces. You then have a \diag* that adds an implicit \left …\right pair on either side of the braces. The non-star version admits as optional argument \big, \Big, &c. for fine tuning the size of the braces. Moreover, you get a code that has the sake of simplicity.

If you want to break your equation in two lines, there is a silghtly less simple code, adapted from a code in the mathtools documentation:

\documentclass[11pt,a4paper]{article}
\usepackage{mathtools} %

\usepackage[showframe]{geometry}
%
\DeclarePairedDelimiterXPP{\Diag }[1]{\mathrm{diag}}\{\}{}{#1}

\newcommand\MTkillspecial[1]{% helper macro
\bgroup
\catcode‘\&=9
\let\\\relax%
\scantokens{#1}%
\egroup
}

\DeclareMathOperator\diag{diag}
\DeclarePairedDelimiter\set\{\}
\reDeclarePairedDelimiterInnerWrapper\set{star}{
\mathopen{#1\vphantom{\MTkillspecial{#2}}\kern-\nulldelimiterspace\right.}
#2
\mathclose{\left.\kern-\nulldelimiterspace\vphantom{\MTkillspecial{#2}}#3}}

\begin{document}

\begin{align}
\mathbf{Q}&= \Diag[\bigg]{\Diag{\underbrace{\mathbf{m}_1, \mathbf{m}_2,\ \ldots, \mathbf{m}_K}_{K}}, \ \ldots
\underbrace{\ldots, \ \Diag{\underbrace{\mathbf{m}_1, \mathbf{m}_2,\ \ldots, \mathbf{m}_K}_{K}}}_{N_x}}
\label{eq:Q}
\end{align}

\begin{align}
\mathbf{Q}= \diag&\set[\bigg]{\Diag{\underbrace{\mathbf{m}_1, \mathbf{m}_2,\ \ldots, \mathbf{m}_K}_{K}}, \ \ldots \\[-1ex]
& \quad\underbrace{\ldots, \ \diag\set{\underbrace{\mathbf{m}_1, \mathbf{m}_2,\ \ldots, \mathbf{m}_K}_{K}}}_{N_x}}
\label{eq:Q}
\end{align}

\end{document}


• Thank you for your answer. But I have to break it into two lines because this equation is too long for me. – HeyMan Sep 11 '14 at 1:05
• @user2270626: I also have a solution with line breaking. See my updated answer. – Bernard Sep 11 '14 at 7:28