[Tex/LaTex] pdflatex indenting first paragraph after section

indentation

I am having an issue where the first paragraph is being indented after a section heading. For instance

\section{My Section}\label{sec:my-section}
This is my section, and I have no idea why it's being indented

I am using the article class:

\documentclass[10pt]{article}

I have narrowed the issue down to this snippet of code:

\makeatletter
\renewcommand\section{\@startsection {section}{1}{0mm} % name, level, indent
                               {3pt} % before skip
                               {3pt} % after skip
                               {\normalfont\bfseries}}
\makeatother

These are the packages being imported:

\usepackage{float,latexsym,longtable,color}
\usepackage[pdftex]{graphics,graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{setspace}
\usepackage[small,compact]{titlesec}
\usepackage{bm}
\usepackage{fancyhdr}
\usepackage{hangcaption}
\usepackage{amsbsy}
\usepackage{floatflt}
\usepackage{epsfig}
\usepackage{wrapfig}            % wrap figures/tables in text
\usepackage{subfigure}          % subcaptions for subfigures
\usepackage{threeparttable}     % tables with footnotes
\usepackage{dcolumn,multirow}   % decimal-aligned tabular math columns
\usepackage{booktabs}
\usepackage{nomencl}            % nomenclature package
\usepackage{lscape}
\usepackage{times}
\usepackage[colorlinks=true, linkcolor=DarkBlue, citecolor=DarkBlue, urlcolor=DarkBlue]{hyperref}
\usepackage{array}
\usepackage{caption}
\usepackage[table]{xcolor}
\usepackage{import}
\usepackage{datetime}
\usepackage{flafter}
\usepackage{enumitem} % Better control over lists

Best Answer

With this code you are precisely telling TeX to indent after section titles.

\makeatletter
\renewcommand\section{\@startsection {section}{1}{0mm} % name, level, indent
                               {3pt} % before skip
                               {3pt} % after skip
                               {\normalfont\bfseries}}
\makeatother

The parameter "before skip" should be negative for having no indentation:

\makeatletter
\renewcommand\section{\@startsection {section}{1}{0mm} % name, level, indent
                               {-3pt} % before skip
                               {3pt} % after skip
                               {\normalfont\bfseries}}
\makeatother

However, it's not a good idea to have fixed spacing around section titles, which don't leave flexibility to the page. Probably

\makeatletter
\renewcommand\section{\@startsection {section}{1}{0mm} % name, level, indent
                               {-3pt plus -2pt minus -1pt} % before skip
                               {3pt plus 1pt} % after skip
                               {\normalfont\bfseries}}
\makeatother

would be a better choice (albeit too tight, in my opinion).

Notice that LaTeX will "change sign" to the specified glue, so it's not a negative vertical spacing.


You would get a very similar result without tampering with low level commands with

\usepackage[tiny,compact]{titlesec}

so my advice is to remove the \@startsection code, as the one provided by titlesec is safer.