# Translating custom \section format to titlesec

I have some custom \section formatting with a horizontal rule, and I'm trying to DRY out my code by using titlesec to define default formatting options. But I can't exactly reproduce what happens when not using titlesec. Here's an example:

\documentclass{article}
\usepackage[explicit]{titlesec}
\usepackage{xhfill}

\begin{document}

% Plain xrfill:
\section*{\large\normalfont First Section \xrfill[0.6ex]{0.4pt}}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

% Via titlesec:
\titleformat{\section}[runin]{\large}{\thetitle}{1em}{#1 \xrfill[0.6ex]{0.4pt}}
\section*{Second Section (\texttt{titlesec})}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

% Titlesec with a \\ at the end:
\titleformat{\section}[runin]{\large}{\thetitle}{1em}{#1 \xrfill[0.6ex]{0.4pt}\\}
\section*{Third Section (line break)}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

\end{document}

Note that using titlesec doesn't put the following text in a new paragraph. I tried to solve this with \\ but that doesn't work either. What can I do to make this work the same way as it would without titlesec?

-

Use the [display] style instead of the [runin] style:

\titleformat{\section}[display]{\large}{\thetitle}{1em}{#1\space\xrfill[0.6ex]{0.4pt}}
\section*{Second Section (\texttt{titlesec})}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua.

-
Great, thanks! But the titlesec documentation seems to claim that runin mimics the default behavior. So why wouldn't this work with runin? – jtbandes Dec 25 '12 at 5:54
The [runin] style is equivalent to the standard classes' \paragraph style. The default style (which in your example would also work) is [hang], which is like the standard \section command (see p.3 of the docs). Because of the rule, I think that the [display] is more appropriate, though. – Alan Munn Dec 25 '12 at 6:04