On Tue, Jun 05, 2001 at 11:15:30AM +0100, Qingchang Zhong wrote:
> Dear Herbert,
> Along with your solution, I obtained a solution to change massive arrays including
>vertical lines.
>
> Some suggestions regarding to vertical/horizontal lines in arrays are:
>
> 1. horizontal lines can be input in arrays directly with \hline at the first cell of
>the row, while lefting the vertical lines to be added later;
> 2. when the file is almost done, (or you are sure you will not modify the array any
>more), take the following steps to add vertical lines.
> Step 1: backup the lyx file and then open the *.lyx file in a common text
>editor;
> Step 2: find the arrays which vertical lines should be added;
> Step 3: add | into the alignment string, for example, ccc|c means vertical
>line lies between col. 3 and col. 4.
> Step 4: replace the \begin_inset Formula before the array as \latex
>latex;
> replace the \end_inset after the array
>as \latex default;
> This step can be done with search/replace function. So you will
>not feel too troublesome.
> 3. dashed lines can also be done in a similar way, but package arydshln should be
>used.
>
> When lyx re-open the file, the arrays will be displayed as latex code (red), when it
>is saved, \ is changed to \backslash. Hence, backing up the file before
> processing is recommended.
I have a better solution:
1. Put the following lines in the preamble:
\usepackage{array}
\newcommand{\arraylines}[1]{{\newcolumntype{r}{c|}#1}}
2. When you insert a matrix, use r alignment instead of c|, namely if
you want cc|c alignment, then write crc in the matrix dialog.
3. Put \arraylines{} around the whole math inset,
or inside the math inset, around the matrix
See the attached file.
#LyX 1.2 created this file. For more info see http://www.lyx.org/
\lyxformat 218
\textclass article
\begin_preamble
\usepackage{array}
\newcommand{\arraylines}[1]{%
{\newcolumntype{r}{c|}#1}}
\end_preamble
\language american
\inputencoding default
\fontscheme default
\graphics default
\paperfontsize default
\spacing single
\papersize Default
\paperpackage a4
\use_geometry 0
\use_amsmath 0
\paperorientation portrait
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language english
\quotes_times 2
\papercolumns 1
\papersides 1
\paperpagestyle default
\layout Standard
\latex latex
\backslash
arraylines{
\latex default
\begin_inset Formula \( \left[ \begin{array}{crc}
1 & 2 & 3\\
\hline 4 & 5 & 6\\
7 & 8 & 9
\end{array}\right] \)
\end_inset
\latex latex
}
\layout Standard
\begin_inset Formula \( \arraylines {\left[ \begin{array}{crc}
1 & 2 & 3\\
\hline 4 & 5 & 6\\
7 & 8 & 9
\end{array}\right] } \)
\end_inset
\the_end