Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Hi I'm trying to display an image with a caption; the parent file (CODE1) calls the chapter file (CODE2) and the .sty file (CODE3).

Here is the the "chapter" file... call it CODE1

\chapter{Introduction}\label{ch:intro}

\section{figure testing}\label{ch:intro:firstsection}
\begin{figure}[h]
\centering
    \includegraphics[width=0.8\textwidth]{glow}
    \caption{Glow discharge at 0.1mm, 0.5mm,1mm and 3mm.}
\end{figure}
\end{document}

Here is the parent file that calls the "chapter" file in the command \newchapter{chapter2} --CODE2--

\documentclass[12pt,letterpaper]{report}
\usepackage[masters,2committee]{cuthesis}
\usepackage{array}
\usepackage{graphicx}
\usepackage{cite}
\usepackage{float}
\usepackage{subfigure}
\usepackage{amsmath,amssymb}
\usepackage{rotating}
\usepackage{setspace}
\usepackage{longtable}
\usepackage{psfrag}
\usepackage{rotating}
\usepackage{epsfig}
\usepackage{multirow}
\usepackage{hyperref}   
\usepackage[version=3]{mhchem}
\usepackage{lmodern}
\usepackage{verbatim} 
\usepackage{color}    
\usepackage{url}
\usepackage[hang,footnotesize,bf]{caption}
\usepackage{amsmath} 
\usepackage{verbatim}  
\usepackage[latin1]{inputenc}
\usepackage{calc}

\DeclareGraphicsExtensions{.pdf,.png,.jpg,.eps}

\begin{document}
    \dept{Mechanical Engineering}
    \title{Ignition systems}
    \author{xxxxxx}
    \submitdate{2040} \copyrightyear{2012}
    \supervisor{John Doe, Supervisor}
    \supervisor{Jane Doe, Industrial Partner}
    \firstcommittee{J. Doe}
    \departmentchair{Steve Doe, Department Chair}


\newchapter{chapter2}

\end{document}

Here is the .sty file that I received for the template. --CODE3--

%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This LaTeX package is used to create theses and dissertations at
% the Carleton University.  It was was written by UNIVERSITY OF RHODE ISLAND
% and modified for use at Carleton University by Calvin Rans from the
% Department of Mechanical and Aerospace Engineering.  It has several
% options which are described below.  Multiple options can be included
% as a comma separated list.  See the examples section for common uses. Some further alterations were made on behalf of the Carleton University Library by Joshua Kilberg.
%
%
%
% Options:
%   manuscript,standard: this specifies which format of thesis you will
%     be creating.  Manuscript format has the references at the end of each
%     chapter, while standard format has one reference section for the
%     whole document.  standard is the default.
%
%   phd,masters: this specifies whether this is a PhD. dissertation
%     or a masters thesis.  masters is the default.
%   DUE TO NEW CHANGES TO THE CARLETON LIBRARY SYSTEM, KEEP MASTERS
%  SELECTED, EVEN IF YOU ARE GETTING A PHD

%   1committee, 2committee, 3committee,4committee,5committee: this is the number of people
%     on your committee (in addition to the department chair), which determines how many signature lines
%     are needed.  Remember that the chairman of the committee
%     does not sign the thesis.  1committee is the default.
%
%   sequential,nonsequential: this specifies whether you want numbering
%     of figures, equations, and tables reset to 1 at the beginning of
%     each chapter (nonsequential), or if you want the numbers to
%     be sequential throughout the whole document.  The default is
%     nonsequential for Manuscript format and sequential for
%     Standard format.
%
%
% Examples:
%   For a standard format masters thesis:
%     \usepackage{cuthesis}
%   CARLETON DOES NOT USE THE WORD DISSERTATION, SO STICK WITH MASTERS
%   For a manuscript format PhD. dissertation:
%     \usepackage[manuscript,phd]{cuthesis}
%
%   For a standard format PhD. dissertation with a four member committee:
%     \usepackage[phd,4committee]{cuthesis}
%
%
% Notes:
%   Portions of this package were derived from the chapterbib
%   package (Version 1.5 (09-OCT-1995) Donald Arseneau), therefore
%   you should be sure not to use that package with this one due
%   to inevitable conflicts.
%
%   You will also need the file cubiblio.bst for creating the
%   bibliography.
%
%   This package has been designed to comply with the library's
%   format guidelines using either a 10pt or 12pt font, which is
%   specified in the \documentclass line.
%
%   By default the department named on the title page is Mechanical
%   and Aerospace Engineering, but that can be changed by putting the
%   command:
%     \dept{My Department}
%   in the main .tex file before any of the chapters are included.
%
%   The acknowledgements, contributions, and dedication sections are not
%   required, but the abstract section is.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%

\@ifundefined{DeclareOption}{}{% LaTeX2e option
\ProvidesPackage{cuthesis}[2003/04/04 \space  v 1.2]

\DeclareOption{manuscript}{\def\@wantmanuscript{true}}
\DeclareOption{standard}{}

\DeclareOption{phd}{\def\@phddissertation{true}}
\DeclareOption{masters}{}

\DeclareOption{nocopy}{\def\@nolibraryrights{true}}
\DeclareOption{copy}{}

\DeclareOption{noleadpages}{\def\@noleadpages{true}}
\DeclareOption{leadpages}{}

\DeclareOption{norefbib}{\def\@norefbib{true}}
\DeclareOption{refbib}{}

\DeclareOption{noextrapages}{\def\@noleadpages{true}\def\@norefbib{true}}
\DeclareOption{extrapages}{}

\DeclareOption{nonsequential}{\def\@wantnonsequential{true}}
\DeclareOption{sequential}{\def\@wantsequential{true}}

\DeclareOption{4committee}{\def\@fourcommittee{true}}
\DeclareOption{5committee}{\def\@fivecommittee{true}}
\DeclareOption{3committee}{\def\@threecommittee{true}}
\DeclareOption{2committee}{\def\@twocommittee{true}}
\DeclareOption{1committee}{}

\ProcessOptions
}

\@ifundefined{@wantmanuscript}{
  % standard
  \@ifundefined{@wantnonsequential}{}{\def\@nonsequential{true}}
}{
  % manuscript
  \@ifundefined{@wantsequential}{\def\@nonsequential{true}}{}
}

\def\bibliocite#1{%
  \if@filesw\immediate\write12{\string\citation{#1}}\fi}

\@ifundefined{@wantmanuscript}{

\@ifundefined{@extra@b@citeb}{
% this is for use without the cite package
\def\@citex[#1]#2{%
  \let\@citea\@empty
  \@cite{\@for\@citeb:=#2\do
    {\@citea\def\@citea{,\penalty\@m\ }%
     \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
     \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
     \if@filesw\immediate\write12{\string\citation{\@citeb}}\fi
     \@ifundefined{b@\@citeb}{\mbox{\reset@font\bfseries ?}%
       \G@refundefinedtrue
       \@latex@warning
         {Citation `\@citeb' on page \thepage \space undefined}}%
       {\hbox{\csname b@\@citeb\endcsname}}}}{#1}}
}
{
% this is for use with the cite package
\def\@nocite#1{\xdef\@no@sparg{\@ignsp#1 \! }% remove *ALL* spaces
 \if@filesw \immediate\write\@auxout {\string\citation {\@no@sparg}}\fi
 \if@filesw \immediate\write12{\string\citation{\@no@sparg}}\fi}
}

}
{

% this section is basically chapterbib

\newenvironment{cbunit}%
{\global\advance\c@inputfile\@ne \xdef\the@ipfilectr{@-\the\c@inputfile}%
  \immediate\write\@auxout{\string\gdef\string\@extra@binfo{\@exele@b@citeb}}}%
{\gdef\the@ipfilectr{}%
  \immediate\write\@auxout{\string\gdef\string\@extra@binfo{\@exele@b@citeb}}%
  }

\let\cb@include\include
\def\include#1{\clearpage \cbunit \xdef\@currentipfile{#1}%
  \cb@include{#1}%
\refsforcb%
\global\let\@currentipfile\@savedjobname\endcbunit}

\newcommand\cbinput[1]{\cbunit \xdef\@currentipfile{#1}%
  \input{#1}\global\let\@currentipfile\@savedjobname\endcbunit}

\@ifundefined{@extra@binfo}{%
  \def\bibcite#1#2{\global\@namedef{b@#1\@extra@binfo}{#2}}%
}{}

\@ifundefined{@exele@b@citeb}{%
 \def\@citex[#1]#2{%
   \let\@citea\@empty%
   \@cite{\@for\@citeb:=#2\do%
     {\@citea\let\@citea\citepunct%
      \edef\@citeb{\expandafter\@iden\@citeb}%
      \ifnum0=\value{mychapcitecount}%
      \if@filesw\immediate\write\@auxout{\string\bibstyle{cubiblio}}\fi%
      \if@filesw\immediate\write\@auxout{\string\bibdata{\@reffile}}\fi%
      \setcounter{mychapcitecount}{1}%
      \fi%
      \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi%
      \if@filesw\immediate\write12{\string\citation{\@citeb}}\fi%
      \@ifundefined{b@\@citeb \@exele@b@citeb}{\mbox{\reset@font\bf ?}%
         \@warning{Citation `\@citeb' in file `\@currentipfile'
             on page \thepage \space undefined}\G@refundefinedtrue}%
      {\hbox{\citeform{\csname b@\@citeb \@exele@b@citeb\endcsname}}}}}{#1}}
}{}% 2nd arg of \@ifundefined{@exele@b@citeb}

\def\@iden#1{#1}

\@ifundefined{citeform}{\let\citeform=\relax}{}
\@ifundefined{citepunct}{\def\citepunct{,\penalty\@m\ }}{}

\xdef\@savedjobname{\jobname}% save root file name as a macro
\let\@currentipfile\@savedjobname
\gdef\the@ipfilectr{}
\def\@exele@b@citeb{\the@ipfilectr}
\newcount\c@inputfile \global\c@inputfile=0

\gdef\@extra@binfo{}  % in case .aux files are left from old run.

\@ifundefined{reset@font}{\let\reset@font\relax}{}
\@ifundefined{G@refundefinedtrue}{\let\G@refundefinedtrue\relax}{}

\let\cb@bibliographystyle\bibliographystyle
\def\cb@roottest{2\ifx\the@ipfilectr\@empty 1\else2\fi}

\def\bibliographystyle#1{\if\cb@roottest\cb@bibliographystyle{#1}\fi}

\def\bibliography#1{\if\cb@roottest%
   \if@filesw\immediate\write\@auxout{\string\bibdata{#1}}\fi%
   \fi \@input{\@currentipfile.bbl}}

\@ifundefined{PackageWarning}{\def\cb@warning{\@warning}}%
 {\def\cb@warning{\PackageWarning{chapterbib}}}

\let\@test@defiii\@testdef

\def\@testdef#1#2#3{%
  \if#1b\relax\@test@defiii b{#2\@extra@binfo}{#3}%
  \else \@test@defiii #1{#2}{#3}\fi%
}

\@ifundefined{bibname}{\def\bibname{Bibliography}}{}

% end of chapterbib section
}

\renewcommand\contentsname{Table of Contents}

\newcounter{myfigcount}
\newcounter{mytablecount}
\newcounter{myeqncount}
\newcounter{mychapcitecount}
\newcounter{mychaptercount}
\newcounter{myappendixcount}

\def\myusefigurespage{%
  \gdef\@myusefigurespage{true}
}

\def\myusetablespage{%
  \gdef\@myusetablespage{true}
}


\makeatletter

\setlength{\oddsidemargin}{.5in}
\setlength{\textwidth}{6.0in}
\setlength{\marginparsep}{.2in}
\setlength{\marginparwidth}{1in}

\setlength{\topmargin}{-0.3in}
\setlength{\headheight}{0.25in}
\setlength{\headsep}{0.25in}
\setlength{\textheight}{8.6in}
\setlength{\footskip}{.5in}

\brokenpenalty=10000

\renewcommand{\baselinestretch}{1.6}
\renewcommand{\arraystretch}{1.4} % 1.3 spacing for tables and arrays

\def\myps@plain{%
  \let\@mkboth\@gobbletwo
  \let\@oddfoot\@empty\let\@evenfoot\@empty
  \def\@evenhead{\thepage\hfil\slshape\leftmark}%
  \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
}

\def\ele@chapapp{}

\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
        \Large\bfseries \@chapapp\space \thechapter
        \par\nobreak
        \vskip 20\p@
    \fi
    \interlinepenalty\@M
    \LARGE \bfseries #1\par\nobreak
    \vskip 40\p@
  }}


\def\@makeschapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \LARGE \bfseries  #1\par\nobreak
    \vskip 40\p@
  }}

\def\cl@chapter{%
  \setcounter{mychapcitecount}{0}%
  \@ifundefined{@nonsequential}{%
    \@elt{section}\@elt{footnote}%
  }{%
    \@elt{equation}\@elt{figure}\@elt{footnote}\@elt{section}\@elt{table}%
  }}
\def\thefigure{%
  \addtocounter{myfigcount}{\value{figure}}%
  \@ifundefined{@nonsequential}{%
    \@arabic\c@figure%
  }{%
    \thechapter.\@arabic\c@figure%
  }}
\def\thetable{%
  \addtocounter{mytablecount}{\value{table}}%
  \@ifundefined{@nonsequential}{%
    \@arabic\c@table%
  }{%
    \thechapter.\@arabic\c@table%
  }}
\def\theequation{%
  \@ifundefined{@nonsequential}{%
    \@arabic\c@equation%
  }{%
    \thechapter.\arabic{equation}%
  }}



\long\def\@footnotetext#1{\insert\footins{\def\baselinestretch{1}\footnotesize
    \interlinepenalty\interfootnotelinepenalty
    \splittopskip\footnotesep
    \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
    \hsize\columnwidth \@parboxrestore
   \edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}\@makefntext
    {\rule{\z@}{\footnotesep}\ignorespaces
      #1\strut}}}

\def\thebibliography#1{\chapter*{List of References
\@mkboth{}{}}\list
 {[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}\leftmargin
\labelwidth
 \advance\leftmargin\labelsep
 \usecounter{enumi}}
 \setlength{\baselineskip}{0.70\baselineskip}
 \def\newblock{\hskip .11em plus .33em minus .07em}
 \sloppy\clubpenalty4000\widowpenalty4000
 \sfcode`\.=1000\relax}
\let\endthebibliography=\endlist

\def\thesisbib{\chapter*{Bibliography
\@mkboth{}{}}\trivlist
 \setlength{\baselineskip}{0.70\baselineskip}
 \def\newblock{\hskip .11em plus .33em minus .07em}
 \sloppy\clubpenalty4000\widowpenalty4000
 \sfcode`\.=1000\relax}
\let\endthesisbib=\endtrivlist

\def\dept#1{\gdef\@dept{#1}}
\def\supervisor#1{\gdef\@supervisor{#1}}
\def\firstcommittee#1{\gdef\@firstcommittee{#1}}
\def\secondcommittee#1{\gdef\@secondcommittee{#1}}
\def\thirdcommittee#1{\gdef\@thirdcommittee{#1}}
\def\fourthcommittee#1{\gdef\@fourthcommittee{#1}}
\def\departmentchair#1{\gdef\@departmentchair{#1}}
\def\copyrightyear#1{\gdef\@copyrightyear{#1}} % \author, \title in report
\def\@title{}\def\@author{}\def\@dept{Mechanical and Aerospace Engineering}
\def\@supervisor{} \def\@firstcommittee{} \def\@secondcommittee{}
\def\@thirdcommittee{} \def\@fourthcommittee{} \def\@departmentchair{}
\def\@copyrightyear{\number\the\year}
\def\submitdate#1{\gdef\submitdate{#1}}

\def\@reffile{references}

\def\reffile#1{%
  \def\@reffile{#1}
}

\def\abstract#1{%
  \def\@abstract{#1}
}

\def\acknowledgements#1{%
  \def\@acknowledgements{#1}
}

\def\contributions#1{%
  \def\@contributions{#1}
}

\def\dedication#1{%
  \def\@dedication{#1}
}

\def\acronyms#1{%
  \def\@acronyms{#1}
}

\def\symbols#1{%
  \def\@symbols{#1}
}


\def\@bibliofileext{bib}
\def\@bibliofile{\jobname\@bibliofileext}

\def\@awork{%
\@ifundefined{@phddissertation}{
  thesis
}{
  dissertation
}}

% Print title page
\def\titlep{%
    \thispagestyle{empty}%
    \begin{center}
        {\Large\bf\@title}\\
        \mbox{}\\
        \mbox{}\\
        by\\
        \mbox{}\\
        \mbox{}\\
        {\textbf{\@author}}\\
    \end{center}
    \mbox{}
    \begin{center}
        A \@ifundefined{@phddissertation}{
      Thesis
    }{
       Dissertation
    } submitted to \\
    the Faculty of Graduate Studies and Research\\
    in partial fulfilment of\\
    the requirements for the degree of\\
    \@ifundefined{@phddissertation}{
    % CHAGE BELOW MASTER OF ARTS TO MASTER OF SCIENCE OR DOCTOR OF PHIL...
 \textbf{Master of Arts}\\
}{
 \textbf{Doctor of Philosophy}\\
}
\mbox{in}
    \end{center}
    \mbox{}
   % \begin{center}
       % Norman Paterson School of International Affairs
    %\end{center}
    \mbox{}
    \begin{center}
        \@dept\\
        Carleton University\\
        Ottawa, Ontario, Canada\\
        \submitdate\\
    \end{center}
    \mbox{}
    \begin{center}
        Copyright \copyright\\
        \@copyrightyear\ - \@author
    \end{center}\clearpage}


\long\def\signature#1{%
  \begin{minipage}[t]{4in}
    \vspace{.4in}
    \hbox{\hfil\shortstack{\vrule width 3in height 0.4pt \\#1}}
  \end{minipage}}

\def\comprof{%
\begin{minipage}[t]{1.5in}
  \begin{flushright}
    \@ifundefined{@phddissertation}{
      Thesis
    }{
       Dissertation
    }
    Committee\\
    Supervisor
  \end{flushright}
\end{minipage}}

% Print signature approval page
\def\signaturepage{%
\thispagestyle{plain}%
\begin{center}
    The undersigned recommend to\\
    the Faculty of Graduate Studies and Research\\
    acceptance of the \@ifundefined{@phddissertation}{
      Thesis
    }{
       Dissertation
    }\\
\end{center}
\mbox{}
\begin{center}
    {\large\bf\@title}
\end{center}
\mbox{}
\begin{center}
    Submitted by \textbf{\@author}\\
    in partial fulfilment of the requirements for the degree of\\
        \@ifundefined{@phddissertation}{
 \textbf{\bf{Master of Science}}\\
}{
 \textbf{\bf{Doctor of Philosophy}}\\
}
\end{center}
\vfill
\begin{center}
  \begin{tabular}{rl}
      & \signature{\@supervisor}\\
    \@ifundefined{@twocommittee}{}
    {
      & \signature\@firstcommittee\\
    }
    \@ifundefined{@threecommittee}{}
    {
      & \signature\@firstcommittee\\
      & \signature\@secondcommittee\\
    }
    \@ifundefined{@fourcommittee}{}
    {
      & \signature\@firstcommittee\\
      & \signature\@secondcommittee\\
      & \signature\@thirdcommittee\\
    }
    \@ifundefined{@fivecommittee}{}
    {
      & \signature\@firstcommittee\\
      & \signature\@secondcommittee\\
      & \signature\@thirdcommittee\\
      & \signature\@fourthcommittee\\
    }
     & \signature{\@departmentchair}
\\
\end{tabular}
\end{center}
\vfill
\begin{center}{
  Carleton University\\
  \@copyrightyear}
\end{center}}

\def\startingpages{%
  \setcounter{page}{0}
  \pagestyle{plain}
  \pagenumbering{roman}
  \titlep
 % \signaturepage
  \immediate\openout12=\@bibliofile.aux
  \immediate\write12{\string\bibstyle{cubiblio}}
  \immediate\write12{\string\bibdata{\@reffile}}
  \@ifundefined{@abstract}{}{
    \doourabstract{\@abstract}
  }
  \@ifundefined{@dedication}{}{
    \doourdedication{\@dedication}
  }
  \@ifundefined{@acknowledgements}{}{
    \doouracknowledgements{\@acknowledgements}
  }
  \@ifundefined{@contributions}{}{
    \doourcontributions{\@contributions}
  }
  \contentspages
  \@ifundefined{@acronyms}{}{
    \doouracronyms{\@acronyms}
  }
  \@ifundefined{@symbols}{}{
    \dooursymbols{\@symbols}
  }
  \pagenumbering{arabic}
  \pagestyle{myheadings}
}

\def\doourabstract#1{%
  \sloppy
  \chapter*{Abstract}
  \addcontentsline{toc}{chapter}{Abstract}
  \@ifundefined{@phddissertation}{
    \thispagestyle{plain}
    %\thispagestyle{empty}
    \pagestyle{plain}
  }{
    \thispagestyle{plain}
    \pagestyle{plain}
  }
  \input{#1}
  \newpage
  \pagestyle{plain}
}

\def\doouracknowledgements#1{%
  \chapter*{Acknowledgments}
  \addcontentsline{toc}{chapter}{Acknowledgments}
  \input{#1}
}

\def\doourdedication#1{%
  \newpage
  \thispagestyle{plain}
  \include{#1}
}

\def\doourcontributions#1{%
  \chapter*{Contributions}
  \addcontentsline{toc}{chapter}{Contributions}
  \input{#1}
}

\def\doouracronyms#1{%
  \chapter*{List of Acronyms}
  \addcontentsline{toc}{chapter}{List of Acronyms}
  \input{#1}
  \newpage
}

\def\dooursymbols#1{%
  \chapter*{List of Symbols}
  \addcontentsline{toc}{chapter}{List of Symbols}
  \input{#1}
  \newpage
}

\def\contentspages{\newpage
  \addcontentsline{toc}{chapter}{Table of Contents}
  \tableofcontents
  \newpage
      \@ifundefined{@myusetablespage}{}{
    {\addvspace{10pt}
    \let\saveaddvspace=\addvspace
    \def\addvspace##1{}
    \addcontentsline{toc}{chapter}{List of Tables}
    \listoftables
    \let\addvspace=\saveaddvspace}
  \newpage
  }
  \@ifundefined{@myusefigurespage}{}{
    {\addvspace{10pt}
    \let\saveaddvspace=\addvspace
    \def\addvspace##1{}
    \addcontentsline{toc}{chapter}{List of Figures}
    \listoffigures
    \let\addvspace=\saveaddvspace}
  \newpage
  }
}

\def\newchapter#1{%
  \ifnum0=\value{mychaptercount}
    \@ifundefined{@noleadpages}{
      \startingpages
    }{}
    \setcounter{mychaptercount}{1}
  \fi
  \include{#1}
}

\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\ele@chapapp\space \protect\numberline{\thechapter}#1}%
                    \else
                      \addcontentsline{toc}{chapter}{#1}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}


\def\newappendix#1{%
  \ifnum0=\value{myappendixcount}
    \startappendix
    \setcounter{myappendixcount}{1}
  \fi
  \include{#1}
}

\def\startappendix{%
  \def\ele@chapapp{Appendix}
  \@ifundefined{@wantmanuscript}{
    \addcontentsline{toc}{chapter}{List of References}
     \bibliographystyle{cubiblio}
    \@ifundefined{@norefbib}{
      \bibliography{\@reffile}
    }{}
    \newpage
  }{}

  \appendix
  % This causes latex to number equations, tables, figures with
  % A-1, A-2, ...
%  \renewcommand{\theequation}{\Alph{chapter}.\arabic{equation}}
%  \renewcommand{\thetable}{\Alph{chapter}.\arabic{table}}
%  \renewcommand{\thefigure}{\Alph{chapter}.\arabic{figure}}
}

% used for manuscript form chapter references
\def\refsforcb{%
  \@ifundefined{@wantmanuscript}{
  }{
    \ifnum0=\value{mychapcitecount}
      \relax
    \else
      \newpage
      \addcontentsline{toc}{section}{List of References}
%      \addcontentsline{toc}{chapter}{List of References}
      \bibliography{\@reffile}
      \bibliographystyle{cubiblio}
      \newpage
    \fi
  }
}

\def\biblio{%
  \ifnum0=\value{myappendixcount}
    \startappendix
  \fi
  \ifnum0=\value{myfigcount}
    \relax
  \else
    \if@filesw\immediate\write\@auxout{\string\myusefigurespage}\fi
  \fi
  \ifnum0=\value{mytablecount}
    \relax
  \else
    \if@filesw\immediate\write\@auxout{\string\myusetablespage}\fi
  \fi
  \addcontentsline{toc}{chapter}{Bibliography}
  \@input{\@bibliofile.bbl}
}

\def\bibliox{\bibliography{\@reffile}}

\@ifundefined{@norefbib}{
  \let\@enddocumenthook\biblio
}{
  \let\@enddocumenthook\bibliox
}

Here is the error I recieve when trying to compile CODE2...

./chapter2.tex:21: Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...
l.21    \caption{
               Glow discharge at 0.1mm, 0.5mm,1mm and 3mm.}

Any idea why I'm getting this error??

share|improve this question
1  
It seems that you forgot to load the calc package. –  egreg Oct 13 '11 at 20:37
    
Your code is incomplete, since the normal \caption command doesn't use the calc package. Adding a \usepackage{caption} might help (it surely won't hurt). If it doesn't, we need a MWE and its log. –  Martin Schröder Oct 13 '11 at 22:43
    
Don't load the calc package. –  egreg Oct 14 '11 at 14:20
    
Whether the calc package is loaded or not I get the same error. –  Nicholas Giordano Oct 14 '11 at 15:01
    
BTW, Welcome to TeX.SE. Good to see another Canadian on here, eh. :-) –  Peter Grill Oct 14 '11 at 19:14
show 1 more comment

3 Answers

up vote 3 down vote accepted

First of all your example is far from being a MWE. Eliminating every package and command not relevant for the error I got:

\documentclass[12pt,letterpaper]{report}
\usepackage[masters,2committee]{cuthesis}
%\usepackage[demo]{graphicx}
\usepackage{calc}

\begin{document}
\begin{figure}
%\centering
%    \includegraphics[width=0.8\textwidth]{glow}
    \caption{Glow discharge at 0.1mm, 0.5mm,1mm and 3mm.}
\end{figure}
\end{document}

(This is the step which should have been done by you, not by me.)

So it seems the cuthesis package is incompatible to the calc package.

Going one step further, means integrating and eliminating everything from the cuthesis package not relevant for the problem, I got:

\documentclass{report}
\newcounter{myfigcount}
\def\thefigure{%
  \addtocounter{myfigcount}{\value{figure}}%
    \thechapter.\arabic{figure}%
  }
\usepackage{calc}

\begin{document}
\begin{figure}
    \caption{}
\end{figure}
\end{document}

So it seems handling with counters (myfigcount) inside a definition bound to a different counter (figure) is a bad idea, at least if the calc package is loaded.

So there are three different solutions to this:

  • Don't load the calc package, as already suggested by egreg.

  • Or write an e-mail to the maintainer of the cuthesis package telling him that his redefinition of \thefigure (and \thetable) is incompatible to the calc package, so he will hopefully fix it. (Advancing the myfigcount by figure seems to be wrong for me anyway.)

  • Or write an e-mail, including this MWE and/or a link to this Question at Stackexchange, to the maintainer of the calc package asking for support.

share|improve this answer
    
The class increments myfigcount and similar counters just to decide whether figures actually appear in the document. Setting globally a flag once should be sufficient; the code should go in the definition of figure and not in \thefigure. That's a very bad idea. –  egreg Oct 15 '11 at 10:36
    
Thanks for the suggestions, I will try to get in contact with the maintainer of the cuthesis package since I'm sure I must not be the only one looking to use the calc package with the cuthesis package. If I can't get ahold of them I will try the other two options. I really appreciate the assistance. –  Nicholas Giordano Oct 19 '11 at 16:06
add comment

To complement Axel's answer, here's a way to avoid the problem: add

\makeatletter
\def\thefigure{%
  \@ifundefined{@nonsequential}{%
    \@arabic\c@figure% 
  }{%
    \thechapter.\@arabic\c@figure%
  }}
\def\thetable{%
  \@ifundefined{@nonsequential}{%
    \@arabic\c@table%
  }{%
    \thechapter.\@arabic\c@table%
  }}

\usepackage{etoolbox}
\preto\figure{\stepcounter{myfigcount}}
\preto\table{\stepcounter{mytablecount}}
\makeatother

to your preamble, just before \begin{document}.

share|improve this answer
    
Thanks, I will try this as well. –  Nicholas Giordano Oct 19 '11 at 16:07
add comment

If you move \usepackage{calc} to the first package loaded (right after \documentclass), this file compiles for me.

Also, note that:

  1. you should remove the \end{document} in the chapter2.tex.
  2. There is inconsistent spacing int the caption after the commas: 0.5mm,1mm should be 0.5mm, 1mm.

It seems that this order of the packages works:

\usepackage{calc}
\usepackage{amsmath,amssymb}

but not this order:

\usepackage{amsmath,amssymb}
\usepackage{calc}

i find it hard to believe that there is some problem with the amsmath or amssymb packages so not sure exactly what is going on.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.