Graphics, Figures & TablesHow to use an image for customizing a chaper head?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
fabioonier
Posts: 26
Joined: Thu Jul 06, 2017 5:37 am

How to use an image for customizing a chaper head?

Post by fabioonier »

Hi, everybody.

I'm writing a book and I need to customize the chapter heads in order to show them like this:
Captura de pantalla de 2017-07-23 23-00-15.png
Captura de pantalla de 2017-07-23 23-00-15.png (101.9 KiB) Viewed 4434 times
I need to replicate the part enclosed by the black frame.

How could I do it?

Thanks for your help.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

How to use an image for customizing a chaper head?

Post by Johannes_B »

The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
fabioonier
Posts: 26
Joined: Thu Jul 06, 2017 5:37 am

How to use an image for customizing a chaper head?

Post by fabioonier »

Hi, Johannes. I know that I posted this topic in other forum The problem is that I'm still without a suggestion about how to get what I need for using an imported image in the chapter head.

I would greatly appreciate it if you or anyone else can help me.

Thanks.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

How to use an image for customizing a chaper head?

Post by Johannes_B »

Please, if you feel the need to crosspost, leave a link on all places referring to the other posts. It avoids double effort by the helpers. Please keep all crossposts updated at all times.

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.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
fabioonier
Posts: 26
Joined: Thu Jul 06, 2017 5:37 am

How to use an image for customizing a chaper head?

Post by fabioonier »

Hellos, Johannes. I understand what you say.

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.
fabioonier
Posts: 26
Joined: Thu Jul 06, 2017 5:37 am

How to use an image for customizing a chaper head?

Post by fabioonier »

Hellos, Johannes. I understand what you say.

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.
fabioonier
Posts: 26
Joined: Thu Jul 06, 2017 5:37 am

How to use an image for customizing a chaper head?

Post by fabioonier »

Hello, everybody. Finally I could make the chapters heads as I need them.

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}]
Here is what I got
Captura de pantalla de 2017-07-28 01-43-26.png
Captura de pantalla de 2017-07-28 01-43-26.png (25.46 KiB) Viewed 4393 times
What I learned with this is that is truly possible to combine \titleformat with \includegraphics and you can customize your chapters head in the way that you wish without using tikz/PGF packages.

Thanks for your help.

This topic can be closed.
Post Reply