LaTeX forum ⇒ Graphics, Figures & TablesTable is not working with my .sty file

Information and discussion about graphics, figures & tables in LaTeX documents.
bmajeed92
Posts: 3
Joined: Mon Apr 01, 2024 11:09 pm

Table is not working with my .sty file

Postby bmajeed92 » Mon Apr 01, 2024 11:19 pm

Hello all,

I am working on my thesis and I have to use the university specified .sty file. But when I use that file I am unable to add any tables using the following.

\begin{table} 
	\caption{Summary Statistics}
	\label{Summary Statistics }
	\centering
	\begin{tabular}{|c|c|c|c|}	\hline
		Statistic	 &A &B &C \\\hline
		AA	   		 &1 &2 &3  \\\hline
	\end{tabular}
\end{table}



Following is the copy of .sty file
%% University of Houston PhD/MS thesis Latex style file -- modifications to the report style
%% 
%% Designed to comply with UH's formatting guidelines, per recommendations in Fall 2019
%%
%% For latest recommendations, please refer to http://www.uh.edu/nsm/computer-science/graduate/defense-guidelines
%%
%% Author: Dr. Babu Sundaram (babusun@central.uh.edu)
%%
%% Last Updated : October 7, 2019


\typeout{Document Style Option `UH Thesis Template' <Aug 2019>.}

\usepackage{geometry}
\usepackage{tocloft}

% The directive below can be finetuned for strict acherence to margin settings
% The default setting works well for the required 1 in margin on all sides
\geometry{verbose, papersize={8.5in,11in},total={6.5in,8.6in}}

\usepackage{setspace}

% Following overrides are used to center the title of the TOC, TOF and TOT listings
\renewcommand{\contentsname}{\begin{center}\Large \bf \uppercase {Table of Contents}\end{center}}
\renewcommand{\listfigurename}{\begin{center}\Large\bf \uppercase {LIST OF FIGURES}\end{center}}
\renewcommand{\listtablename}{\begin{center}\Large\bf \uppercase{LIST OF TABLES}\end{center}}
\renewcommand{\refname}{Bibliography}

\long\def\comment#1{}

\comment{

Example of use:
    \documentstyle[12pt,fullpage]{article}
    \usepackage{uhthesis2019}
    \begin{document}
    \title{Long, Complicated Thesis Title and \\ Make Sure to Capitalize Each Word}
    \author{Maya K Student} % The graduate student/author name
    \chair{Thesis Chairman} % DO not include Dr./Prof. titles in the faculty names
    \cochair{Co Chair}% Comment out this field if no co-chair and also include the \cochairfalse directive
    \firstreader{Committee Member1}
    \secondreader{Committee Member2}
     % All the following additional members are optional (third and fourth required for Ph.D.)
     % Make sure to set the options /(three|four|five)readers(true|false) appropriately
    \thirdreader{Committee Member3}
    \fourthreader{Committee Member4}
    \fifthreader{Committee Member5}
    
    % Following command will create the title and copyright pages (not included in TOC)
    \makecoverpages


    \begin{dedication} % optional section
       Quotes and or words of dedication
    \end{dedication}
    \begin{acknowledgements} % optional section
        I would like to thank...
    \end{acknowledgements}
    \begin{abstract} % Mandatory
       This thesis tells you all you need to know about...
       Should be double-spaced
    \end{abstract}
    % Following command will create the content pages (with roman numbering) and lead to TOC...
    \makecontentspages


    \chapterpages

    \chapter{Introduction}
         ...
    \chapter{Conclusions}
         ...
    \appendix
    \chapter{A Long Proof}
         ...
    \bibliographystyle{plain}
    \bibliography{mybib}
    \end{document}

Documentation:
    This style file modifies the standard report style to follow the
    Dean's Office "Preparing your Thesis/Dissertation for Submission
    to the college of Natural Sciences and Mathematics: A Guideline".  

    The \makecoverpages command creates a copyright page (optionally),
    the title page and, and the signature page.  The \begin{abstact}
    command creates the abstract page.  The abstract itself should be
    included between a \begin{abstact} and an \end{abstact} command, 
    as usual. Your (optional) acknowlegments should be included in the 
    (optional) \begin{acknowledments} ...\end{acknowledments} section.  
    The \makecontentspages command produces the table of contents, the 
    list of tables (optional) and the list of figures (optional). Finally,
    the \chapterpages command sets the page style of the main body of 
    your thesis.
    
    The following commands can control what goes in the front matter
    material:

    \title{thesis title}
    \author{author's name}
        \degree{author's degree}{type of thesis}
                - e.g. \degree{Masters of Science}{Thesis}
                - if \degree is ommitted,
                  \degree{Doctor of Philosophy}{Dissertation} is assumed
    \department{author's department}
        - Computer Science if omitted
        \college{the college or school the thesis is submitted to}  
                - College of Natural Sciences and Mathematics if omitted
    \chair{the chair's name}
    \firstreader{the first reader's name}
    \secondreader{the second reader's name}
    \thirdreader{the third reader's name}
    \fourthreader{the fourth reader's name}
    \fifthreader{the fifth reader's name}    
    \cochairtrue or \cochairfalse
        - print or don't print a Co-chair in the
                  signature page (true by default)
    \threereaderstrue or \threereadersfalse
        - print or don't print a third reader in the
                  signature page (true by default)
    \fourreaderstrue or \fourreadersfalse
        - print or don't print a fourth reader in the
                  signature page (true by default)
    \fivereaderstrue or \fivereadersfalse
        - print or don't print a fifth reader in the
                  signature page (true by default)                  
    \submitdate{month year in which the thesis is submitted}
        - date LaTeX'd if omitted
    \copyrighttrue or \copyrightfalse
        - produce or don't produce a copyright page (true by default)
    \figurelisttrue or \figurelistfalse
        - produce or don't produce a List of Figures page
          (true by default)
    \tablelisttrue or \tablelistfalse
        - produce or don't produce a List of Tables page
          (true by default)


    This style uses interline spacing that is 1.6 times normal, except
    in the figure and table environments where normal spacing is used.
    That can be changed by doing:
       \renewcommand{\baselinestretch}{1.6}
       (or whatever you want instead of 1.6)
    Unfortunately, that command probably won't take effect unless it comes
    before the \begin{document} or after something like \small \normalsize.

    The example above shows the 12pt substyle being used.  This seems to give
    acceptable looking results, but it may be omitted to get smaller print. A full
    example might look like this:



}

% Disallow page breaks at hyphens (this will give some underfull vbox's,
% so an alternative is to use \brokenpenalty=100 and manually search
% for and fix such page breaks)
\brokenpenalty=10000

% Use 1.6 times the normal baseline-to-baseline skip
\renewcommand{\baselinestretch}{1.7}

% Roman page numbers in cover pages - Should be arabic in thesis text pages starting after TOC/TOF/TOT
\pagenumbering{roman}

% Redefine the macro used for floats (including figures and tables)
% so that single spacing is used.
% (Note \def\figure{\@float{figure}set single spacing} doesn't work
%  because figure has an optional argument)
\def\@xfloat#1[#2]{\ifhmode \@bsphack\@floatpenalty -\@Mii\else
   \@floatpenalty-\@Miii\fi\def\@captype{#1}\ifinner
      \@parmoderr\@floatpenalty\z@
    \else\@next\@currbox\@freelist{\@tempcnta\csname ftype@#1\endcsname
       \multiply\@tempcnta\@xxxii\advance\@tempcnta\sixt@@n
       \@tfor \@tempa :=#2\do
                        {\if\@tempa h\advance\@tempcnta \@ne\fi
                         \if\@tempa t\advance\@tempcnta \tw@\fi
                         \if\@tempa b\advance\@tempcnta 4\relax\fi
                         \if\@tempa p\advance\@tempcnta 8\relax\fi
         }\global\count\@currbox\@tempcnta}\@fltovf\fi
    \global\setbox\@currbox\vbox\bgroup 
    \def\baselinestretch{1}\@normalsize
    \boxmaxdepth\z@
    \hsize\columnwidth \@parboxrestore}

% Redefine the macro used for footnotes to use single spacing
\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}}}

% \author, \title are defined in report style; here are the rest definitions
% Define degree & thesis type 
% it takes two arguments: author's degree and thesis/disseration/whatever
% defaults Doctor of Philosophy and Dissertation
\def\degree#1#2{
    \gdef\@degree{#1}
    \gdef\@thesistype{#2}}
\def\@degree{\rm Doctor of Philosophy}
\def\@thesistype{dissertation}

% Define college/school  -- default College of Natural Sciences and Mathematics
\def\college#1{\gdef\@college{#1}}
\def\@college{\rm College of Natural Sciences and Mathematics}


% Define department -- default Computer Science
\def\department#1{\gdef\@department{#1}}
\def\@department{\rm Computer Science}

% Define major -- default Computer Science
\def\major#1{\gdef\@major{#1}}
\def\@major{\rm Industrial Engineering}



% Thesis advisor and committee
\def\chair#1{\gdef\@chair{#1}}
\def\cochair#1{\gdef\@cochair{#1}}
\def\firstreader#1{\gdef\@firstreader{#1}}
\def\secondreader#1{\gdef\@secondreader{#1}}
\def\thirdreader#1{\gdef\@thirdreader{#1}}
\def\fourthreader#1{\gdef\@fourthreader{#1}}
\def\fifthreader#1{\gdef\@fifthreader{#1}}
\def\submitdate#1{\gdef\@submitdate{#1}}

% \author, \title in report
\def\@title{}
\def\@author{}
\def\@chair{}
\def\@cochair{}
\def\@firstreader{}
\def\@coreader{}
\def\@secondreader{}
\def\@thirdreader{}
\def\@fourthreader{}
\def\@fifthreader{}
\def\@submitdate{\ifcase\the\month\or
  January,\or February,\or March,\or April,\or May,\or June,\or
  July,\or August,\or September,\or October,\or November,\or December,\fi
  \space \number\the\year}

\newif\ifcopyright 
\copyrighttrue 

\newif\iffigurelist
\figurelisttrue 

\newif\iftablelist
\tablelisttrue

\newif\ifcochair
\cochairtrue


\newif\ifthreereaders
\threereaderstrue

\newif\iffourreaders
\fourreaderstrue

\newif\iffivereaders
\fivereaderstrue

%Cover pages
 %%%%%%%%%%%%%%%%%%% Create the Title Page %%%%%%%%%%%%%%%%%%%%%%%%%%%   
\def\titlep{%
    \newpage
    \thispagestyle{empty}%
    \setcounter{page}{1}
    \begin{center}
        \Large\expandafter{\@title}
    \end{center}
    \vskip.2in
    
    \begin{center}
    by\\
    \vskip-.1in
    \@author
    \vskip1in
    A \expandafter{\@thesistype} submitted to the Department of \expandafter{\@department}, \\
    \expandafter{\@college}\\
    in partial fulfillment of the requirements for the degree of
    \vskip.3in
    \expandafter{\@degree}
    \vskip-.1in
    in \expandafter{\@major}\\

    \vskip.9in
    \begin{tabular}{l}
    Chair of Committee: \expandafter{\@chair}\\
    %\vskip-.1in
    \ifcochair
    Co-Chair of Committee: \expandafter{\@cochair}\\
    %\vskip-.1in
    \fi
    Committee Member: \expandafter{\@firstreader}\\
    %\vskip-.1in
    Committee Member: \expandafter{\@secondreader}\\
    %\vskip-.1in
    \ifthreereaders
        Committee Member: \expandafter{\@thirdreader}\\
        %\vskip-.1in
    \fi
    \iffourreaders
        Committee Member: \expandafter{\@fourthreader}\\
        %\vskip-.1in
    \fi
    \iffivereaders
        Committee Member: \expandafter{\@fifthreader}\\
        %\vskip-.1in
    \fi
    \end{tabular}
    
    \vskip.8in
    University of Houston\\
    \vskip-.15in
    \@submitdate\\

    \end{center}
    
}
%%%%%%%%%%%%%%%%%%% End of Title Page %%%%%%%%%%%%%%%%%%%%%%%%%%%   


\def\copyrightpage{%
   \newpage
        \thispagestyle{empty}%
        \setcounter{page}{2}
        \null\vskip2.5in
    \begin{center}
        Copyright 2024, \expandafter{\@author}
    \end{center}}


\def\signaturepage{%
      \newpage
      \begin{center}
        \Large\uppercase\expandafter{\@title}
      \end{center}
      \vspace{.4in}
      \rightline{\shortstack[l]{\vrule width 3.75in height 0.4pt\\
           \@author}}
      \vspace{0.15in}
      \hspace{0in} \rm APPROVED:
      \rightline{ APPROVED:\hspace{2.71in} }
      \vspace{.375in}
      \rightline{\shortstack[l]{\vrule width 3.75in height 0.4pt\\ \@chair}}
      \vspace{.375in}
      \rightline{\shortstack[l]{\vrule width 3.75in height 0.4pt\\ \@firstreader}}
      \vspace{.375in}

      \rightline{\shortstack[l]{\vrule width 3.75in height 0.4pt\\ \@secondreader}}
      \vspace{.375in}
      \ifthreereaders
        \rightline{\shortstack[l]{\vrule width 3.75in height 0.4pt\\ \@thirdreader}}
      \fi
      \vspace{.375in}
      \iffourreaders
        \rightline{\shortstack[l]{\vrule width 3.75in height 0.4pt\\ \@fourthreader}}
      \fi
      \vspace{.375in}
      \iffivereaders
        \rightline{\shortstack[l]{\vrule width 3.75in height 0.4pt\\ \@fifthreader}}
      \fi
      \vspace{.4in}
      
      \rightline{\shortstack[l]{\vrule width 3.75in height 
                 0.4pt\\Dean, \expandafter{\@college}}}}

\def\makecoverpages{%
    \titlep
    \ifcopyright\copyrightpage\fi
}


%Abstract cover page
\def\abstractp{%
        \newpage
    \begin{center}
        \Large\uppercase\expandafter{\@title}
        \end{center}
    \vskip.3in
        \centerline{\vrule width 1.5in height 0.4pt}
    \vskip.5in
    \begin{center}
        \rm An Abstract of a \expandafter{\@thesistype}\\
        Presented to\\
                the Faculty of the Department of 
            \expandafter{\@department}\\
        University of Houston
    \vskip.4in
        \centerline{\vrule width 1.5in height 0.4pt}
    \vskip.5in
        In Partial Fulfillment\\
                of the Requirements for the Degree\\
        \expandafter{\@degree}
    \vskip.4in
        \centerline{\vrule width 1.5in height 0.4pt}
    \vskip.5in
        \rm By\\
        \@author\\
        \@submitdate\\
    \end{center}}

%Abstract 
\def\abstract{
            \def\baselinestretch{1.6}\@normalsize
            %\abstractp
            \newpage
            \begin{center}
                  \large{ \bf {\uppercase{Abstract}}}
            \end{center}
            \addcontentsline{toc}{section}{\numberline{} {\large {\bf {\uppercase{Abstract}}}}}
}

\def\endabstract{
                 \def\baselinestretch{1.7}\@normalsize}

%Dedication and Epigraph

\def\dedication{
            \newpage
            \begin{center}
            \large { \bf {\uppercase {Dedication/Epigraph}}}
            \end{center}
            \addcontentsline{toc}{section}{\numberline{} {\large {\bf {\uppercase{Dedication}}}}}
}

%\def\endacknowledgements{}

%Acknowledgements
\def\acknowledgements{
            \newpage
            \begin{center}
            \large { \bf {\uppercase {Acknowledgments}}}
            \end{center}
            \addcontentsline{toc}{section}{\numberline{} {\large {\bf {\uppercase{Acknowledgments}}}}}
}

%\def\endacknowledgements{}

%Table of contents
\def\makecontentspages{
    \def\baselinestretch{1}\@normalsize
    %\renewcommand{\cfttoctitlefont}{\normalfont\Large\bfseries\MakeUppercase}
    \tableofcontents
    \newpage
    \iffigurelist
          \listoffigures
          \addcontentsline{toc}{section}{\numberline{} {\large {\bf {\uppercase{List of Figures}}}}}
          \newpage
        \fi
    \iftablelist
          \listoftables
          \addcontentsline{toc}{section}{\numberline{} {\large {\bf {\uppercase{List of Tables}}}}}
          \newpage
        \fi
    \def\baselinestretch{1.7}\@normalsize}

%Chapter page definition
\def\chapterpages{
        % Put the page number on the top of the page
%        \def\@oddhead{\rm\hfil\thepage\hfil}
%        \def\@oddfoot{}
%        \let\@evenhead\@oddhead
%        \let\@evenfoot\@oddfoot

    \pagenumbering{arabic}}

% Redefine \thebibliography to go to a new page and put an entry in the
% table of contents
\let\@ldthebibliography\thebibliography
\renewcommand{\thebibliography}[1]{
        \newpage
        \def\baselinestretch{1}\@normalsize
    \addcontentsline{toc}{section}{\uppercase{Bibliography}}
    \@ldthebibliography{#1}}

% Single space for drafts
\def\singlespace{
        \def\baselinestretch{1}\@normalsize}

%That's all folks
Last edited by Stefan Kottwitz on Tue Apr 02, 2024 3:34 pm, edited 1 time in total.
Reason: code marked

Recommended reading 2021:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
User avatar
Stefan Kottwitz
Site Admin
Posts: 10159
Joined: Mon Mar 10, 2008 9:44 pm

Table is not working with my .sty file

Postby Stefan Kottwitz » Tue Apr 02, 2024 3:37 pm

Hello,

welcome to the forum!

That thesis package redefines the internal \@xfloat command so that tables have a single line spacing, while the text baseline stretch is 1.7. That redefinition is not good and causes the error.

To have the same effect, in your document, replace

\usepackage{uhthesis2019}


by the following lines:

\makeatletter
\let\latex@xfloat=\@xfloat
\usepackage{uhthesis2019}
\def\@xfloat #1[#2]{\latex@xfloat #1[#2]\def\baselinestretch{1}\normalsize}
\makeatother


Does it work for you?

Stefan
LaTeX.org admin

bmajeed92
Posts: 3
Joined: Mon Apr 01, 2024 11:09 pm

Table is not working with my .sty file

Postby bmajeed92 » Tue Apr 02, 2024 4:24 pm

This worked like magic. Thank you so much Stefan.

bmajeed92
Posts: 3
Joined: Mon Apr 01, 2024 11:09 pm

Table is not working with my .sty file

Postby bmajeed92 » Tue Apr 02, 2024 4:27 pm

Stefan, in the same package I am unable to use the
\chapter{XYZ} as shown in the .sty file example. Can you help me with that as well?

User avatar
Stefan Kottwitz
Site Admin
Posts: 10159
Joined: Mon Mar 10, 2008 9:44 pm

Table is not working with my .sty file

Postby Stefan Kottwitz » Tue Apr 02, 2024 6:10 pm

At the beginning of the document, load report instead of article, so you can have the \chapter command. And insert this before the thesis package is loaded:

\providecommand\refname{}

That's because the package relies on an existing \refname macro, which is in the article class, but not in the report class.

Stefan
LaTeX.org admin

rais
Posts: 409
Joined: Sun Nov 16, 2014 8:51 pm

Table is not working with my .sty file

Postby rais » Thu Apr 04, 2024 9:35 pm

bmajeed92 wrote:Following is the copy of .sty file
[..]

this was a joke, right? As in `April 1st', you know, fool's day?

KR
Rainer


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 8 guests