Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
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
add comment

migrated from stackoverflow.com Aug 7 '11 at 9:08

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

2 Answers

up vote 1 down vote accepted

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 :)

share|improve this answer
add comment

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}
\titlelabel{\llap{\thetitle\quad}}
\usepackage{lipsum}
\begin{document}
\section{foo}
\lipsum[1]
\section{bar}
\subsection{foo bar}
\lipsum[1]
\end{document}

The result:

enter image description here

In relation to your comment:

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

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.