5
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts

\usepackage{optidef}

\begin{document}

\title{Title}

\author{
    \IEEEauthorblockN{Author}
}

\maketitle

\section{Test}
The optimization problem is formulated as
\begin{mini!}|l|[3]
    {w}{f(w)+ R(w+6x) \protect\label{eq:ObjectiveExample1}}
    {\label{eq:Example1}}
    {y=}
    \addConstraint{g(w)}{=0;\quad\protect\label{eq:C1Example3}}{\text{first constraint}}
    \addConstraint{n(w)}{= 6;\quad\protect\label{eq:C2Example1}}{\text{second constraint}}
    \addConstraint{L(w)+r(x)}{=Kw+p;\quad\protect\label{eq:C3Example1}}{\text{third constraint}}
\end{mini!}
where $a$ is abc, $a$ is abc, $a$ is abc, $a$ is abc, $a$ is abc,
$a$ is abc, $a$ is abc, $a$ is abc, $a$ is abc, and $a$ is abc.

\end{document}

enter image description here

As seen in the figure, there is an indentation before 'where'. I actually do not know why the indentation appears. Is there any method to remove the indentation?

3

The optidef package suffers from many unprotected end-of-lines, creating unwanted spaces.

For the present problem a fix would be to define more efficiently an internal environment.

\documentclass[conference]{IEEEtran}
\usepackage{newtxtext,newtxmath}

\IEEEoverridecommandlockouts

\usepackage{optidef}

\RenewEnviron{BaseMiniExclam}[7]{%
  \selectConstraintMult{#1}%
  \renewcommand{\localOptimalVariable}{#2}%
  \begin{subequations}
  \ifthenelse{\equal{#7}{b}}{\allowdisplaybreaks}%
  #4
  \begin{alignat}{5}
    \bodyobj{#2}{#3}{#6}{#5}
    \BODY
  \end{alignat}
  \end{subequations}%
  \setStandardMini
}

\begin{document}

\title{Title}

\author{
    \IEEEauthorblockN{Author}
}

\maketitle

\section{Test}
The optimization problem is formulated as
\begin{mini!}|l|[3]
    {w}{f(w)+ R(w+6x) \protect\label{eq:ObjectiveExample1}}
    {\label{eq:Example1}}
    {y=}
    \addConstraint{g(w)}{=0;\quad\protect\label{eq:C1Example3}}{\text{first constraint}}
    \addConstraint{n(w)}{= 6;\quad\protect\label{eq:C2Example1}}{\text{second constraint}}
    \addConstraint{L(w)+r(x)}{=Kw+p;\quad\protect\label{eq:C3Example1}}{\text{third constraint}}
\end{mini!}
where $a$ is abc, $a$ is abc, $a$ is abc, $a$ is abc, $a$ is abc,
$a$ is abc, $a$ is abc, $a$ is abc, $a$ is abc, and $a$ is abc.

\end{document}

I used newtx because I can't stand Computer Modern math and Times text.

enter image description here

|improve this answer|||||
  • I will solve the problem using the same way as your suggestion, without changingoptidef. Thank you. – Danny_Kim Jul 23 '18 at 8:14
  • In my original optimization problem, some constraints have 3 terms, e.g. $\lVert x_i-x_j\rVert\le d_{th};\quad x_i,x_j\in\mathcal{X};\quad \mathcal{X}\in f(t)$. In this case, is there any method to vertically align the third terms? – Danny_Kim Jul 23 '18 at 8:21
  • @Danny_Kim This is a whole new question. – egreg Jul 23 '18 at 9:07
  • Dear @egreg, do you know any good resource where I can learn more about unprotected end-of-lines and unwanted spaces? I am the main developer of the optidef package and I would like to correct this issue. I think that the issue should be corrected using the % character at the end of lines, however I am not able to successfully achieve that within the optidef package. For example, in the original BaseMiniExclam environment, if you want to keep the double if structure with the begingroup and endgroup commands, how can you protect the end of lines? – jesus Aug 7 '18 at 12:33
  • @egreg If it helps, perhaps we could continue the discussion in github.com/jeslago/optidef/issues/19, or I could open a new question in tex.stackexchange – jesus Aug 7 '18 at 12:36
2

It's really hard to tell why it happens. I suspect it's something related to the definition of mini!, and that it has some unwanted spaces in its \end definition. Anyways, telling LaTeX that we want a new paragraph without indentation seems to solve the problem: \par\noindent:

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts

\usepackage{optidef}

\begin{document}

\title{Title}

\author{
    \IEEEauthorblockN{Author}
}

\maketitle

\section{Test}
The optimization problem is formulated as
\begin{mini!}|l|[3]
    {w}{f(w)+ R(w+6x) \protect\label{eq:ObjectiveExample1}}
    {\label{eq:Example1}}
    {y=}
    \addConstraint{g(w)}{=0;\quad\protect\label{eq:C1Example3}}{\text{first constraint}}
    \addConstraint{n(w)}{= 6;\quad\protect\label{eq:C2Example1}}{\text{second constraint}}
    \addConstraint{L(w)+r(x)}{=Kw+p;\quad\protect\label{eq:C3Example1}}{\text{third constraint}}
\end{mini!}
 \par\noindent where $a$ is abc, $a$ is abc, $a$ is abc, $a$ is abc, $a$ is abc,
$a$ is abc, $a$ is abc, $a$ is abc, $a$ is abc, and $a$ is abc.

\end{document}
|improve this answer|||||
  • you should never need \noindent in latex so this is really a workaround for the broken package definition also note it suppresses indentation but not other features of the start of a paragraph such as vertical space if \parskip is non zero. – David Carlisle Jul 23 '18 at 8:04
  • Wow, \par\noindent readily works well in my case, but one line is spaced. Anyhow, thank you for me to know the command \par\noindent. – Danny_Kim Jul 23 '18 at 8:13
  • @DavidCarlisle Did not know that! Thanks! – Andreas Storvik Strauman Jul 23 '18 at 8:17
  • @Danny_Kim You should go with the other answer! – Andreas Storvik Strauman Jul 23 '18 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.