# Inserting text before a titlerule in titlesec

I'm using titlesec to replicate the header of a CV I made in Microsoft Word. Here's what I have so far:

\documentclass[11pt, a4paper]{article}
\usepackage[top=0.5cm, left=1.27cm, bottom=0.5cm, right=1.27cm]{geometry}
\usepackage{fontspec}
\usepackage{titlesec}
\usepackage{ulem}
\setmainfont{Times New Roman}
\newfontfamily\sectionfont{Copperplate Gothic Bold}
\newfontfamily\subsectionfont{Copperplate Gothic Bold}

\titleformat{\section}{\filcenter\sectionfont\fontsize{18}{18}\selectfont}{\thesection}{0em}{}[{\titlerule[1.4pt]}]
\titleformat{\subsection}{\subsectionfont\selectfont}{\thesection}{0em}{\uline}

\begin{document}
\section*{David Krappenschitz}
\subsection*{Education}

\end{document}


Which, I am happy to say, generates the following header:

I would like to now (still using titlesec) achieve something like this:

How can I go about doing this?

# EDIT

As @campa indicated there might be no real reason to stick with titlesec here. I tried the following:

\documentclass[11pt, a4paper]{article}
\usepackage[top=0.5cm, left=1.27cm, bottom=0.5cm, right=1.27cm]{geometry}
\usepackage{fontspec}
\usepackage{titlesec}
\usepackage{ulem}
\setmainfont{Times New Roman}
\newfontfamily\sectionfont{Copperplate Gothic Bold}
\newfontfamily\subsectionfont{Copperplate Gothic Bold}

\titleformat{\section}{\filcenter\sectionfont\fontsize{18}{18}\selectfont}{\thesection}{0em}{}%[{\titlerule[1.4pt]}]
\titleformat{\subsection}{\subsectionfont\selectfont}{\thesection}{0em}{\uline}

\begin{document}
\section*{David Krappenschitz}

26 College Ave \textbullet College City, FL \textbullet +001-865-8976 \textbullet dave.krappenschitz@gmail.com

\rule{\textwidth}{1pt}

\subsection*{Education}

\end{document}


But for some reason the rule and text itself are not properly aligned with the titles anymore...

• Any particular reason for using titlesec at all? Aug 17 '21 at 13:22
• I guess not... I also tried without... Please see edit to original question... Aug 17 '21 at 13:26
• The package that eases customisation of headings is titiling. Aug 17 '21 at 13:29
• Your comment is right. I corrected the answer. Thank you for your feedback. Aug 18 '21 at 12:36

Use fancyhdr. It will put the heading that you define on each page. (The rule comes free).

.

\documentclass[11pt,a4paper]{article}

\usepackage{fontspec}

\setmainfont{Times New Roman}

\pagestyle{fancy}
\fancyhf{}
{\normalfont\small\itshape 26 College Ave \textbullet\ College City, FL \textbullet\ 0123-456\,789 \textbullet\ dave.krappenschitz@somemail.com\medskip}

• Thanks. That's a lot closer to what I'm looking for. Is it strictly necessary to use \parbox and \centering? Doesn't fancyhdr automatically center the header contents when you specify the [C] option? Aug 18 '21 at 7:55