LaTeX forum ⇒ GeneralHow 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?

Postby fabioonier » Mon Jul 17, 2017 6:01 pm

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
Captura de pantalla de 2017-07-17 10-41-21.png (22.04 KiB) Viewed 1232 times


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


And this is what I have for now.

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


Captura de pantalla de 2017-07-17 10-43-42.png
Captura de pantalla de 2017-07-17 10-43-42.png (28.65 KiB) Viewed 1232 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}
  14. \usepackage{pstricks-add,pst-math,pst-xkey,pst-pdf,auto-pst-pdf}
  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}
  36. \addcontentsline{toc}{chapter}{Prefacio}
  37.  
  38. \include{EnsayoPrefacio}
  39. \include{Ensayos}
  40. \include{Index}
  41. \printindex
  42.  
  43. \end{document}


Thanks for your help.

Tags:

rais
Posts: 148
Joined: Sun Nov 16, 2014 8:51 pm

Postby rais » Tue Jul 18, 2017 10:56 am

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...

However, fancyhdr, that you're already loading as well, might come in handy to restyle your header's layout.

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

Postby fabioonier » Tue Jul 18, 2017 2:52 pm

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.

Thanks for your help.

rais
Posts: 148
Joined: Sun Nov 16, 2014 8:51 pm

Postby rais » Tue Jul 18, 2017 8:08 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{}
  13. \fancyhead[RE]{Algebra}
  14. \fancyhead[LE]{\makebox[0pt][l]{%
  15. \hspace{-4em}\raisebox{-1ex}{\includegraphics[height=4ex]{foo-p1}}%
  16. }\thepage}
  17. \fancyhead[RO]{\makebox[0pt][l]{%
  18. \hspace{-0.5em}\raisebox{-1ex}{\includegraphics[height=4ex]{foo-p1}}%
  19. }\thepage}
  20. \fancyhead[LO]{\makebox[0pt][l]{%
  21. \hspace{-4em}\raisebox{-1ex}{\includegraphics[height=4ex]{foo-p2}}%
  22. }\leftmark}
  23. \renewcommand*\headrulewidth{0pt}
  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

Postby fabioonier » Wed Jul 19, 2017 1:19 am

Hello, rais.

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

Thanks for your help.

I guess that this topic is solved.

Thanks to everyone for your help.

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

Postby Johannes_B » Thu Jul 27, 2017 9:19 am

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: 1
Joined: Tue Oct 03, 2017 11:07 am

Postby Marcus Bettin » Tue Oct 03, 2017 11:10 am

Thanks for the link, Johannes_B!
I really like those new book of ra slot themes. There's something special about them. It's all about Egyptian culture, which I like. Yeah, it's a perfect place for gambling enthusiasts.


Return to “General”

Who is online

Users browsing this forum: No registered users and 8 guests