enter image description here

I'm trying to make what I made in the above handwritten picture. Underbrace doesn't seem to work since you can't use a number as a beginning and end of an underbrace. Ideas?

  • 1
    It would be helpful to show us what you have tried. Posting a minimal working example that indicates what you are trying to do makes it easier for people to understand what you want. It also makes it easier for people to help you, since they have some code to start from, and much more likely that some one will try to help you. – Andrew Nov 28 '16 at 3:13

I would use a tikz matrix of math nodes for doing this. These matrices give a nice way of displaying "decorated" matrices. In this case, your decorations are the \underbraces. Any \matrix of math nodes can have an \underbrace put below it but the tricky thing is that you need to put an \underbrace between several different columns. The code below defines a pic for putting an \underbrace between the specified columns with the given label. The code produces:

enter image description here

Here is the full MWE:


  pics/underbrace/.style args={#1,#2,#3}{%
    % a pic for putting an underbrace under certain columns
    % #1 = left column
    % #2 = right column index
    % #3 = label text
    code = {
       \pgfextractx\colL{\pgfpointanchor{M-1-#1}{south}}  % x-coords of columns
       % draw the delimiter with the correct width
       \node[rectangle, below delimiter={\}}, minimum width=\dimexpr\colR-\colL-1pt]
              at ($ (M-1-#1)!0.5!(M-1-#2) $){};
       % the label
       \node at ($ (M-1-#1.south)!0.5!(M-1-#2.south) $)[below=1mm]{$\scriptstyle #3$};


    \matrix (M)[matrix of math nodes,row sep=1cm,column sep=1mm]{
      x! & 2x! & 3x! & \ldots & (n-x-1)x! & (n-x)x! & (x+1)!\\


A few more words of explanation:

  • The command \pic{underbrace={col1,col2,text}}; takes three arguments, which are the two columns that the \underbrace should span and the text below the brace. I have hard-coded in the row index as row 1. It would be straightforward to add another argument to allow the underbraces to be added to arbitrary rows.

  • The (M) in the \matrix (M) command says that the rows and columns of the matrix can be referred to as M-<row index>-<column index>. So the entries of the first row are M-1-1, M-1-2, ...

  • The 0.5 in ($ (M-1-1.south)!0.5!(M-1-2.south) $) says that this is a point is half way in between columns 1 and 2

|improve this answer|||||
  • I have a progression x! 2x! 3x! ... (n-x)x!, with a final term (x+1)!. The point is, you can't make the underbrace have 2x! as the end and start of the next underbrace. What you wrote looks bad at 2x!. – Bryce Sandlund Nov 28 '16 at 3:22
  • @BryceSandlund OK, I understand what you want now. Will edit. – Andrew Nov 28 '16 at 5:01
  • Looks pretty good! I'm having trouble getting it to compile though. What tikz libraries are needed for this? I'm getting: "Undefined control sequence. <argument> \colL \pic{underbrace={1,2,2}}; – Bryce Sandlund Nov 28 '16 at 18:27
  • @BryceSandlund In terms of tikz libraries, you only need \usetikzlibrary{matrix,calc} (positioning is not needed, so I'll remove it from the MWE). Just as importantly, you also need \newdimen\colL\newdimen\colR. – Andrew Nov 29 '16 at 0:30

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.