General ⇒ Chapter's title
Chapter's title
Hello,
I'm modifying the \chapter command in order to get (when a new chapter starts) something like this: With some help from the frame.tss file of the titlesec package I got some almost perfect results, but I can't get the number (\thechapter) centered below the name (\chaptername)
Do someone have and idea of how can I do it?
Thank you!
I'm modifying the \chapter command in order to get (when a new chapter starts) something like this: With some help from the frame.tss file of the titlesec package I got some almost perfect results, but I can't get the number (\thechapter) centered below the name (\chaptername)
Do someone have and idea of how can I do it?
Thank you!
Last edited by n070161 on Mon Aug 30, 2010 8:49 pm, edited 1 time in total.
NEW: TikZ book now 40% off at Amazon.com for a short time.

Re: Chapter's title
Why don't you show us what code you have so far, so we can possibly suggest revisions?
Chapter's title
That's right, sorry.
*Edited*
There's the code that I'm using (from frame.tss):
The lane where \chaptername is printed is:
\setbox\z@\hbox{#2}%
and I would like to print \thechapter just below (and centered with "CHAPTER").
I hope I'm being clear, because my level of english and my level of LaTeX aren't as high as I want...
*Edited*
There's the code that I'm using (from frame.tss):
Code: Select all
\gdef\ttlh@frame#1#2#3#4#5#6#7#8{%
\def\ttl@filleft##1{\hfill}%
\def\ttl@filright##1{\hfill}%
\gdef\ttl@makeline##1{%
\ttl@calc\hspace{#6}##1\ttl@calc\hspace{#7}}%
\interlinepenalty\@M
\ttl@changecentercr
#1\ifhmode\ttl@hmode@error\fi
\parindent\z@
\leavevmode
\@tempdima\fboxrule
\addtolength\@tempdima{#3}%
\setlength\leftskip{#6}%
\setlength\rightskip{#7}%
\lower\@tempdima\hbox{%
\everypar{}%
\setbox\z@\hbox{#2}%
\addtolength\hsize{-#6}%
\addtolength\hsize{-#7}%
\@tempdima\dp\z@ % 2002/3/22
\advance\@tempdima.5\ht\z@
\vbox{%
\hbox to \hsize{%
\leaders\hrule\@height\fboxrule\ttl@filleft{#3}%
\ifttl@label\lower.5\ht\z@\box\z@\fi
\leaders\hrule\@height\fboxrule\ttl@filright{#3}}%
\vskip-\lineskip
\ifttl@label\vskip-\@tempdima\fi
\hbox{%
\vrule\@width\fboxrule
\kern-\fboxrule
\vbox{%
\ttl@calc\vspace{#3}%
\leavevmode
\addtolength\leftskip {#3}\addtolength\leftskip{-#6}%
\addtolength\rightskip{#3}\addtolength\rightskip{-#7}%
\strut#4{#8}\kern\z@\strut\@@par
\ttl@calc\vspace{#3}}%
\kern-\fboxrule
\vrule\@width\fboxrule}%
\hrule\@height\fboxrule}}%
\@@par\nobreak#5\@@par}
The lane where \chaptername is printed is:
\setbox\z@\hbox{#2}%
and I would like to print \thechapter just below (and centered with "CHAPTER").
I hope I'm being clear, because my level of english and my level of LaTeX aren't as high as I want...
Last edited by n070161 on Mon Aug 30, 2010 6:31 pm, edited 1 time in total.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Chapter's title
Don't think so complicated. Just use the example on top of page 23 in the titlesec manual and adapt it to chapters.
Thorsten
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Chapter's title
First of all, sorry for the 'troubled' post (the external links and the code fragment).
I tried what you suggest, but I can't find the way of printing the number (\thechapter) below the name (\chaptername), so that's why I want to modify the underlying code, because the titlesec's default options aren't as flexible as I need
Thank you again.
I tried what you suggest, but I can't find the way of printing the number (\thechapter) below the name (\chaptername), so that's why I want to modify the underlying code, because the titlesec's default options aren't as flexible as I need
Thank you again.
Chapter's title
I guess I also think it's easiest to stick with titlesec and make use of some tricks to get the flexibility you want. E.g., to set the chapter number centered underneath the word "Chapter", you could use the \underset command of amsmath or similar.
This is just a rough approximation; tweak as needed.
This is just a rough approximation; tweak as needed.
Code: Select all
\documentclass{book}
\usepackage{xcolor,titlesec,amsmath}
\setlength{\fboxrule}{7\fboxrule}
\titleformat{\chapter}[frame]
{\normalfont\color{cyan}}
{\filright
\enspace \textcolor{black}{$\underset{\textsf{\Huge\thechapter}}{\textsf{CHAPTER}}$} \enspace}
{8pt}
{\filleft\LARGE\sffamily\color{black}}
\begin{document}
\chapter{Chapter's title}
Hello world.
\end{document}
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Chapter's title
Based on the solution of frabjous, here's another idea that works with a \parbox. The output is attached.
Code: Select all
\documentclass{report}
\usepackage{titlesec}
\usepackage[x11names]{xcolor}
\newlength{\chpnamewidth}
\settowidth{\chpnamewidth}{\MakeUppercase{\chaptername}}
\setlength{\fboxrule}{7\fboxrule}
\titleformat{\chapter}[frame]
{\normalfont\color{cyan}}
{\filright
\enspace\textcolor{black}{\raisebox{1ex}{\parbox[t]{\chpnamewidth}{\centering\MakeUppercase{\chaptername}\\[-1ex] \Huge\thechapter}}}\enspace}
{8pt}
{\filleft\LARGE\sffamily\color{black}}
\begin{document}
\chapter{Chapter's title}
The quick brown fox jumps over the lazy dog.
\end{document}
- Attachments
-
- Framed chapter style as obtained with the provided code.
- FramedChapter.png (4.55 KiB) Viewed 3683 times
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Chapter's title
Thank you very much
both solutions worked for me
Really thank you

Really thank you