2

I am writing a lab report introduction and am showing a figure of the reaction path. The image is very small and only requires the space of about 10 lines of text. However, when typesetting, Latex formats the figure so it is on a separate page, which looks very silly. How can I get the figure so be on the same page as the introduction paragraph?

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}          
\usepackage{graphicx}
\usepackage{setspace}\onehalfspacing
\usepackage{float}

\begin{document}

\title{Experiment 3}

\author{Sophie Parsons%
  \thanks{CRSid: \texttt{bb70}}}
\affil{university}


\date{Dated: \today}

\maketitle



\section{Introduction}
In the reactor, the benzene and maleic anhydride can also degrade into other useless products, as shown in figure \ref{fig:7}.

\begin{figure}[H]
\begin{center}
\includegraphics[scale=0.8]{scheme.pdf}
\caption{default}
\label{fig:7}
\end{center}
\end{figure}

\end{document}

enter image description here

7
  • 1
    You shouldn't use the H position specifier, as it may result in unwanted white spaces. Use !htb instead. This being said, try replacing the center environment (which adds a supplementary vertical spacing to the one added by the figureenvironment) with the \centering directive.
    – Bernard
    Feb 6, 2018 at 13:09
  • I have now done both these recommendations but it has moved my figure to the back of the report? Feb 6, 2018 at 13:34
  • 1
    Then you should post a minimal example demonstrating the problem. Are you sure your image is as small as it seems to be? It might have a bounding box much larger than the real image. You can test this using \fbox{\includegraphics[scale=0.8]{scheme.pdf}.
    – Bernard
    Feb 6, 2018 at 13:39
  • you are right Bernard,the box fills the A4 page. However, I have now attached my image to the questions, and as you can see, the actual image is much smaller. \begin{figure}[!htb] {\centering \fbox{\includegraphics[scale=0.8]{scheme.pdf}} %\includegraphics[scale=0.8]{scheme.pdf} \caption{default} \label{fig:7} } \end{figure} Feb 6, 2018 at 13:55
  • Did you obtain this image yourself, and if so, how?
    – Bernard
    Feb 6, 2018 at 14:24

1 Answer 1

2

your image you can generate with the following small document:

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta, 
                chains,
                decorations.markings,
                positioning,
                quotes,
                }

\begin{document}
    \begin{tikzpicture}[
            > = Triangle,
   decoration = {markings,% switch on markings
                 mark=at position 0.5 with {\arrow[thick]{>}}
                 },
     N/.style = {on chain},
node distance = 7mm and 21 mm,
    start chain = going right
                    ]
\node (a) [N]   {A};
\node (b) [N]   {B};
\node (c) [N]   {C};
%
\coordinate[below=of a] (aux);
\draw[postaction={decorate}]    (a) to ["$k_1$"]    (b);
\draw[postaction={decorate}]    (b) to ["$k_2$"]    (c);
\draw[postaction={decorate}]    (a) -- (aux) to ["$k_3$" '] (aux -| c) -- (c);
    \end{tikzpicture}
\end{document}

enter image description here

or include its code directly to your document:

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{setspace}\onehalfspacing
\usepackage{tikz} % <--- added
\usetikzlibrary{arrows.meta,         % <--- added
                chains,              % <--- added
                decorations.markings,% <--- added
                positioning,         % <--- added
                quotes,              % <--- added
                }

\begin{document}

\title{Experiment 3}
\author{Sophie Parsons%
  \thanks{CRSid: \texttt{bb70}}}
%\affil{university}
\date{Dated: \today}
\maketitle


\section{Introduction}
In the reactor, the benzene and maleic anhydride can also degrade into other useless products, as shown in figure \ref{fig:7}.
    \begin{figure}[ht]
\centering% <--- changed
        \begin{tikzpicture}[  % <--- added, instead of includegraphics
                > = Triangle,
       decoration = {markings,% switch on markings
                     mark=at position 0.5 with {\arrow[thick]{>}}
                     },
         N/.style = {on chain},
    node distance = 7mm and 21 mm,
        start chain = going right
                        ]
    \node (a) [N]   {A};
    \node (b) [N]   {B};
    \node (c) [N]   {C};
    %
    \coordinate[below=of a] (aux);
    \draw[postaction={decorate}]    (a) to ["$k_1$"]    (b);
    \draw[postaction={decorate}]    (b) to ["$k_2$"]    (c);
    \draw[postaction={decorate}]    (a) -- (aux) to ["$k_3$" '] (aux -| c) -- (c);
        \end{tikzpicture}
\caption{default}
\label{fig:7}
    \end{figure}
\end{document}

and obtain:

enter image description here

note:

  • instead of tikz package, you can use pstric (with latter i'm not familiar)
  • image generated in separate document (its name is name of image, if you like to include as .pdf image) or with code by which you replace \includegraphics{...} hasn't spurious space around it. consequently it should be on the same page as they are inserted in text (with exception, that it is inserted till before bottom of page).
  • i drown this image for fun and exercise. if you have question about tikz, don't hesitate to ask new questions ...

You must log in to answer this question.

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