Page LayoutBibliography Entry in ToC not aligned with other Entries

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
selmeryd
Posts: 3
Joined: Fri Aug 12, 2011 2:10 pm

Bibliography Entry in ToC not aligned with other Entries

Post by selmeryd »

Hi,

I am using a LaTeX template for a report I'm writing. Currently, I am having one small issue. The formatting of the TOC is not correct. When I create a pdf from the files, the Bibliography entry is indented (it has a left-margin of about 5 whitespaces) and not aligned with the other entries. How can I adjust this? Am using MixTex 2.9 and TexMakerX. Here are the files:

Code: Select all

%main.tex
%------------------------------------------------------------------------


\documentclass[11pt,a4paper]{report}

% Packages and commands file

\input{include/packagescommands}

% Settings (Metadata)
\input{include/settings}

\begin{document}

% Title page and abstract
\input{include/titlepageabstract}

% Table of contents
\newpage
\pagenumbering{roman}
\setcounter{page}{1}
\pagestyle{fancy}
\setspecialhdr
\tableofcontents

% Main area
\newpage
\setdefaulthdr
\pagenumbering{arabic}	
\setcounter{page}{1}


% Content
\input{include/introduction}

\newpage

% Test kapitel
%\input{include/test}

% Test method
%\input{include/method}


%\input{include/discussion}



% Nocite references
\nocite{Brody1996,Carillo2011,boken}
\bibliography{references}

\addcontentsline{toc}{chapter}{\numberline{} Bibliography} % For pdf
\setspecialhdr

\newpage

% Appendices
\appendix
\setdefaulthdr
%\input{include/appendix1}



\end{document}

Code: Select all

%include/settings.tex
%------------------------------------------------------------------------

% References, choose bst-file


\bibliographystyle{elsart-num}

% PDF Metadata and link styles
\hypersetup{
		pdftitle={Master's Thesis: },%
		pdfauthor={John Doe},%
    colorlinks=true,%
    citecolor=black,%
    filecolor=black,%
    linkcolor=black,%
    urlcolor=black
}

% Dropping initial letter color
\renewcommand{\LettrineFontHook}{\color[gray]{0.5}}

% Chapter headings style (fncychap)
\makeatletter
\ChNumVar{\fontsize{20pt}{20pt}\selectfont {\bf Chapter} }
%\ChNumVar{\fontsize{40pt}{20pt}Chapter } % sets the style for digit
%\ChTitleVar{\Huge\bfseries\centering} % sets the style for title
\ChRuleWidth{4pt} % Set RW=4pt
\ChNameUpperCase % Make name uppercase
\renewcommand{\DOCH}{
%\centering
{\CNoV {\bf \fontsize{20pt}{20pt}\selectfont\thechapter} }
\vskip 40\p@}
\renewcommand{\DOTI}[1]{%
\CTV\FmTi{#1}\par\nobreak
\vskip 40\p@}
\renewcommand{\DOTIS}[1]{%
\CTV\FmTi{#1}\par\nobreak
\vskip 40\p@}
\makeatother

% Single page abstract
\renewenvironment{abstract}%
{\begin{center} \bfseries \abstractname \end{center}}%
{\vspace{2\baselineskip}}%

% Figure & Table captions
\captionsetup{margin=10pt,font=small,labelfont=bf}
\captionsetup[table]{position=top}
\setlength{\extrarowheight}{4pt}
\addtolength{\headheight}{\baselineskip}

% Fancyheader (see packagescommands.tex for default/special)
\pagestyle{fancy}
\setdefaulthdr

% Stolen settings (unknown origin):
% Alter some LaTeX defaults for better treatment of figures:
% See p.105 of "TeX Unbound" for suggested values.
% See pp. 199-200 of Lamport's "LaTeX" book for details.
%   General parameters, for ALL pages:
\renewcommand{\topfraction}{0.9}	% max fraction of floats at top
\renewcommand{\bottomfraction}{0.8}	% max fraction of floats at bottom
%   Parameters for TEXT pages (not float pages):
\setcounter{topnumber}{2}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{4}     % 2 may work better
\setcounter{dbltopnumber}{2}    % for 2-column pages
\renewcommand{\dbltopfraction}{0.9}	% fit big float above 2-col. text
\renewcommand{\textfraction}{0.07}	% allow minimal text w. figs
%   Parameters for FLOAT pages (not text pages):
\renewcommand{\floatpagefraction}{0.7}	% require fuller float pages
% N.B.: floatpagefraction MUST be less than topfraction !!
\renewcommand{\dblfloatpagefraction}{0.7}	% require fuller float pages

% remember to use [htp] or [htpb] for placement



%include/titlepageabstract.tex
%------------------------------------------------------------------------


\begin{titlepage}

%\AddToShipoutPicture{\backgroundpic{-4}{56.7}{fig/auxiliary/frontpage}}
\mbox{}
\vfill
\addtolength{\voffset}{2cm}
\begin{flushleft}
	{\noindent {\Huge Legacy Systems} \\[0.5cm]
	\emph{\Large Master's Thesis in Software Engineering} \\[.8cm]
	
	{\huge John Doe}\\[.8cm]
	
	{\Large Department of Computer Science \& Software Engineering \\
	Non-linear Dynamics \& Statistical Physics \\
	\textsc{University of Technology} \\
	Goburg, England 2011 \\
	Master's Thesis 2011:1\\
	} 
	}
\end{flushleft}

\end{titlepage}
\ClearShipoutPicture
% End Chalmers title page

\pagestyle{empty}
\newpage
\clearpage
\mbox{}
\newpage
\clearpage
\thispagestyle{empty}

\begin{abstract}
This is a case study regarding a legacy system that is is to be modernised with MDE. 
\end{abstract}

\newpage
\clearpage
\mbox{}
\newpage
\clearpage
\thispagestyle{empty}
\section*{Acknowledgements}
I wanna thank... \\[1cm]

\hfill John Doe, Goburg 2011
\newpage
\clearpage
\mbox{}

%include/packagescommands.tex
%------------------------------------------------------------------------


\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{ae}
\usepackage{icomma}
\usepackage{units}
\usepackage{color}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{subfigure}
\usepackage{bbm}
\usepackage{caption}
\usepackage[square, numbers, sort]{natbib}
\usepackage{multirow}
\usepackage{array}
\usepackage{geometry}
\usepackage{fancyhdr}
\usepackage{fncychap}
\usepackage[hyphens]{url}
\usepackage[breaklinks,pdfpagelabels=false]{hyperref}
\usepackage{lettrine}
\usepackage{eso-pic}



\newcommand{\rd}{\ensuremath{\mathrm{d}}}
\newcommand{\id}{\ensuremath{\,\rd}}
\newcommand{\degC}{\ensuremath{\,\unit{^\circ C}}}

% Fancyheader shortcuts
\newcommand{\setdefaulthdr}{%
\fancyhead[L]{\slshape \rightmark}%
\fancyhead[R]{\slshape \leftmark}%
\fancyfoot[C]{\thepage}%
}
\newcommand{\setspecialhdr}{%
\fancyhead[L]{ }%
\fancyhead[R]{\slshape \leftmark}%
\fancyfoot[C]{\thepage}%
}

\newcommand{\mail}[1]{\href{mailto:#1}{\nolinkurl{#1}}}
\newcommand{\backgroundpic}[3]{%
	\put(#1,#2){
		\parbox[b][\paperheight]{\paperwidth}{%
			\centering
			\includegraphics[width=\paperwidth,height=\paperheight,keepaspectratio]{#3}
			\vfill
}}}





%include/introduction.tex
%------------------------------------------------------------------------

\chapter{Introduction}
%\lettrine[lines=4, loversize=-0.1, lraise=0.1]{L}{orem ipsum dolor}  % Fixar stora förstabokstäver
Sit amet, consectetur adipiscing elit. Donec viverra gravida adipiscing. Morbi vitae dui eu leo dapibus venenatis quis laoreet augue. 

Proin sem nunc, lobortis sed gravida id, iaculis id justo. Sed convallis, mauris vel mattis posuere, tortor quam molestie sem, vel 

feugiat risus dolor sit amet purus. Nulla facilisi. Duis ac velit non tortor malesuada pellentesque vitae vitae erat. Aliquam dapibus 

porta lorem lacinia vestibulum. Nulla convallis venenatis euismod. Suspendisse adipiscing lacus id nisi hendrerit dapibus. Sed quam 

diam, pretium vel accumsan vel, pulvinar et odio. Nulla facilisis ullamcorper metus non suscipit. Aliquam nec augue odio. In hac 

habitasse platea dictumst. Nulla facilisi. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis 

egestas. Maecenas consequat mattis metus, in imperdiet purus suscipit eu. Mauris velit lorem, pharetra nec vehicula cursus, vulputate 

sit amet dui. Nam sed eros magna, quis molestie urna.
\section{Maecenas iaculis}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec viverra gravida adipiscing. Morbi vitae dui eu leo dapibus venenatis 

quis laoreet augue. Proin sem nunc, lobortis sed gravida id, iaculis id justo. Sed convallis, mauris vel mattis posuere, tortor quam 

molestie sem, vel feugiat risus dolor sit amet purus. Nulla facilisi. Duis ac velit non tortor malesuada pellentesque vitae vitae erat
\begin{gather*}
\left\{\begin{split}
\tan \varphi &= \lambda \tan \tau \\
\tan^2 \theta &= \tan^2 \gamma (\sin^2\tau + \lambda^2 \cos^2\tau)
\end{split}\right., \tau = \frac{\pi}{2}-\beta t.
\end{gather*}
Aliquam dapibus porta lorem lacinia vestibulum. Nulla convallis venenatis euismod. Suspendisse adipiscing lacus id nisi hendrerit 

dapibus. Sed quam diam, pretium vel accumsan vel, pulvinar et odio. Nulla facilisis ullamcorper metus non suscipit. Aliquam nec augue 

odio. In hac habitasse platea dictumst. Nulla facilisi. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac 

turpis egestas. Maecenas consequat mattis metus, in imperdiet purus suscipit eu. Mauris velit lorem, pharetra nec vehicula cursus, 

vulputate sit amet dui. Nam sed eros magna, quis molestie urna.




\subsection{Sub-header}
\section{Header}
\subsection{Sub-header}
\subsection{Sub-header}

%include/references.bib
%------------------------------------------------------------------------

% ARTICLES (FLUID DYNAMICS)

@article{Brody1996,
author = {Bladig, J and Yager, P and Goldstein, R and Austin, R},
doi = {10.1016/S0006-3495(96)79538-3},
file = {:D$\backslash$:/MendeleyPapers/Brody et al./1996/Biotechnology at low Reynolds numbers - 1996.pdf:pdf},
issn = {00063495},
journal = {Biophysical Journal},
month = dec,
number = {6},
pages = {3430--3441},
publisher = {Elsevier},
title = {{Biotechnology at low Reynolds numbers}},
url = {http://linkinghub.elsevier.com/retrieve/pii/S0006349596795383},
volume = {71},
year = {1996}
}

@article{Carrillo2011,
author = {Carrillo de Gea, J.M. and Nicolas, J. and Aleman, J.L.F. and Toval, A. and Ebert, C. and Vizcaino, A. and },
title = {Requirements Engineering Tools},
journal = {IEEE Software},
year = {2011},
OPTvolume = {28},
OPTnumber = {4},
OPTpages = {89-91},
OPTmonth = {July/August}
}

@INPROCEEDINGS{Gherbi2009,
author={Gherbi, T. and Meslati, D. and Borne, I.},
booktitle={Computer Modelling and Simulation, 2009. UKSIM '09. 11th International Conference on}, title={MDE between Promises and 

Challenges},
year={2009},
month={march},
volume={},
number={},
pages={152 -155},
keywords={MDA;MDE;OMG;model driven architecture;model driven engineering;object management group;software construction;software 

development approach;object-oriented programming;software engineering;},
doi={10.1109/UKSIM.2009.13},
ISSN={},}
Last edited by localghost on Fri Sep 09, 2011 7:15 pm, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Bibliography Entry in ToC not aligned with other Entries

Post by kaiserkarl13 »

Your example does not compile. After adding some lines,

Code: Select all

    \usepackage{fancyhdr}
    \usepackage{caption}
    \usepackage{array}
    \usepackage{fncychap}
    \usepackage{lettrine}
    \usepackage{hyperref}
to the beginning, I get most of the way through until it hits this:
(./include/packagescommands.tex
! Undefined control sequence.
l.55 \setdefaulthdr
Please fix your example and we might be able to figure out what's wrong. If you've been ignoring errors, please stop doing so! (I've replied to formatting issue posts before and the solution was to fix the code so it doesn't generate errors!)
selmeryd
Posts: 3
Joined: Fri Aug 12, 2011 2:10 pm

Bibliography Entry in ToC not aligned with other Entries

Post by selmeryd »

Thank you for trying out the code. Im sorry that it is not compiling for you, I tested it before posting and it worked for me.

I noticed now however that if i run the latex command to compile i also get:

Code: Select all

titlepageabstract.tex error line 23 `fig/auxiliary/frontpage' not found. \end{titlepage}
But if i run the pdflatex command to compile I do not get any errors.

Here is the original link to the template (that I haven't messed with). Perhaps it will compile for you:
http://bror.einarsson.net/chalmersthesi ... mplate.zip
kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Bibliography Entry in ToC not aligned with other Entries

Post by kaiserkarl13 »

OK, I realized after reading your reply that I must have put all the package commands at the end of one file instead of the beginning of another. It works now. For future reference, please try to construct a smaller example that isn't as prone to cut-and-paste errors such as I made (i.e., put everything in one file or make the example a lot shorter so you don't NEED six files).

The only problem I'm seeing with your table of contents is the following line:

Code: Select all

\addcontentsline{toc}{chapter}{\numberline{} Bibliography}
That extra space will expand to produce extra whitespace, causing the misalignment. If I get rid of that whitespace and run pdflatex (twice), the Bibliography word is aligned with the word "Introduction" as it should be:

Code: Select all

\addcontentsline{toc}{chapter}{\numberline\bibname}
That said, I get warning messages related to hyperref when compiling, such as "(./main.bbl (/usr/share/texmf/tex/latex/ae/t1aett.fd))pdfTeX warning (ext4): destination with the same identifier (name{page.3}) has been already used, duplicate ignored
<to be read again>
\relax
l.57 \newpage
[3]"
I suspect these warnings are incompatibilities between natbib and hyperref (which may or may not be helped by the hypernat package, which I would suggest using). Also make sure that hyperref is loaded AFTER natbib.

Your original post seems to indicate you think it is further indented than it is in my copy. If you mean that the "B" in "Bibliography" is not aligned with the section number, that's because it's not supposed to be---it's aligned with the other section headings. However, I noticed that removing "\numberline{}" from your \addtocontents command removes that space (though I don't know precisely why).

Good luck!
selmeryd
Posts: 3
Joined: Fri Aug 12, 2011 2:10 pm

Re: Bibliography Entry in ToC not aligned with other Entries

Post by selmeryd »

Aaa, thank you, that fixes it!

Also thanks for the additional tips regarding all those warnings, I'll keep that in mind. Sorry for the complex example code but since I'm using a template I wasn't sure what parts could be removed, so I posted most of it.
Post Reply