2

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

2 Answers 2

2

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
  • In recent versions of LyX, as long as you first do CTRL+M to get a math box, or there's a mathbox already there (as in the case where we had a pmatrix that we wanted to replace with a bmatrix), if you copy and paste any latex code, it should automatically show up as LyX formatted math :) Jun 10, 2018 at 20:33
1
  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.

You must log in to answer this question.

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