Graphics, Figures & Tables ⇒ How to use an image for customizing a chaper head?
-
- Posts: 26
- Joined: Thu Jul 06, 2017 5:37 am
How to use an image for customizing a chaper head?
I'm writing a book and I need to customize the chapter heads in order to show them like this:
I need to replicate the part enclosed by the black frame.
How could I do it?
Thanks for your help.
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
How to use an image for customizing a chaper head?
-
- Posts: 26
- Joined: Thu Jul 06, 2017 5:37 am
How to use an image for customizing a chaper head?
I would greatly appreciate it if you or anyone else can help me.
Thanks.
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
How to use an image for customizing a chaper head?
As it was said in the TeX.SX comments: A solution depends on the document class you are using. I myself am not even sure what image you mean. I can see the number of the chapter on the outside as well as a framed box which includes the chapter title. The framed boxed could be done with TikZ or tcolorbox. It doesn't seem too complex to me, but knowing the document class is very needed, as different classes define different internal commands that are accesed.
-
- Posts: 26
- Joined: Thu Jul 06, 2017 5:37 am
How to use an image for customizing a chaper head?
I'm using the book class and the image that I have to use is the gray frame where the chapter title is written on.
You say that it's easy to draw it with tikz or tcolorbox, but I don't know much about those packages. I have the image of the gray frame and I want to know how import it and write the title of the chapter on it.
Is it possible combine \titleformat with \includegraphics in order to get what I need?
Thanks for your help.
-
- Posts: 26
- Joined: Thu Jul 06, 2017 5:37 am
How to use an image for customizing a chaper head?
I'm using the book class and the image that I have to use is the gray frame where the chapter title is written on.
You say that it's easy to draw it with tikz or tcolorbox, but I don't know much about those packages. I have the image of the gray frame and I want to know how import it and write the title of the chapter on it.
Is it possible combine \titleformat with \includegraphics in order to get what I need?
Thanks for your help.
-
- Posts: 26
- Joined: Thu Jul 06, 2017 5:37 am
How to use an image for customizing a chaper head?
I took the last example of
https://tex.stackexchange.com/questions ... er-heading
and I made it some changes. The final code that I made was
Code: Select all
\newcommand*{\chapnumfont}{%Define font and fontsize for the number of the chapter\fontsize{3.2cm}{5cm}%\selectfont\myfont%I defined previously a font and named it "myfont"}\newcommand*{\chaptitlefont}{%Define font and fontsize for the title of the chapter\fontsize{22}{26}%\selectfont\myfont%}\titleformat{\chapter}[block]%Insert the predefined image where the title o chapter is on{\normalfont\huge\bfseries}{\hspace{-2cm}\parbox{0pt}{\includegraphics[width=1.2\textwidth,height=1.5\baselineskip]{the image}}{0pt}{\begin{minipage}{11cm}\hspace{2cm}\filleft\color{your color}\chaptitlefont #1\end{minipage}\begin{minipage}{4cm} \vspace{-0.5cm}\filleft\chapnumfont\color{your color}\thechapter}[\end{minipage}]
Thanks for your help.
This topic can be closed.