texlive[41551] Master/texmf-dist: optidef (27jun16)

commits+karl at tug.org commits+karl at tug.org
Mon Jun 27 22:38:25 CEST 2016


Revision: 41551
          http://tug.org/svn/texlive?view=revision&revision=41551
Author:   karl
Date:     2016-06-27 22:38:25 +0200 (Mon, 27 Jun 2016)
Log Message:
-----------
optidef (27jun16)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/optidef/README.md
    trunk/Master/texmf-dist/doc/latex/optidef/optidef.pdf
    trunk/Master/texmf-dist/doc/latex/optidef/optidef.tex
    trunk/Master/texmf-dist/tex/latex/optidef/optidef.sty

Modified: trunk/Master/texmf-dist/doc/latex/optidef/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/optidef/README.md	2016-06-27 20:38:13 UTC (rev 41550)
+++ trunk/Master/texmf-dist/doc/latex/optidef/README.md	2016-06-27 20:38:25 UTC (rev 41551)
@@ -2,15 +2,16 @@
 
 Optidef is a small library that provides a standard set of environments for writing optimization problems. 
 
-## Features:
 
+## Features
+
 The most important features are:
 
 - It automatically aligns the problems in the most convenient way allowing even two different output formats:
    * Beginning of the words "minimize/argmin" and "subject to"
    * Double format for the location of the constraints: either to the right of  subject to aligned with the objective function or below subject to.
-   * The $= | > | <$ signs of the constraints.
-   * Optionally, the user can add manually a double align character \&\& to align some common constraints feature. A clear example could be the constraints names, e.g. (boundary constraint) alignment with (dynamic constraint), or the index of the constraints, e.g. in the case of having something like $h(x_k,u_k)\leq 0,\quad k=0,\ldots,N$, align the indexes $k=0,\ldots,N$ across constraint lines.
+   * The =, > and < signs of the constraints.
+   * Optionally, an alignment point for some constraints features. An example could be the constraints names, e.g. align (boundary constraint) with (dynamic constraint), or the index of the constraints, e.g. in the case of having something like h(xk,uk) < 0, k=0, ...,N, the third alignment point can align the constraint indexes k=0, ...,N across different constraint lines.
 
 
 - It provides an easy interface to define optimization problem for three different reference situations:
@@ -25,9 +26,13 @@
    * maximize
    * arg mini
    * arg maxi
- 
 
-## Syntax:
+## Usage
+
+Import the package by directly adding \usepackage{optidef} to your LaTeX document. Consult the documentation for different examples and syntax usage.
+
+
+## Syntax
     
 The syntax to define an optimization problem is given by:
  
@@ -35,12 +40,13 @@
             {Optimization variable}
             {Objective function \label{Objective function referece}}
             {\label{Global referece of Optimization Problem}}  
-            {Result of the optimization problem or any expression on the left of the minimize word}
-            \addConstraint{LHS Constraint 1}{RHS Constraint 1 \label{Reference Constraint 1}}
-            \addConstraint{LHS Constraint 2}{RHS Constraint 2 \label{Reference Constraint 2}}
+            {Result of the optimization problem or any expression on the left
+            of the minimize word}
+            \addConstraint{LHS Constraint 1}{RHS Constraint 1 \label{Reference Constraint 1}}{Extra Info Constraint 1}
+            \addConstraint{LHS Constraint 2}{RHS Constraint 2 \label{Reference Constraint 2}}{Extra Info Constraint 2}
             .
             .
-            \addConstraint{LHS N}  {RHSConstraint N \label{Reference Constraint N}}
+            \addConstraint{LHS N}{RHSConstraint N \label{Reference Constraint N}}{Extra Info Constraint N}
         \end{mini#}
 
 
@@ -57,12 +63,18 @@
 
 Finally note that \begin{mini#} can be substituted by \begin{maxi#}, \begin{argmini#} or \begin{argmaxi#}. 
 
-## Contact:
+## Contact for issue reporting or suggestions
 
 E-mail: jesus.lago.garcia at venus.uni-freiburg.de
 
-## Licensing:
+Github: https://github.com/jeslago/optidef
 
+## Latest stable version: Optidef 1.1
+
+CTAN: https://www.ctan.org/pkg/optidef
+
+## Licensing
+
 Copyright 2016 Jesus Lago Garcia
 
 This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 of this license or (at your option) any later version.

Modified: trunk/Master/texmf-dist/doc/latex/optidef/optidef.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/optidef/optidef.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/optidef/optidef.tex	2016-06-27 20:38:13 UTC (rev 41550)
+++ trunk/Master/texmf-dist/doc/latex/optidef/optidef.tex	2016-06-27 20:38:25 UTC (rev 41551)
@@ -1,9 +1,10 @@
 \documentclass[]{report}
 \usepackage{remreset}
 \usepackage{optidef}
+\usepackage{listings}
 
 % Title Page
-\title{\textit{\textbf{Optidef}} \\ A Latex library for optimization problems\\ \textnormal{Version - 1.0}}
+\title{\textit{\textbf{Optidef}} \\ A Latex library for optimization problems\\ \textnormal{Version - 1.1}}
 
 \author{Jesus Lago Garcia}
 
@@ -20,12 +21,37 @@
 
 This small library provides a standard set of environments for writing minimization problems. The most important features are:
 \begin{enumerate}
-	\item It automatically aligns the problems in the most convenient way allowing even two different output formats:
+	\item It automatically aligns the problems in the most convenient way allowing different output formats:
 		\begin{enumerate}
-			\item Alignment at the beginning of the words \textit{minimize/argmin} and \textit{subject to}.
+			\item Alignment at the beginning of the words \textit{minimize/argmin} and \textit{subject to}:
+					\begin{mini*}
+						{w}{f(w)+ R(w+6x)}
+						{\label{eq:Ex1}}{}
+						\addConstraint{g(w)}{=0}
+					\end{mini*}
 			\item Double format for the location of the constraints: either to the right of  \textit{subject to} aligned with the objective function or below \textit{subject to}.
-			\item Alignment at the $=,~>,~<$ signs of the constraints.
-			\item Optionally, the user can add manually a double align character \&\& to align some common constraints feature. A clear example could be the constraints names, e.g. (boundary constraint) alignment with (dynamic constraint), or the index of the constraints, e.g. in the case of having something like $h(x_k,u_k)\leq 0,\quad k=0,\ldots,N$, align the indexes $k=0,\ldots,N$ across constraint lines.
+			\item Optional alignment at the $=,~>,~<$ signs of the constraints.
+								\begin{mini*}
+									{w}{f(w)+ R(w+6x)}
+									{\label{eq:Ex1}}{}
+									\addConstraint{g(w)+h(w)}{=0}
+									\addConstraint{l(w)}{=5w.}
+								\end{mini*}
+			\item Optionally, the user can add a third alignment point on the constraints to set some constraint features. A clear example could be the constraints names:
+						\begin{mini*}
+							{w}{f(w)+ R(w+6x)}
+							{\label{eq:Ex1}}{}
+							\addConstraint{g(w)+h(w)}{=0,}{\text{(Topological Constraint)}}
+							\addConstraint{l(w)}{=5w,\quad}{\text{(Boundary Constraint)}}
+						\end{mini*}
+			
+			or the index of the constraints:
+						\begin{mini*}
+							{w,u}{f(w)+ R(w+6x)}
+							{\label{eq:Ex1}}{}
+							\addConstraint{g(w_k)+h(w_k)}{=0,}{k=0,\ldots,N-1}
+							\addConstraint{l(w_k)}{=5u,\quad}{k=0,\ldots,N-1}
+						\end{mini*}
 		\end{enumerate}
 
 \item It provides an easy interface to define optimization problem for three different reference situations:
@@ -38,7 +64,6 @@
 \item It also allows a definition of any optimization problem without a limitless number of constraints.
 
 \end{enumerate}
-
 \section{Environment types}
 There are three basic environments depending on the type of referencing that should be used.
 \begin{enumerate}
@@ -62,25 +87,42 @@
 			\end{mini!}		
 \end{enumerate}
 
-\section{Environment types}
-There are two basic output formats. By default the constraints are aligned with the objective function and to the right of \textit{subject to}. However the user can choose to locate them below \textit{subject to}.
-\begin{enumerate}
-	\item Standard format:
-	\begin{mini}
-		{w}{f(w)+ R(w+6x)}
-		{\label{eq:Ex1}}{}
-		\addConstraint{g(w)}{=0}
-	\end{mini}
-	\item Alternative format:
-	\begin{mini}[1]
-		{w}{f(w)+ R(w+6x)}
-		{\label{eq:Ex1}}{}
-		\addConstraint{g(w)}{=0}
-	\end{mini}
-\end{enumerate}
-
+\section{Output formats}
+\label{sec:format}
+There are four basic output formats. 
+ \begin{enumerate}
+ 	\item \textbf{Standard format}: by default the constraints are aligned with the objective function, to the right of \textit{subject to} and with a second alignment point at the $=,~\leq,~\geq$:
+ 	\begin{mini}
+ 		{w}{f(w)+ R(w+6x)}
+ 		{\label{eq:Ex1}}{}
+ 		\addConstraint{g(w)+h(w)}{=0}
+ 		\addConstraint{t(w)}{=0.}
+ 	\end{mini}
+ 	\item \textbf{Alternative 1}: a possible variation is to locate the constraints below \textit{subject to}:
+ 	\begin{mini}[1]
+ 		{w}{f(w)+ R(w+6x)}
+ 		{\label{eq:Ex1}}{}
+ 		\addConstraint{g(w)+h(w)}{=0}
+ 		\addConstraint{t(w)}{=0.}
+ 	\end{mini}
+ 	\item \textbf{Alternative 2}: a second variation is to copletely remove the second alignment point:
+ 	\begin{mini}[2]
+ 		{w}{f(w)+ R(w+6x)}
+ 		{\label{eq:Ex1}}{}
+ 		\addConstraint{g(w)+h(w)}{=0}
+ 		\addConstraint{t(w)}{=0.}
+ 	\end{mini} 	
+ 	\item \textbf{Alternative 3}: a third variation would be the combination of both of them:
+ 	\begin{mini}[3]
+ 		{w}{f(w)+ R(w+6x)}
+ 		{\label{eq:Ex1}}{}
+ 		\addConstraint{g(w)+h(w)}{=0}
+ 		\addConstraint{t(w)}{=0.}
+ 	\end{mini} 	
+ \end{enumerate}
+ 
 \section{Environment Syntaxes}
-The three environments use the same syntax with the same number of parameters. In particular, considering that LHS stands for Left-hand-side and RHS for Right-hand-side, the basic structure to define a general optimization problem is:
+The three environments use the same syntax with the same number of parameters. In particular, considering that \textit{Const} stands for constraint ,\textit{LHS} stands for Left-hand-side and \textit{RHS} for Right-hand-side, the basic structure to define a general optimization problem is:
 \begin{verbatim}
 
 \begin{mini#}[Format]
@@ -90,11 +132,14 @@
    {Result of the optimization problem or any expression on 
    the left of the minimize word}
 
-   \addConstraint{LHS Constraint 1}{RHS Constraint 1 \label{Reference Constraint 1}}
-   \addConstraint{LHS Constraint 2}{RHS Constraint 2 \label{Reference Constraint 2}}
+   \addConstraint{LHS Const 1}{RHS Const 1 \label{Reference
+    Const 1}}{Extra Const 1 Info}
+   \addConstraint{LHS Const 2}{RHS Const 2 \label{Reference
+    Constraint 2}}{Extra Const 2 Info}
    .
    .
-   \addConstraint{LHS N}{RHSConstraint N \label{Reference Constraint N}}
+   \addConstraint{LHS N}{RHS Const N \label{Reference 
+   Const N}}{Extra Const N Info}
 \end{mini#}
 \end{verbatim}
 
@@ -107,7 +152,13 @@
 	\item \verb|Objective function|, e.g. $\|w\|_2$.
 	\item \verb|\label{Global referece of Optimization Problem}|: it defines the main and general reference for the optimization problem. It is used for the \verb|mini| and \verb|mini!| enviroments. In the \verb|mini*| environment leave it blank, i.e. \{\}.   
 	\item \verb|Result of the optimization problem|: optionally a term expressing the result of the optimization problem, e.g. $J(w^*)~=$.
-	\item \verb|Format|: optional parameter if the user want to start the constraints right below \textit{subject to}, instead to the default location on the right of \textit{subject to}.
+	\item \verb|Format|: optional parameter to change the format of the constraints. By default the constraints are located at the right of \textit{subject to} and aligned on the $=,\leq,\geq$ signs. However, as represented in Section \ref{sec:format}), the following variations are possible:
+	\begin{enumerate}
+		\item If Format=1: same alignment as the default format but the constraints appear right below \textit{subject to}. Check  Alternative 1 in Section \ref{sec:format}).
+		\item If Format=2: constraints are located on the right of \textit{subject to} but left aligned. Check  Alternative 2 in Section \ref{sec:format}).
+		\item If Format=3: constraints are located below \textit{subject to} but left aligned. Check  Alternative 3 in Section \ref{sec:format}).
+	\end{enumerate}
+
 \end{enumerate}
 
 \noindent Notice that only the first two mandatory parameters (variable and objective) will be really necessary in every definition, nevertheless and for the sake of having homogeneous definitions, we opted for requiring the 4 parameters in every definition and expecting empty parameters definitions, i.e. \{\}, when they are not needed.
@@ -119,12 +170,15 @@
 \verb|\addConstraint{LHS Constraint k}|
 
 \verb|{RHS Constraint k \label{Reference Constraint k}}| 
+
+\verb|{Extra Infor Contraint k}| 
 ~\\
 
 \noindent has to be used, where:
 \begin{enumerate}
 	\item \verb|LHS Constraint|: the left-hand side of the any constraint, e.g. $3w^\top w$.
-	\item \verb|RHS Constraint|: the right-hand side of the first constraints including the equal, less and greater signs, e.g. $\leq \|w\|_\infty$, as well as the constraint label.
+	\item \verb|RHS Constraint|: the right-hand side of the first constraints including the equal, less and greater signs, e.g. $\leq \|w\|_\infty$, as well as the constraint label.\textbf{ Keep in mind that this parameter is optional and if not included or leave it blank all the constraints will be aligned to the left (See alternative format 2 and 3 in Section \ref{sec:format}).}
+	\item \verb|Extra Info|: optional parameter to add extra info such as contraints set definition or constraint name. Look Example 8 or the fourth described feature in Section 1.
 \end{enumerate}
 
 \subsubsection{Constraints referencing}
@@ -264,19 +318,73 @@
 	\addConstraint{h(x)}{=0.}
 \end{mini}
 
+\subsubsection{Example 6 - third format}
 
-\subsubsection{Example 6 - mini* + extra constraint alignment}
+\noindent If including a 2 as optional parameter, the constraint will appear to the right of  \textit{subject to} but a single alignment point.
+
+\begin{verbatim}
+\begin{mini}[2]
+{w}{f(w)+ R(w+6x)}
+{\label{eq:Example1}}
+{}
+
+\addConstraint{g(w)}{=0}
+\addConstraint{n(w)}{= 6}
+\addConstraint{L(w)+r(x)}{=Kw+p}
+\addConstraint{h(x)}{=0.}
+\end{mini}
+\end{verbatim}
+
+\noindent outputs:
+
+\begin{mini}[2]
+	{w}{f(w)+ R(w+6x)}
+	{\label{eq:Ex1}}{}
+	\addConstraint{g(w)}{=0}
+	\addConstraint{n(w)}{= 6}
+	\addConstraint{L(w)+r(x)}{=Kw+p}
+	\addConstraint{h(x)}{=0.}
+\end{mini}
+
+\subsubsection{Example 7 - fourth format}
+
+\noindent If including a 3 as optional parameter, the first constraint will appear aligned to the left right below \textit{subject to} and with a single alignment point.
+
+\begin{verbatim}
+\begin{mini}[3]
+{w}{f(w)+ R(w+6x)}
+{\label{eq:Example1}}
+{}
+
+\addConstraint{g(w)}{=0}
+\addConstraint{n(w)}{= 6}
+\addConstraint{L(w)+r(x)}{=Kw+p}
+\addConstraint{h(x)}{=0.}
+\end{mini}
+\end{verbatim}
+
+\noindent outputs:
+
+\begin{mini}[3]
+	{w}{f(w)+ R(w+6x)}
+	{\label{eq:Ex1}}{}
+	\addConstraint{g(w)}{=0}
+	\addConstraint{n(w)}{= 6}
+	\addConstraint{L(w)+r(x)}{=Kw+p}
+	\addConstraint{h(x)}{=0.}
+\end{mini}
+
+\subsubsection{Example 8 - mini* + extra constraint alignment}
 Adding the fourth optional alignment to add constraint names:
 
 \begin{verbatim}
 \begin{mini*}
-{w}{f(w)+ R(w+6x)}
-{}{}
-
-\addConstraint{g(w)}{=0, \quad && \text{(Dynamic constraint)}}
-\addConstraint{n(w)}{= 6, \quad && \text{(Boundary constraint)}}
-\addConstraint{L(w)+r(x)}{=Kw+p, \quad && \text{(Random constraint)}}
-\addConstraint{h(x)}{=0.\quad && \text{(Path constraint)}}  
+	{w}{f(w)+ R(w+6x)}
+	{}{}
+	\addConstraint{g(w)}{=0,}{ \quad  \text{(Dynamic constraint)}}
+	\addConstraint{n(w)}{= 6,}{ \quad  \text{(Boundary constraint)}}
+	\addConstraint{L(w)+r(x)}{=Kw+p,}{ \quad  \text{(Random constraint)}}
+	\addConstraint{h(x)}{=0,}{ \quad  \text{(Path constraint).}}
 \end{mini*}
 \end{verbatim}
 
@@ -284,10 +392,10 @@
 \begin{mini*}
 	{w}{f(w)+ R(w+6x)}
 	{}{}
-	\addConstraint{g(w)}{=0, \quad && \text{(Dynamic constraint)}}
-	\addConstraint{n(w)}{= 6, \quad && \text{(Boundary constraint)}}
-	\addConstraint{L(w)+r(x)}{=Kw+p, \quad && \text{(Random constraint)}}
-	\addConstraint{h(x)}{=0. \quad && \text{(Path constraint).}}
+	\addConstraint{g(w)}{=0,}{ \quad  \text{(Dynamic constraint)}}
+	\addConstraint{n(w)}{= 6,}{ \quad  \text{(Boundary constraint)}}
+	\addConstraint{L(w)+r(x)}{=Kw+p,}{ \quad  \text{(Random constraint)}}
+	\addConstraint{h(x)}{=0,}{ \quad  \text{(Path constraint).}}
 \end{mini*}
 
 
@@ -407,26 +515,32 @@
 
 \section{Code definition}
 \begin{verbatim}
-% optidef - Version 08/06/2016
-%
+%optidef - Version 1.1
 %Copyright 2016 J. Lago Garcia
-%
-%This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 of this license or (at your option) any later version.
-%The latest version of this license is in http://www.latex-project.org/lppl.txt and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later.
-%
-%This work has the LPPL maintenance status 'maintained'. The Current Maintainer of this work is J. Lago Garcia, under the supervision of Prof. Dr. Moritz Diehl and Prof. Dr. Sebastien Gross.
-%
+
+%This work may be distributed and/or modified under the conditions of the LaTeX
+%Project Public License, either version 1.3 of this license or (at your option) any 
+%later version.
+%The latest version of this license is in http://www.latex-project.org/lppl.txt and 
+version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or 
+%later.
+
+%This work has the LPPL maintenance status 'maintained'. The Current Maintainer 
+% of this work is J. Lago Garcia, under the supervision of Prof. Dr. Moritz Diehl 
+%and Prof. Dr. Sebastien Gross.
+
 %E-mail: jesus.lago.garcia at venus.uni-freiburg.de
-%
+
 %This work consists of the file optidef.sty.
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{optidef}[2016/06/06 Package for defining optimization problems]
+\ProvidesPackage{optidef}[2016/06/26 - version=1.1,  Package for defining optimization problems]
 
 \RequirePackage{environ}
 \RequirePackage{mathtools}	
 \RequirePackage{xifthen}	
 \RequirePackage{etoolbox}	
+\RequirePackage{xparse}	
 \newtoggle{bodyCon}
 \toggletrue{bodyCon}
 
@@ -433,34 +547,100 @@
 % Input minimization evironments
 
 % Macros for objective definition, constraint definition and extra constraint definition
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% % -------- DEFINITION COMMAND OBJECTIVE  -----------
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \newcommand{\bodyobj}[4]
 {
 \ifthenelse{\isempty{#4}}
 {
-&\underset{\displaystyle #1}{\mbox{#3}} \quad #2\span\span\span\span
+&\underset{\displaystyle #1}{\mathrm{#3}} \quad #2\span\span\span\span
 }
 {
-#4 ~~ &\underset{\displaystyle #1}{\mbox{#3}} \quad #2\span\span\span\span
+#4 ~~ &\underset{\displaystyle #1}{\mathrm{#3}} \quad #2\span\span\span\span
 }
 }
 
 
-\newcommand{\bodyconst}[2]
-{\\ &\text{subject to} \quad &#1 & #2}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%  -------- DEFINITION DIFFERENT TYPE OF BODY CONSTRAINTS  --------%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-\newcommand{\bodyconstRight}[2]
-{\\ &\text{subject to} \quad &#1 & #2}
+\DeclareDocumentCommand{\bodyconst}{m G{}}
+{	\ifthenelse{\equal{#2}{}}{
+\\ &\mathrm{subject~to} \quad &&#1 #2
+}{
+\\ &\mathrm{subject~to} \quad &#1 & #2
+}
+}
 
-\newcommand{\bodyconstBelow}[2]
-{\\ &\text{subject to} \span\span \\
-&\quad&#1 & #2}
+% Standard version
+\DeclareDocumentCommand{\bodyconstRight}{m G{}}
+{	\ifthenelse{\equal{#2}{}}{
+\\ &\mathrm{subject~to} \quad &&#1 #2
+}{
+\\ &\mathrm{subject~to} \quad &#1 & #2
+}
+}
 
-\newcommand{\bodyconstBelowMult}[2]
-{\\ &\text{subject to} \span\span\span\span \nonumber \\
-&\quad&#1 & #2}
+% Single alignment point
+\DeclareDocumentCommand{\bodyconstOneAlign}{m G{}}
+{
+\\ &\mathrm{subject~to} \quad &&#1 #2
+}
 
-\newcommand{\addConstraint}[2]{
+% Contraints below subject to and with a single alignment point
+\DeclareDocumentCommand{\bodyconstOneAlignBelow}{m G{}}
+{
+\\ &\mathrm{subject~to} \span\span \\
+&&&#1 #2		
+}
+
+% Contraints below subject to
+\DeclareDocumentCommand{\bodyconstBelow}{m G{}}
+{	\ifthenelse{\equal{#2}{}}{
+\\ &\mathrm{subject~to} \span\span\span\span \\
+&&&#1 #2		
+}{
+\\ &\mathrm{subject~to} \span\span\span\span \\
+&&#1 & #2
+}
+}
+
+% Contraints below subject to for the case of having multiple equations
+\DeclareDocumentCommand{\bodyconstBelowMult}{m G{}}
+{	\ifthenelse{\equal{#2}{}}{
+\\ &\mathrm{subject~to} \span\span\span\span \nonumber \\
+&&&#1 #2		
+}{
+\\ &\mathrm{subject~to} \span\span\span\span \nonumber \\
+&&#1 & #2
+}
+}
+
+% Contraints below subject to and with a single alignment point for the case of having several equations
+\DeclareDocumentCommand{\bodyconstOneAlignBelowMult}{m G{}}
+{
+\\ &\mathrm{subject~to} \span\span\span\span \nonumber \\
+&&&#1 #2		
+}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%  -------- DEFINITION DIFFERENT TYPE OF ADDING CONSTRAINTS  --- --%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\DeclareDocumentCommand{\addConstraint}{m G{} G{}}{
+\ifthenelse{\equal{#2}{}}{
 \iftoggle{bodyCon}{
+\bodyconst{#1}
+\togglefalse{bodyCon}
+}{
+,\\&\quad &&#1 #2
+\togglefalse{bodyCon}
+}
+}{
+\iftoggle{bodyCon}{
 \bodyconst{#1}{#2}
 \togglefalse{bodyCon}
 }{
@@ -468,7 +648,85 @@
 \togglefalse{bodyCon}
 }
 }
+}
 
+% Standard version of adding constraints
+\DeclareDocumentCommand{\standardAddConstraint}{m G{} G{}}{
+\iftoggle{bodyCon}{
+\bodyconstRight{#1}{#2}
+\togglefalse{bodyCon}
+}{
+\ifthenelse{\equal{#2}{}}{
+,\\&\quad &&#1 #2
+}{
+,\\&\quad &#1 & #2
+}
+\togglefalse{bodyCon}
+}
+}
+
+% Adding constraints below subject to
+\DeclareDocumentCommand{\BelowAddConstraint}{m G{} G{}}{
+\iftoggle{bodyCon}{
+\bodyconstBelow{#1}{#2}
+\togglefalse{bodyCon}
+}{
+\ifthenelse{\equal{#2}{}}{
+,\\&&&#1  #2
+}{
+,\\ &&#1  &#2}
+\togglefalse{bodyCon}
+}
+}
+
+% Adding constraints for a single alignment point
+\DeclareDocumentCommand{\oneAlignAddConstraint}{m G{} G{}}{
+\iftoggle{bodyCon}{
+\bodyconstOneAlign{#1}{#2}
+\togglefalse{bodyCon}
+}{
+,\\&\quad &&#1  #2
+\togglefalse{bodyCon}
+}
+}
+
+% Adding constraints for a single alignment point and with the constraints below
+\DeclareDocumentCommand{\oneAlignBelowAddConstraint}{m G{} G{}}{
+\iftoggle{bodyCon}{
+\bodyconstOneAlignBelow{#1}{#2}
+\togglefalse{bodyCon}
+}{
+,\\& &&#1  #2
+\togglefalse{bodyCon}
+}
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%  ------------- SELECTING TYPE OF FORMAT  -----------%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newcommand{\selectConstraint}[1]{
+\ifthenelse{\equal{#1}{1}}{
+\let\addConstraint\BelowAddConstraint
+}{
+\ifthenelse{\equal{#1}{2}}{
+\let\addConstraint\oneAlignAddConstraint
+}{
+\ifthenelse{\equal{#1}{3}}{
+\let\addConstraint\oneAlignBelowAddConstraint
+}{}
+}
+}
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%  ------------- SETTING DEFAULT FORMAT  -------------%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newcommand{\setStandardMini}{
+\toggletrue{bodyCon}
+\let\addConstraint\standardAddConstraint	
+}
+
+
 \newcommand{\breakObjectiveOneConstraint}[1]{&&&#1\\}
 
 
@@ -476,9 +734,7 @@
 %MINIMIZATION ENVIRONMENTS
 
 \NewEnviron{mini}[5][]{%
-\ifthenelse{\equal{#1}{1}}{
-\let\bodyconst\bodyconstBelow
-}{}
+\selectConstraint{#1}
 \begin{equation}
 #4
 \begin{alignedat}{4}
@@ -486,14 +742,11 @@
 \BODY
 \end{alignedat}
 \end{equation}
-\toggletrue{bodyCon}
-\let\bodyconst\bodyconstRight
+\setStandardMini
 }
 
 \NewEnviron{argmini}[5][]{%
-\ifthenelse{\equal{#1}{1}}{
-\let\bodyconst\bodyconstBelow
-}{}
+\selectConstraint{#1}
 \begin{equation}
 #4
 \begin{alignedat}{4}
@@ -501,12 +754,11 @@
 \BODY
 \end{alignedat}
 \end{equation}
+\setStandardMini
 }
 
 \NewEnviron{mini*}[5][]{%
-\ifthenelse{\equal{#1}{1}}{
-\let\bodyconst\bodyconstBelow
-}{}
+\selectConstraint{#1}
 \begin{equation*}
 #4
 \begin{alignedat}{4}
@@ -514,14 +766,11 @@
 \BODY
 \end{alignedat}
 \end{equation*}
-\toggletrue{bodyCon}
-\let\bodyconst\bodyconstRight
+\setStandardMini
 }
 
 \NewEnviron{argmini*}[5][]{%
-\ifthenelse{\equal{#1}{1}}{
-\let\bodyconst\bodyconstBelow
-}{}
+\selectConstraint{#1}
 \begin{equation*}
 #4
 \begin{alignedat}{4}
@@ -529,6 +778,7 @@
 \BODY
 \end{alignedat}
 \end{equation*}
+\setStandardMini	
 }
 
 
@@ -543,8 +793,7 @@
 \BODY
 \end{alignat}
 \end{subequations}
-\toggletrue{bodyCon}
-\let\bodyconst\bodyconstRight		
+\setStandardMini
 }
 
 \NewEnviron{argmini!}[5][]{%
@@ -557,15 +806,14 @@
 \bodyobj{#2}{#3}{arg min}{#5}
 \BODY
 \end{alignat}
-\end{subequations}			
+\end{subequations}	
+\setStandardMini		
 }
 
 %MAXIMIZATION ENVIRONMENTS
 
 \NewEnviron{maxi}[5][]{%
-\ifthenelse{\equal{#1}{1}}{
-\let\bodyconst\bodyconstBelow
-}{}
+\selectConstraint{#1}
 \begin{equation}
 #4
 \begin{alignedat}{4}
@@ -573,12 +821,11 @@
 \BODY
 \end{alignedat}
 \end{equation}
+\setStandardMini
 }
 
 \NewEnviron{argmaxi}[5][]{%
-\ifthenelse{\equal{#1}{1}}{
-\let\bodyconst\bodyconstBelow
-}{}
+\selectConstraint{#1}
 \begin{equation}
 #4
 \begin{alignedat}{4}
@@ -586,12 +833,11 @@
 \BODY
 \end{alignedat}
 \end{equation}
+\setStandardMini
 }
 
 \NewEnviron{maxi*}[5][]{%
-\ifthenelse{\equal{#1}{1}}{
-\let\bodyconst\bodyconstBelow
-}{}
+\selectConstraint{#1}
 \begin{equation*}
 #4
 \begin{alignedat}{4}
@@ -599,12 +845,11 @@
 \BODY
 \end{alignedat}
 \end{equation*}
+\setStandardMini
 }
 
 \NewEnviron{argmaxi*}[5][]{%
-\ifthenelse{\equal{#1}{1}}{
-\let\bodyconst\bodyconstBelow
-}{}
+\selectConstraint{#1}
 \begin{equation*}
 #4
 \begin{alignedat}{4}
@@ -612,6 +857,7 @@
 \BODY
 \end{alignedat}
 \end{equation*}
+\setStandardMini
 }
 
 
@@ -625,7 +871,8 @@
 \bodyobj{#2}{#3}{maximize}{#5}		
 \BODY
 \end{alignat}
-\end{subequations}			
+\end{subequations}	
+\setStandardMini		
 }
 
 \NewEnviron{argmaxi!}[5][]{%
@@ -638,7 +885,8 @@
 \bodyobj{#2}{#3}{arg maxi}{#5}		
 \BODY
 \end{alignat}
-\end{subequations}			
+\end{subequations}
+\setStandardMini			
 }
 \end{verbatim}
 

Modified: trunk/Master/texmf-dist/tex/latex/optidef/optidef.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/optidef/optidef.sty	2016-06-27 20:38:13 UTC (rev 41550)
+++ trunk/Master/texmf-dist/tex/latex/optidef/optidef.sty	2016-06-27 20:38:25 UTC (rev 41551)
@@ -1,4 +1,4 @@
-% optidef - Version 1.0
+% optidef - Version 1.1
 %
 %Copyright 2016 J. Lago Garcia
 %
@@ -12,54 +12,368 @@
 %This work consists of the file optidef.sty.
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{optidef}[2016/06/06 Package for defining optimization problems]
+\ProvidesPackage{optidef}[2016/06/26 - version=1.1,  Package for defining optimization problems]
 
 \RequirePackage{environ}
 \RequirePackage{mathtools}	
 \RequirePackage{xifthen}	
 \RequirePackage{etoolbox}	
+\RequirePackage{xparse}	
+\RequirePackage{multirow}	
+
+% Toogle to indicate if during the addConstraint command the first constraint should be built together with "subject to"
 \newtoggle{bodyCon}
 \toggletrue{bodyCon}
 
-% Input minimization evironments
+% If the previous constraints has 3 elements, we avoid setting \span\span at the beginning of the next constraint. If there is no previous third element, \span\span must be included for correct alignment
+\newtoggle{previousThird}
+\togglefalse{previousThird}
+\newcommand{\spanit}{}
 
+
 % Macros for objective definition, constraint definition and extra constraint definition
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% % -------- DEFINITION COMMAND OBJECTIVE  -----------
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \newcommand{\bodyobj}[4]
 {
 	\ifthenelse{\isempty{#4}}
 	{
-		&\underset{\displaystyle #1}{\mbox{#3}} \quad #2\span\span\span\span
+		&\underset{\displaystyle #1}{\mathrm{#3}} \quad #2\span\span\span\span
 	}
 	{
-		#4 ~~ &\underset{\displaystyle #1}{\mbox{#3}} \quad #2\span\span\span\span
+		#4 ~~ &\underset{\displaystyle #1}{\mathrm{#3}} \quad #2\span\span\span\span
 	}
 }
 
 
-\newcommand{\bodyconst}[2]
-{\\ &\text{subject to} \quad &#1 & #2}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%  -------- DEFINITION DIFFERENT TYPE OF BODY CONSTRAINTS  --------%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-\newcommand{\bodyconstRight}[2]
-{\\ &\text{subject to} \quad &#1 & #2}
+\DeclareDocumentCommand{\bodyconst}{m G{}}
+{	\ifthenelse{\equal{#2}{}}{
+	\\ &\mathrm{subject~to} \quad &&#1 #2 
+	}{
+	\\ &\mathrm{subject~to} \quad &#1 & #2
+	}
+}
 
-\newcommand{\bodyconstBelow}[2]
-{\\ &\text{subject to} \span\span \\
-	 &\quad&#1 & #2}
+% Standard version
+\DeclareDocumentCommand{\bodyconstRight}{m G{} G{}}
+{	\ifthenelse{\equal{#3}{}}{
+			\ifthenelse{\equal{#2}{}}{
+			\\ &\mathrm{subject~to} \quad &&#1 #2 	
+		}{
+		\\ &\mathrm{subject~to} \quad &#1 & #2 
+		}
+		\togglefalse{previousThird}
+	}{
+		\ifthenelse{\equal{#2}{}}{
+			\\ &\mathrm{subject~to} \quad &&#1 #2 &&#3
+		}{
+		\\ &\mathrm{subject~to} \quad &#1 & #2 &&#3
+		}
+		\toggletrue{previousThird}
+	}
+}
 
-\newcommand{\bodyconstBelowMult}[2]
-{\\ &\text{subject to} \span\span\span\span \nonumber \\
-	&\quad&#1 & #2}
+% Single alignment point
+\DeclareDocumentCommand{\bodyconstOneAlign}{m G{} G{}}
+{
+	\ifthenelse{\equal{#3}{}}{
+		\\ &\mathrm{subject~to} \quad &&#1 #2 	\togglefalse{previousThird}
+	}{
+		\\ &\mathrm{subject~to} \quad &&#1 #2 &&#3
+		\toggletrue{previousThird}
+	}
+}
 
-\newcommand{\addConstraint}[2]{
+% Contraints below subject to and with a single alignment point
+\DeclareDocumentCommand{\bodyconstOneAlignBelow}{m G{} G{}}
+{
+	\ifthenelse{\equal{#3}{}}{
+		\\ &\mathrm{subject~to} \span\span\span\span \\
+		&&&#1 #2 \togglefalse{previousThird}
+	}{
+		\\ &\mathrm{subject~to} \span\span\span\span \\
+		&&&#1 #2 &&#3	
+		\toggletrue{previousThird}
+	}	
+}
+
+% Contraints below subject to
+\DeclareDocumentCommand{\bodyconstBelow}{m G{} G{}}
+{
+	\ifthenelse{\equal{#3}{}}{
+		\ifthenelse{\equal{#2}{}}{
+			\\ &\mathrm{subject~to} \span\span\span\span \\
+			&&&#1 #2 
+		}{
+		\\ &\mathrm{subject~to} \span\span\span\span \\
+		 &&#1 & #2 
+		}
+		\togglefalse{previousThird}
+	}{
+		\ifthenelse{\equal{#2}{}}{
+			\\ &\mathrm{subject~to} \span\span\span\span \\
+			&&&#1 #2 &&#3
+		}{
+		\\ &\mathrm{subject~to} \span\span\span\span \\
+		&&#1 & #2 &&#3
+		}
+		\toggletrue{previousThird}	
+	}
+}
+
+% Contraints below subject to for the case of having multiple equations
+\DeclareDocumentCommand{\bodyconstBelowMult}{m G{} G{}}
+{
+	\ifthenelse{\equal{#3}{}}{
+		\ifthenelse{\equal{#2}{}}{
+			\\ &\mathrm{subject~to} \span\span\span\span \nonumber \\
+			&&&#1 #2	
+		}{
+		\\ &\mathrm{subject~to} \span\span\span\span \nonumber \\
+		&&#1 & #2 
+		}
+		\togglefalse{previousThird}
+	}{
+		\ifthenelse{\equal{#2}{}}{
+			\\ &\mathrm{subject~to} \span\span\span\span \nonumber \\
+			&&&#1 #2	&&#3
+		}{
+		\\ &\mathrm{subject~to} \span\span\span\span \nonumber \\
+		&&#1 & #2 &&#3
+		}
+		\toggletrue{previousThird}	
+	}
+}
+
+% Contraints below subject to and with a single alignment point for the case of having several equations
+\DeclareDocumentCommand{\bodyconstOneAlignBelowMult}{m G{} G{}}
+{
+	\ifthenelse{\equal{#3}{}}{
+		\\ &\mathrm{subject~to} \span\span\span\span \nonumber \\
+		&&&#1 #2		\togglefalse{previousThird}
+	}{
+		\\ &\mathrm{subject~to} \span\span\span\span \nonumber \\
+		&&&#1 #2 &&	#3
+		\toggletrue{previousThird}
+	}
+}
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%  -------- DEFINITION DIFFERENT TYPE OF ADDING CONSTRAINTS  --- --%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\DeclareDocumentCommand{\addConstraint}{m G{} G{}}{
+\ifthenelse{\equal{#3}{}}{	
+		\ifthenelse{\equal{#2}{}}{
+			\iftoggle{bodyCon}{
+				\bodyconst{#1}
+				\togglefalse{bodyCon}
+			}{
+			,\\&\quad &&#1 #2\span\span
+			\togglefalse{bodyCon}
+				}
+		}{
+			\iftoggle{bodyCon}{
+				\bodyconst{#1}{#2}
+				\togglefalse{bodyCon}
+			}{
+			,\\&\quad &#1 & #2\span\span
+			\togglefalse{bodyCon}
+			}
+		}
+			\togglefalse{previousThird}
+	}{
+			\iftoggle{bodyCon}{
+				\bodyconst{#1}{#2}{#3}
+				\togglefalse{bodyCon}
+			}{
+				\ifthenelse{\equal{#2}{}}{
+					,\\&\quad &&#1 #2 && #3
+				}{
+					,\\&\quad &#1 & #2 && #3
+				}
+				\togglefalse{bodyCon}
+			}
+		\toggletrue{previousThird}
+		}
+}
+
+% Standard version of adding constraints
+\DeclareDocumentCommand{\standardAddConstraint}{m G{} G{}}{
+	\iftoggle{previousThird}
+	{\renewcommand{\spanit}{}}
+	{\renewcommand{\spanit}{\span\span}}
+\iftoggle{bodyCon}{
+	\bodyconstRight{#1}{#2}{#3}
+	\togglefalse{bodyCon}
+}{
+	\ifthenelse{\equal{#2}{}}{
+		\ifthenelse{\equal{#3}{}}{
+			,\spanit\\&\quad &&#1 #2 
+			\togglefalse{previousThird}
+		}{
+			,\spanit\\&\quad &&#1 #2 && #3
+			\toggletrue{previousThird}
+		}
+	}{
+		\ifthenelse{\equal{#3}{}}{
+			,\spanit\\&\quad &#1 & #2 
+			\togglefalse{previousThird}
+		}{
+			,\spanit\\&\quad &#1 & #2 && #3
+			\toggletrue{previousThird}
+		}
+}
+\togglefalse{bodyCon}
+}
+}
+
+% Adding constraints below subject to
+\DeclareDocumentCommand{\BelowAddConstraint}{m G{} G{}}{
 	\iftoggle{bodyCon}{
-		\bodyconst{#1}{#2}
+		\bodyconstBelow{#1}{#2}{#3}
 		\togglefalse{bodyCon}
 	}{
-	,\\&\quad &#1 & #2
-	\togglefalse{bodyCon}
+		\ifthenelse{\equal{#2}{}}{
+			\ifthenelse{\equal{#3}{}}{
+				,\spanit\\&&&#1  #2 		\togglefalse{previousThird}
+			}{
+				,\spanit\\&&&#1  #2 && #3
+				\toggletrue{previousThird}		
+			}
+		}{
+			\ifthenelse{\equal{#3}{}}{
+				,\spanit\\ &&#1  &#2 \togglefalse{previousThird}
+			}{
+				,\spanit\\ &&#1  &#2 && #3
+				\toggletrue{previousThird}
+			}
+		}
+		\togglefalse{bodyCon}
 	}
 }
 
+% Adding constraints for a single alignment point
+\DeclareDocumentCommand{\oneAlignAddConstraint}{m G{} G{}}{
+		\iftoggle{bodyCon}{
+			\bodyconstOneAlign{#1}{#2}{#3}
+			\togglefalse{bodyCon}
+		}{
+			\ifthenelse{\equal{#3}{}}{
+				,\spanit\\&\quad &&#1  #2 \togglefalse{previousThird}
+			}{
+				,\spanit\\&\quad &&#1  #2 && #3
+				\toggletrue{previousThird}
+			}
+		\togglefalse{bodyCon}
+		}
+}
+
+% Adding constraints for a single alignment point and with the constraints below
+\DeclareDocumentCommand{\oneAlignBelowAddConstraint}{m G{} G{}}{
+	\iftoggle{bodyCon}{
+		\bodyconstOneAlignBelow{#1}{#2}{#3}
+		\togglefalse{bodyCon}
+	}{
+		\ifthenelse{\equal{#3}{}}{
+			,\spanit\\& &&#1  #2\togglefalse{previousThird}
+		}{
+			,\spanit\\& &&#1  #2 && #3
+			\toggletrue{previousThird}
+		}
+		\togglefalse{bodyCon}
+	}
+}
+
+% Adding constraints below subject to for multiple references
+\DeclareDocumentCommand{\BelowAddConstraintMult}{m G{} G{}}{
+	\iftoggle{bodyCon}{
+		\bodyconstBelowMult{#1}{#2}{#3}
+		\togglefalse{bodyCon}
+	}{
+		\ifthenelse{\equal{#3}{}}{
+			\ifthenelse{\equal{#2}{}}{
+				,\spanit\\&&&#1  #2
+			}{
+			,\spanit\\ &&#1  &#2
+			}
+			\togglefalse{previousThird}
+		}{
+			\ifthenelse{\equal{#2}{}}{
+				,\spanit\\&&&#1  #2 && #3
+			}{
+			,\spanit\\ &&#1  &#2&& #3}
+		\toggletrue{previousThird}
+		}
+		\togglefalse{bodyCon}
+	}
+}
+
+% Adding constraints for a single alignment point and with the constraints below for multiple references
+\DeclareDocumentCommand{\oneAlignBelowAddConstraintMult}{m G{} G{}}{
+	\iftoggle{bodyCon}{
+		\bodyconstOneAlignBelowMult{#1}{#2}
+		\togglefalse{bodyCon}
+	}{
+		\ifthenelse{\equal{#3}{}}{
+			,\spanit\\& &&#1  #2 \togglefalse{previousThird}
+		}{
+			,\spanit\\& &&#1  #2 && #3
+			\toggletrue{previousThird}
+		}
+	\togglefalse{bodyCon}
+}
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%  ------------- SELECTING TYPE OF FORMAT  -----------%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newcommand{\selectConstraint}[1]{
+	\ifthenelse{\equal{#1}{1}}{
+		\let\addConstraint\BelowAddConstraint
+	}{
+	\ifthenelse{\equal{#1}{2}}{
+		\let\addConstraint\oneAlignAddConstraint
+	}{
+	\ifthenelse{\equal{#1}{3}}{
+		\let\addConstraint\oneAlignBelowAddConstraint
+	}{
+		\let\addConstraint\standardAddConstraint}
+}
+}
+}
+
+% Selecting for multiple references
+\newcommand{\selectConstraintMult}[1]{
+	\ifthenelse{\equal{#1}{1}}{
+		\let\addConstraint\BelowAddConstraintMult
+	}{
+	\ifthenelse{\equal{#1}{2}}{
+		\let\addConstraint\oneAlignAddConstraint
+	}{
+	\ifthenelse{\equal{#1}{3}}{
+		\let\addConstraint\oneAlignBelowAddConstraintMult
+	}{
+	\let\addConstraint\standardAddConstraint}
+}
+}
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%  ------------- SETTING DEFAULT FORMAT  -------------%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\newcommand{\setStandardMini}{
+	\toggletrue{bodyCon}
+	\let\addConstraint\standardAddConstraint	
+}
+
+
 \newcommand{\breakObjectiveOneConstraint}[1]{&&&#1\\}
 
 
@@ -67,167 +381,138 @@
 %MINIMIZATION ENVIRONMENTS
 
 \NewEnviron{mini}[5][]{%
-	\ifthenelse{\equal{#1}{1}}{
-		\let\bodyconst\bodyconstBelow
-	}{}
+\selectConstraint{#1}
+\let\addConstraint\standardAddConstraint
 	\begin{equation}
 	#4
-	\begin{alignedat}{4}
+	\begin{alignedat}{5}
 	\bodyobj{#2}{#3}{minimize}{#5}
 	\BODY
 	\end{alignedat}
 	\end{equation}
-\toggletrue{bodyCon}
-\let\bodyconst\bodyconstRight
+\setStandardMini
 }
 
 \NewEnviron{argmini}[5][]{%
-	\ifthenelse{\equal{#1}{1}}{
-		\let\bodyconst\bodyconstBelow
-	}{}
+\selectConstraint{#1}
 	\begin{equation}
 	#4
-	\begin{alignedat}{4}
+	\begin{alignedat}{5}
 	\bodyobj{#2}{#3}{arg min}{#5}
 	\BODY
 	\end{alignedat}
 	\end{equation}
+\setStandardMini
 }
 
 \NewEnviron{mini*}[5][]{%
-	\ifthenelse{\equal{#1}{1}}{
-		\let\bodyconst\bodyconstBelow
-	}{}
-	\begin{equation*}
-	#4
-	\begin{alignedat}{4}
+\selectConstraint{#1}
+	\begin{alignat*}{5}
 	\bodyobj{#2}{#3}{minimize}{#5}
 	\BODY
-	\end{alignedat}
-\end{equation*}
-\toggletrue{bodyCon}
-\let\bodyconst\bodyconstRight
+	\end{alignat*}
+\setStandardMini
 }
 
 \NewEnviron{argmini*}[5][]{%
-	\ifthenelse{\equal{#1}{1}}{
-		\let\bodyconst\bodyconstBelow
-	}{}
-	\begin{equation*}
-	#4
-	\begin{alignedat}{4}
-	\bodyobj{#2}{#3}{arg min}{#5}
+\selectConstraint{#1}
+	\begin{alignat*}{5}
+	\bodyobj{#2}{#3}{arg~mini}{#5}
 	\BODY
-	\end{alignedat}
-	\end{equation*}
+	\end{alignat*}
+\setStandardMini	
 }
 
 
 \NewEnviron{mini!}[5][]{%
-	\ifthenelse{\equal{#1}{1}}{
-		\let\bodyconst\bodyconstBelowMult
-	}{}
+\selectConstraintMult{#1}
 	\begin{subequations}
 		#4
-		\begin{alignat}{4}
+		\begin{alignat}{5}
 		\bodyobj{#2}{#3}{minimize}{#5}
 		\BODY
 		\end{alignat}
 	\end{subequations}
-	\toggletrue{bodyCon}
-\let\bodyconst\bodyconstRight		
+\setStandardMini
 }
 
 \NewEnviron{argmini!}[5][]{%
-	\ifthenelse{\equal{#1}{1}}{
-		\let\bodyconst\bodyconstBelowMult
-	}{}
+\selectConstraintMult{#1}
 	\begin{subequations}
 		#4
-		\begin{alignat}{4}
+		\begin{alignat}{5}
 		\bodyobj{#2}{#3}{arg min}{#5}
 		\BODY
 		\end{alignat}
-	\end{subequations}			
+	\end{subequations}	
+\setStandardMini		
 }
 
 %MAXIMIZATION ENVIRONMENTS
 
 \NewEnviron{maxi}[5][]{%
-	\ifthenelse{\equal{#1}{1}}{
-		\let\bodyconst\bodyconstBelow
-	}{}
+\selectConstraint{#1}
 	\begin{equation}
 	#4
-	\begin{alignedat}{4}
+	\begin{alignedat}{5}
 	\bodyobj{#2}{#3}{maximize}{#5}
 	\BODY
 	\end{alignedat}
 	\end{equation}
+\setStandardMini
 }
 
 \NewEnviron{argmaxi}[5][]{%
-	\ifthenelse{\equal{#1}{1}}{
-		\let\bodyconst\bodyconstBelow
-	}{}
+\selectConstraint{#1}
 	\begin{equation}
 	#4
-	\begin{alignedat}{4}
+	\begin{alignedat}{5}
 	\bodyobj{#2}{#3}{arg maxi}{#5}
 	\BODY
 	\end{alignedat}
 	\end{equation}
+\setStandardMini
 }
 
 \NewEnviron{maxi*}[5][]{%
-	\ifthenelse{\equal{#1}{1}}{
-		\let\bodyconst\bodyconstBelow
-	}{}
-	\begin{equation*}
-	#4
-	\begin{alignedat}{4}
+\selectConstraint{#1}
+	\begin{alignat*}{5}
 	\bodyobj{#2}{#3}{maximize}{#5}
 	\BODY
-	\end{alignedat}
-	\end{equation*}
+	\end{alignat*}
+\setStandardMini
 }
 
 \NewEnviron{argmaxi*}[5][]{%
-	\ifthenelse{\equal{#1}{1}}{
-		\let\bodyconst\bodyconstBelow
-	}{}
-	\begin{equation*}
-	#4
-	\begin{alignedat}{4}
+\selectConstraint{#1}
+	\begin{alignat*}{5}
 	\bodyobj{#2}{#3}{arg maxi}{#5}
 	\BODY
-	\end{alignedat}
-	\end{equation*}
+	\end{alignat*}
+\setStandardMini
 }
 
 
 \NewEnviron{maxi!}[5][]{%
-	\ifthenelse{\equal{#1}{1}}{
-		\let\bodyconst\bodyconstBelowMult
-	}{}
+\selectConstraintMult{#1}
 	\begin{subequations}
 		#4
-		\begin{alignat}{4}
+		\begin{alignat}{5}
 		\bodyobj{#2}{#3}{maximize}{#5}		
 		\BODY
 		\end{alignat}
-	\end{subequations}			
+	\end{subequations}	
+\setStandardMini		
 }
 
 \NewEnviron{argmaxi!}[5][]{%
-	\ifthenelse{\equal{#1}{1}}{
-		\let\bodyconst\bodyconstBelowMult
-	}{}
+\selectConstraintMult{#1}
 	\begin{subequations}
 		#4
-		\begin{alignat}{4}
+		\begin{alignat}{5}
 		\bodyobj{#2}{#3}{arg maxi}{#5}		
 		\BODY
 		\end{alignat}
-	\end{subequations}			
+	\end{subequations}
+\setStandardMini			
 }
\ No newline at end of file



More information about the tex-live-commits mailing list