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 like to recreate the layout of an official template, in order to get rid of Word. Because the template is from the government, I must recreate it 1:1.

In the end, the document should look like this:

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et 
accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata.

1.      First Section Title
        Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
        tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
        vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren.

1.1     First Subsection Title
        Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
        tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
        vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren.

1.1.1   First Subsubsection Title
        Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
        tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
        vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren.

My main problem is the spacing between the section numbers and the titles. All section titles must begin on a fixed indent defined by the template, so the spacing between the numbers and the titles must be dynamic. With plain latex and titlesec I was only able to specify a fixed space. I also tried the memoir package with hangsecnum, but with this option the numbers will be aligned left, also with a fixed space between the section numbers and the title.

Would it be possible to give me a hint how to create such a layout?

share|improve this question
    
Could you please provide a few more specifics regarding papersize (a4?, usletter?, ...), width and height of text block on page, the amount of indent (1.5cm?, 1inch?, ...), the appearance of the (subsub,sub)section headers (same font size as text? same font weight as text, or boldface and/or italics?), and the amount of spacing above and below sectioning headers? –  Mico Aug 29 '11 at 21:14
    
You might also want to consider cmhughes's solution to my question: "How can I align section titles and list environments in the left margin?" –  user2473 Jan 2 '12 at 17:34
add comment

2 Answers

\documentclass[a4paper]{article}
\newlength{\texthanging}
\setlength{\texthanging}{2cm}
\makeatletter
\def\@seccntformat#1{\protect\makebox[0pt][r]{%
  \protect\makebox[\texthanging][l]{\csname the#1\endcsname.}}}
%\def\@seccntformat#1{\llap{\hbox to\texthanging{
%  \csname the#1\endcsname.\hfil}}}
\makeatother
\newcommand\hanging{\leftskip=\texthanging}
\newcommand\nohanging{\leftskip=0pt }

\begin{document}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et 
accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata.

\hanging

\section{First Section Title}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren.

\subsection{First Subsection Title}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren.

\subsubsection{First Subsubsection Title}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren.

\nohanging

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et 
accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata.

\end{document}

The uncommented and the commented versions of \@seccntformat are equivalent, but the commented version uses low level commands.

share|improve this answer
add comment

You can use the titlesec as follows:

\usepackage{calc}%
\usepackage{titlesec}%
\titleformat{\section} {\normalfont\bfseries}{\makebox[3em][l]{\itshape\thesection}}{1em}{}%
\titleformat{\subsection} {\normalfont\bfseries}{\makebox[3em][l]{\itshape\thesubsection}}{1em}{}%
\titleformat{\subsubsection} {\normalfont\bfseries}{\makebox[3em][l]{\itshape\thesubsubsection}}{1em}{}%

\addtolength{\leftskip}{\widthof{\normalfont\bfseries\makebox[4em]{}}}% Indent text

enter image description here

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