\begin{document} ended by \end{figure}, latex error in thesis template

I am writing a thesis in latex, when I add the pstricks code it runs but when I insert the \begin{figure} and \end{figure} command to caption the figure, it generates error \begin{document} ended by \end{figure}...

These are the packages I am using.

\documentclass[12pt]{report}
\usepackage[usenames,dvipsnames]{pstricks}
\usepackage[centertags]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm,amssymb}
\usepackage{newlfont}
\usepackage{xthesis} %DAL Thesis Style
\usepackage{xtocinc} %Include Table of Contents as the first entry in TOC
%                    Advanced Studies and Research Board insists on this!?
\usepackage[usenames,dvipsnames]{pstricks}
\usepackage{pst-grad} % For gradients
\usepackage{pst-plot} % For axes
\usepackage{epsfig}
\usepackage{pstricks-add}
\usepackage{pst-blur}
\usepackage{caption}
\usepackage{graphics, tikz}
\hfuzz2pt % Don't bother to report over-full boxes if over-edge is < 2pt
% Line spacing -----------------------------------------------------------
\newlength{\defbaselineskip}
\setlength{\defbaselineskip}{\baselineskip}
\newcommand{\setlinespacing}[1]%
{\setlength{\baselineskip}{#1 \defbaselineskip}}
\newcommand{\doublespacing}{\setlength{\baselineskip}%
{2.0 \defbaselineskip}}
\newcommand{\singlespacing}{\setlength{\baselineskip}{\defbaselineskip}}
% MATH -------------------------------------------------------------------
\newcommand{\A}{{\cal A}}
\newcommand{\h}{{\cal H}}
\newcommand{\s}{{\cal S}}
\newcommand{\W}{{\cal W}}
\newcommand{\BH}{\mathbf B(\cal H)}
\newcommand{\KH}{\cal K(\cal H)}
\newcommand{\Real}{\mathbb R}
\newcommand{\Complex}{\mathbb C}
\newcommand{\Field}{\mathbb F}
\newcommand{\RPlus}{[0,\infty)}
\newcommand{\norm}[1]{\left\Vert#1\right\Vert}
\newcommand{\essnorm}[1]{\norm{#1}_{\text{\rm\normalshape}}}
\newcommand{\abs}[1]{\left\vert#1\right\vert}
\newcommand{\set}[1]{\left\{#1\right\}}
\newcommand{\seq}[1]{\left<#1\right>}
\newcommand{\eps}{\varepsilon}
\newcommand{\To}{\longrightarrow}
\newcommand{\RE}{\operatorname{Re}}
\newcommand{\IM}{\operatorname{Im}}
\newcommand{\Poly}{{\cal{P}}(E)}
\newcommand{\EssD}{{\cal{D}}}
% THEOREMS ---------------------------------------------------------------
\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
%
\theoremstyle{definition}
\newtheorem{defn}{Definition}[section]
%
\theoremstyle{remark}
\newtheorem{rem}{Remark}[section]
%
\numberwithin{equation}{section}
\renewcommand{\theequation}{\thesection.\arabic{equation}}
%%% ----------------------------------------------------------------------
\setlength{\tclineskip}{1.05\baselineskip}
%%% ----------------------------------------------------------------------
\def\ZZ{Z\!\!\!Z}
\begin{document}
%\nobib
%\draft
%\nofront
%\permissionfalse
\dedicate{\textit{Dedications\\ To my Parents\\
and\\ those who taught me even a single word\\ in my life.}}
\nolistoftables \nolistoffigures \msc \copyrightyear{2013}

\submitdate{September, 2013}

% ------------------------------------------------------------------------
\title{}

\author{}

\supervisor{}
% ------------------------------------------------------------------------
{
\typeout{:?0000} % Don't bother with over/under-full boxes
%\beforepreface
\typeout{:?1111} % Process All Errors from Here on
}

\setlinespacing{2}
% ------------------------------------------------------------------------
{\typeout{Introduction} \markright{\it Ch 1: Introduction}
\include{T0}
% ------------------------------------------------------------------------
\setlinespacing{2}
\setlinespacing{1.5} \markright{\it References}
\bibliographystyle{amsplain}
%\bibliography{XBib}
%\appendix
%\include{Appendix}
\end{document}
% ------------------------------------------------------------------------


This the code of my chapter in which i have added the figure

\def\baselinestretch{1}
\chapter{Introduction}
\def\baselinestretch{1.66}
%%% ----------------------------------------------------------------------
\goodbreak
\begin{figure}
\scalebox{1} % Change this value to rescale the drawing.
{
\begin{pspicture}(0,-1.6045313)(2.64,1.6045313)
\psline[linewidth=0.04cm](0.0,0.94609374)(2.62,-1.0739063)
\psline[linewidth=0.04cm](0.62,0.18609375)(0.96,0.18609375)
\psline[linewidth=0.04cm](0.96,0.22609375)(0.84,0.56609374)
\usefont{T1}{ptm}{m}{n}
\rput(0.17078125,1.4360938){P}
\usefont{T1}{ptm}{m}{n}
\rput(2.1767187,-1.3839062){Q}
\usefont{T1}{ptm}{b}{it}
\rput(2.0196874,0.13609375){x}
\end{pspicture}
}\end{figure}


This file generates the error. If i remove \begin{figure} and \end{figure} it works.

• Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – LaRiFaRi Mar 18 '16 at 8:55
• the most likely cause is that you have an \end{figure} without a \begin{figure} but it is hard to debug that if you only show a part of your document that is unrelated to the error. – David Carlisle Mar 18 '16 at 8:56
• why???? are you loading newlfont this century? unless you particularly need to make font commands work like nfss-latex2.09 that was distributed around 1991-2 before latex2e was published. why load pstricks twice and why load epsfig at all (again unless you are emulating a document from 1990) – David Carlisle Mar 18 '16 at 8:59
• don't add code in comments you can edit the question to fix the example, it should start \documentclass and end \end{docuemnt} and produce the error message that you are asking about . start from a copy of your document and delete everything that you can delete while still having the error. – David Carlisle Mar 18 '16 at 9:29
• I have posted the code it generates the same error – Mathematics Mar 18 '16 at 9:48

1 Answer

I am using package setspacefor the vertical spacing. THis works:

\documentclass[12pt]{report}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage[scaled=0.85]{beramono}
\usepackage[centertags]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm,amssymb}
%\usepackage{xthesis} %DAL Thesis Style
%\usepackage{xtocinc} %Include Table of Contents as the first entry in TOC
%                    Advanced Studies and Research Board insists on this!?
\usepackage[dvipsnames]{pstricks}
\usepackage{pst-grad} % For gradients
\usepackage{pst-plot} % For axes
\usepackage{pstricks-add}
\usepackage{pst-blur}
\usepackage{caption}
\usepackage{graphicx, tikz}
\hfuzz2pt % Don't bother to report over-full boxes if over-edge is < 2pt
% Line spacing -----------------------------------------------------------
\usepackage{setspace}
\newcommand{\A}{{\cal A}}
\newcommand{\h}{{\cal H}}
\newcommand{\s}{{\cal S}}
\newcommand{\W}{{\cal W}}
\newcommand{\BH}{\mathbf B(\cal H)}
\newcommand{\KH}{\cal K(\cal H)}
\newcommand{\Real}{\mathbb R}
\newcommand{\Complex}{\mathbb C}
\newcommand{\Field}{\mathbb F}
\newcommand{\RPlus}{[0,\infty)}
\newcommand{\norm}[1]{\left\Vert#1\right\Vert}
\newcommand{\essnorm}[1]{\norm{#1}_{\text{\rm\normalshape}}}
\newcommand{\abs}[1]{\left\vert#1\right\vert}
\newcommand{\set}[1]{\left\{#1\right\}}
\newcommand{\seq}[1]{\left<#1\right>}
\newcommand{\eps}{\varepsilon}
\newcommand{\To}{\longrightarrow}
\newcommand{\RE}{\operatorname{Re}}
\newcommand{\IM}{\operatorname{Im}}
\newcommand{\Poly}{{\cal{P}}(E)}
\newcommand{\EssD}{{\cal{D}}}
% THEOREMS ---------------------------------------------------------------
\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
%
\theoremstyle{definition}
\newtheorem{defn}{Definition}[section]
%
\theoremstyle{remark}
\newtheorem{rem}{Remark}[section]
%
\numberwithin{equation}{section}
\renewcommand{\theequation}{\thesection.\arabic{equation}}
\def\ZZ{Z\!\!\!Z}
\begin{document}
%   \dedicate{\textit{Dedications\\ To my Parents\\
%           and\\ those who taught me even a single word\\ in my life.}}
%   \nolistoftables \nolistoffigures \msc \copyrightyear{2013}
%   \submitdate{September, 2013}
\title{}
\author{}
%   \supervisor{}
%   \setspace{2}
% ------------------------------------------------------------------------
\markright{\itshape Ch 1: Introduction}
\singlespacing
\chapter{Introduction}
\setstretch{1.66}       \goodbreak
\begin{figure}\centering
\psscalebox{1} % Change this value to rescale the drawing.
{%
\begin{pspicture}(0,-1.6045313)(2.64,1.6045313)
\psline[linewidth=0.04cm](0.0,0.94609374)(2.62,-1.0739063)
\psline[linewidth=0.04cm](0.62,0.18609375)(0.96,0.18609375)
\psline[linewidth=0.04cm](0.96,0.22609375)(0.84,0.56609374)
\usefont{T1}{ptm}{m}{n}
\rput(0.17078125,1.4360938){P}
\usefont{T1}{ptm}{m}{n}
\rput(2.1767187,-1.3839062){Q}
\usefont{T1}{ptm}{b}{it}
\rput(2.0196874,0.13609375){x}
\end{pspicture}%
}
\end{figure}
\setstretch{1.5} \markright{\it References}
\bibliographystyle{amsplain}
\end{document}

• But it is not running the dedication command – Mathematics Mar 19 '16 at 18:57
• When i enable the xthesis package it again shows the same error. – Mathematics Mar 19 '16 at 19:38
• is this package available for download? – user2478 Mar 19 '16 at 19:43
• xthesis seems to be a LaTeX 2.09 package which redefines \@xfloat` in a way incompatible to the current LaTeX2e implementation!? – user2574 Mar 25 '16 at 23:12