General ⇒ Chapter's title
Chapter's title
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!
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
Re: Chapter's title
Chapter's title
*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...
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Chapter's title
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Chapter's title
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
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
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 3804 times
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Chapter's title

Really thank you