LyXCreating an Augmented matrix?

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

Creating an Augmented matrix?

Post by turkish »

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 :P).

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

Any ideas?

Thanks and regards.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Creating an Augmented matrix?

Post by Stefan Kottwitz »

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:

Code: Select all

\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):

Code: Select all

\begin{pmatrix}[cc|c]
  1 & 2 & 3\\
  4 & 5 & 9
\end{pmatrix}
matrix1.png
matrix1.png (1.86 KiB) Viewed 45027 times
Even more sophisticated, with color, adjusted spacing, bold font, right alignment:

Code: Select all

\begin{bmatrix}[*2cr@{\quad}|@{\quad}>{\bf\color{red}}r]
  a & b & 1  &  4 \\
  c & d & -2 & -3
\end{bmatrix}
matrix2.png
matrix2.png (1.89 KiB) Viewed 45027 times
You see you can use complex array column specifications.

Stefan
LaTeX.org admin
turkish
Posts: 2
Joined: Thu Jan 17, 2013 11:30 am

Creating an Augmented matrix?

Post by turkish »

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
augmented_matrix.PNG (6.65 KiB) Viewed 45025 times
Exactly what I wanted. Thanks a bunch :)


Cheers!
gry
Posts: 1
Joined: Sat Apr 12, 2014 2:06 am

Re: Creating an Augmented matrix?

Post by gry »

You haven't actually told me what you used to insert a vertical bar into an array.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Creating an Augmented matrix?

Post by Johannes_B »

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

Creating an Augmented matrix?

Post by cm1971 »

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?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Creating an Augmented matrix?

Post by Stefan Kottwitz »

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
LaTeX.org admin
Post Reply