This is what I'm trying to do:
[Tex/LaTex] How to make section title text align with paragraph indentation
indentationsectioning
Related Solutions
This is surely possible, without automation, using the changepage
package's adjustwidth
environment:
\documentclass{article}
\usepackage{changepage,lipsum,titlesec}% http://ctan.org/pkg/{changepage,lipsum,titlesec}
\titleformat{\section}[block]{\bfseries}{\thesection.}{1em}{}
\titleformat{\subsection}[block]{}{\thesubsection}{1em}{}
\titleformat{\subsubsection}[block]{}{\thesubsubsection}{1em}{}
\titlespacing*{\subsection} {2em}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\subsubsection} {3em}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\begin{document}
\section{A section}
\lipsum[1]
\subsection{A subsection}
\begin{adjustwidth}{2em}{0pt}
\lipsum[2]
\end{adjustwidth}
\subsubsection{A subsubsection}
\begin{adjustwidth}{3em}{0pt}
\lipsum[3]
\end{adjustwidth}
\end{document}
The first argument to adjustwidth
is the left-hand indentation, while the second is the right-hand indentation.
The above MWE also includes Gonzalo's suggestions for better alignment and true-to-titlesec
spacing of sectional units using \titlespacing
.
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}
Best Answer
An option using
titlesec
; the idea is to place the counter inside a box of width equal to the value for\parindent
:Most probably you won't need the line
I used it in my example code to have a generous value for
\parindent
, which apparently your class already provides. Since your class seems to be a non-standard one (seeing the font size for section titles), please consider changing the\Large
in the second mandatory argument ofto conform to your class definitions.