1

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->_______________________________________________

<-0.75in->1.    Section heading
          <-x->|
                Some text blah blah blah..................
                which is left-aligned with the section 
                heading.

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{}
    \renewcommand{\headrulewidth}{1pt}
    \setlength{\headheight}{0.75in} 
    \setlength{\headsep}{12pt}
    \setlength{\footskip}{30pt}
    \setlength{\textheight}{670pt}
    \fancyhead[HL]{10/22/2014}
    \fancyhead[HC]{\footnotesize\textbf{My Title}}
    \fancyhead[HR]{Mr. Stumped}
    \fancyhead[RO]{\footnotesize \bf \thepage}
}

\fancypagestyle{fancyHWrest}
{
    \fancyhf{}
    \renewcommand{\headrulewidth}{1pt}
    \setlength{\headheight}{0.75in} 
    \setlength{\headsep}{12pt}
    \setlength{\textheight}{670pt}  
    \fancyhead[RE]{\footnotesize \it \nouppercase{\rightmark}}
    \fancyhead[LO]{\footnotesize \it \nouppercase{\rightmark}}
    \fancyhead[RO, LE]{\footnotesize \bf \thepage}
}

\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.

6
  • 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, 2014 at 5:37
  • @user3489620: What is the H specification for fancyhead?
    – Bernard
    Oct 25, 2014 at 10:01
  • @Bernard HE = header on even pages, HL = header on left, HLE = header on left on evenpages... etc. Oct 25, 2014 at 17:59
  • @user3489620: Where is it defined? I couldn't find it in the documentation.
    – Bernard
    Oct 25, 2014 at 18:02
  • @Bernard [en.wikibooks.org/wiki/LaTeX/Page_Layout] section 7.2.3 Oct 25, 2014 at 18:07

2 Answers 2

2

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[vmargin=0.5in, left=1.25in, right=0.75in, headheight=0.75in, headsep=12pt, footskip=30pt, textheight=670pt]{geometry}
\usepackage[pagestyles, indentafter]{titlesec}

\newpagestyle{wideoddhead}{%
\setheadrule{1pt}
\widenhead[0pt][0pt]{0.5in}{0pt}
\sethead[\footnotesize\bfseries\thepage][][\footnotesize\itshape{\sectiontitle}]{10/22/2014}{\footnotesize\textbf{My Title}}{\footnotesize\bfseries\thepage}
}

\titleformat{\section}[block]{\bfseries\large}{\llap{\makebox[0.5in][l]{\thesection.}}}{0pt}{}
\pagestyle{wideoddhead}
\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} 

enter image description here

enter image description here

2
  • 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. Oct 26, 2014 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, 2014 at 20:42
1

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.

1
  • 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 Oct 25, 2014 at 18:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .