(Apologies for pasting this huge chunk of code, but since I can't pin point where the problem lies, I thought it best to show you the whole thing)
This code (which is very much a work-in-progress) seems to generate empty pages before and after my chapters.
Case in point, from the top, we have a "Preamble", followed by an "Introduction", followed by a blank page and the first chapter. The first chapter should appear where the first blank page pops up though.
The same situation occurs later, between the end of Chapter 1 and the beginning of Chapter 2: indeed, here again, there's a blank page where Chapter 2 should be. And a final blank-page appears after Chapter 2.
I also noticed that "List of Tables" keeps appearing in the headers above the "Preamble", "Introduction" and first blank-page pages. I mention this here as I have a feeling that it's all related to the same issue: my code seems to not obeying my \clearpage commands to start afresh.
Could the issues I describe above be helped by segmenting my document and start using the \include command to call-in individual latex files, for each chapter, etc.?
Any help (and explanation) would be much welcome.
Thank you for your time.
- Alex
Code: Select all
% PREAMBLE
\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\usepackage[english]{babel}
\usepackage{tocloft}
\usepackage[nottoc]{tocbibind}
\usepackage{hyperref}
\usepackage{geometry}
\usepackage{multicol}
\usepackage{babel}
\usepackage{graphicx}
\graphicspath{ {h:/} }
\usepackage{enumitem}
\usepackage{marginnote}
\usepackage[document]{ragged2e}
\usepackage{eso-pic}
\usepackage{ifthen}
\usepackage{tikz}
\usepackage{color}
%\usepackage{showframe}
\usepackage{blindtext}
\usepackage{lipsum}
\setlength{\columnsep}{8mm}
%Table of Content depth
\geometry{verbose}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{5}
\setlength{\parindent}{0pt}
%Hyperlinks for TOC
\makeatletter
\hypersetup{
colorlinks,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=black
}
\makeatother
%Formating Document per Pto-M-cook
\geometry{
a4paper,
total={21.59cm,27.94cm},
top=2.8cm,
bottom=2.1cm,
inner=1.91cm,
outer=6.68cm,
marginparwidth=4cm,
marginparsep=0.8cm
}
%\renewcommand{\cfttoctitlefont}{\hfil \Huge}
% FRONTMATTER STARTS
\begin{document}
\frontmatter
\title{A Fantastic Title}
\author{Author's Name}
\begingroup
\oddsidemargin=0.5\dimexpr\paperwidth-\textwidth-2in\relax
\evensidemargin=\oddsidemargin
\newpage
\maketitle
\newpage
\newpage
\tableofcontents
\newpage
\newpage
\listoftables
\newpage
\newpage
\phantomsection
\addcontentsline{toc}{section}{Preface}
\section*{Preface}
\blindtext
\newpage
\newpage
\phantomsection
\addcontentsline{toc}{section}{Introduction}
\section*{Introduction}
\blindtext
\newpage
\clearpage
\endgroup
\clearpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Following is the code used to create vertical bars between text body and margin
\def\bottommargin{\paperheight - \topmargin - \textheight - \headheight - \headsep - 1in - \voffset}
\def\toptotalheight{\paperheight - \topmargin - \headheight - \headsep - 1in - \voffset}
\def\leftlength{
\evensidemargin - 0.5*\marginparsep
+ 1in
+ \hoffset
}
\def\rightlength{\paperwidth
- \evensidemargin + 0.5*\marginparsep
- 1in - \hoffset}
\makeatletter
\newcommand{\nomarginbar}{\let\ESO@HookIIBG\@empty}
\makeatother
\newcommand{\thisisfullsize}{\path (0,0) -- (\paperwidth,\paperheight);}
\newcommand\LeftBar{%
\put(0,0){%
\parbox[b][\paperheight]{\paperwidth}{%
\vfill
\centering
\begin{tikzpicture}
\thisisfullsize
\color{lightgray}
\draw[line width=1pt] (\leftlength,\bottommargin) -- (\leftlength,\toptotalheight);
\end{tikzpicture}
\vfill
}}}
\newcommand\RightBar{%
\put(0,0){%
\parbox[b][\paperheight]{\paperwidth}{%
\vfill
\centering
\begin{tikzpicture}
\thisisfullsize
\color{lightgray}
\draw[line width=1pt] (\rightlength,\bottommargin) -- (\rightlength,\toptotalheight);
\end{tikzpicture}
\vfill
}}}
%%% Use this in two-side documents
\AtBeginShipout{%
\ifthenelse{\isodd{\value{page}}}%
{\AddToShipoutPictureBG*{\LeftBar}%
}%
{\AddToShipoutPictureBG*{\RightBar}%
}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% MAINMATTER STARTS
\mainmatter
\chapter{The First Chapter}
\begin{multicols*}{2}
\section{THE FIRST SECTION HAS A REALLY LONG AND THEREFORE PROBLEMATIC TITLE}
\blindtext
And now this table:
\begin{table*}
\centering
\begin{tabular}{r|c|c|l}
\hline
Information & Information & Information & Information\tabularnewline \hline Information & Information & Information & Information\tabularnewline Information & Information & Information & Information\tabularnewline Information & Information & Information & Information\tabularnewline Information & Information & Information & Information\tabularnewline Information & Information & Information & Information\tabularnewline
\hline
\end{tabular}
\caption{Important Data}
\end{table*}
\marginnote{\lipsum[75]}[0cm]
\blindtext
\subsection{The Subsection}
\blindtext
And now I'm going to list a list of listed things:
\begin{enumerate}[noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt]
\item \blindtext
\item \blindtext
\item \blindtext
\end{enumerate}
\blindtext
\subsubsection{A Subsubsection}
\blindtext
\marginnote{\lipsum[75]}[0cm]
\blindtext
%To clear empty page before Chapter
%\let\cleardoublepage\clearpage
\chapter{The Second Chapter}
\section{The Second Proper Section}
\blindtext
The image should appear right after this:
%\includegraphics*{universe}
And now, more text to see how this works.
\subsection{The Second Subsection}
\blindtext
\subsubsection{A Second Subsubsection}
\blindtext
\marginnote{\lipsum[75]}[0cm]
\blindtext
\end{multicols*}
% BACKMATTER STARTS
%\appendix
\backmatter
%\printindex
\end{document}