18

I am searched for changing a thickness of a \hrule in my report document ? any idea?

5
  • 5
    the latex syntax is \rule not \hrule but if you want to use \hrule then \hrule height 2cm should work. The latex syntax would be \rule{\texwidth}{2cm} Jun 9, 2018 at 18:47
  • Thaank's it's working now (y)
    – YounessGI
    Jun 9, 2018 at 18:51
  • @DavidCarlisle, typo: \textwidth
    – Sigur
    Jun 9, 2018 at 18:56
  • @YounessGI, don't forget to use \noindent before the rule to pull it to the left margin.
    – Sigur
    Jun 9, 2018 at 18:56
  • @Sigur if you use \rule, not \hrule. Jun 9, 2018 at 19:42

2 Answers 2

32

The latex syntax is \rule not \hrule but if you want to use \hrule then

\hrule height 2cm 

should work. The latex syntax would be

\begin{center}
\rule{\textwidth}{2cm}
\end{center}
4
  • Wow, the parametrisation of \hrule is quite uncommon, I expected something like \hrule[height=2cm] or so. But surprisingly it worked.
    – peterh
    Mar 25, 2021 at 23:45
  • @peterh-ReinstateMonica [] optional arguments are a latex macro syntax, no tex primitives use square brackets in such a way. (Nor should the primitives appear in latex documents) Mar 25, 2021 at 23:49
  • \rule and \hrule are not identical though, is that right? In particular, hrule does not introduce vertical space whereas rule does.
    – jII
    Jun 4, 2022 at 21:58
  • 1
    @jII they are completely different \hruleis a latex-defined horizontal mode command, \hrule is a tex primitve veritical mode command. \ruledoes not produce vertical space but like a letter such as x will start a paragraph if used in vmode, and a paragraph start may introduce space. Jun 4, 2022 at 22:02
1

I think

\begin{center}
\rule{\textwidth}{2pt}
\end{center}

is what most users would want..

1
  • titletoc doesn't like it though, it somehow indents the line; no problem with hrule Apr 2, 2023 at 14:57

You must log in to answer this question.

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