2

My problem is very simple - my figure is appearing far away from the text, as seen below.

Latexfigure

The actual image I am pasting is here - figure so there is some white space above, but clearly not as much as Latex would lead us to believe. There is no text below the image. I am going to struggle to provide a MWE because I am using a thesis template, and the .cls file does a lot of the stuff for me.

I know that given the size, it is not going to fit on the previous page, however, surely should it go to at least the top of the next page?

Additional information from the thesis.cls file

%% This is file `Thesis.cls', based on 'ECSthesis.cls', by Steve R. Gunn
%% generated with the docstrip utility.
%%
%% Created by Steve R. Gunn, modified by Sunil Patel: www.sunilpatel.co.uk
[skip some stuff]

\usepackage{setspace}
\onehalfspacing
\setlength{\parindent}{0pt}
\setlength{\parskip}{2.0ex plus0.5ex minus0.2ex}
\usepackage{vmargin}
\setmarginsrb           { 1.0in}  % left margin
                    { 0.6in}  % top margin
                    { 1.0in}  % right margin
                    { 0.8in}  % bottom margin
                    {  20pt}  % head height
                    {0.25in}  % head sep
                    {   9pt}  % foot height
                    { 0.3in}  % foot sep
\raggedbottom
\setlength{\topskip}{1\topskip \@plus 5\p@}
\doublehyphendemerits=10000       % No consecutive line hyphens.
\brokenpenalty=10000              % No broken words across columns/pages.
\widowpenalty=9999                % Almost no widows at bottom of page.
\clubpenalty=9999                 % Almost no orphans at top of page.
\interfootnotelinepenalty=9999    % Almost never break footnotes.
\usepackage{fancyhdr}
\lhead[\rm\thepage]{\fancyplain{}{\sl{\rightmark}}}
\rhead[\fancyplain{}{\sl{\leftmark}}]{\rm\thepage}
\chead{}\lfoot{}\rfoot{}\cfoot{}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\btypeout{\thechapter\space #1}\markboth{\@chapapp\    \thechapter\ #1}{\@chapapp\ \thechapter\ #1}}
\renewcommand{\sectionmark}[1]{}
\renewcommand{\subsectionmark}[1]{}
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\usepackage{amsmath,amsfonts,amssymb,amscd,amsthm,xspace}
\theoremstyle{plain}
\newtheorem{example}{Example}[chapter]
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{axiom}[theorem]{Axiom}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
\usepackage[centerlast,small,sc]{caption}
\setlength{\captionmargin}{20pt}
\newcommand{\fref}[1]{Figure~\ref{#1}}
\newcommand{\tref}[1]{Table~\ref{#1}}
\newcommand{\eref}[1]{Equation~\ref{#1}}
\newcommand{\cref}[1]{Chapter~\ref{#1}}
\newcommand{\sref}[1]{Section~\ref{#1}}
\newcommand{\aref}[1]{Appendix~\ref{#1}}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{.85}
\renewcommand{\textfraction}{0.1}
\renewcommand{\dbltopfraction}{.85}
\renewcommand{\floatpagefraction}{0.75}
\renewcommand{\dblfloatpagefraction}{.75}
\setcounter{topnumber}{9}
\setcounter{bottomnumber}{9}
\setcounter{totalnumber}{20}
\setcounter{dbltopnumber}{9}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage[scriptsize]{subfigure}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{listings}
\usepackage{lstpatch}
\lstset{captionpos=b,
    frame=tb,
    basicstyle=\scriptsize\ttfamily,
    showstringspaces=false,
    keepspaces=true}
\lstdefinestyle{matlab} {
    language=Matlab,
    keywordstyle=\color{blue},
    commentstyle=\color[rgb]{0.13,0.55,0.13}\em,
    stringstyle=\color[rgb]{0.7,0,0} }
 \usepackage[pdfpagemode={UseOutlines},bookmarks=true,bookmarksopen=true,
 bookmarksopenlevel=0,bookmarksnumbered=true,hypertexnames=false, hyperfootnotes=false,
 colorlinks,linkcolor={blue},citecolor={blue},urlcolor={red},
 pdfstartview={FitV},unicode,breaklinks=true]{hyperref}
 **snip**

I also have the following in my preamble

\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}

But I am sure that is just to do with tables.

My current code

\begin{figure}[ht]
\includegraphics[scale=0.75]{Tinto.png}
\caption{Tinto's Student Integration Model (1975)}
\end{figure}
  • 5
    Please always include a complete document so people can reproduce the problem. It is impossible to tell from the fragment of source and image you posted. Is that the end of the document (or end of chapter, etc. or is there more text that could have come below the figure? Is the white space above the figure part of the png or added by latex? It is impossible to answer anything given the information here – David Carlisle Mar 04 '14 at 15:33
  • 4
    A "MWE" should start \documentclass and end with \end{document} (that's what the W means:-) – David Carlisle Mar 04 '14 at 15:34
  • @David Carlise - thanks, but I don't think I can post a MWE because I am using a thesis template, and the person who created the template uses a .cls file for many of the settings of the document. I will try and find the relevant code - I suspect it has to do with margins. In the meantime, I have given some additional information. When I just used that image in a separate document (a MWE I guess), it was positioned correctly. – The Statistician Magician Mar 04 '14 at 15:53
  • Since you mentioned the problems is only on specific case, you can upload the .cls file and ask for help. – Tawei Mar 04 '14 at 16:05
  • @selwyndd21 done, although I deleted some of .cls file which dealt with stuff not relevant to this question. – The Statistician Magician Mar 04 '14 at 16:19
  • @Chris so you should be able to make a complete document (preferably replacing the \includegraphics by a \rule of similar size) If you can't make a small document that shows the effect then the effect is caused in the part of the document you haven't shown, which doesn't make it easy to help. – David Carlisle Mar 04 '14 at 16:40
  • If the float hasn't been placed by the time you get to \clearpage either explicitly or in \chapter or end of document then it will be dumped into a float page (which by default are vertically centred) That is why I asked if there is following text, – David Carlisle Mar 04 '14 at 16:42
  • You might be interested in the matlab-prettifier package; see this answer. – jub0bs Apr 28 '14 at 16:36

2 Answers2

5

use the H function from the float package:

\begin{figure}[H]
    \includegraphics ...
\end{figure}
1

You can use the [h!t] or [h!], it will make the figure to be where you want it to be.

\begin{figure}[h!t]
\includegraphics[width=400pt, scale=0.75]{Tinto.png}
\caption{Tinto's Student Integration Model (1975)}
\end{figure}

It works for me.

sulbash
  • 53