We must give more structure to the right mark emitted by the \chapter
command; so we do
\renewcommand{\chaptermark}[1]{%
\markboth{\chaptername\ \thechapter}
{\noexpand\firstsubsectiontitle}}
The \subsectiontitle
macro will be defined by the \subsection
command; of course it won't work if no subsection starts in the first page:
\renewcommand{\subsectionmark}[1]{%
\markright{#1}\gdef\firstsubsectiontitle{#1}}
Here's an example; notice some changes I've made to your code. For instance I've redefined the \sectionmark
command so it doesn't emit any mark.
The solution to the numbering problem of subsection is to \setcounter{secnumdepth}{1}
.
\documentclass{report}
% PACKAGES
\usepackage{fancyhdr}
\usepackage{lastpage} % Allows referencing of the last page to allow footer to read: "Page [Current page] of [Total number of pages]."
\usepackage{comment} % Allows comments of the type: \begin{comment}This text is commented out.\end{comment}
%\usepackage[colorlinks=true]{hyperref} % Turns table of contents and labels into clickable links. Commented out to speed up compiling.
\usepackage[T1]{fontenc} % Allows use of ">" symbol.
\usepackage{lmodern} %Not really sure what this is for.
% FORMATTING
% Header and Footer
\pagestyle{fancy}
% Allows calling chapter and section names in headers and footers.
\renewcommand{\chaptermark}[1]{%
\markboth{\chaptername\ \thechapter}
{\noexpand\firstsubsectiontitle}}
\renewcommand{\sectionmark}[1]{}
\renewcommand{\subsectionmark}[1]{%
\markright{#1}\gdef\firstsubsectiontitle{#1}}
\newcommand\firstsubsectiontitle{}
% General Header and Footer
\fancyhf{}
\fancyhead[L]{\DocumentAuthor}
\fancyhead[R]{\BookAuthor>\leftmark>\rightmark}
\fancyfoot[C]{Page \thepage\ of \pageref{LastPage}}
% Chapter Header and Footer
\fancypagestyle{plain}{%
\fancyhf{} \fancyhead[L]{\DocumentAuthor}%
\fancyhead[R]{\BookAuthor>\leftmark>\rightmark}%
\fancyfoot[C]{Page \thepage\ of \pageref{LastPage}}%
}
% Header/Footer Separation-line Width
\renewcommand\headrulewidth{0.4pt}
\renewcommand\footrulewidth{0.4pt}
\setlength\parindent{0pt} % Remove paragraph indentation.
% NAME AND CLASS SECTION
\newcommand{\DocumentAuthor}{Author Name}
\newcommand{\BookAuthor}{Book Author}
\setcounter{secnumdepth}{1}
%DOCUMENT
\begin{document}
\tableofcontents
\thispagestyle{empty}
\chapter{Title of Chapter 1}
\section{Sample Problems}
\subsection{Title of Subsection 1}
\pagebreak{}
\subsection{Title of Subsection 2}
\subsection{Title of Subsection 3}
\pagebreak{}
\subsection{Title of Subsection 4}
\end{document}
With this code the first subsection in the page will be put in the header.
What's \noexpand\firstsubsectiontitle
doing? The \markboth
and \markright
commands must record the current values of the counters and titles, so their arguments are passed through an \edef
; this, in the case of the first chapter and English language, would set a left mark with value Chapter\ 1
. If we said only \firstsubsectiontitle
in the second argument, it would be expanded leaving a wrong right mark because it would be empty for the first chapter and would contain the last subsection in the preceding chapter!
So we say "dear TeX, don't expand \firstsubsectiontitle
right now, but only when you'll set the header."
Actually, if there can be more than one subsection in the chapter pages, a different solution should be used:
% Allows calling chapter and section names in headers and footers.
\renewcommand{\chaptermark}[1]{%
\markboth{\chaptername\ \thechapter}
{\noexpand\firstsubsectiontitle}%
\global\firstsubsectionmarktrue}
\renewcommand{\sectionmark}[1]{}
\renewcommand{\subsectionmark}[1]{%
\markright{#1}%
\iffirstsubsectionmark
\gdef\firstsubsectiontitle{#1}%
\fi
\global\firstsubsectionmarkfalse}
\newif\iffirstsubsectionmark
\def\firstsubsectiontitle{}
so that the first subsection would set the mark.
The immediate problem is that you need the counter for paragraphs to be reset when you start a new subsubsubsection. To do this, all you need to do is add:
\@addtoreset{paragraph}{subsubsubsection}
Note, though, that you probably will also find you want to add some further resets depending on the structure of your document.
More generally, I have to say that the fact that you find the need to do this indicates to me that you need to rethink the structure of your document. Even if you are writing a book or thesis (for which article
would not be a suitable class), 9 levels is just going to be confusing. The only exception is probably legal documentation which seems to positively require insane levels of hierarchy. I think you should really be asking what you expect your readers to gain from the structure in terms of clarity. If the answer is nothing or, worse, greater complexity and confusion, you know you need to rethink.
However, this is TeX SE and so I can provide a 'solution' with a clean conscience since the site is not in the business of ensuring people write well, but only of assisting them to write whatever they do in TeX.
\documentclass{article}
\usepackage{titlesec}
\titleclass{\subsubsubsection}{straight}[\subsection]
\newcounter{subsubsubsection}[subsubsection]
\renewcommand\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}
\renewcommand\theparagraph{\thesubsubsubsection.\arabic{paragraph}}
\renewcommand\thesubparagraph{\theparagraph.\arabic{subparagraph}}
\titleformat{\subsubsubsection}
{\normalfont\normalsize\bfseries}{\thesubsubsubsection}{1em}{}
\titlespacing*{\subsubsubsection}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
{3.25ex \@plus1ex \@minus.2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}
\renewcommand\subparagraph{\@startsection{subparagraph}{6}{\parindent}
{3.25ex \@plus1ex \@minus .2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}
\def\toclevel@subsubsubsection{4}
\def\toclevel@paragraph{5}
\def\toclevel@paragraph{6}
\def\l@subsubsubsection{\@dottedtocline{4}{7em}{4em}}
\def\l@paragraph{\@dottedtocline{5}{10em}{5em}}
\def\l@subparagraph{\@dottedtocline{6}{14em}{6em}}
\@addtoreset{subsubsubsection}{section}
\@addtoreset{subsubsubsection}{subsection}
\@addtoreset{paragraph}{subsubsubsection}
\makeatother
\setcounter{secnumdepth}{6}
\setcounter{tocdepth}{6}
\author{Author}
\title{Title}
\date{2014}
\begin{document}
\tableofcontents
\section{Section 1}
\subsection{subsection 1}
\subsubsection{subsubsection 1}
\subsubsubsection{Subsubsubsection 1}
Some description here
\paragraph{paragraph 1}
Some description here
\paragraph{Paragraph 2}
Some description here
\subsubsubsection{subsubsubsection 2}
Description here
\subsubsubsection{subsubsubsection 3}
description here
\subsubsubsection{subsubsubsection 4}
description here
\paragraph{paragraph 1}
Some description here
\paragraph{paragraph 2}
some description here
\paragraph{Paragraph 3}
\subsubsubsection{subsubsubsection 5}
description here
\end{document}
Best Answer
The
amsart
document class is programmed to insert a "dot" (aka "period" of "full stop") at the end of all sectioning headers below the section level -- and not just in the appendix, but throughout the entire document.My working assumption is that if you want the dot removed from unnumbered subsection-level headers in the appendix, you will also want to have the dots removed from all other sectioning headers, throughout the entire document.
If this assumption is correct, you can achieve your formatting objective by adding the following code in the preamble:
I will leave it to your imagination to determine what
\@addpunct.
does. :-)