Using this code:
\documentclass{article}
\usepackage{parskip}
\usepackage[margin=.5cm]{geometry}
\usepackage{makeidx}
\usepackage{paralist}
\usepackage{amsmath,amssymb}
\usepackage{mdwtab}
\usepackage{graphicx,subfigure}
\DeclareMathSymbol{,}{\mathord}{letters}{"3B}
\newcommand{\np}{\newpage}
\begin{document}
\begin{figure}
$$
\sigma( w^T x + b) = \frac{1}{1 + e^{-(w^T x + b)}}
$$
\vspace*{-7mm}
\caption{Sigmoid function}
\end{figure}
\begin{figure}
$$
J = -\frac{1}{m}\sum_{i=1}^{m}y^{(i)}\log(a^{(i)})+(1-y^{(i)})\log(1-a^{(i)})
$$
\vspace*{-7mm}
\caption{Cost function}
\end{figure}
\begin{figure}
$$
J = \overline{J}
$$
\vspace*{-7mm}
\caption{Take mean of J}
\end{figure}
\title{ \LaTeX\\
}
\author{\textbf{\Large }\\
\textbf{\Large }
}
\maketitle
\thispagestyle{empty}
\np
\tableofcontents
\np
\end{document}
renders third figure:
\begin{figure}
$$
J = \overline{J}
$$
\vspace*{-7mm}
\caption{Take mean of J}
\end{figure}
on second page of generated pdf document despite there being ample space available on current page for figure 3.
How can I amend my code so that all figures use max amount of space available on page?
Update :
Have tried using \begin{equation} , \end{equation} as suggested in comments
:
\documentclass{article}
\usepackage{parskip}
\usepackage[margin=.5cm]{geometry}
\usepackage{makeidx}
\usepackage{paralist}
\usepackage{amsmath,amssymb}
\usepackage{mdwtab}
\usepackage{graphicx,subfigure}
\DeclareMathSymbol{,}{\mathord}{letters}{"3B}
\newcommand{\np}{\newpage}
\begin{document}
\begin{equation}
$$
\sigma( w^T x + b) = \frac{1}{1 + e^{-(w^T x + b)}}
$$
\vspace*{-7mm}
\caption{Sigmoid function}
\end{equation}
\begin{equation}
$$
J = -\frac{1}{m}\sum_{i=1}^{m}y^{(i)}\log(a^{(i)})+(1-y^{(i)})\log(1-a^{(i)})
$$
\vspace*{-7mm}
\caption{Cost function}
\end{equation}
\begin{equation}
$$
J = \overline{J}
$$
\vspace*{-7mm}
\caption{Take mean of J}
\end{equation}
\title{ \LaTeX\\
}
\author{\textbf{\Large }\\
\textbf{\Large }
}
\maketitle
\thispagestyle{empty}
\np
\tableofcontents
\np
\end{document}
but returns error :
Have also tried \[ \] but same error.
The $ symbol is defined within math expressions correctly ?
I'm using mactex (http://www.tug.org/mactex/) with TexShop (http://pages.uoregon.edu/koch/texshop/)


figure. Use\[ \]or\begin{equation} \end{equation}(without$signs). – Sigur Nov 28 '17 at 22:44\begin{figure}with\begin{figure}[h!]. And, please read the posting Why is\[ ... \]preferable to$$ ... $$? – Mico Nov 28 '17 at 22:48\[\]orequationwithout dollar signs. – campa Nov 29 '17 at 08:51