a x + ... + a x = b i e {1, ..., n} (13)
i1 1 in n i
q x + ... + q x = b i e {1, ..., n} (14)
i1 1 in n i
In other words, I want the elements in the matrix to align properly, I want
the equals signs to match up, and I want the right hand sides to align. I
also want the "for all" stuff to align properly, and I want the equations
to be numbered.
I have found that the "array" environment *almost* suits my needs, but not
quite. You can't (to my knowledge) get automatic equation numbering within
the array environment. If you use "eqnarray", the equal signs align, the
numbering works properly, but the equations themselves do not align on the
left sides, nor can you get the "for all" stuff to align easily.
Suggestions, anyone? Thanks in advance.
Gregory Glockner
Graduate Research Assistant gloc...@isye.gatech.edu
Logistics Optimization Center (404) 894-2366 (w)
School of ISyE, Georgia Inst. of Technology (404) 634-8855 (h)
To get this, you could use the following:
\documentstyle{article}
%
\newcommand{\eqnnum}{\refstepcounter{equation}\hfill(\theequation)}
%
\begin{document}
\[
\begin{array}{l@{\;+\:\ldots\:+\;}l@{\;=\;}l@{\hspace{1cm}}lp{3cm}}
a_{i1} x_1 & a_{in} x_n & b_i & i \in \{ 1, \ldots, n\} & \eqnnum \\
q_{i1} x_1 & q_{in} x_n & b_i & i \in \{ 1, \ldots, n\} & \eqnnum
\end{array}
\]
\end{document}
That is not fully satisfying, but seems to be elegant enough.
You might want to adjust the spacings.
Matthias Prinz
--
Matthias
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ Derek Holmes dho...@engin.umich.edu ++ 1205 Beal Ave., +++
+++ Ind. & Operations Eng., Univ. of Michigan ++ Ann Arbor, MI 48109-2117 +++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TK
---
Tom Keyser, Industrial Engineering Department
Clemson University - Office: Freeman 125
Phone: (803)-654-4718
Reply to any of the following: tke...@eng.clemson.edu
tke...@clemson.clemson.edu
**************************************************************************
* Paul A. Rubin Phone: (517) 336-3509 *
* Department of Management Fax: (517) 336-1111 *
* Eli Broad Graduate School of Management Net: RU...@MSU.EDU *
* Michigan State University *
* East Lansing, MI 48824-1122 (USA) *
**************************************************************************
Another solution is a little style file that I wrote called optprog.sty
which create the optprog and optprog* environments for defining optimization
problems (subject to my own personal layout preferences). To use it, place
optprog.sty and specify it as an optional argument. Here is a little sample
for using it.
--
\documentstyle[optprog]{article}
\begin{document}
Here is an example of its usage on a LP:
\begin{optprog}
\optaction[x_i]{Maximize} & \objective{Z = \sum_{j=1}^n c_j x_j} \label{obj}\\
subject to & \sum_{j=1}^n a_{ij} x_j & \leq & b_i & i=1\ldots{}m \label{cons1} \\
and & x_i & \geq & 0 & j=1\ldots{}n \label{cons2}
\end{optprog}
\end{document}
--
And here is the style file:
-- Cut here and save as optprog.sty
% optprog.sty
% <14 Apr 93> Bob Bowerman (bowe...@dial.uwaterloo.ca)
%
% This file defines the optprog environment and is just a hacked up
% version of the eqnarray environment designed for use with optimization
% problems. Instead of just 3 columns optprog lays out 7 columns set up as
% follows: rrcllll. The overall environment is set in displaystyle with
% the first column being defined as normal text. The first column is
% intended for text associated with the specification of the optimization
% program such as `Minimize' or `subject to'. The second, third, and fourth
% columns are intended for the lhs, operator, and rhs of the constraints.
% The fifth, sixth, and seventh columns are intended for defining the range
% for the indices of the constraints. The columns are centred between the
% left and right margins and both the objective function and the
% constraints are numbered.
%
% As well several utility macros are defined.
% \objective{#1} Typesets the objective function. Left
% aligns the objective function over the last 6 columns.
% \optaction[#2]{#1} Sets #2 in mathmode underneath #1 which is shown in
% text, e.g. \optarg[x_i]{Mimimize} puts $x_i$ directly underneath Minimize
%
% The optprog* environment is defined which does not include
% equation numbers. As well, \nonumber suppresses the equation number for
% a single line.
%
% Here is an example of its usage on a LP:
% \begin{optprog}
% \optaction[x_i]{Maximize} & \objective{Z = \sum_{j=1}^n c_j x_j} \label{obj}\\
% subject to & \sum_{j=1}^n a_{ij} x_j & \leq & b_i & i=1\ldots{}m \label{cons1} \\
% and & x_i & \geq & 0 & j=1\ldots{}n \label{cons2}
% \end{optprog}
\immediate\write\sixt@@n{Optprog Environment defined <14 Apr 93>}
\chardef\f@ur=4
\chardef\f@ve=5
\chardef\s@x=6
\def\@optprog{\stepcounter{equation}\let\@currentlabel\theequation
\global\@eqnswtrue\m@th
\global\@eqcnt\z@\tabskip\@centering\let\\\@prbspcr
$$\halign to\displaywidth\bgroup
\hfil\hskip\@centering \hbox{\tabskip\z@{##}}&
\global\@eqcnt\@ne\hskip 2\arraycolsep \hfill\hskip\@centering $\displaystyle\tabskip\z@{##}$&
\global\@eqcnt\tw@\hskip \arraycolsep \hfill${##}$\hfill&
\global\@eqcnt\thr@@\hskip \arraycolsep
$\displaystyle\tabskip\z@{##}$&
\global\@eqcnt\f@ur\hskip 2\arraycolsep
$\displaystyle\tabskip\z@{##}$&
\global\@eqcnt\f@ve\hskip 2\arraycolsep
$\displaystyle\tabskip\z@{##}$&
\global\@eqcnt\s@x\hskip 2\arraycolsep
$\displaystyle\tabskip\z@{##}$\hfil\tabskip\@centering&
\llap{##}\tabskip\z@\cr}
\def\endoptprog{\@@prbspcr\egroup
\global\advance\c@equation\m@ne$$\global\@ignoretrue}
\def\objective#1{\multispan{6} \global\@eqcnt\s@x\hskip \arraycolsep
$\displaystyle\tabskip\z@{#1}$\hfil\tabskip\@centering}
\def\optaction[#1]#2{\mbox{$\displaystyle\mathrel{\mathop{\hbox{#2}}\limits_{\textstyle#1}}$}}
\def\@prbspcr{{\ifnum0=`}\fi\@ifstar{\global\@eqpen\@M
\@yprbspcr}{\global\@eqpen\interdisplaylinepenalty \@yprbspcr}}
\def\@yprbspcr{\@ifnextchar [{\@xprbspcr}{\@xprbspcr[\z@]}}
\def\@xprbspcr[#1]{\ifnum0=`{\fi}\@@prbspcr
\noalign{\penalty\@eqpen\vskip\jot\vskip #1\relax}}
\def\@@prbspcr{\let\@tempa\relax
\ifcase\@eqcnt \def\@tempa{& & & & & &}\or \def\@tempa{& & & & & &}
\or \def\@tempa{& & & & &} \or \def\@tempa{& & & &}
\or \def\@tempa{& & &} \or \def\@tempa{& &}
\else \def\@tempa{&}\fi
\@tempa \if@eqnsw\@eqnnum\stepcounter{equation}\fi
\global\@eqnswtrue\global\@eqcnt\z@\cr}
% Here's the optprog* environment:
\let\@sprbspcr=\@prbspcr
\@namedef{optprog*}{\def\@prbspcr{\nonumber\@sprbspcr}\optprog}
\@namedef{endoptprog*}{\nonumber\endoptprog}
\def\optprog{\@ifnextchar [{\@optprog1}{\@optprog}}
-- Cut here
I hope people find this of use.
Cheers,
Bob
--
Bob Bowerman
Department of Systems Design Engineering | Phone: (519)885-1211 x5194
University of Waterloo | Fax: (519)746-4791
Waterloo, ON N2L 3G1 | Email: bowe...@dial.uwaterloo.ca
,.;. squirrels: a source of campus nutrition
|\__/| .~ ~.
/o=o'`./ .' recipe for squirrel au vin:
{o__, \ { ingredients:
/ . . ) \ 1 squirrel (remove hair)
`-` '-' \ } 1 bottle of Andres Baby Duck
.( _( )_.' to prepare:
:. '---.~_ _ _| Get really drunk, eat the squirrel.