4

I used the GUI to make a matrix with round brackets, and now I want to remove the round brackets (or change them to square brackets), how do I do that?

1
  • I don't know if this is possible. If you don't get a response, you might want to open an enhancement request on lyx.org/trac
    – scottkosty
    Jun 10, 2018 at 4:05

3 Answers 3

3

A very dirty workaround.

Suppose you have myfile.lyx:

enter image description here

Save it as myfile2.lyx to have a backup in case of error.

Close LyX and open myfile.lyx with a text editor (like Notepad++ or similar), you'll have this:

#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 508
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass article
\use_default_options true
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Standard
I want this without round brackets: 
\begin_inset Formula 
\[
\begin{pmatrix}a & b\\
c & d
\end{pmatrix}
\]

\end_inset


\end_layout

\begin_layout Standard
I want this with square brackets: 
\begin_inset Formula 
\[
\begin{pmatrix}a & b\\
c & d
\end{pmatrix}
\]

\end_inset


\end_layout

\end_body
\end_document

Now change pmatrix with array if you don't want brackets or pmatrix with bmatrix if you want square brackets, you'll get this:

#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 508
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass article
\use_default_options true
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Standard
I want this without round brackets: 
\begin_inset Formula 
\[
\begin{array}a & b\\% <-- changed
c & d
\end{array}% <-- changed
\]

\end_inset


\end_layout

\begin_layout Standard
I want this with square brackets: 
\begin_inset Formula 
\[
\begin{bmatrix}a & b\\% <-- changed
c & d
\end{bmatrix}% <-- changed
\]

\end_inset


\end_layout

\end_body
\end_document

Save it and close the text editor.

Open it with LyX, et voilà:

enter image description here

Pay attention: do not change anything else, unless you know what you're doing, and always make a backup copy of your .lyx document before doing these things.

6
  • Well in that case, just highlight the matrix in the LyX GUI, copy, paste into a text editor, and edit "pmatrix" to "matrix" or "bmatrix", then paste back into the LyX GUI. Jun 10, 2018 at 20:09
  • @user1271772 Yes, of course, but you have to use ERT
    – CarLaTeX
    Jun 10, 2018 at 20:11
  • No you don't, I just did it, it was fine. Jun 10, 2018 at 20:12
  • @user1271772 Good, I didn't think you could paste LaTeX code into LyX without ERT
    – CarLaTeX
    Jun 10, 2018 at 20:14
  • 1
    @user1271772 Good to know. I didn't usually use LyX but I'm pleased to know the existence of this feature :)
    – CarLaTeX
    Jun 10, 2018 at 20:38
2
  1. Highlight the matrix in the LyX GUI.
  2. Copy and paste it into a text editor.
  3. Edit "pmatrix" to "matrix" (no brackets) or "bmatrix" (square brackets),
  4. Paste back into the LyX GUI.
1

With version 2.3.7 it's perfectly possible to copy-paste the elements of a matrix like any other objects.


Let's use this matrix:

enter image description here

  1. Select the elements by clicking inside the matrix, then using Ctrl-a once or twice (the first selects the row, the second all rows, but sometimes all elements are selected at once):

    enter image description here

    Note the brackets are not selected.

  2. Send the selection to the clipboard (Ctrl-c).

  3. Create a new matrix using Insert|Math|Matrix... choose the appropriate size and alignment, and set Decoration Type to any value, e.g. choose None if you want to remove the brackets:

    enter image description here

  4. Click in the first element, to set the start of the coming paste.

  5. Paste (Ctrl-v):

    enter image description here

You could use this procedure as well to copy only some elements, and possibly paste them elsewhere into the same matrix.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .