# Customizing indentation in section and subsection headings

I would like to be able to \renewcommand\section and get LaTeX to format the section and subsection headings so that their numbers are left-justified, and the headings are exactly above the paragraph indentation:

1          Section title
1.1        Subsection title
Start of paragraph


I found advice to change the indentation of the Section title like so:

\renewcommand\section{%
\def\@seccntformat##1{\csname the##1\endcsname\hspace{_____}}
\@startsection{your}{parameters}{here}...
}


If I insert 1in in the \hspace command, I get exactly one inch from the end of the section number. I want 1 inch from the left margin, so something like \hspace{1in \@minus \width\csname}, or something like that. That command doesn't work, but at least shows my intention.

-

## migrated from stackoverflow.comAug 7 '11 at 9:08

This question came from our site for professional and enthusiast programmers.

Welcome to TeX.sx! Your question was migrated here from another stackexchange site. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. –  N.N. Aug 7 '11 at 9:28

Which document class do you use? Here is an example with scrartlc

\documentclass{scrartcl}
\usepackage{lipsum}
\renewcommand*{\othersectionlevelsformat}[3]{%
\llap{#3\autodot\enskip}}
\begin{document}
\section{foo}
\lipsum[1]
\section{bar}
\subsection{foo bar}
\lipsum[1]
\end{document}


By using a standard class you can use the package titlesec

\documentclass{article}
\usepackage{titlesec}
\usepackage{lipsum}
\begin{document}
\section{foo}
\lipsum[1]
\section{bar}
\subsection{foo bar}
\lipsum[1]
\end{document}


The result:

\documentclass{article}
\usepackage{titlesec}
%1inch=25,4mm
\titlelabel{\llap{\makebox[1cm][l]{\thetitle}}\hspace*{25.4mm}}
%\usepackage{indentfirst}
\usepackage{lipsum}
\usepackage{showframe}
\begin{document}
\section{foo}
\hspace*{25.4mm}\lipsum[1]
\section{bar}
\subsection{foo bar}
\lipsum[1]
\end{document}


The package indentfirst is a possibility if every indent should be 1inch. I think 1inch is to big.

-
The class that I'm using is not a standard Latex class, but it does \LoadClass{article}. I'm trying to tweak the class so that it conforms to my company's memo template. The section / subsection numbering should be left-justified, and the section /subsection heading should be indented from the left margin 1 inch. The paragraph indentation should also be one inch. I've edited my post to clarify. –  Josh Aug 8 '11 at 16:41
@Josh: I edited my post. –  Marco Daniel Aug 8 '11 at 17:05

As indicated by @Marco, I did require the titlesec package.

\titleformat{\section}
{}
{\makebox[1in][l]{\thesection}}{0in}{}


and

\titleformat{\subsection}
{}
{\makebox[1in][l]{\thesubsection}}{0in}{}


got me what I needed. I agree that 1 inch is way too large of an indentation for the section label and paragraph, but I don't get to choose the format :)

-