0

I am working on customizing sections, subsections, and paragraphs for my report.

I almost have the functionality that I want, but I am missing a small part.

Current Situation:

\titleformat{\paragraph}
[runin]
{\large\mdseries\sffamily}
{\rlap{\color{paragraphColor}\rule[-6pt]{\textwidth}{1.2pt}}}
{15pt}
{\color{paragraphColor}#1}

The code above gives the following result of the colorized paragraph heading:

enter image description here

I can also underline the paragraph by doing this:

\titleformat{\paragraph}
[runin]
{\large\mdseries\sffamily}
{\rlap{\color{paragraphColor}\rule[-6pt]{\textwidth}{1.2pt}}}
{15pt}
{\uline{#1}}

Which gives the following result:

enter image description here

Desired Result: I am trying to combine those two by making the paragraph both colored and underlined.

The closest I was able to get to is this:

\titleformat{\paragraph}
[runin]
{\large\mdseries\sffamily}
{\rlap{\color{paragraphColor}\rule[-6pt]{\textwidth}{1.2pt}}}
{15pt}
{\uline{\color{paragraphColor}#1}}

Unfortunately, this only colors the first word:

enter image description here

Thanks in advance for any help.

1 Answer 1

0

Try with this:

\documentclass[10pt,a4paper]{article}
\usepackage[T1]{fontenc}

\usepackage[explicit]{titlesec}  % Add explicit option !
\usepackage{ulem} % For \uline
\usepackage{xcolor}

\definecolor{paragraphColor}{RGB}{190, 30, 30}

\titleformat{\paragraph}
    {\large\mdseries\sffamily\color{paragraphColor}}
    {\thesubsection}
    {1em} 
    {\uline{#1}
}

\begin{document}
    \paragraph{Test paragraph}
\end{document}

result

Remember tu add explicit option to titlesec. More info here (3.7. Other Package Option)

If you want to add [runin] for having all in the same line after the paragraph, try with this:

\titleformat{\paragraph}
    [runin]
    {\large\mdseries\sffamily}
    {\thesubsection}
    {1em} 
    {\color{paragraphColor}\uline{#1}
}

result2

1
  • That works, thanks a lot!
    – AArtlone
    Commented May 11, 2021 at 14:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .