1

I have written the attached optimization problem. But, as it can be seen that equations (1c)-(1j) are very close to one another. I want to add a small space between each equation. What is the neatest way to do this?

Thanks a lot!!

\documentclass[review,12pt]{elsarticle}
\usepackage{array}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{setspace}
\usepackage{subfigure}
\DeclareMathOperator{\Tr}{Tr}
\DeclareMathOperator{\rank}{rank}
\DeclareMathOperator{\diag}{diag}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{footnote}
\makesavenoteenv{tabular}
\makesavenoteenv{table}
\newcommand{\tightermath}{%
\setlength{\thickmuskip}{.3\thickmuskip}
\setlength{\medmuskip}{.3\medmuskip}
\setlength{\thinmuskip}{.3\thinmuskip}}
\onehalfspacing
\begin{document}
\begin{figure}[h]
\begin{subequations}
    \setlength\parindent{0pt}
    \rule{\columnwidth}{1pt}
    \textbf{M2:} \textbf{SDP-based OPF} \\
    \rule[1ex]{\columnwidth}{1pt}       
    \vspace*{-1.5\baselineskip} 
    \begin{flalign}
    \mathbf{M2: } \underset{\Psi}{\mathbf{minimize}}\ f(\Psi)&&& 
    \end{flalign}       
    \vspace*{-1.5\baselineskip}     
    \begin{flalign}
    &\mathbf{variable:}\hspace{1em}\mathbf{W}&\\
    & \hspace{5.7em}P_{g_k}^\varphi, Q_{g_k}^\varphi \hspace{2em}\forall \varphi \in \eta_{k}, \forall k \in N & \nonumber
    \end{flalign}   
    $\mathbf{subject}$ $\mathbf{to:}$ 
    \begin{flalign}
    & \Tr(\mathbf{\Psi}_{k,nw_p}^\varphi \mathbf{W}) + P_{l_k}^\upsilon = 0, \hspace{11.7em}\forall \varphi \in \eta_k, \upsilon \in \chi_k, k \in N\backslash G \label{eq:PBL2}\\ 
    & \Tr(\mathbf{\Psi}_{k,nw_q}^\varphi \mathbf{W}) + Q_{l_k}^\upsilon-y_{c_k}^\upsilon  \Tr(\mathbf{\Psi}_{k,nw_v}^\varphi\mathbf{W}) = 0, \hspace{3em}\forall \varphi \in \eta_k, \upsilon \in \chi_k, k \in N\backslash G \label{eq:QBL2} \\
    & \underline{P}_{g_i} \leq \Tr(\mathbf{\Psi}_{i,nw_p}^\varphi \mathbf{W}) {+} P_{l_i}^\upsilon \leq \overline{P}_{g_i}, \hspace{8.8em}\forall \varphi \in \eta_i, \upsilon \in \chi_i, i \in G \label{eq:PBG2}\\
    & \underline{Q}_{g_i} \leq \Tr(\mathbf{\Psi}_{i,nw_q}^\varphi \mathbf{W}) {+} Q_{l_i}^\upsilon \leq \overline{Q}_{g_i}, \hspace{8.8em}\forall \varphi \in \eta_i, \upsilon \in \chi_i, i \in G \label{eq:QBG2}\\
    & (\underline{V}_k)^2 \leq \Tr(\mathbf{\Psi}_{k,nw_v}^\varphi \mathbf{W}) \leq (\overline{V_k})^2, \hspace{9.0em}\forall \varphi \in \eta_k, k \in N^+ \label{eq:Vol2} \\
    & [\mathbf{W}]_{\eta_0 \times \eta_0} = \mathbf{V}_0 \mathbf{V}_0^H \\
    & \mathbf{W} \succeq 0, \\
    & \rank(\mathbf{W}) = 1 \label{rank_con}
    \end{flalign}
    \rule[1ex]{\columnwidth}{1pt}
\end{subequations}
\end{figure}
\end{document}
2
  • 1
    You would typically add space to the line feed, changing \\ to \\[8pt] for example Feb 22, 2019 at 10:55
  • 2
    You're hard-coding every thing to obtain an algorithm, while there are specialized packages for writing algorithms that are easy to use.
    – AboAmmar
    Feb 22, 2019 at 10:55

2 Answers 2

1

The lines are particularly tight because of \onehalfspacing. Remove it.

\documentclass[review,12pt]{elsarticle}

\usepackage{amsmath}

\DeclareMathOperator{\Tr}{Tr}
\DeclareMathOperator{\rank}{rank}
\DeclareMathOperator{\diag}{diag}

\begin{document}

\begin{figure}[ht]
\setlength{\abovedisplayskip}{0pt}
\setlength{\belowdisplayskip}{0pt}
\begin{subequations}
\hrule height 1pt\kern6pt

\textbf{M2:} \textbf{SDP-based OPF}

\kern6pt\hrule height 1pt

\begin{flalign}
&\textbf{M2: } \operatorname*{\mathbf{minimize}}_{\Psi} f(\Psi)&& \\
&\textbf{variable:}\quad
    \begin{aligned}[t]
    &\mathbf{W}\\[-\jot]
    &P_{g_k}^\varphi, Q_{g_k}^\varphi \qquad \forall \varphi \in \eta_{k}, \forall k \in N
    \end{aligned} &&
\\
& \textbf{subject to:} && \nonumber
\\
&\! \Tr(\mathbf{\Psi}_{k,nw_p}^\varphi \mathbf{W}) + P_{l_k}^\upsilon = 0, 
  && \forall \varphi \in \eta_k, \upsilon \in \chi_k, k \in N\backslash G
\label{eq:PBL2}
\\ 
&\! \Tr(\mathbf{\Psi}_{k,nw_q}^\varphi \mathbf{W}) 
    + Q_{l_k}^\upsilon-y_{c_k}^\upsilon  \Tr(\mathbf{\Psi}_{k,nw_v}^\varphi\mathbf{W}) = 0,
  &&\forall \varphi \in \eta_k, \upsilon \in \chi_k, k \in N\backslash G
\label{eq:QBL2}
\\
& \underline{P}_{g_i} \leq \Tr(\mathbf{\Psi}_{i,nw_p}^\varphi \mathbf{W})
  + P_{l_i}^\upsilon \leq \overline{P}_{g_i},
  &&\forall \varphi \in \eta_i, \upsilon \in \chi_i, i \in G
\label{eq:PBG2}
\\
& \underline{Q}_{g_i} \leq \Tr(\mathbf{\Psi}_{i,nw_q}^\varphi \mathbf{W})
  + Q_{l_i}^\upsilon \leq \overline{Q}_{g_i},
  &&\forall \varphi \in \eta_i, \upsilon \in \chi_i, i \in G
\label{eq:QBG2}
\\
& (\underline{V}_k)^2 \leq \Tr(\mathbf{\Psi}_{k,nw_v}^\varphi \mathbf{W}) \leq (\overline{V_k})^2,
  &&\forall \varphi \in \eta_k, k \in N^+
\label{eq:Vol2}
\\
& [\mathbf{W}]_{\eta_0 \times \eta_0} = \mathbf{V}_0 \mathbf{V}_0^H
\\
& \mathbf{W} \succeq 0,
\\
&\! \rank(\mathbf{W}) = 1
\label{rank_con}
\end{flalign}

\kern6pt\hrule height 1pt
\end{subequations}
\end{figure}

\end{document}

I made also some other changes to avoid guessing the spaces.

enter image description here

1

Increasing space between two individual lines is done by appending a value to \\, e.g.

 \\[2ex]

If you want to do this for all lines of a display, then plain TeX has the command \openup typically used as

\openup 2\jot

where \jot is a standard amount of space. In amsmath this built in internally in the commands, and to get at it you need to adjust the macro \spread@equation. The code below is with 3\jot for exaggeration.

Sample output

\documentclass{article}

\usepackage[fleqn]{amsmath}

\DeclareMathOperator{\Tr}{Tr}
\DeclareMathOperator{\rank}{rank}
\setlength{\mathindent}{0pt}

\begin{document}

\begin{subequations}
  \setlength{\parindent}{0pt} \setlength{\abovedisplayskip}{0pt}
  \setlength{\belowdisplayskip}{0pt}
  \makeatletter
  \def\spread@equation{\reset@strutbox@
  \openup3\jot \let\spread@equation\@empty}
  \makeatother

  \rule{\columnwidth}{1pt}

  \textbf{M2:} \textbf{SDP-based OPF}

  \rule[1ex]{\columnwidth}{1pt}
  \begin{gather}
    \textbf{M2:} \qquad \operatorname*{minimize}_{\Psi} f(\Psi)\\
    \textbf{variables:} \quad\begin{aligned}[t] &\mathbf{W}\\
      &P_{g_k}^\varphi, Q_{g_k}^\varphi \qquad \forall \varphi \in
      \eta_{k}, \forall k \in N
    \end{aligned}\\
    \textbf{subject to:} \nonumber\\
    \Tr(\mathbf{\Psi}_{k,nw_p}^\varphi \mathbf{W}) + P_{l_k}^\upsilon
    = 0, \qquad\forall \varphi \in \eta_k, \upsilon \in \chi_k, k \in
    N\backslash G,
    \label{eq:PBL2}\\
    \Tr(\mathbf{\Psi}_{k,nw_q}^\varphi \mathbf{W}) +
    Q_{l_k}^\upsilon-y_{c_k}^\upsilon
    \Tr(\mathbf{\Psi}_{k,nw_v}^\varphi\mathbf{W}) = 0, \quad\forall
    \varphi \in \eta_k, \upsilon \in \chi_k, k \in
    N\backslash G \label{eq:QBL2}, \\
    \underline{P}_{g_i} \leq \Tr(\mathbf{\Psi}_{i,nw_p}^\varphi
    \mathbf{W}) {+} P_{l_i}^\upsilon \leq \overline{P}_{g_i},
    \qquad\forall \varphi \in \eta_i, \upsilon \in \chi_i, i \in
    G, \label{eq:PBG2}\\
    \underline{Q}_{g_i} \leq \Tr(\mathbf{\Psi}_{i,nw_q}^\varphi
    \mathbf{W}) {+} Q_{l_i}^\upsilon \leq \overline{Q}_{g_i},
    \qquad\forall \varphi \in \eta_i, \upsilon \in \chi_i, i \in
    G, \label{eq:QBG2}\\
    (\underline{V}_k)^2 \leq \Tr(\mathbf{\Psi}_{k,nw_v}^\varphi
    \mathbf{W}) \leq (\overline{V_k})^2, \qquad\forall \varphi \in
    \eta_k, k \in N^+, \label{eq:Vol2} \\
    [\mathbf{W}]_{\eta_0 \times \eta_0} = \mathbf{V}_0 \mathbf{V}_0^H \\
    \mathbf{W} \succeq 0, \\
    \rank(\mathbf{W}) = 1. \label{rank_con}
  \end{gather}
  \rule[1ex]{\columnwidth}{1pt}
\end{subequations}

\end{document}

Note that I have killed some of the vertical space by adjusting internal variables instead of adding \vspace commands ad hoc.

1
  • @campa Thanks - typo corrected Oct 10, 2019 at 12:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .