0

I am writing an article using LaTeX. As I never used LaTeX before i downloaded a template that i could reuse. First it used \documentclass{Thesis} which required the article to use chapters. However in order not to need chapters (only sections) I changed the documentclass to "article" and changed all \chapter tags to \section, \section tags to \subsection and so on.

Everything went fine except the numbering. Every section's numbering is prefixed with 0. Hence the first section is numbered 0.1, than 0.2, and so on.

How could I remove this prefixed 0?

%----------------------------------------------------------------------------------------
%   PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass[11pt, oneside]{article} % The default font size and one-sided printing (no margin offsets)

\graphicspath{{Pictures/}} % Specifies the directory where pictures are stored

\usepackage[official]{eurosym}
\usepackage[normalem]{ulem}
\usepackage[square, numbers, comma, sort&compress]{natbib} % Use the natbib reference package - read up on this to edit the reference style; if you want text (e.g. Smith et al., 2012) for the in-text references (instead of numbers), remove 'numbers' 
\hypersetup{urlcolor=blue, colorlinks=true} % Colors hyperlinks in blue - change to black if annoying
\title{\ttitle} % Defines the thesis title - don't touch this

\begin{document}

\frontmatter % Use roman page numbering style (i, ii, iii, iv...) for the pre-content pages

\setstretch{1.3} % Line spacing of 1.3

% Define the page headers using the FancyHdr package and set up for one-sided printing
\fancyhead{} % Clears all page headers and footers
\rhead{\thepage} % Sets the right side header to show the page number
\lhead{} % Clears the left side page header

\pagestyle{fancy} % Finally, use the "fancy" page style to implement the FancyHdr headers

\newcommand{\HRule}{\rule{\linewidth}{0.5mm}} % New command to make the lines in the title page

% PDF meta-data
\hypersetup{pdftitle={\ttitle}}
\hypersetup{pdfsubject=\subjectname}
\hypersetup{pdfauthor=\authornames}
\hypersetup{pdfkeywords=\keywordnames}

%----------------------------------------------------------------------------------------
%   TITLE PAGE
%----------------------------------------------------------------------------------------

\begin{titlepage}
\begin{center}

\textsc{\LARGE \univname}\\[1.5cm] % University name
\textsc{\Large Bachelor Thesis Pre Study}\\[0.5cm] % Thesis type

\HRule \\[0.4cm] % Horizontal line
{\huge \bfseries \ttitle}\\ % Thesis title
\HRule \\[1.5cm] % Horizontal line

\begin{minipage}{0.4\textwidth}
\begin{flushleft} \large
\emph{Author:}\\
{\authornames} % Author name - remove the \href bracket to remove the link
\end{flushleft}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\begin{flushright} \large
\emph{Supervisor:} \\
\href{http://soft.vub.ac.be/~egonzale/egonzale/#/Home}{\supname} % Supervisor name - remove the \href bracket to remove the link  
\end{flushright}
\end{minipage}\\[3cm]

\groupname\\\deptname\\[2cm] % Research group name and department name

{\large \today}\\[1cm] % Date
\includegraphics{Pictures/vub_logo} % University/department logo - uncomment to place it

\vfill
\end{center}

\end{titlepage}


%----------------------------------------------------------------------------------------
%   ABSTRACT PAGE
%----------------------------------------------------------------------------------------

\addtotoc{Abstract} % Add the "Abstract" page entry to the Contents

\abstract{\addtocontents{toc}{\vspace{1em}} % Add a gap in the Contents, for aesthetics

The Thesis Abstract is written here (and usually kept to just this page). The page is kept centered vertically so can expand into the blank space above the title too\ldots
}

\clearpage % Start a new page

%----------------------------------------------------------------------------------------
%   ACKNOWLEDGEMENTS
%----------------------------------------------------------------------------------------

\setstretch{1.3} % Reset the line-spacing to 1.3 for body text (if it has changed)

\acknowledgements{\addtocontents{toc}{\vspace{1em}} % Add a gap in the Contents, for aesthetics

The acknowledgements and the people to thank go here, don't forget to include your project advisor\ldots
}
\clearpage % Start a new page

%----------------------------------------------------------------------------------------
%   LIST OF CONTENTS/FIGURES/TABLES PAGES
%----------------------------------------------------------------------------------------

\pagestyle{fancy} % The page style headers have been "empty" all this time, now use the "fancy" headers as defined before to bring them back

\lhead{\emph{Contents}} % Set the left side page header to "Contents"
\tableofcontents % Write out the Table of Contents

%----------------------------------------------------------------------------------------
%   THESIS CONTENT - CHAPTERS
%----------------------------------------------------------------------------------------

\mainmatter % Begin numeric (1,2,3...) page numbering

\pagestyle{fancy} % Return the page headers back to the "fancy" style

% Include the chapters of the thesis as separate files from the Chapters folder
% Uncomment the lines as you write the chapters

\input{Chapters/Chapter1}
\input{Chapters/Chapter2} 
\input{Chapters/Chapter3}
\input{Chapters/Chapter4} 
\input{Chapters/Chapter5} 
\input{Chapters/Chapter6} 
\input{Chapters/Chapter7} 

%----------------------------------------------------------------------------------------
%   THESIS CONTENT - APPENDICES
%----------------------------------------------------------------------------------------

\addtocontents{toc}{\vspace{2em}} % Add a gap in the Contents, for aesthetics

\appendix % Cue to tell LaTeX that the following 'chapters' are Appendices

% Include the appendices of the thesis as separate files from the Appendices folder
% Uncomment the lines as you write the Appendices

\input{Appendices/AppendixA}
%\input{Appendices/AppendixB}
%\input{Appendices/AppendixC}

\addtocontents{toc}{\vspace{2em}} % Add a gap in the Contents, for aesthetics

\backmatter

%----------------------------------------------------------------------------------------
%   BIBLIOGRAPHY
%----------------------------------------------------------------------------------------

\label{Bibliography}

\lhead{\emph{Bibliography}} % Change the page header to say "Bibliography"

\bibliographystyle{unsrtnat} % Use the "unsrtnat" BibTeX style for formatting the Bibliography

\bibliography{Bibliography} % The references (bibliography) information are stored in the file named "Bibliography.bib"

\end{document}  

This is how "chapters" that i include look like :

 %----------------------------------------------------------------------------------------


% Chapter 1
\section{Thesis description} % Main chapter title

\label{Chapter1} % For referencing the chapter elsewhere, use \ref{Chapter1} 

\lhead{Chapter 1. \emph{Thesis description}} % This is for the header on each page - perhaps a shortened title

%----------------------------------------------------------------------------------------
\subsection{Introduction} \label{sec:ThesisIntro}
Bla bla bla

\subsection{Thesis goals}
.....

\subsection{Literature study}
...
%----------------------------------------------------------------------------------------
  • Welcome to TeX.SX! I don't think your example will compile at all! \mainmatter isn't available for article and the standard behaviour is to have 1 etc. sections, not begin prepended with another number. Most likely some other setup in your chapter files spoils the document – user31729 Dec 14 '15 at 21:26
  • @ChristianHupfer Thanks, I now removed \mainmatter. My chapter files contain \setcounters, sections, subsections, subsubsection and paragraphs. Furthermore they also use references to other sections. Could one of these spoil the document numbering? – Kevin Dec 14 '15 at 21:30
  • 1
    There are more issues: \usepackage{graphicx}, \usepackage{hyperref} and \usepackage{fancyhdr} are missing, as well as \frontmatter should be removed, as well as \setspace. And after that, the code runs normal, with \section etc. --- Do you have some \renewcommand{\thesection} ??? – user31729 Dec 14 '15 at 21:31
  • 2
    @HyperZ: Hmmm, renaming Thesis.cls to Article.cls is not the same as using (the default) article.cls. – Werner Dec 14 '15 at 22:20
  • 1
    @HyperZ: Why do you think renaming Thesis.cls should provide the article.cls, apart from the upper case name. There would be a warning any way, about the mismatch what \ProvidesClass says and the file name. – user31729 Dec 14 '15 at 22:39
5

I think you misunderstood some things here and I want to show you the direction you should go on.

You wrote

"As I never used LaTeX before i downloaded a template that i could reuse."

I think that is exactly the problem: you used code you did not understand.

Because you are a beginner of LaTeX I ask you to visit a introductory course at your university/school or to start with reading a book or pdf introducing LaTeX. For example read lshort.pdf (internet, ctan) or try on your console texdoc lshort. That is not unfriendly, I think it helps you not to waste too much time ...

Starting to learn LaTeX means, do not use templates you can not understand. Start with a simple document class like book, and learn step by step to prepare your own document.

To make your MWE compilable (I just commented out all commands causing errors) please see the following code. Because there are a lot of commands included defined in the original Thesis.cls I had to comment those parts. (The template you used should have an introduction how to use it. Have you read it?)

Code:

\documentclass[11pt, oneside]{book} % The default font size and one-sided printing (no margin offsets)

%\graphicspath{{Pictures/}} % Specifies the directory where pictures are stored

\usepackage[official]{eurosym}
\usepackage[normalem]{ulem}
\usepackage[square, numbers, comma, sort&compress]{natbib} 
\usepackage{fancyhdr} % <===============================================
\usepackage{hyperref} % <===============================================
\hypersetup{urlcolor=blue, colorlinks=true} 
%\title{\ttitle} % Defines the thesis title - don't touch this

\begin{document}

\frontmatter 

%\setstretch{1.3} % Line spacing of 1.3

% Define the page headers using the FancyHdr package and set up for one-sided printing
\fancyhead{} % Clears all page headers and footers
\rhead{\thepage} % Sets the right side header to show the page number
\lhead{} % Clears the left side page header

\pagestyle{fancy} % Finally, use the "fancy" page style to implement the FancyHdr headers

\newcommand{\HRule}{\rule{\linewidth}{0.5mm}} % New command to make the lines in the title page

% PDF meta-data
%\hypersetup{pdftitle={\ttitle}}
%\hypersetup{pdfsubject=\subjectname}
%\hypersetup{pdfauthor=\authornames}
%\hypersetup{pdfkeywords=\keywordnames}

%----------------------------------------------------------------------------------------
%   TITLE PAGE
%----------------------------------------------------------------------------------------

%\begin{titlepage}
%\begin{center}
%
%\textsc{\LARGE University name}\\[1.5cm] % University name
%\textsc{\Large Bachelor Thesis Pre Study}\\[0.5cm] % Thesis type
%
%\HRule \\[0.4cm] % Horizontal line
%{\huge \bfseries \ttitle}\\ % Thesis title
%\HRule \\[1.5cm] % Horizontal line
%
%\begin{minipage}{0.4\textwidth}
%\begin{flushleft} \large
%\emph{Author:}\\
%{\authornames} % Author name - remove the \href bracket to remove the link
%\end{flushleft}
%\end{minipage}
%\begin{minipage}{0.4\textwidth}
%\begin{flushright} \large
%\emph{Supervisor:} \\
%\href{http://soft.vub.ac.be/~egonzale/egonzale/#/Home}{\supname} % Supervisor name - remove the \href bracket to remove the link  
%\end{flushright}
%\end{minipage}\\[3cm]
%
%\groupname\\\deptname\\[2cm] % Research group name and department name
%
%{\large \today}\\[1cm] % Date
%\includegraphics{Pictures/vub_logo} % University/department logo - uncomment to place it
%
%\vfill
%\end{center}
%
%\end{titlepage}


%----------------------------------------------------------------------------------------
%   ABSTRACT PAGE
%----------------------------------------------------------------------------------------

%\addtotoc{Abstract} % Add the "Abstract" page entry to the Contents

%\abstract{\addtocontents{toc}{\vspace{1em}} % Add a gap in the Contents, for aesthetics
%
%The Thesis Abstract is written here (and usually kept to just this page). The page is kept centered vertically so can expand into the blank space above the title too\ldots
%}

\clearpage % Start a new page

%----------------------------------------------------------------------------------------
%   ACKNOWLEDGEMENTS
%----------------------------------------------------------------------------------------

%\setstretch{1.3} % Reset the line-spacing to 1.3 for body text (if it has changed)

%\acknowledgements{\addtocontents{toc}{\vspace{1em}} % Add a gap in the Contents, for aesthetics
%
%The acknowledgements and the people to thank go here, don't forget to include your project advisor\ldots
%}
%\clearpage % Start a new page

%----------------------------------------------------------------------------------------
%   LIST OF CONTENTS/FIGURES/TABLES PAGES
%----------------------------------------------------------------------------------------

\pagestyle{fancy} % The page style headers have been "empty" all this time, now use the "fancy" headers as defined before to bring them back

\lhead{\emph{Contents}} % Set the left side page header to "Contents"
\tableofcontents % Write out the Table of Contents

%----------------------------------------------------------------------------------------
%   THESIS CONTENT - CHAPTERS
%----------------------------------------------------------------------------------------

\mainmatter % Begin numeric (1,2,3...) page numbering

\pagestyle{fancy} % Return the page headers back to the "fancy" style

% Include the chapters of the thesis as separate files from the Chapters folder
% Uncomment the lines as you write the chapters

 %----------------------------------------------------------------------------------------
\chapter{Test to show} % <=============================================

% Chapter 1
\section{Thesis description} % Main chapter title

\label{Chapter1} % For referencing the chapter elsewhere, use \ref{Chapter1} 

\lhead{Chapter 1. \emph{Thesis description}} % This is for the header on each page - perhaps a shortened title

%----------------------------------------------------------------------------------------
\subsection{Introduction} \label{sec:ThesisIntro}
Bla bla bla

\subsection{Thesis goals}
.....

\subsection{Literature study}
...
%----------------------------------------------------------------------------------------
%\input{Chapters/Chapter2} 
%\input{Chapters/Chapter3}
%\input{Chapters/Chapter4} 
%\input{Chapters/Chapter5} 
%\input{Chapters/Chapter6} 
%\input{Chapters/Chapter7} 

%----------------------------------------------------------------------------------------
%   THESIS CONTENT - APPENDICES
%----------------------------------------------------------------------------------------

\addtocontents{toc}{\vspace{2em}} % Add a gap in the Contents, for aesthetics

\appendix % Cue to tell LaTeX that the following 'chapters' are Appendices

% Include the appendices of the thesis as separate files from the Appendices folder
% Uncomment the lines as you write the Appendices

%\input{Appendices/AppendixA}
%\input{Appendices/AppendixB}
%\input{Appendices/AppendixC}

\addtocontents{toc}{\vspace{2em}} % Add a gap in the Contents, for aesthetics

\backmatter

%----------------------------------------------------------------------------------------
%   BIBLIOGRAPHY
%----------------------------------------------------------------------------------------

\label{Bibliography}

\lhead{\emph{Bibliography}} % Change the page header to say "Bibliography"

\bibliographystyle{unsrtnat} % Use the "unsrtnat" BibTeX style for formatting the Bibliography

\bibliography{Bibliography} % The references (bibliography) information are stored in the file named "Bibliography.bib"

\end{document} 

Please study my changes. Check the parts I commented out. Try to understand why. Please note that the bibliography can not be built because the bib file is missing. The code above compiles without errors, but of course the complete titlepage is missing (I had to comment it out).

See the main changes marked with <=================== in the code ...

  • 1
    +1. I've taken the liberty of fixing a couple of typos. Hope that's OK. – Mico Dec 14 '15 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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