# Re: How to implement batch convertion on equations style.

Laser Yuan wrote:

I have attached the sample file bellow. I have put many equations in arrays
since I want to get multiline equation with single label and align them to
the left. But it turned out that elements in the array are not in display
style. Finally, I found using aligned AMS environment is what I desired. I
just need to put all of them to the second column to get them align left.
But situation now is that I have so many equations need to perform this
conversion. Could anybody give a  suggest on what I shall do to minimize the
workload. Thanks in advance!

Laser


Am I missing something, or isn't it just a matter of replacing "\begin{array}{1}" with "\begin{aligned} &"? If so, then you just do it in any text editor. For more complex stuff, you can use sed, or perl, or awk, or whatever. I tend to use perl, because you can just do this:

#!/usr/bin/perl
while (<>) {
# operate on $_ print$_;
}

and get a useful filter quite quickly, which you can then run via:
>perl myfilter.pl <infile.lyx
and get the output on the console, where you can examine it.

rh


#LyX 1.6.1 created this file. For more info see http://www.lyx.org/
\lyxformat 345
\begin_document
\textclass article
\begin_preamble
\usepackage{lmodern}
\newcommand{\1}{\mbox{1\hspace{-1mm}I}}
\numberwithin{equation}{section}

%control the line space in multiline equations
\usepackage{calc}
\setlength{\jot}{3mm+3pt}
\end_preamble
\use_default_options true
\begin_modules
theorems-ams
\end_modules
\language english
\inputencoding auto
\font_roman default
\font_sans default
\font_typewriter default
\font_default_family default
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100

\graphics default
\paperfontsize 11
\spacing double
\use_hyperref true
\pdf_bookmarks true
\pdf_bookmarksnumbered true
\pdf_bookmarksopen true
\pdf_bookmarksopenlevel 3
\pdf_pdfborder false
\pdf_backref false
\pdf_pdfusetitle true
\papersize a4paper
\use_geometry true
\use_amsmath 1
\use_esint 1
\cite_engine basic
\use_bibtopic false
\paperorientation portrait
\leftmargin 1.5cm
\topmargin 3cm
\rightmargin 1.5cm
\bottommargin 1.5cm
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle plain
\tracking_changes false
\output_changes false
\author ""
\author ""

\begin_body

\begin_layout Standard
I have inputed so many equations like this ( faractions, exponentials are
not in display style, equations aligned to the left, with only one lable):
\begin_inset Formula $$\begin{array}{l} v^{-}\left(x;a,b\right)=-\left(c^{+}+c^{-}\right)\frac{\exp\rho_{1}\left(x-b\right)-\exp\rho_{2}\left(x-b\right)}{\exp\rho_{1}\left(b-a\right)-\exp\rho_{2}\left(b-a\right)}\\ +\frac{\left(h-rc^{+}\right)\exp-\left(\rho_{1}+\rho_{2}\right)b}{r\left(\exp\rho_{1}\left(b-a\right)-\exp\rho_{2}\left(b-a\right)\right)}\left(\exp\left(\rho_{1}x+\rho_{2}a\right)-\exp\left(\rho_{2}x+\rho_{1}a\right)\right)\\ +\frac{\left(p+h\right)\left(\exp\left(\rho_{1}x+\rho_{2}a\right)-\exp\left(\rho_{2}x+\rho_{1}a\right)\right)\left(\rho_{2}\exp-\rho_{2}b-\rho_{1}\exp-\rho_{1}b\right)}{r\left(\rho_{1}-\rho_{2}\right)\left(\exp\rho_{1}\left(a-b\right)-\exp\rho_{2}\left(a-b\right)\right)}\\ +\frac{p+rc^{-}}{r}\frac{\left(\exp\rho_{1}\left(x-b\right)-\exp\rho_{2}\left(x-b\right)-\exp\rho_{1}\left(a-b\right)+\exp\rho_{2}\left(a-b\right)\right)}{\exp\rho_{1}\left(b-a\right)-\exp\rho_{2}\left(b-a\right)}\end{array}\label{eq:with one lable}$$

\end_inset

\end_layout

\begin_layout Standard
What's the quickest way to convert all those equations into this style (all
items are in display style )
\begin_inset Formula \begin{aligned} & v^{-}\left(x;a,b\right)=-\left(c^{+}+c^{-}\right)\frac{\exp\rho_{1}\left(x-b\right)-\exp\rho_{2}\left(x-b\right)}{\exp\rho_{1}\left(b-a\right)-\exp\rho_{2}\left(b-a\right)}\\ & +\frac{\left(h-rc^{+}\right)\exp-\left(\rho_{1}+\rho_{2}\right)b}{r\left(\exp\rho_{1}\left(b-a\right)-\exp\rho_{2}\left(b-a\right)\right)}\left(\exp\left(\rho_{1}x+\rho_{2}a\right)-\exp\left(\rho_{2}x+\rho_{1}a\right)\right)\\ & +\frac{\left(p+h\right)\left(\exp\left(\rho_{1}x+\rho_{2}a\right)-\exp\left(\rho_{2}x+\rho_{1}a\right)\right)\left(\rho_{2}\exp-\rho_{2}b-\rho_{1}\exp-\rho_{1}b\right)}{r\left(\rho_{1}-\rho_{2}\right)\left(\exp\rho_{1}\left(a-b\right)-\exp\rho_{2}\left(a-b\right)\right)}\\ & +\frac{p+rc^{-}}{r}\frac{\left(\exp\rho_{1}\left(x-b\right)-\exp\rho_{2}\left(x-b\right)-\exp\rho_{1}\left(a-b\right)+\exp\rho_{2}\left(a-b\right)\right)}{\exp\rho_{1}\left(b-a\right)-\exp\rho_{2}\left(b-a\right)}\end{aligned} \label{eq:still one lable}

\end_inset

\end_layout

\end_body
\end_document