![将 Optidef 包的 mini 环境重新标记为 optimize](https://linux22.com/image/441825/%E5%B0%86%20Optidef%20%E5%8C%85%E7%9A%84%20mini%20%E7%8E%AF%E5%A2%83%E9%87%8D%E6%96%B0%E6%A0%87%E8%AE%B0%E4%B8%BA%20optimize.png)
我想定义一个新的环境,其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}