LaTeX forum ⇒ Page LayoutBlank Pages before and after chapters

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
cyanidebaby
Posts: 11
Joined: Tue Feb 07, 2017 1:56 pm

Blank Pages before and after chapters

Postby cyanidebaby » Tue Feb 07, 2017 3:32 pm

Hello,

(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

  1. % PREAMBLE
  2.  
  3. \documentclass{book}
  4. \usepackage[T1]{fontenc}
  5. \usepackage[latin9]{inputenc}
  6. \usepackage{geometry}
  7. \usepackage[english]{babel}
  8. \usepackage{tocloft}
  9. \usepackage[nottoc]{tocbibind}
  10. \usepackage{hyperref}
  11. \usepackage{geometry}
  12. \usepackage{multicol}
  13. \usepackage{babel}
  14. \usepackage{graphicx}
  15. \graphicspath{ {h:/} }
  16. \usepackage{enumitem}
  17. \usepackage{marginnote}
  18. \usepackage[document]{ragged2e}
  19. \usepackage{eso-pic}
  20. \usepackage{ifthen}
  21. \usepackage{tikz}
  22. \usepackage{color}
  23. %\usepackage{showframe}
  24. \usepackage{blindtext}
  25. \usepackage{lipsum}
  26.  
  27. \setlength{\columnsep}{8mm}
  28.  
  29. %Table of Content depth
  30. \geometry{verbose}
  31. \setcounter{secnumdepth}{3}
  32. \setcounter{tocdepth}{5}
  33. \setlength{\parindent}{0pt}
  34.  
  35. %Hyperlinks for TOC
  36. \makeatletter
  37. \hypersetup{
  38. colorlinks,
  39. citecolor=black,
  40. filecolor=black,
  41. linkcolor=black,
  42. urlcolor=black
  43. }
  44.  
  45. \makeatother
  46.  
  47. %Formating Document per Pto-M-cook
  48. \geometry{
  49. a4paper,
  50. total={21.59cm,27.94cm},
  51. top=2.8cm,
  52. bottom=2.1cm,
  53. inner=1.91cm,
  54. outer=6.68cm,
  55. marginparwidth=4cm,
  56. marginparsep=0.8cm
  57. }
  58.  
  59. %\renewcommand{\cfttoctitlefont}{\hfil \Huge}
  60.  
  61. % FRONTMATTER STARTS
  62.  
  63. \begin{document}
  64.  
  65. \frontmatter
  66.  
  67. \title{A Fantastic Title}
  68. \author{Author's Name}
  69.  
  70. \begingroup
  71.  
  72. \oddsidemargin=0.5\dimexpr\paperwidth-\textwidth-2in\relax
  73. \evensidemargin=\oddsidemargin
  74.  
  75. \newpage
  76. \maketitle
  77. \newpage
  78.  
  79. \newpage
  80. \tableofcontents
  81. \newpage
  82.  
  83. \newpage
  84. \listoftables
  85. \newpage
  86.  
  87. \newpage
  88. \phantomsection
  89. \addcontentsline{toc}{section}{Preface}
  90. \section*{Preface}
  91. \blindtext
  92. \newpage
  93.  
  94.  
  95. \newpage
  96. \phantomsection
  97. \addcontentsline{toc}{section}{Introduction}
  98. \section*{Introduction}
  99. \blindtext
  100. \newpage
  101.  
  102. \clearpage
  103. \endgroup
  104. \clearpage
  105.  
  106. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  107. % Following is the code used to create vertical bars between text body and margin
  108.  
  109. \def\bottommargin{\paperheight - \topmargin - \textheight - \headheight - \headsep - 1in - \voffset}
  110. \def\toptotalheight{\paperheight - \topmargin - \headheight - \headsep - 1in - \voffset}
  111. \def\leftlength{
  112. \evensidemargin - 0.5*\marginparsep
  113. + 1in
  114. + \hoffset
  115. }
  116. \def\rightlength{\paperwidth
  117. - \evensidemargin + 0.5*\marginparsep
  118. - 1in - \hoffset}
  119.  
  120. \makeatletter
  121. \newcommand{\nomarginbar}{\let\ESO@HookIIBG\@empty}
  122. \makeatother
  123.  
  124. \newcommand{\thisisfullsize}{\path (0,0) -- (\paperwidth,\paperheight);}
  125.  
  126. \newcommand\LeftBar{%
  127. \put(0,0){%
  128. \parbox[b][\paperheight]{\paperwidth}{%
  129. \vfill
  130. \centering
  131. \begin{tikzpicture}
  132. \thisisfullsize
  133. \color{lightgray}
  134. \draw[line width=1pt] (\leftlength,\bottommargin) -- (\leftlength,\toptotalheight);
  135. \end{tikzpicture}
  136. \vfill
  137. }}}
  138.  
  139. \newcommand\RightBar{%
  140. \put(0,0){%
  141. \parbox[b][\paperheight]{\paperwidth}{%
  142. \vfill
  143. \centering
  144. \begin{tikzpicture}
  145. \thisisfullsize
  146. \color{lightgray}
  147. \draw[line width=1pt] (\rightlength,\bottommargin) -- (\rightlength,\toptotalheight);
  148. \end{tikzpicture}
  149. \vfill
  150. }}}
  151.  
  152. %%% Use this in two-side documents
  153. \AtBeginShipout{%
  154. \ifthenelse{\isodd{\value{page}}}%
  155. {\AddToShipoutPictureBG*{\LeftBar}%
  156. }%
  157. {\AddToShipoutPictureBG*{\RightBar}%
  158. }%
  159. }
  160.  
  161. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  162.  
  163. % MAINMATTER STARTS
  164.  
  165. \mainmatter
  166.  
  167. \chapter{The First Chapter}
  168.  
  169. \begin{multicols*}{2}
  170.  
  171. \section{THE FIRST SECTION HAS A REALLY LONG AND THEREFORE PROBLEMATIC TITLE}
  172. \blindtext
  173.  
  174. And now this table:
  175.  
  176. \begin{table*}
  177. \centering
  178. \begin{tabular}{r|c|c|l}
  179. \hline
  180. 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
  181. \hline
  182. \end{tabular}
  183. \caption{Important Data}
  184. \end{table*}
  185.  
  186. \marginnote{\lipsum[75]}[0cm]
  187.  
  188. \blindtext
  189.  
  190. \subsection{The Subsection}
  191. \blindtext
  192.  
  193. And now I'm going to list a list of listed things:
  194. \begin{enumerate}[noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt]
  195. \item \blindtext
  196. \item \blindtext
  197. \item \blindtext
  198. \end{enumerate}
  199. \blindtext
  200.  
  201. \subsubsection{A Subsubsection}
  202. \blindtext
  203.  
  204. \marginnote{\lipsum[75]}[0cm]
  205.  
  206. \blindtext
  207.  
  208. %To clear empty page before Chapter
  209. %\let\cleardoublepage\clearpage
  210.  
  211. \chapter{The Second Chapter}
  212.  
  213. \section{The Second Proper Section}
  214. \blindtext
  215.  
  216. The image should appear right after this:
  217.  
  218. %\includegraphics*{universe}
  219.  
  220. And now, more text to see how this works.
  221.  
  222. \subsection{The Second Subsection}
  223. \blindtext
  224.  
  225. \subsubsection{A Second Subsubsection}
  226. \blindtext
  227.  
  228. \marginnote{\lipsum[75]}[0cm]
  229.  
  230. \blindtext
  231.  
  232. \end{multicols*}
  233.  
  234. % BACKMATTER STARTS
  235.  
  236. %\appendix
  237.  
  238. \backmatter
  239.  
  240. %\printindex
  241.  
  242. \end{document}

Tags:

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

Postby Stefan Kottwitz » Tue Feb 07, 2017 5:21 pm

Hi Alex,

welcome to the forum!

Segmenting the document and using \include for chapters can make working easier. But it is not necessary to fix the issue here.

Here, after the introduction section, you have multiple page breaks - remove them or comment them out (\newpage, \clearpage)

  1. \newpage
  2. \phantomsection
  3. \addcontentsline{toc}{section}{Introduction}
  4. \section*{Introduction}
  5. \blindtext
  6. \newpage
  7.  
  8. \clearpage
  9. \endgroup
  10. \clearpage


Chapters start at right hand pages by default. So they start at odd numbered pages (1, 3, 5, 7, ..). If the text before ends at page 5, the next chapter starts at page 7. You can add the openany option to the document class if you would like to suppress this, or just for testing now: \documentclass[openany]{book}

The \mainmatter command has an implicit \cleardoublepage. So it contains a page break and possibly inserts an empty page so the next page starts on a right hand side. Comment out \mainmatter as additional test. Then, together with openany, there should not be an empty page before the first chapter.

Stefan
Site admin

cyanidebaby
Posts: 11
Joined: Tue Feb 07, 2017 1:56 pm

Postby cyanidebaby » Tue Feb 07, 2017 6:34 pm

Hi Stefan.

Thank you very much for your reply.

Your suggestions work ... mostly.

\documentclass[openany]{book} does the trick ... in part (I totally forgot about the odd/even way pages are handled in the book class. Thank you for that.).

Indeed, as often is the case with LaTex (at least, in my very limited experience), one solution to a problem leads to additional or unintended problems.
Case in point, the [openany] solution: the blank page that used to appear after Chapter 2 is now gone, which is great. But the blank page between "Introduction" and "Chapter 1" is still there.

So I commented out \mainmatter, which gets rid of the blank page before "Chapter 1" (yay!), but the numerals for the whole document are now Roman Numerals ( :lol: ), and the line which I've positioned between the text body and the margin now starts on the page that follows the first Chapter 1 page. Oops.
My head is spinning.

Goes without saying that I put \mainmatter the way it was.

Then I got rid of the many unneeded \newpage page breaks.
Removing too many of them sticks the "Preamble" and "Introduction" to the "List of Tables" though, so I had to keep some.

So, the result, as of right now is: the blank page after Chapter 2 is gone, but the blank page before Chapter 1 is still there.

  1. % PREAMBLE
  2.  
  3. \documentclass[openany]{book}
  4. \usepackage[T1]{fontenc}
  5. \usepackage[latin9]{inputenc}
  6. \usepackage{geometry}
  7. \usepackage[english]{babel}
  8. \usepackage{tocloft}
  9. \usepackage[nottoc]{tocbibind}
  10. \usepackage{hyperref}
  11. \usepackage{geometry}
  12. \usepackage{multicol}
  13. \usepackage{babel}
  14. \usepackage{graphicx}
  15. \graphicspath{ {h:/} }
  16. \usepackage{enumitem}
  17. \usepackage{marginnote}
  18. \usepackage[document]{ragged2e}
  19. \usepackage{eso-pic}
  20. \usepackage{ifthen}
  21. \usepackage{tikz}
  22. \usepackage{color}
  23. %\usepackage{showframe}
  24. \usepackage{blindtext}
  25. \usepackage{lipsum}
  26.  
  27. \setlength{\columnsep}{8mm}
  28.  
  29. %Table of Content depth
  30. \geometry{verbose}
  31. \setcounter{secnumdepth}{3}
  32. \setcounter{tocdepth}{5}
  33. \setlength{\parindent}{0pt}
  34.  
  35. %Hyperlinks for TOC
  36. \makeatletter
  37. \hypersetup{
  38. colorlinks,
  39. citecolor=black,
  40. filecolor=black,
  41. linkcolor=black,
  42. urlcolor=black
  43. }
  44.  
  45. \makeatother
  46.  
  47. %Formating Document per Pto-M-cook
  48. \geometry{
  49. a4paper,
  50. total={21.59cm,27.94cm},
  51. top=2.8cm,
  52. bottom=2.1cm,
  53. inner=1.91cm,
  54. outer=6.68cm,
  55. marginparwidth=4cm,
  56. marginparsep=0.8cm
  57. }
  58.  
  59. %\renewcommand{\cfttoctitlefont}{\hfil \Huge}
  60.  
  61. % FRONTMATTER STARTS
  62.  
  63. \begin{document}
  64.  
  65. \frontmatter
  66.  
  67. \title{A Fantastic Title}
  68. \author{Author's Name}
  69.  
  70. \begingroup
  71.  
  72. \oddsidemargin=0.5\dimexpr\paperwidth-\textwidth-2in\relax
  73. \evensidemargin=\oddsidemargin
  74.  
  75. \maketitle
  76.  
  77. \tableofcontents
  78.  
  79. \newpage
  80. \listoftables
  81. \newpage
  82.  
  83. \phantomsection
  84. \addcontentsline{toc}{section}{Preface}
  85. \section*{Preface}
  86. \blindtext
  87. \newpage
  88.  
  89. \phantomsection
  90. \addcontentsline{toc}{section}{Introduction}
  91. \section*{Introduction}
  92. \blindtext
  93.  
  94. \clearpage
  95. \endgroup
  96. \clearpage
  97.  
  98. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  99. % Following is the code used to create vertical bars between text body and margin
  100.  
  101. \def\bottommargin{\paperheight - \topmargin - \textheight - \headheight - \headsep - 1in - \voffset}
  102. \def\toptotalheight{\paperheight - \topmargin - \headheight - \headsep - 1in - \voffset}
  103. \def\leftlength{
  104. \evensidemargin - 0.5*\marginparsep
  105. + 1in
  106. + \hoffset
  107. }
  108. \def\rightlength{\paperwidth
  109. - \evensidemargin + 0.5*\marginparsep
  110. - 1in - \hoffset}
  111.  
  112. \makeatletter
  113. \newcommand{\nomarginbar}{\let\ESO@HookIIBG\@empty}
  114. \makeatother
  115.  
  116. \newcommand{\thisisfullsize}{\path (0,0) -- (\paperwidth,\paperheight);}
  117.  
  118. \newcommand\LeftBar{%
  119. \put(0,0){%
  120. \parbox[b][\paperheight]{\paperwidth}{%
  121. \vfill
  122. \centering
  123. \begin{tikzpicture}
  124. \thisisfullsize
  125. \color{lightgray}
  126. \draw[line width=1pt] (\leftlength,\bottommargin) -- (\leftlength,\toptotalheight);
  127. \end{tikzpicture}
  128. \vfill
  129. }}}
  130.  
  131. \newcommand\RightBar{%
  132. \put(0,0){%
  133. \parbox[b][\paperheight]{\paperwidth}{%
  134. \vfill
  135. \centering
  136. \begin{tikzpicture}
  137. \thisisfullsize
  138. \color{lightgray}
  139. \draw[line width=1pt] (\rightlength,\bottommargin) -- (\rightlength,\toptotalheight);
  140. \end{tikzpicture}
  141. \vfill
  142. }}}
  143.  
  144. %%% Use this in two-side documents
  145.  
  146. \AtBeginShipout{%
  147. \ifthenelse{\isodd{\value{page}}}%
  148. {\AddToShipoutPictureBG*{\LeftBar}%
  149. }%
  150. {\AddToShipoutPictureBG*{\RightBar}%
  151. }%
  152. }
  153.  
  154. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  155.  
  156. % MAINMATTER STARTS
  157. \mainmatter
  158.  
  159. \chapter{The First Chapter}
  160.  
  161. \begin{multicols*}{2}
  162.  
  163. \section{THE FIRST SECTION HAS A REALLY LONG AND THEREFORE PROBLEMATIC TITLE}
  164. \blindtext
  165.  
  166. And now this table:
  167.  
  168. \begin{table*}
  169. \centering
  170. \begin{tabular}{r|c|c|l}
  171. \hline
  172. 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
  173. \hline
  174. \end{tabular}
  175. \caption{Important Data}
  176. \end{table*}
  177.  
  178. \marginnote{\lipsum[75]}[0cm]
  179.  
  180. \blindtext
  181.  
  182. \subsection{The Subsection}
  183. \blindtext
  184.  
  185. And now I'm going to list a list of listed things:
  186. \begin{enumerate}[noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt]
  187. \item \blindtext
  188. \item \blindtext
  189. \item \blindtext
  190. \end{enumerate}
  191. \blindtext
  192.  
  193. \subsubsection{A Subsubsection}
  194. \blindtext
  195.  
  196. \marginnote{\lipsum[75]}[0cm]
  197.  
  198. \blindtext
  199.  
  200. \chapter{The Second Chapter}
  201.  
  202. \section{The Second Proper Section}
  203. \blindtext
  204.  
  205. The image should appear right after this:
  206.  
  207. %\includegraphics*{universe}
  208.  
  209. And now, more text to see how this works.
  210.  
  211. \subsection{The Second Subsection}
  212. \blindtext
  213.  
  214. \subsubsection{A Second Subsubsection}
  215. \blindtext
  216.  
  217. \marginnote{\lipsum[75]}[0cm]
  218.  
  219. \blindtext
  220.  
  221. \end{multicols*}
  222.  
  223. % BACKMATTER STARTS
  224.  
  225. %\appendix
  226.  
  227. \backmatter
  228.  
  229. %\printindex
  230.  
  231. \end{document}

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

Postby Stefan Kottwitz » Tue Feb 07, 2017 6:38 pm

Instead of \mainmatter you could use

  1. \makeatletter
  2. \@mainmattertrue
  3. \pagenumbering{arabic}}
  4. \makeatother


Basically it's switching to arabic numbers and starting with 1, but I added setting the internal variable for being in the main matter too.

Stefan
Site admin

User avatar
Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Tue Feb 07, 2017 6:46 pm

The blank page is needed and correct there. What Stefan posted may seem to work, but set the outer margin to a value of 8 cm (which is extreme). Also add the showframe option for package geometry. An odd page is always a right hand page.

The command \pagenumbering needs to have a \cleardoublepage in front, and in my opinion that should be defined within that command so a user doesn't have to care.

Say, do you want to print your document as a book (left and right are printed on) or mor like a school report or thesis? In that case, maybe try oneside.

EDIT: Upon a closer look, the template isn't very good. :-/
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

cyanidebaby
Posts: 11
Joined: Tue Feb 07, 2017 1:56 pm

Postby cyanidebaby » Tue Feb 07, 2017 8:42 pm

Thank you both for your replies.

Stefan:
I've been getting interesting results with twocolumn instead of with multicol, so I'm going to go ahead and explore that a little. If it still doesn't work, I'll move one and find another solution.

Johannes:
For print?
At this point, it looks like the book is never going to be printed. Still, I would like to keep that option opened.

The blank pages?
They are indeed part of the book documentclass, but I'd like to get rid of them, as the book will be mostly read/used as a PDF ... and blank pages in PDFs are not great.

This template is bad:
Well, I actually agree ... in part. Indeed, as you've realized, the book is not a novel. It's a sort of encyclopedic guide, part history, part geography and part culture. It's long, with lots of text (close to 400 single spaced pages), side notes on almost every page, few illustrations but quite a few tables and charts (some small, some full page), and a long, very detailed index (and probably an appendix too).
Because the book is so full of at times tough to digest information, I thought that the text would benefit from being presented in a template with a wide margin (for the many side notes; not a fan of footnotes), and a two column body to help reader with the text (some pages will be formatted as a single column though, on a case to case basis).

This WIP template you've looked at is based on a book that was published a little while back (see attached image).
Yes, it's not the latest in great book design, but it's one that contains the sort of info the book I'm working on contains.
If you have a ready-made template in mind for that sort of book, please, let me know. I'd love to take a look at it, which would save me time!

Anyway, I appreciate your useful straight forward comment.
Attachments
Capture.PNG
Capture.PNG (158.17 KiB) Viewed 13654 times

User avatar
Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Tue Feb 07, 2017 9:35 pm

Imagine: if this is a pdf which will be read as a pdf, one page, another page, anothe page, another page. Do you need the margin notes to flip sides?

If this is going to be printed, you have to care about the margin note beeing on this or that side. But only if it is printed, which is (i am assunimg) in the future.

You cannot compare a printed document with an ebook :-)
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

cyanidebaby
Posts: 11
Joined: Tue Feb 07, 2017 1:56 pm

Postby cyanidebaby » Tue Feb 07, 2017 9:58 pm

All very good points. Yes.

Back to my cauldron then.


Return to “Page Layout”

Who is online

Users browsing this forum: No registered users and 1 guest