0

enter image description here

There are two parts to this code. First is the figures and calculations after. (Indicated by the two comments). But when I run them they appeared in the reverse order.

\subsection*{Figures}
\begin{center}       
%should appear first
    \begin{figure}[ht]
        \begin{subfigure}[b]{0.5\linewidth}
        \centering
        \includegraphics[width=0.9\linewidth]{../figures/Ptime.jpg}
        \caption{Pressure vs Step}
        \vspace{4ex}
        \end{subfigure}
        \begin{subfigure}[b]{0.5\linewidth}
        \centering
        \includegraphics[width=0.9\linewidth]{../figures/temptime.jpg}
        \caption{Temperature vs Step}
        \vspace{4ex}
        \end{subfigure} 
        \begin{subfigure}[b]{0.5\linewidth}
        \centering
        \includegraphics[width=0.9\linewidth]{../figures/KEtime.jpg}
        \caption{Kinetic Energy vs Step}
        \end{subfigure} 
        \begin{subfigure}[b]{0.5\linewidth}
        \centering
        \includegraphics[width=0.9\linewidth]{../figures/PEtime.jpg}
        \caption{Potential Energy vs Step}
        \end{subfigure}
    \caption{}
    \end{figure}
    \end{center}
    %should appear next
    \textit{Calculation of Self Diffusion Coefficient}
    \begin{equation*}
    \begin{split}
    \text{slope} & = 0.0021 \\
    \text{Self Diffusion Coeff} & =\frac{1}{6}\times \text{(Slope of MSD at long time)}\\
    & = \frac{1}{6} \times \text{0.0021}\\
    & = \SI{3.5e-4} {\text{LJ units}}
    \end{split}
    \end{equation*}
    \text{Considering the LJ liquid to be liquid Ar, we have $\sigma = 0.34 \textit{ nm}$, $\frac{\epsilon}{k_B}=120 \textit{ K}$. }\\
    \text{$\therefore \frac{{(L^*)}^2}{t^*}=\frac{{L^2}/{\sigma^2}}{t\sqrt{\frac{\epsilon}{m\sigma^2}}}\implies \frac{L^2}{t}= (\sigma^3\sqrt{m/\epsilon}) \frac{(L^*)^2}{t^*} \implies \frac{L^2}{\epsilon}=\num{2.49e-31}\frac{(L^*)^2}{t^*}$}
    \linebreak
    \begin{equation*}
    \begin{split}
    \text{Diffusion Coefficient in SI Units} &= \num{3.5e-4}\times \SI{2.489e-31}{\meter^2 /\second}\\
    &=\SI{8.7e-34}{\meter^2 /\second}
    \end{split}
    \end{equation*}
  • 2
    Search for "Figures position". It can be a pain in the neck. The [ht] after \begin{figure} is what you need to experiment with. The h is a soft "here" the t is a "top" (as in top of the page). If it is ok, try changing the t to a b (bottom), or try changing the h to a H (a "hard" here). – Emil Vatai Nov 27 '19 at 8:31
  • 3
    Putting a figure inside center dies not make sense as the figure floats I would start by setting the float placement to [htp] and work from there. The H has its uses but should not be used in a normal document – daleif Nov 27 '19 at 9:04
  • did the answer below meet your requirement? – js bibra Dec 21 '19 at 14:26
  • The short answer is that the {figure} environment is allowed to float to where TeX thinks is best. If you don't want that, you don't need to use the {figure} environment. A longer answer would be tex.stackexchange.com/q/39017/107497 and everything that links to it. – Teepeemm Jan 30 at 16:12
0

Works correctly once the text above the second eqn is shortened to just one text word considering --probably some error in the eqn --other than that lines up correctly

enter image description here

\documentclass[]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}   
\usepackage{mathtools}
\usepackage{amssymb,booktabs}
\usepackage{caption,subcaption}

\begin{document}
\subsection*{Figures}
\begin{center}       
%should appear first
    \begin{figure}[ht]
        \begin{subfigure}[b]{0.5\linewidth}
        \centering
        \includegraphics[width=0.9\linewidth]{example-image-a}
        \caption{Pressure vs Step}
        \vspace{4ex}
        \end{subfigure}
        \begin{subfigure}[b]{0.5\linewidth}
        \centering
        \includegraphics[width=0.9\linewidth]{example-image-a}
        \caption{Temperature vs Step}
        \vspace{4ex}
        \end{subfigure} 
        \begin{subfigure}[b]{0.5\linewidth}
        \centering
        \includegraphics[width=0.9\linewidth]{example-image-a}
        \caption{Kinetic Energy vs Step}
        \end{subfigure} 
        \begin{subfigure}[b]{0.5\linewidth}
        \centering
        \includegraphics[width=0.9\linewidth]{example-image-a}
        \caption{Potential Energy vs Step}
        \end{subfigure}
    \caption{}
    \end{figure}
    \end{center}
    %should appear next
    \textit{Calculation of Self Diffusion Coefficient}
    \begin{equation}
\begin{split}
TCU & = \frac{\text{purchasing cost} + \text{setup cost} + \text{holding cost}}{time} \\
    & = \frac{cy+K+h\frac{y}{2}t_0}{t_0}
\end{split}
\end{equation}
    \text{Considering the LJ liquid to be liquid Ar, we have $\sigma = 0.34 \textit{ nm}$, $\frac{\epsilon}{k_B}=120 \textit{ K}$. }\\
    \text{$\therefore \frac{{(L^*)}^2}{t^*}=\frac{{L^2}/{\sigma^2}}{t\sqrt{\frac{\epsilon}{m\sigma^2}}}\implies \frac{L^2}{t}= (\sigma^3\sqrt{m/\epsilon}) \frac{(L^*)^2}{t^*} \implies \frac{L^2}{\epsilon}=\num{2.49e-31}\frac{(L^*)^2}{t^*}$}
    \linebreak
    \begin{equation}
\begin{split}
TCU & = \frac{\text{purchasing cost} + \text{setup cost} + \text{holding cost}}{time} \\
    & = \frac{cy+K+h\frac{y}{2}t_0}{t_0}
\end{split}
\end{equation}
    \end{document}
| improve this answer | |
  • Hi, excuse me for my comment, but mathtools loads the amsmath package. Therefore you can delete amsmath . – Sebastiano Dec 30 '19 at 16:17
  • @Sebastiano done! – js bibra Dec 31 '19 at 15:22
  • 1
    figure shouldn't be put inside center. That could leave extra space unassociated with figure that might well change the placement of the figure, including moving it to a different page. – barbara beeton May 29 at 20:11

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.