# Remove huge empty space before and after an equation

I have this extract from a latex code to define several equations:

$$\min C = \sum_{t=0}^{Z} (x_t \cdot P^{HPmax} + P_t^{DemandEl}) \cdot \Delta t \cdot p_t \label{eq:objective_function}$$

subject to:

\begin{align}
&T^{min} \leq T^{Building}_t \leq T^{max} \label{eq:temperature_balance} \\
&T^{Building}_t = T^{Building}_{t-1} + \frac{Q_t^{HP} - Q_t^{DemandSH} -  Q_t^{LossesSH}}{V^{UFH} \cdot  \rho^{Concrete} \cdot c^{Concrete}} \label{eq:temperature_difference_equation} \\
&Q_t^{HP} = x_t \cdot P^{HPmax}  \cdot COP_t \cdot \Delta t \label{eq:heating_energy_HP} \\
&h^{switchedOff}_t \leq h^{on}_{t-1} \label{eq:hp_switched_off_1}  \\
&h^{switchedOff}_t \leq 1 - h^{on}_{t} \label{eq:hp_switched_off_2}  \\
&h^{switchedOff}_t \geq h^{on}_{t-1} - h^{on}_{t} \label{eq:hp_switched_off_3} \\
&k_t^{switchedOff} =   \sum_{\tau=0}^{t} h_\tau^{switchedOff} \label{eq:hp_switched_off_4} \\
&k^{switchedOff}_t \leq n^{switchedOff} \label{eq:hp_switched_off_5} \\
&x_t \leq h^{on}_{t} \label{eq:hp_min_mod_1} \\
&x_t \geq h^{on}_{t} \cdot mod^{min} \label{eq:hp_min_mod_2} \\
&x_t \in [0,1], h^{switchedOff}_t \in \{0,1\}, h^{on}_{t} \in \{0,1\} \label{eq:non_negativity}
\end{align}


The big problem is, that before and after the first equation, that I define separately such that I can add the text "subject to" underneath it, there is a huge empty space that I would like to eliminate. Here is the screenshot:

How can I reduce the empty space?

Update: Here is the main latex file:

\documentclass[5p,times,twocolumn]{elsarticle}
\usepackage{physics}
\usepackage{tabularx}
\usepackage{siunitx}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage{csquotes}
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
\usepackage{acro}
\include{sections/00_acro}
\graphicspath{{figures/}}
\usepackage{lipsum}
\usepackage{booktabs}
\usepackage{float}
\usepackage{comment}
\usepackage{subcaption}
\usepackage{framed} % Framing content
\usepackage{multicol} % Multiple columns environment
\usepackage{nomencl} % Nomenclature package
\usepackage{xurl}
\usepackage{todonotes}

\usepackage{makecell}
\usepackage{afterpage}

%Test new equation system display
\usepackage[margin=2cm]{geometry}
\usepackage{mathtools,kantlipsum}
\newenvironment{AllowDisplayBreaks}{\allowdisplaybreaks}{\ignorespacesafterend}
\newcommand\stxt[1]{\scriptscriptstyle\textup{#1}}

%Define the color of the links
\usepackage{xcolor}
\usepackage{hyperref}

\definecolor{myColor}{RGB}{0, 0.0, 0}

\hypersetup{
citecolor=myColor,
urlcolor=myColor,
}

\journal{Applied Energy}

% Remove preprint submitted to Applied Energy and the date
\makeatletter
\def\ps@pprintTitle{
\def\@oddfoot{}%
\let\@evenfoot\@oddfoot
}
\makeatother

\begin{document}

\begin{frontmatter}

\title{Title}

\author[1]{A}
\author[1]{B}

\begin{abstract}
\input{sections/00_abstract}
\end{abstract}

\begin{comment}
%%Graphical abstract
\begin{graphicalabstract}
\includegraphics{grabs}
\end{graphicalabstract}

%%Research highlights
\begin{highlights}
\item Research highlight 1
\item Research highlight 2
\end{highlights}
\end{comment}

\begin{keyword}
%% keywords here, in the form: keyword \sep keyword
keyword 1 \sep keyword 2 \sep keyword 3 \sep keyword 4 \sep keyword 5
%% PACS codes here, in the form: \PACS code \sep code
%\PACS 0000 \sep 1111
%% MSC codes here, in the form: \MSC code \sep code
%% or \MSC[2008] code \sep code (2000 is the default)
%MSC 0000 \sep 1111
\end{keyword}

\end{frontmatter}

%% \linenumbers

\input{sections/00_nomecl}
\input{sections/01_intro}
\input{sections/02_related_work}
\input{sections/03_optimization_problem_for_the_building}
\input{sections/04_immitation_learning_for_building_control}
\input{sections/05_results}
\input{sections/06_conclusion}
\input{sections/ending}

\thispagestyle{empty} % Remove page number and header/footer on the first page

%% If you have bibdatabase file and want bibtex to generate the
%% bibitems, please use
%%
\bibliographystyle{elsarticle-num}
\bibliography{refs}

%% else use the following coding to input the bibitems directly in the
%% TeX file.

% \begin{thebibliography}{00}

% %% \bibitem{label}
% %% Text of bibliographic item

% \bibitem{}

% \end{thebibliography}
\end{document}
\endinput
%%
%% End of file elsarticle-template-num.tex'.

• Where do you prefer the break? In the middle of the align? Commented Mar 13 at 14:30
• Unrelated you should probably use \mathrm{....} or \textup{....} on all those names in ^{...} (aka use ^{\textup{...}} not ^{...} that makes it easier to read. Commented Mar 13 at 14:33
• An align is not allowed to be page/column broken unless you tell it to. Commented Mar 13 at 14:34
• Note that you problably do not want to have blank lines around sublect to as that phrase is not a new paragraph. Commented Mar 13 at 14:35
• never leave a blank line before a display it produces a white empty line of text (it is not vertical space and is not dropped at a page break) Commented Mar 13 at 15:25

Here is what I would do (though I'd be using smaller text indicices)

The AllowDisplayBreaks env is just so we can add this locally. Tip: \\* discourage a page/column break.

I use \stxt to format the textual superscripts, given the size of these I choose to make the even smaller.

\documentclass[a4paper,twocolumn]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{mathtools,kantlipsum}
\newenvironment{AllowDisplayBreaks}{\allowdisplaybreaks}{\ignorespacesafterend}
\newcommand\stxt[1]{\scriptscriptstyle\textup{#1}}
\begin{document}

% just to force a column break

\vspace*{12cm}

\kant[2]

$$\min C = \sum_{t=0}^{Z} (x_t \cdot P^{\stxt{HPmax}} + P_t^{\stxt{DemandEl}}) \cdot \Delta t \cdot p_t \label{eq:objective_function}$$
%
subject to:
%
\begin{AllowDisplayBreaks}
\begin{align}
&T^{\stxt{min}} \leq T^{\stxt{Building}}_t \leq T^{\stxt{max}} \label{eq:temperature_balance} \\
&T^{\stxt{Building}}_t = T^{\stxt{Building}}_{t-1} + \frac{Q_t^{\stxt{HP}} - Q_t^{\stxt{DemandSH}} -  Q_t^{\stxt{LossesSH}}}{V^{\stxt{UFH}} \cdot  \rho^{\stxt{Concrete}} \cdot c^{\stxt{Concrete}}} \label{eq:temperature_difference_equation} \\
&Q_t^{\stxt{HP}} = x_t \cdot P^{\stxt{HPmax}}  \cdot COP_t \cdot \Delta t \label{eq:heating_energy_HP} \\
&h^{\stxt{switchedOff}}_t \leq h^{\stxt{on}}_{t-1} \label{eq:hp_switched_off_1}  \\
&h^{\stxt{switchedOff}}_t \leq 1 - h^{\stxt{on}}_{t} \label{eq:hp_switched_off_2}  \\
&h^{\stxt{switchedOff}}_t \geq h^{\stxt{on}}_{t-1} - h^{\stxt{on}}_{t} \label{eq:hp_switched_off_3} \\
&k_t^{\stxt{switchedOff}} =   \sum_{\tau=0}^{t} h_\tau^{\stxt{switchedOff}} \label{eq:hp_switched_off_4} \\
&k^{\stxt{switchedOff}}_t \leq n^{\stxt{switchedOff}} \label{eq:hp_switched_off_5} \\
&x_t \leq h^{\stxt{on}}_{t} \label{eq:hp_min_mod_1} \\
&x_t \geq h^{\stxt{on}}_{t} \cdot mod^{\stxt{min}} \label{eq:hp_min_mod_2} \\
&x_t \in [0,1], h^{\stxt{switchedOff}}_t \in \{0,1\}, h^{\stxt{on}}_{t} \in \{0,1\} \label{eq:non_negativity}
\end{align}
\end{AllowDisplayBreaks}

\end{document}

• Thanks for your answer. I have to admit that your solution is extremely bad. First of all, I think because of \kant[2], some text from another source is added that has nothing to do with my article. Moreover, your suggested approach just shifted the empty white space. Altough in the formular itself it was not visible, but on other parts of the document a huge empty space was introduced. Can you maybe think of a solution without all these new packages and especially without \kant[2] and \vspace*{12cm} Commented Mar 13 at 15:24
• @PeterBe \kant and \vspace are just used to generate a break in the align environment. It's to illustrate the solution, not part of the solution.
– jlab
Commented Mar 13 at 15:29
• @PeterBe daleif used vspace and lipsum because you had failed to provide an example that shows the problem, the bad column break relies on all the text you show in teh image which is unreasonable to expect people to type in, and kandlipsum is just approximating that. Commented Mar 13 at 15:32
• To format subscripts and superscripts I wrote the package altsubsup. It allows to write T^[min] so min is formatted with \text. This can be change with \SetAltSubSupCommands{\stxt} to use your macro \stxt in place of \text`.
– jlab
Commented Mar 13 at 15:34
• @jlab: Thanks for your comment. I might consider this altough I don't see it as a big problem having the superscripts the way I use it. Commented Mar 13 at 15:40