## LaTeX forum ⇒ LyX ⇒ Creating an Augmented matrix? Topic is solved

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
turkish
Posts: 2
Joined: Thu Jan 17, 2013 11:30 am

### Creating an Augmented matrix?

Hello,

How do I create an augmented matrix in LyX? That is, a set of cells on the left and right separated by a | (vertical line).

I did a Google search, searched the manual and searched on this forum, but the best solution I could find says right click an adjacent cell and then click 'insert line left' or 'right'. When I do that I only get the options 'insert line above' and 'below' (which works nicely, but I don't need it there ).

I'm wondering if there is a module for this that I don't installed.

Any ideas?

Thanks and regards.

Stefan Kottwitz
Posts: 8453
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
Hi,

welcome to the board!

If you use only LyX tools, you could use an array (like tabular) instead of a matrix. Internally matrices are array too. With an array you can use vertical lines.

If you would use LaTeX in LyX, the matrix environment could be extended. I write about this some time ago on my blog: An extension to amsmath matrix environments.

In LyX it can be done by adding to the document preamble:

\makeatletter\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%   \hskip -\arraycolsep   \let\@ifnextchar\new@ifnextchar   \array{#1}}\makeatother

Later you can use matrices with LaTeX (!) syntax, also in LyX (ERT):

\begin{pmatrix}[cc|c]   1 & 2 & 3\\   4 & 5 & 9\end{pmatrix}

matrix1.png (1.86 KiB) Viewed 12150 times

Even more sophisticated, with color, adjusted spacing, bold font, right alignment:

\begin{bmatrix}[*2cr@{\quad}|@{\quad}>{\bf\color{red}}r]   a & b & 1  &  4 \\   c & d & -2 & -3\end{bmatrix}

matrix2.png (1.89 KiB) Viewed 12150 times

You see you can use complex array column specifications.

Stefan

turkish
Posts: 2
Joined: Thu Jan 17, 2013 11:30 am
Stefan,

You are a legend. Thank you for the quick reply.

I'm a little intimidated by ERT so I prefer the LyX tools (one of the reasons it's so great IMO).

I inserted an array instead, as you suggested, and the insert left/right line option is now visible. I created the following in about 10 seconds.

augmented_matrix.PNG (6.65 KiB) Viewed 12148 times

Exactly what I wanted. Thanks a bunch

Cheers!

gry
Posts: 1
Joined: Sat Apr 12, 2014 2:06 am
You haven't actually told me what you used to insert a vertical bar into an array.

Johannes_B
Site Moderator
Posts: 3551
Joined: Thu Nov 01, 2012 4:08 pm
The vertical bar is represented by the vertical line (|, pipe symbol) in the argument of the matrix?
If this was not what you wanted to know, i guess you need to be a little clearer about what you are asking.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

cm1971
Posts: 1
Joined: Tue May 30, 2017 7:11 pm
1. How to run Latex code on LYX?
2. I use array on LYX to create an augmented matrix but I coud not insert the vertical line that separated the entries on the left and the right?
any help?

Stefan Kottwitz
Posts: 8453
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
LaTeX code can be embedded in LyX via "ERT" that means Evil Red Text.

If you would like to let us help to to fix or to improve your code, please post your code.

Stefan