5

I use the titlesec package for decoration sections and subsections. But i do not know how to change leftmargin or indent for this. Look at the picture, the green line is where i want to move the section.

I use this code

\documentclass[a4paper, 14pt]{extreport}
\usepackage{titlesec}

\titleformat{\section}{}{\thesection}{14pt}{}

enter image description here

  • Welcome to TeX.SX! It would be very useful to add the code you have up to now. Is it the blue line? – egreg Jun 1 '12 at 8:54
  • @egreg i added code – mark Jun 1 '12 at 9:00
  • That code produces an error. – egreg Jun 1 '12 at 9:05
  • but in texmaker this works without errors. – mark Jun 1 '12 at 9:07
  • I don't think so. Please, make a complete example: only the class, the loading of titlesec and the relevant commands. – egreg Jun 1 '12 at 9:13
4

A layout as you'd like can be obtained by

\documentclass{report}
\usepackage{indentfirst}
\usepackage{titlesec}
\usepackage{lipsum}

\newlength{\normalparindent}
\AtBeginDocument{\setlength{\normalparindent}{\parindent}}

\titleformat{name=\section}[block]
  {\LARGE}
  {\hspace*{\normalparindent}\thesection}
  {1em}
  {}

\titleformat{name=\section,numberless}[block]
  {\LARGE}
  {}
  {0pt}
  {\hspace*{\normalparindent}}

\begin{document}

\section{Lorem Ipsum Dolor}
\lipsum[1]

\section*{Nam Dui Ligula}
\lipsum[2]

\end{document}

It's necessary to specify the numberless variant, otherwise the indentation would not be respected for unnumbered sections. Adjust the size (I used \LARGE) and the spacing between the number and the title (I used 1em).

The definition and setting of \normalparindent is necessary because the value of \parindent is not available (better, it's set to zero) when LaTeX is typesetting a section title.


enter image description here


Note. I don't like such a layout at all.

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.