I want to place a long bold \hrule-type line under the \section to make it more distinctive. How can I do that?
Asked
Active
Viewed 3.8k times
37
cyberSingularity
- 9,113
lhhNJU
- 545
-
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
1 Answers
40
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}

Gonzalo Medina
- 505,128
-
-
@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 03 '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 03 '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\makeboxyou can also obtain lines wider than the\textwidth. – Gonzalo Medina May 03 '13 at 20:56 -
1This 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\titleformatcommand. – Martin Thoma Sep 11 '17 at 09:43 -