1

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 The sample that I need to imitate The sample that I need to imitate

And this what I have for now. What I have for now enter image description here

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.

\documentclass[letterpaper,reqno]{book}
\listfiles
\usepackage{makeidx}
\usepackage[spanish,es-nosectiondot]{babel}
\usepackage[utf8]{inputenc}
\usepackage{infwarerr}
\usepackage{color}
\usepackage{verbatim} %Para comentar bloques de texto
\usepackage[text={168mm,240mm},centering]{geometry}%Define el ancho y la    altura del texto (Página)
\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}% Este paquete modifica los parámetros de la Tabla de   Contenidos (ToC)
\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.

Fabio
  • 197
  • Please add a minimal working example. The answer highly depends on your code. – TeXnician Jul 17 '17 at 15:59
  • This is a MWE of my book. – Fabio Jul 17 '17 at 16:16
  • 1
    For really fancy headers, you need to use everypage and tikz. See https://tex.stackexchange.com/questions/276358/text-on-background-image-footer-and-header/276453?s=3|0.2042#276453 for example. – John Kormylo Jul 18 '17 at 03:42
  • 1
    Crosspost http://latex.org/forum/viewtopic.php?f=5&t=29954&p=101262#p101262 – Johannes_B Jul 27 '17 at 07:20
  • 2
    It is unacceptable to see that you a) don't openly show your crossposts and b) you don't update your question with the info gained at the other site. – Johannes_B Jul 27 '17 at 07:21

2 Answers2

0

Finally I got a solution. This topic was posted in other forum and there I was given the solution. Someone gave this code and I just had to edit it a little bit.

\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}

Thanks for everything. This topic can be considered closed.

Fabio
  • 197
  • You should attribute the code to its author and provide a link. Mere basic courtesy. – cfr Jul 28 '17 at 00:20
  • You are right and I apologize. This solution was given by rais and this is the links where you can see it http://latex.org/forum/viewtopic.php?f=5&t=29954 – Fabio Jul 28 '17 at 01:22
  • Please add that to your answer. Comments are not permanent. – cfr Jul 28 '17 at 01:37
0

everybody. I've been making several mistakes everytime I participate in this forum. I'm sorry about that.

The solution to my problem was to introduce and edit this code:

\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}

This was supplied in latex.org forum.

I just added the gray bars with \includegraphics and edited the vertical position.

Fabio
  • 197