I'm trying to customise my \chapter format. What I want is something like \hrulefill but that allow me to control how much I want to raise the line from the baseline and how thick ther rule is. For example with \rule command I can set the options \rule[raise from baseline]{length}{width} so I can make all the possible combination, i.e. using \textwidth command, if i want the same result as \hrulefill = \rule{\textwidth}.

Now my problem is that I don't want the rule to be long as text width, but as long as the rule encounter a word, in my case the "Chapter No. of Chapter".

I have written the code

    {\bfseries\Huge} % 
    {\flushright \rule[15pt]{280pt}{5pt} %here I want to change 280pt with something like \textwidth
        {\fontsize{70}{60}\selectfont\thechapter}} % 
    {10 pt}%

which gives me the output


And of course it does not fit with my intentions, as the rule's length is fixed (280pt) and maybe will not work for other chapters with greater numbers. Otherwise if I put \textwidth instead of the fixed length, my output becomes

Example 2

Making the Chapter going below the rule. Now, is there a command that fill the text width with a rule but stops when it finds the first word of the line? I know there are similar questions, but no one specifically solved this problem in this way and I would like to keep this format for the code changing the less as possible.
Thanks in advance.

EDIT: maybe I did not explain myself very well. In fact, what I want is something more similar to the first image (with the rule inline with the sign Chapter) than to the second image, but that fills the entire text width (while you can see in the 1st example that the rule starts not in line with the text).


Here is a solution. I changed the value of the last argument of \titlespacing(0pt) led to a chapter title much too close to the following text. But maybe you don't mean to have chapter titles, only the label?

\documentclass[12pt, a4paper]{book}% http://ctan.org/pkg/amsproc
\SetTracking[no ligatures={f}]{encoding=*}{100}


{\bfseries\Huge} %
 & \textsuperscript{\fontsize{30}{60}\selectfont{Chapter}}%
{\fontsize{70}{60}\selectfont\thechapter}\end{tabularx}} %
{10 pt}%


\chapter{Test chapter}%}{Example chapter}


The output is shown below:

enter image description here

  • I tried with \titlerule[5pt]\vspace{1.5ex}%, but I still get the line over the "Chapter 1", as in the second example. What I would like to do is having a line "in line" with the text as the example 1, but that fills the entire line. Thanks anyway! – GiuTeX Mar 2 '17 at 11:43
  • Yes, I do not want the rule above the Chapter word, I want it in line with the Chapter word – GiuTeX Mar 2 '17 at 11:44
  • 1
    It seems I misunderstood you requirement. I'll propose another solution in a moment. – Bernard Mar 2 '17 at 12:17
  • 1
    I pposted another code, but I can't post the image of the result… :-( – Bernard Mar 2 '17 at 12:33
  • 1
    It means there's no padding on both sides of the table. In short: the table (and the rule) begins exactly at the left margin and ends at the right margin. – Bernard Mar 2 '17 at 13:03

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.