我想定义一个新的环境,其opti
工作方式与环境相同,mini
但将“最小化”一词替换为“优化”。
答案1
但是,你可以将环境定义从包的 .sty 文件复制到你的前言中并进行相应的修改。请注意,和mini
有单独的定义。mini*
mini!
minie
(我不知道缩写“opt”在这种情况下是否有意义。)
\documentclass{article}
\usepackage{optidef}
% modification of mini environment
\DeclareDocumentEnvironment{opti}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} D<>{} m m m m}{%
\ifthenelse{\equal{#3}{b}}{%
\ifthenelse{\equal{#1}{s}}%
% Short version problem
{\setFormatShort{opt}{#4}\BaseMiniStar{#2}{#4}{#5}{#7}{opt}{#3}}%
% Long version problem
{\setFormatLong{optimize}{#4}\BaseMiniStar{#2}{#4}{#5}{#7}{optimize}{#3}}%
}{%
\ifthenelse{\equal{#1}{s}}%
% Short version problem
{\setFormatShort{opt}{#4}\BaseMini{#2}{#4}{#5}{#6}{#7}{opt}}%
% Long version problem
{\setFormatLong{optimize}{#4}\BaseMini{#2}{#4}{#5}{#6}{#7}{optimize}}%
}%
}%
{\endBaseMini\toggletrue{bodyCon}}
\begin{document}
\begin{opti}
{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{opti}
\end{document}