# Margin adjustment for section text

I've been messing with my margins, section dimensions, geometry package dimensions, and titlesec settings to get this layout (and have, so far, failed): (left margin set at 0.75in)

<-0.75in->HEADER LEFT                        HEADER RIGHT
<-0.75in->_______________________________________________

<-x->|
Some text blah blah blah..................
which is left-aligned with the section


I've tried utilizing \titleformat to move the section number to the left, but this leaves the header left margin aligned with the main text. I'm also trying to do this within a custom class that I have built. For this reason, I would prefer to universally change the margin for the text within sections to be aligned with section title text, and allow for page margin changes without having to adjust a multitude of other values.

I hope this makes sense. Thanks.

EDIT: MWE

\documentclass[10pt, letterpaper, twoside]{article}
\usepackage[top=0.5in, bottom=0.5in, left=1.25in, right=0.75in]{geometry}
\usepackage{titlesec}
\usepackage{fancyhdr}
\usepackage{indentfirst}
\usepackage{lipsum}

\fancypagestyle{fancyHW}
{
\fancyhf{}
\setlength{\footskip}{30pt}
\setlength{\textheight}{670pt}
}

\fancypagestyle{fancyHWrest}
{
\fancyhf{}
\setlength{\textheight}{670pt}
}

\pagestyle{fancyHWrest}
\renewcommand{\sectionmark}[1]{ \markright{#1}{} }
\thispagestyle{fancyHW}

\setlength{\parindent}{0pt}

\titleformat{\section}[block]{\bfseries\large\hspace{-0.5in}}{\thesection.}{\leftmargin}{}

\begin{document}
\section{The First Section}
As you can see, the header is aligned with the text.  I am trying to get the header aligned with the section number while keeping the text aligned with the section title.

\lipsum

\section{The Next Section}
It also gets really messed up for two-sided documents, if the left and right margin are set to different values.  Moving only section text would alleviate this problem.
\end{document}


CLARIFICATION: I apologize if this is confusing. Let me try to clarify what I have, compared to what I want to accomplish.

-What I have:

I am able to align the section body text with the section label text by shifting the section label number -0.5in into the left margin and aligning the section label text with \leftmargin. However, this is a two-sided document. So, if I decide to make the "inner" margin smaller than the "outer" margin (as is with the MWE), there is a problem: it is fine on odd pages where the section number is 0.75in from the left side of the page. However, because of the section number's offset into the left margin, the section number becomes 0.25in from the left side of the page on even pages.

-What I'm trying to accomplish:

Align the section number with \leftmargin and align both section label text AND section body text a specified distance from \leftmargin. This would allow me to change the margins within geometry at will, without the current spacing problem between the left side of the page and section numbers on even pages.

• Welcome to TeX.SX! When asking questions it is better to provide a full minimal working example (MWE) both in order to demonstrate what you are trying to do and to help others help you. The MWE should like like \documentclass...\begin{document}...\end{document}, it should compile and contain close to the minimal amount of code needed to explain/demonstrate what you are asking. This saves a lot of time for everyone – user30471 Oct 25 '14 at 5:37
• @user3489620: What is the H specification for fancyhead? – Bernard Oct 25 '14 at 10:01
• @Bernard HE = header on even pages, HL = header on left, HLE = header on left on evenpages... etc. – user3489620 Oct 25 '14 at 17:59
• @user3489620: Where is it defined? I couldn't find it in the documentation. – Bernard Oct 25 '14 at 18:02
• @Bernard [en.wikibooks.org/wiki/LaTeX/Page_Layout] section 7.2.3 – user3489620 Oct 25 '14 at 18:07

Here is a solution with titleps. I define a wideoddhead pagestyle that does what you want (if I understood well) without having to change margins. I had to modify the sectrion formatting. Also simplified your preamble:

\documentclass[10pt, letterpaper, twoside]{article}

\usepackage[pagestyles, indentafter]{titlesec}

}

\titleformat{\section}[block]{\bfseries\large}{\llap{\makebox[0.5in][l]{\thesection.}}}{0pt}{}
\raggedbottom

\begin{document}

\section{The First Section}
Text text text text text text text text text text text text text text text text text text text text text text text text text.
As you can see, the header is aligned with the text. I am trying to get the header aligned with the section number while keeping the text aligned with the section title.
\pagebreak
\section{The Next Section}
It also gets really messed up for two-sided documents, if the left and right margin are set to different values. Moving only section text would alleviate this problem.

\end{document}


• That does an outstanding job of simplifying my preamble, but notice that page 2 has a 0.25in margin between the section number and the left side of the page. This is the crux of my problem. – user3489620 Oct 26 '14 at 20:21
• @user3489620: That comes from your narrow right margin (which is the left margin on even pages). Are you stuck to the 0.5 in value for the distance between section number and left margin? or you simply could increase the margin(s). It is impossible to respect all your constraints and have a greater distance between left side of the page and section number. – Bernard Oct 26 '14 at 20:42

The section number is placed in the left margin, so it is not going to align with the header, unless you redefine one or both of them.

I'm not sure what you mean when you say "it gets really messed up for two-sided documents." If you don't want the left and right margins to have different values, change the documentclass line option to oneside or reset the left and right margins with the following commands:

\setlength\oddsidemargin{0in}
\setlength\evensidemargin{0in}


Adjust the values to achieve the margin widths you want.

• The point is that, currently, I have to put the section number in the margin in order for the text to align with the section label text. This creates a problem with twoside. Example: on odd pages, the section number is (within the MWE) 0.75 in from the left margin and the right margin of the text is 0.75 in from the right side of the page. However, on the even pages, the section number becomes 0.25 in from the left margin. As requested, I need a solution to indent all body text within a section a specific distance from the \leftmargin – user3489620 Oct 25 '14 at 18:05