Text FormattingChapter formatting, swap chapter number and text

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Joep
Posts: 1
Joined: Fri Jun 12, 2015 12:22 pm

Chapter formatting, swap chapter number and text

Post by Joep »

Dear all,

I am using Kile in Linux with a PDFLaTeX compiler to make a report. I use an altered version of the documentclass "book". The alterations are not causing any problems and are not the reason for this post.

I was wondering if it is possible to interchange the chapter label and text within the book enviroment using the titlesec package.

Code: Select all

\documentclass{book}
\usepackage[noindentafter]{titlesec}

\def\titlefont{\rmfamily}
\def\titleshape{\scshape}
\def\titlestyle{\titlefont\titleshape\bfseries}

\definecolor{cyan}{cmyk}{1,0,0,0}
\colorlet{title}{cyan}

\titleformat{\chapter}
    {\flushright\titlestyle}
    {\fontsize{96pt}{96pt}\selectfont\bfseries\thechapter}
    {0pt}
    {\Huge\color{title}}

\begin{document}
\chapter{Introduction}
\end{document}
I have an attachment to exemplify what I want. The first shows how it is constructed now and I want to swap the label and text so that I get the lower image. Does anyone know how to do this with the titlesec package? Or is there an easy alternative to get this?

Thanks in advance for the help!
Attachments
chapterformat.png
chapterformat.png (7.33 KiB) Viewed 2424 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

Chapter formatting, swap chapter number and text

Post by rais »

Joep wrote: I was wondering if it is possible to interchange the chapter label and text within the book enviroment using the titlesec package.
yes, with its explicit option, you can put something after the title.

Code: Select all

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[noindentafter, explicit]{titlesec}
\usepackage{xcolor}
\usepackage{showframe}

\colorlet{title}{cyan}

\def\titlefont{\rmfamily\Huge}
\def\titleshape{\scshape}
\def\titlestyle{\titlefont\titleshape\bfseries\raggedleft\color{title}}

\titleformat{\chapter}
    {\titlestyle}
    {}
    {0pt}
    {#1~\fontsize{96pt}{96pt}\selectfont\thechapter}
\titleformat{name=\chapter, numberless}
    {\titlestyle}
    {}
    {0pt}
    {#1}

\begin{document}
\chapter{Introduction}
\end{document}
BTW: Before you can play around with color, you need to load one of the color packages, where cyan is usually predefined.
The command form of the flushright environment is \raggedleft.

KR
Rainer
Post Reply