4

I would like to change the color of section rule, as it obtained using sectsty package.

Here is what I have:

\documentclass{article}

\usepackage{xcolor,sectsty,lipsum}
\sectionfont{\sectionrule{0pt}{0pt}{-5pt}{0.8pt}[\color{blue}]}

\begin{document}
\section*{title}
\lipsum
\end{document}

Since I am writing my report using both english and greek language I compile my document using xelatex engine.

PS: I have tried to implement the answer that I found here. However, the problem is that with titlesec package greek characters on my section titles are not recognised.

1 Answer 1

5

By default the \sectionrule doesn't have any colour (or, it's black). You can add the colour through a patch (using regexpatch):

enter image description here

\documentclass{article}

\usepackage{xcolor,sectsty,regexpatch}

\makeatletter
\newcommand{\setsectionrulecolor}[1]{\colorlet{secrulecolor}{#1}}
\setsectionrulecolor{black}% default
\xpatchcmd*{\SS@normsectionrule}% <cmd>
  {\rule}% <search>
  {\color{secrulecolor}\rule}% <replace>
  {}{}% <success><failure>
\makeatother

\sectionfont{\sectionrule{0pt}{0pt}{-5pt}{0.8pt}}

\usepackage{lipsum}

\begin{document}
\section*{title}
Lorem ipsum

\setsectionrulecolor{blue}%
\section*{title}
Lorem ipsum

\section*{title}
Lorem ipsum

\setsectionrulecolor{black!50}%
\section*{title}
Lorem ipsum
\end{document}

The above example implements \setsectionrulecolor{<colour>} which allows you to update the rule colour as need.

You must log in to answer this question.

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