27

I want to place a long bold \hrule-type line under the \section to make it more distinctive. How can I do that?

  • Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It is considered a lot better to put in some code that will compile, as it makes it a lot easier for us to copy it into our text editor and work with it, and see exactly what it is you are trying to do. – henrique Nov 24 '12 at 15:39
31

You can use the titlesec package; the optional argument for \titlerule allows you to control the rule "thickness":

\documentclass{article}
\usepackage{titlesec}

\titleformat{\section}
  {\normalfont\Large\bfseries}{\thesection}{1em}{}[{\titlerule[0.8pt]}]

\begin{document}

\section{Test Section}

\end{document}

enter image description here

| improve this answer | |
  • And for the width? Because default is \textwidth... – Aurelius May 3 '13 at 20:13
  • @FormlessCloud can you please expand your question a little? I don't understand what you mean. Do you want the line only to cover the title and not the whole text width? – Gonzalo Medina May 3 '13 at 20:23
  • Sure, for example, if I would a \titlerule that have the width of for example .5\textwidth how can I do this? Because if I type only \titlerule that command give me automatically a rule that fit the entire width of my page. In sinthesys I would to adjust the length (or I can call it width, how you prefer) of my line. – Aurelius May 3 '13 at 20:46
  • 1
    @FormlessCloud Ah, I see. In that case, instead of [{\titlerule[0.8pt]}] you can use something like [\vskip-10pt{\makebox[\linewidth][l]{\rule{0.5\textwidth}{0.8pt}}}] (adjusting the vertical skip, if necessary). Changing the settings for the \makebox you can also obtain lines wider than the \textwidth. – Gonzalo Medina May 3 '13 at 20:56
  • 1
    This does not work if one uses \usepackage{sectsty}. I use this package for setting the color of the section. Alternatively, just set \color{red} within the \titleformat command. – Martin Thoma Sep 11 '17 at 9:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.