1

I want the text inside a \section{} tag to be unindented, how do I accomplish this? I have tried \noindent and \parindent0pt{text} and neither one seems to affect the text inside a section.

  • 6
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Reinstate Monica - M. Schröder Oct 19 '14 at 21:56
  • 1
    This might depend on the document class, since they tend to define \section differently. – John Kormylo Oct 19 '14 at 22:04
  • 3
    In the default classes, section titles are not indented, are they? So something must be redefining the format...? – cfr Oct 20 '14 at 0:52
0

Below I have defined SpecialSection which will disable the \parindent and adds a blank line in between paragraphs. It has been applied to the second section in the image below:

enter image description here

Notes:

Code:

\documentclass{article}
\usepackage{lipsum}
\usepackage{letltxmacro}

\LetLtxMacro\OldSection{\section}%

%% Handle case where the \SpecialSection is the LAST section in the document
\newcommand*{\EndGroupAtEndDocumentIfNeeded}{}%
\AtEndDocument{\EndGroupAtEndDocumentIfNeeded}%

\newcommand*{\SpecialSection}[2][]{%
    \section[#1]{#2}%
    \begingroup%
    \vspace*{-\baselineskip}%
    \setlength{\parindent}{0pt}%
    \setlength{\parskip}{\baselineskip}%
    \def\EndGroupAtEndDocumentIfNeeded{\endgroup}%
    \def\section{%
        \endgroup%
        \def\EndGroupAtEndDocumentIfNeeded{}%
        \let\section\OldSection%
        \OldSection%
    }%
}

\newcommand{\TestText}{%
 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur sed mattis turpis. Nam id mauris non lectus cursus tincidunt quis nec tortor.  

Praesent tempor eleifend felis, in convallis dui imperdiet quis. Vestibulum felis risus, hendrerit nec tempor eget, pulvinar vitae eros. Vestibulum non facilisis purus. 

Nulla eu sagittis elit. Suspendisse ac erat vitae nulla porta molestie ac non sapien. Ut nec venenatis ipsum, ut sagittis enim. Sed mollis urna sed odio fermentum, eget ultrices nisi tempor.
}%

\begin{document}
\section{Normal Section}
\TestText
\SpecialSection{Section that has no parindent}
\TestText
\section{Another Normal Section}
\TestText
\end{document}
0

It is not clear from your question whether you want the paragraph indentation to be zero for all paragraphs or if you only want the section headings to be unindented. If the former, use

\setlength\parindent{0em}

to set the indentation to zero for all paragraphs.

What \documentclass are you using? In the report and book classes, which I use most often, the section headings are not indented.

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