[Tex/LaTex] How to align the chapter number to the right

chapterssectioningtitlesec

Is there any way to align the chapter number to the right (without the CHAPTER word!) and the chapter title itself to the left? The chapter title must be on the line below the chapter number

Here is part of the code I use (both the chapter number and title are right aligned):

\usepackage{titlesec}

\titleformat{\chapter}[display]
{\normalfont\Huge\bfseries\color[RGB]{0,120,182}}
{\thechapter}{1em}

PS: I use Sphinx to generate latex output if it matters

Thanks in advance

Best Answer

You can use \filleft just before \thechapter:

\documentclass{book}
\usepackage{titlesec}
\usepackage{xcolor}
\usepackage{lipsum}% just to generate text for the example

\titleformat{\chapter}[display]
  {\normalfont\Huge\bfseries\color[RGB]{0,120,182}}
  {\filleft\thechapter}{1em}{}

\begin{document}

\chapter{Test chapter}
\lipsum[2]

\end{document}

enter image description here