# How to write a vertical vector in LaTeX for LyX

I can't work out how to write a vertical (two dimensional) vector, with brackets spanning two lines. Do you know how to write it for LyX?

-

When in mathmode, go to Insert --> Math --> Matrix (or click the button on the bottom toolbar: ).

Make it two rows by one column, and in the lower right of the window choose the appropriate type:

# Keyboard shortcut

As mentioned by JohnReed in the comments, you could create a shortcut for inserting a math-matrix, but this would add an array without delimiters. It is however possible to add the desired delimiters, rows and columns with one shortcut.

Shortcuts are added in Tools --> Preferences --> Editing --> Shortcuts (see Shortcuts for Lemma, Claim, Theorem etc for some more details). The LyX function you need to use for this new shortcut is of the form

``````math-ams-matrix <# columns> <# rows> <name of amsmath matrix type>
``````

The `amsmath` package provides several matrix environments with different delimiters:

• `pmatrix`: ( )
• `bmatrix`: [ ]
• `Bmatrix`: { }
• `vmatrix`: | |
• `Vmatrix`: || ||

So for creating a matrix with two rows, one column and square brackets around it, the necessary LyX function is

``````math-ams-matrix 1 2 bmatrix
``````

If this is the only type of matrix you need a shortcut for, just choose an appropriate shortcut. Should you want to have shortcuts for different size matrices and delimiters, using the same pattern for all would be helpful in remembering them. For the example above you could use a shortcut such as

• Ctrl + Alt + Shift + M 2 1 b

in other words, hold down Ctrl, Alt and Shift and tap M, then release all the keys and type 2 1 b. You could set up similar shortcuts where the numbers indicate number of rows and columns, and the final letter the delimiter.

-
great answer! is there a shortcut for this? – Danny Rancher May 4 '12 at 15:35
@DannyRancher Torbjørn T. already gave the shortest way by default. There is no default shortcut key for inserting a matrix but you can make your own: Preferences > Editing > Shortcuts > Mathematical Symbols > math-matrix. This won't open the dialog, but it will create a 1 by 1 matrix where you can then add additional rows and/or columns as desired (using the add column and add row buttons in the math toolbar). – JohnReed May 4 '12 at 16:31
@DannyRancher I added a section about adding a keyboard shortcut. – Torbjørn T. May 5 '12 at 7:21
excellent answer! – scottkosty May 5 '12 at 7:28
@scottkosty Thanks! – Torbjørn T. May 5 '12 at 7:39

Torbjørn T. posted the correct answer. I just want to show this alternative way because it is good practice for adding other kinds of "shortcuts" for cases where there is not an explicit LyX command. For more information on math macros, see Section 22 in Help > Math

-