jeslago / optidef

A Latex library for optimization problems
57 stars 3 forks source link

Incorrect indent after argmini! #29

Closed aking7 closed 5 years ago

aking7 commented 5 years ago

There is an incorrect indentation of the text following a argmini! environment.

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[short]{optidef}

\begin{document}

The optimization problem is defined as
\begin{argmini!}
    % Optimization variable
    {R,L_{\beta},\beta}
    % Objective function
    {\frac{\left\lVert Z_{\text{FRAC}}(R,L_{\beta},\beta,\omega) - Z_{\text{FEA}}(\omega)\right\rVert^{2}}{\left\lVert Z_{\text{FEA}}(\omega)\right\rVert^{2}} \label{eq:objectiveFunction}}
    % Optimization problem label
    {\label{eq:optimizationProblem}}
    % Optimization results
    {}
    % Constraints
    \addConstraint{R}{> 0, \quad R &&\in \mathbb{R}}
    \addConstraint{L_{\beta}}{> 0, \quad L_{\beta} &&\in \mathbb{R}}
    \addConstraint{0 \leq \beta}{\leq 1, \quad \beta &&\in \mathbb{R} \label{eq:betaConstraint}}
\end{argmini!}
where $Z_{\text{FRAC}}(R,L_{\beta},\beta,\omega)$ is the impedance calculated from the fractional model  and $Z_{\text{FEA}}(\omega)$ is the impedance determined by FEA.

\end{document}
jeslago commented 5 years ago

Why is it incorrect? This is what I get when testing your code:

Screenshot from 2019-04-15 21 14 20

As far as I can see the alignments are correct.

aking7 commented 5 years ago

@jeslago Really? I'm using the standard pdflatex compiler in TeXstudio for Windows and get this:

image

jeslago commented 5 years ago

And what is the issue in that figure? I fail to see the difference between the figure that you posted and the figure I posted.

aking7 commented 5 years ago

@jeslago the "where" should not be indented after the equation, as it is a continuation of the paragraph. It looks fine in yours for some reason.

jeslago commented 5 years ago

As the issue was not part of the optimization problem, I did not noticed. Some questions/suggestions:

  1. Are you using the latest optidef package? If not, can you download it and try it?

  2. Which documentclass are you using?

  3. If you write \noindent before where does it solve the problem?

aking7 commented 5 years ago
  1. Yes, I'm using version 3.0.
  2. I'm using \documentclass{article} as in the example.
  3. \noindent does not help.

The following works fine using the normal argmini environment. It only breaks using argmini!.

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[short]{optidef}

\begin{document}

The optimization problem is defined as
\begin{argmini}
    % Optimization variable
    {R,L_{\beta},\beta}
    % Objective function
    {\frac{\left\lVert Z_{\text{FRAC}}(R,L_{\beta},\beta,\omega) - Z_{\text{FEA}}(\omega)\right\rVert^{2}}{\left\lVert Z_{\text{FEA}}(\omega)\right\rVert^{2}}}
    % Optimization problem label
    {}
    % Optimization results
    {}
    % Constraints
    \addConstraint{R}{> 0, \quad R &&\in \mathbb{R}}
    \addConstraint{L_{\beta}}{> 0, \quad L_{\beta} &&\in \mathbb{R}}
    \addConstraint{0 \leq \beta}{\leq 1, \quad \beta &&\in \mathbb{R} \label{eq:betaConstraint}}
\end{argmini}
where $Z_{\text{FRAC}}(R,L_{\beta},\beta,\omega)$ is the impedance calculated from the fractional model  and $Z_{\text{FEA}}(\omega)$ is the impedance determined by FEA.

\end{document}

Thanks for looking into it!

jeslago commented 5 years ago

Can you download the current optidef version in github and try it out? I can replicate the issue with version 3.0 when it was released, since then, I have made some changes in the code to correct some issues.

I suspect the issue is related on how the end lines were defined in the initial 3.0 release.

aking7 commented 5 years ago

Hey, it's fixed! Thank you @jeslago :)