13

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?

6

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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