セクションの後にページ区切りが挿入されるのはなぜですか?

セクションの後にページ区切りが挿入されるのはなぜですか?

問題は、セクション、いくつかの章、および目次の後に改ページと水平線が挿入されることです。どの部分で問題が発生しているのか、またその理由がわからないため、すべてのコードを記載しました。

\documentclass[letterpaper]{book}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{helvet}
\usepackage{wrapfig}
\usepackage[letterpaper, top=4cm, bottom=2.5cm, left=4cm, right=2.5cm]{geometry}
\usepackage{setspace}
\doublespacing
\usepackage[pdftex]{graphicx}
\renewcommand{\familydefault}{\sfdefault}
\pagestyle{fancyplain}
\fancyhf{}
\fancyfoot[R]{\thepage}
\rfoot{\thepage}
\addto\captionsspanish{\renewcommand*\contentsname{TABLA DE CONTENIDOS}}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

\begin{document}
\frontmatter
%\input{./title.tex}
\tableofcontents
\mainmatter
\section*{MySection}
\addcontentsline{toc}{subsection}{Preface}
\chapter{Introduction}
\section{MySection}
\section{MySection}
\section{MySection}
\subsection{subsect}
Lorem  ipsum  dolor  sit  amet,  consectetuer  adipiscing  
elit.   Etiam  lobortisfacilisis sem.  Nullam nec mi et 
neque pharetra sollicitudin.  Praesent imperdietmi nec ante. 
Donec ullamcorper, felis non sodales
\chapter{Chapter2}
\appendix
\chapter{Reproducible Research}
\end{document}

ここライブドキュメントです。

答え1

これらの線は、ページのヘッダーとテキストを区切るためのものです。幅を 0 に設定することで無効にすることができます。

\renewcommand{\headrulewidth}{0pt}

これはパッケージによって設定されますfancyhdr。これらは、異なる形式を使用する目次の最初のページや章の最初のページなどの「特別な」ページではデフォルトで無効になっています。

各章は右ページから始まる必要があるため、空白ページが挿入されます。これを無効にしたい場合 (実際には無効にすべきではありませんが)、次のopenanyオプションを使用します。

\documentclass[letterpaper,openany]{book}

sectionなしのchapterは意味をなさないので、 を付けないでください(最初のsection*)。

関連情報