Change of chapter appearance

1,319

To have label and title on the same line, use the block style, and the command \filleft as the first mandatory argument (global settings):

\documentclass[a4paper]{report}
\usepackage[T1]{fontenc}%
\usepackage{geometry}%%
\usepackage{garamondx}%
\usepackage{xcolor}
\usepackage{titlesec}

\titleformat{\chapter}[block]%
{\bfseries\Large\filleft}%
{\fontsize{60}{50}\selectfont\color{gray}\thechapter}%
{1em}
{\fontsize{30}{50}\selectfont\scshape}%
[\vspace{-2ex}]

\begin{document}
\setcounter{chapter}{10}
\chapter{Who Stole the Tarts?}
The King and Queen of Hearts were seated on their throne when they arrived, with a great crowd assembled about them--all sorts of little birds and beasts, as well as the whole pack of cards: the Knave was standing before them, in chains, with a soldier on each side to guard him; and near the King was the White Rabbit, with a trumpet in one hand, and a scroll of parchment in the other. In the very middle of the court was a table, with a large dish of tarts upon it: they looked so good, that it made Alice quite hungry to look at them--`I wish they'd get the trial done,' she thought, `and hand round the refreshments!' But there seemed to be no chance of this, so she began looking at everything about her, to pass away the time.

 Alice had never been in a court of justice before, but she had read about them in books, and she was quite pleased to find that she knew the name of nearly everything there. `That's the judge,' she said to herself, `because of his great wig.'

 The judge, by the way, was the King; and as he wore his crown over the wig, (look at the frontispiece if you want to see how he did it), he did not look at all comfortable, and it was certainly not becoming.

 `And that's the jury-box,' thought Alice, `and those twelve creatures,' (she was obliged to say `creatures,' you see, because some of them were animals, and some were birds,) `I suppose they are the jurors.' She said this last word two or three times over to herself, being rather proud of it: for she thought, and rightly too, that very few little girls of her age knew the meaning of it at all. However, `jury-men' would have done just as well.

 The twelve jurors were all writing very busily on slates. `What are they doing?' Alice whispered to the Gryphon. `They can't have anything to put down yet, before the trial's begun.'

 `They're putting down their names,' the Gryphon whispered in reply, `for fear they should forget them before the end of the trial.'

 `Stupid things!' Alice began in a loud, indignant voice, but she stopped hastily, for the White Rabbit cried out, `Silence in the court!' and the King put on his spectacles and looked anxiously round, to make out who was talking.

 Alice could see, as well as if she were looking over their shoulders, that all the jurors were writing down `stupid things!' on their slates, and she could even make out that one of them didn't know how to spell `stupid,' and that he had to ask his neighbour to tell him. `A nice muddle their slates'll be in before the trial's over!' thought Alice.

 One of the jurors had a pencil that squeaked. This of course, Alice could not stand, and she went round the court and got behind him, and very soon found an opportunity of taking it away. She did it so quickly that the poor little juror (it was Bill, the Lizard) could not make out at all what had become of it; so, after hunting all about for it, he was obliged to write with one finger for the rest of the day; and this was of very little use, as it left no mark on the slate.

 `Herald, read the accusation!' said the King.

 \end{document} 

enter image description here

Share:
1,319

Related videos on Youtube

Niels Møller
Author by

Niels Møller

Updated on August 01, 2022

Comments

  • Niels Møller
    Niels Møller over 1 year

    I got the following code for making the chapter appearance in [report] mode, which I would like to keep:

    \renewcommand{\thechapter}{\arabic{chapter}}
    \titleformat{\chapter}[display]
    {\bfseries\Large}
    {\hfill\fontsize{60}{50}\selectfont\color{gray}\textbf{\thechapter}}
    {-2ex}
    {\filleft\fontsize{30}{50}\selectfont\scshape}
    [\vspace{-2ex}]  
    

    It creates an arabic number in the color gray matching the chapter number. Then, in a new line, it creates the title of the chapter (all right aligned). But what I want is to have the number and title on the same line (to save space in this specific report). I have tried the following:

    \renewcommand{\thechapter}{\arabic{chapter}}
    \titleformat{\chapter}[display]
    {\bfseries\Large}
    {\hfill\fontsize{60}{50}\selectfont\color{gray}\textbf{\thechapter}       
    \filleft\fontsize{30}{50}\selectfont\scshape}
    [\vspace{-2ex}]
    

    But it doesn't seem to change anything. I guess it is a simple task, but I need help :(

    • Bernard
      Bernard almost 9 years
      Use the block style instead of display.
    • Niels Møller
      Niels Møller almost 9 years
      It works! But how do I add a bit of space between the number and the chapter title?
    • David Carlisle
      David Carlisle almost 9 years
      It would have been helpful to say what package you are using (and preferably provided a usable test file). (\titleformat is not a standard command)
    • Bernard
      Bernard almost 9 years
      Oh! Didn't notice all the details of your code. Simply replace –2ex with 1em or more if you want. The fourth argument of \titleformat is the distance between label and title.
    • Niels Møller
      Niels Møller almost 9 years
      Thank you so much! I'm relatively new to this site - next time, I'll make sure to add a usable test file, sorry!
    • Bernard
      Bernard almost 9 years
      You're welcome. Btw, if I understand well your code, your chapter titles are flushright. You should use filleft in the third argument, which sets global formatting for label + title, and remove \hfill in the fifth.
    • egreg
      egreg over 7 years
      @Bernard Can you provide an answer and ping when you did so?
    • Bernard
      Bernard over 7 years
      @egreg: Done! That's an old story…