We have designed a class for some journal. We wanted our section titles to be separated by a horizontal line from the previous line. Here is the code:
\def\section{%
\vskip 1.2\@bls%
\hrule height 1pt%
\@startsection{section}{1}{\z@}{-1pt}{1pt}{\normalfont\large\bfseries}%
}
There are two problems, though:
Sometimes, when a page (or column) ends, the horizontal line remains at the preceding page (or column), and the paragraph title is printed on the new page (or column). I read something about setting some penalty value to fix this, but I wasn't successful.
We like our section titles to be aligned left, but LaTeX justifies and hyphenates them. Adding the command
\flushleft
changed nothing.
Edit:
Using Stefan Kottwitz's excellent answer, I changed the above code as follows. Unfortunately, it still does not work: LaTeX typesets the section heading after the horizontal line, without any line/paragraph break whatsoever.
\def\section{%
\begin{minipage}{7cm} %
\vskip 1.2\@bls%
\hrule height 1pt%
\raggedright\@startsection{section}{1}{\z@}{-1pt}{1pt}{\normalfont\large\bfseries}%
\protect\end{minipage}%
}