GeneralHow to make a header with a predetermined image?

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

How to make a header with a predetermined image?

Post by fabioonier »

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

Code: Select all

\documentclass[letterpaper,reqno]{book}
\listfiles
\usepackage{makeidx}
\usepackage[spanish,es-nosectiondot]{babel}
\usepackage[utf8]{inputenc}
\usepackage{infwarerr}
\usepackage{color}
\usepackage{verbatim} 
\usepackage[text={168mm,240mm},centering]{geometry}
\usepackage{amssymb,amsmath,amsthm}
\usepackage{epsfig,graphicx,psfrag,float}
\usepackage{ltxcmds}
\usepackage[pdf]{pstricks}
\usepackage{pstricks-add,pst-math,pst-xkey,pst-pdf,auto-pst-pdf}
\usepackage[all]{xy}
\usepackage{tocloft}
\usepackage{fancyhdr}
\usepackage{enumerate}
\usepackage{hyperref}

\makeindex

\renewcommand{\cftchappresnum}{Capítulo }
\renewcommand{\cftchapaftersnum}{}
\renewcommand{\cftchapaftersnumb}{\\ }
\renewcommand{\cftchapnumwidth}{0mm}

\renewcommand{\chaptermark}[1]{\markboth{Algebra}{\chaptername\ \thechapter.\ #1}}

\begin{document}

\pagenumbering{roman}

\tableofcontents
\pagenumbering{arabic}
\addcontentsline{toc}{chapter}{Prefacio}

\include{EnsayoPrefacio}
\include{Ensayos}
\include{Index}
\printindex

\end{document}
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グラフィックス
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

How to make a header with a predetermined image?

Post by rais »

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

How to make a header with a predetermined image?

Post by fabioonier »

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: 419
Joined: Sun Nov 16, 2014 8:51 pm

How to make a header with a predetermined image?

Post by rais »

In that case you can try to adapt this:

Code: Select all

\listfiles % the usual place for \listfiles is here: above \documentclass. Easier to cleanup after troubleshooting all the issues, IMHO.
\documentclass[letterpaper,reqno]{book}
\usepackage[spanish,es-nosectiondot]{babel}
\usepackage[utf8]{inputenc}
\usepackage[text={168mm,240mm},centering]{geometry}
\usepackage{%epsfig,<-- do you really need that?
  graphicx%,psfrag,float
}
\usepackage{fancyhdr}
\usepackage{blindtext}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RE]{Algebra}
\fancyhead[LE]{\makebox[0pt][l]{%
  \hspace{-4em}\raisebox{-1ex}{\includegraphics[height=4ex]{foo-p1}}%
  }\thepage}
\fancyhead[RO]{\makebox[0pt][l]{%
  \hspace{-0.5em}\raisebox{-1ex}{\includegraphics[height=4ex]{foo-p1}}%
  }\thepage}
\fancyhead[LO]{\makebox[0pt][l]{%
  \hspace{-4em}\raisebox{-1ex}{\includegraphics[height=4ex]{foo-p2}}%
  }\leftmark}
\renewcommand*\headrulewidth{0pt}
\renewcommand*\footrulewidth{0pt}
\begin{document}
  \Blinddocument
  \Blinddocument
\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

How to make a header with a predetermined image?

Post by fabioonier »

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: 4182
Joined: Thu Nov 01, 2012 4:08 pm

How to make a header with a predetermined image?

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.
Marcus Bettin
Posts: 2
Joined: Tue Oct 03, 2017 11:07 am

How to make a header with a predetermined image?

Post by Marcus Bettin »

Thanks for the link, Johannes_B!
That book of ra play com website is really something! For the guys like me there are options to get more games. It's so great! I can always get more there.
Post Reply