1

I am trying to get the subsection title flush with the top margin when it appears on a new page. I was able to get all the section headings flush with the top margin by using the the \setstretch{1} command in the \titleformat{\section}. The same trick doesn't work for the subsection because I am using hang for them instead of display so it has the unwanted affect of removing the double spacing.

In the second image, how can I get the subsection title to be flush with the top margin just like the section on the first page? I have tried \titlespacing{\subsection}{0pt}{-.5in}{0pt} but this messes up the subsection on the first page and it also doesn't do anything for subsections that appear on a new page.

Some things to note: I do not want to mess up the long subsection heading that is on the first page. Also, this is a problem that I am trying to solve for a large document. Also, I am pretty committed to the titlesec package at this point. Finally, I have the same exact issue with subsubsection so I am looking for a solution that will also work with that.

\documentclass[12pt]{article}
\usepackage[paperwidth=8.5in, paperheight=11in, margin=1in, showframe=true]{geometry} % Set paper size.

%Set font to Arial font
\usepackage{helvet}
\usepackage{setspace}
\usepackage{titlesec}
\usepackage{calc}
\usepackage{lipsum}

\newcommand{\sectionbreak}{\clearpage}%new page for each section
\titleformat{\section}[display]{\centering}{\setstretch{1}SECTION \thesection}{0pt}{}
\titleformat{\subsection}[hang]{\centering}{\thesubsection}{\widthof{\space}}{}
\titlespacing{\section}{0pt}{0pt}{0pt}%Removes spacing around section titles
\titlespacing{\subsection}{0pt}{0pt}{0pt}%Removes spacing around subsection titles


\begin{document}
\raggedright % Flush left
\setlength\parindent{0.5in}%Indent the text. Must be after raggedright.
\setstretch{2} % Double space the entire document (used to be \doublespacing)
\section{LONG TITLE LONG TITLE LONG TITLE LONG TITLE  LONG TITLE  LONG TITLE  LONG TITLE }
\lipsum[5]
\subsection{LONG TITLE LONG TITLE LONG TITLE LONG TITLE  LONG TITLE  LONG TITLE  LONG TITLE }


\newpage
\subsection{LONG TITLE LONG TITLE LONG TITLE LONG TITLE  LONG TITLE  LONG TITLE  LONG TITLE }
\end{document}

First page: The section is flush with the top margin. In the first page, the section is flush with the top margin.

Second page: The subsection is not flush with the top margin like the section on the first page. Here, on page 2 you can see that the subsection is title is not flush with the top margin like the first page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.