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 redefined some commands to meet my university requirements in my 'report' based class, and these commands basically work fine. Additionally, I need to change sections/subsections header margin rules.

Now I have:

    1.1 Very long section name Lorem ipsum dolor sit amet, consectetur adipisci veliturea
        adipiscing elit. Ut convallis pharetra augue at aliquet.

    Text text text Aliquam sem quam, euismod id consequat in, rutrum ac ipsum. Vestibulum 
pellentesque vitae lectus. Mauris feugiat lectus gravida nisi aliquam quis sodales eros. 

And what I need:

    1.1 Very long section name Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.

    Text text text Aliquam sem quam, euismod id consequat in, rutrum ac ipsum. Vestibulum 
pellentesque vitae lectus. Mauris feugiat lectus gravida nisi aliquam quis sodales eros.

Current 'section' command:

\newcommand\section{%
      \renewcommand{\@seccntformat}[1]{%
      %% custom section caption
      \csname thesection\endcsname\hspace{0.5em}}%
      %% custom first line indent
      \@startsection {section}{1}{10mm}%
      {3.5ex \@plus 1ex \@minus .2ex}%
      {2.3ex \@plus.2ex}%
      %% disable hyphenation 
      {\normalfont\bfseries\raggedright}}

In other words, I want to preserve the first line indent that I have set, but all other lines in section/subsection headers should be presented with zero margin, as in chapter header. How can I do that?

UPD. I think we can see it with standard 'report' class (the same behavior):

\documentclass{report}

\usepackage{indentfirst}

\begin{document}

\chapter{Very long chapter name Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.}

\section{Very long section name Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.}

Some text Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.

\end{document}
share|improve this question
    
Welcome to TeX.SX. Please, expand the code into a real minimal example. –  egreg Apr 14 '12 at 23:00
    
I added an example. Seems it comes from the original 'report' class. I need to have the section header text margin the same as in header, or text below (without any indent for the second line.) –  Denis Apr 14 '12 at 23:38
add comment

2 Answers

up vote 5 down vote accepted

Another option, not requiring additional packages would be to use the TeX primitive \parshape:

\newcommand\section{%
      \renewcommand{\@seccntformat}[1]{%
      \csname thesection\endcsname\hspace{0.5em}}%
      \@startsection {section}{1}{10mm}%
      {3.5ex \@plus 1ex \@minus .2ex}%
      {2.3ex \@plus.2ex}%
      {\normalfont\bfseries\raggedright\parshape 1 0cm \textwidth}}

An example:

\documentclass{book}

\makeatletter
\renewcommand\section{%
      \renewcommand{\@seccntformat}[1]{%
      \csname thesection\endcsname\hspace{0.5em}}%
      \@startsection {section}{1}{10mm}%
      {3.5ex \@plus 1ex \@minus .2ex}%
      {2.3ex \@plus.2ex}%
      {\normalfont\bfseries\raggedright\parshape 1 0cm \textwidth}}
\makeatother

\begin{document}
\chapter{Test Chapter}

\section{Very long section name Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.}

Some text Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.

\end{document}

enter image description here

share|improve this answer
    
Thank you, this is exactly what I need. –  Denis Apr 15 '12 at 10:41
add comment

I would use the titlesec package to reformat your sections. Here's an example of what you want (I think):

\documentclass{report}
\usepackage{titlesec}
\usepackage{indentfirst}
\titleformat{\section}[block]{\normalfont\bfseries\raggedright}{\hspace{10mm}\thesection}{0.5em}{}
\titlespacing*{\section}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus.2ex}
\begin{document}

\chapter{}

\section{Very long section name Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.}

Some text Lorem ipsum dolor sit amet, consectetur adipisci veliturea
adipiscing elit. Ut convallis pharetra augue at aliquet.

\end{document}

output of code

share|improve this answer
    
Many thanks! Could you advise, how can I combine it with the existing 'section' definition from the first post? –  Denis Apr 15 '12 at 0:03
1  
@Denis I've added a \titlespacing* command to set the spacing the same as in your example. Everything else should be the same, so you don't need your redefinition of \section. Or am I missing something? –  Alan Munn Apr 15 '12 at 0:56
    
I need to redefine 'section' anyway, because there are a lot of changes from standard 'report' class. That was only one example. I have tried to use 'titlesec', but it didn't find 'paragraph/subparagraph' stuff (it seems to use it I need to define/redefine them in my class.) –  Denis Apr 15 '12 at 10:50
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.