## LaTeX forum ⇒ General ⇒ How to make a header with a predetermined image? Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
fabioonier
Posts: 26
Joined: Thu Jul 06, 2017 5:37 am

### How to make a header with a predetermined image?

Hi, everybody.

I'm writing a book in LaTeX and I need to do the headers with the publisher's stye. That styles uses an image in every header but with two different texts: the even pages contain the title of the book and the odd pages contain the title of the chapter. It's something like this

Captura de pantalla de 2017-07-17 10-41-21.png (22.04 KiB) Viewed 1548 times

Captura de pantalla de 2017-07-17 10-41-26.png (28.05 KiB) Viewed 1548 times

And this is what I have for now.

Captura de pantalla de 2017-07-17 10-43-31.png (25.21 KiB) Viewed 1548 times

Captura de pantalla de 2017-07-17 10-43-42.png (28.65 KiB) Viewed 1548 times

How can I make the headers with an predertmined image but with different texts depending on the chapter?

This is a MWE of my book.
1. \documentclass[letterpaper,reqno]{book}
2. \listfiles
3. \usepackage{makeidx}
4. \usepackage[spanish,es-nosectiondot]{babel}
5. \usepackage[utf8]{inputenc}
6. \usepackage{infwarerr}
7. \usepackage{color}
8. \usepackage{verbatim}
9. \usepackage[text={168mm,240mm},centering]{geometry}
10. \usepackage{amssymb,amsmath,amsthm}
11. \usepackage{epsfig,graphicx,psfrag,float}
12. \usepackage{ltxcmds}
13. \usepackage[pdf]{pstricks}
15. \usepackage[all]{xy}
16. \usepackage{tocloft}
17. \usepackage{fancyhdr}
18. \usepackage{enumerate}
19. \usepackage{hyperref}
20.
21. \makeindex
22.
23. \renewcommand{\cftchappresnum}{Capítulo }
24. \renewcommand{\cftchapaftersnum}{}
25. \renewcommand{\cftchapaftersnumb}{\\ }
26. \renewcommand{\cftchapnumwidth}{0mm}
27.
28. \renewcommand{\chaptermark}[1]{\markboth{Algebra}{\chaptername\ \thechapter.\ #1}}
29.
30. \begin{document}
31.
32. \pagenumbering{roman}
33.
34. \tableofcontents
35. \pagenumbering{arabic}
37.
38. \include{EnsayoPrefacio}
39. \include{Ensayos}
40. \include{Index}
41. \printindex
42.
43. \end{document}

Tags:

rais
Posts: 151
Joined: Sun Nov 16, 2014 8:51 pm
fabioonier wrote:How can I make the headers with an predertmined image but with different texts depending on the chapter?

Do you have those images?
Then you could put it into a \makebox[0pt][l]{\includegraphics{...}} construct, the following text will overwrite it.
Or do you want to recreate those images? Should be possible with pstricks...

fabioonier wrote:This is a MWE of my book.

No, it's not. A real MWE doesn't include files no one but yourself has. Nor does it use packages that are not related to the issue at hand.

KR
Rainer

fabioonier
Posts: 26
Joined: Thu Jul 06, 2017 5:37 am
Hello, rais.

I have the gray box (as a PNG image) where the text of the header is written on. I need to place that box (image) and then to write the headers: the title of the book in even pages and the title of the each chapter in the odd pages.

I'm going to search about the \makebox command.

rais
Posts: 151
Joined: Sun Nov 16, 2014 8:51 pm
In that case you can try to adapt this:
1. \listfiles % the usual place for \listfiles is here: above \documentclass. Easier to cleanup after troubleshooting all the issues, IMHO.
2. \documentclass[letterpaper,reqno]{book}
3. \usepackage[spanish,es-nosectiondot]{babel}
4. \usepackage[utf8]{inputenc}
5. \usepackage[text={168mm,240mm},centering]{geometry}
6. \usepackage{%epsfig,<-- do you really need that?
7. graphicx%,psfrag,float
8. }
9. \usepackage{fancyhdr}
10. \usepackage{blindtext}
11. \pagestyle{fancy}
12. \fancyhf{}
15. \hspace{-4em}\raisebox{-1ex}{\includegraphics[height=4ex]{foo-p1}}%
16. }\thepage}
18. \hspace{-0.5em}\raisebox{-1ex}{\includegraphics[height=4ex]{foo-p1}}%
19. }\thepage}
21. \hspace{-4em}\raisebox{-1ex}{\includegraphics[height=4ex]{foo-p2}}%
22. }\leftmark}
24. \renewcommand*\footrulewidth{0pt}
25. \begin{document}
26. \Blinddocument
27. \Blinddocument
28. \end{document}

Replace foo-p1 with the shorter image and foo-p2 with the longer one (assuming there are two image files)

KR
Rainer

fabioonier
Posts: 26
Joined: Thu Jul 06, 2017 5:37 am
Hello, rais.

I did what you suggested and after several changes... it worked!!!!!!!!

I guess that this topic is solved.

Thanks to everyone for your help.

Johannes_B
Site Moderator
Posts: 3643
Joined: Thu Nov 01, 2012 4:08 pm
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Marcus Bettin
Posts: 2
Joined: Tue Oct 03, 2017 11:07 am