3
\fancypagestyle{myfancy}{
\fancyhf{}
\fancyhead[LE,RO]{\slshape\nouppercase{\leftmark}}
\fancyfoot[LE,RO]{\tikz[baseline={(0,0)},anchor=center] \node[label={center:\thepage}]{\includegraphics[scale=.25]{apple}};}%
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
}

The above code generates header and in the footer it generates page numbers with images on the corners of odd and even pages respectively.Now I want to add quotes by famous people in the footer area in the center which I tried by \fancyfoot[C] leading to overriding of existing settings.How do I do that?Secondly,I have the quotes and the authors in a .csv file.I want to read the author and the quote one by one and for each page I want to display one.I am aware of the datatool package but how do I do it?

Here is the source code:

%Template for Technical Document
\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage{suffix}
\usepackage{lipsum}
\usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry}
%\renewcommand{\chaptername}{Article}
\usepackage{fancyhdr}
\usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry}
% Can also use centering, or hcentering


\fancypagestyle{plain}{
  \fancyhf{}
  \fancyfoot[LE,RO]{\tikz[baseline={(0,0)},anchor=center]
    \node[label={center:\thepage}]{\includegraphics[scale=.25]{apple}};}%
  \fancyhf[cf]{Hello World}  
  \renewcommand{\footrulewidth}{0.4pt}
  \renewcommand{\headrulewidth}{0.0pt}
}


\fancypagestyle{myfancy}{
\fancyhf{}
\fancyhead[LE,RO]{\slshape\nouppercase{\leftmark}}
\fancyfoot[LE,RO]{\tikz[baseline={(0,0)},anchor=center] \node[label={center:\thepage}]{\includegraphics[scale=.25]{apple}};}%
\fancyhf[cf]{Hello World}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
}


\usepackage{microtype}

\usepackage{afterpage}
\let\oldcleardoublepage\cleardoublepage
\renewcommand{\cleardoublepage}{\afterpage{\thispagestyle{empty}}\oldcleardoublepage}

\pagestyle{myfancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}


\begin{document}
\chapter{Install Backtrack on an Android Device}
\section{What is Backtrack?}
\lipsum[10]
\section{Security Tools in Backtrack}
\lipsum[10]
\section{Installing Backtrack on Android Device}
\lipsum[10]
\end{document}

Also the footer center text is not aligning with the page number.How to modify that as well?enter image description here

4
  • Please post a Minimum Working Example showing what effort you've made to solve the problem. At the very least, make your code compile and post sufficient code for people to reproduce the issue and work on it. That will make it much easier for people to help and you'll be much more likely to get useful advice. \fancyhf[cf]{} will change the centre footer.
    – cfr
    Feb 2 '14 at 3:28
  • Question edited @cfr Feb 2 '14 at 3:50
  • 1
    Well you've told it to put the page number in the centre of the image. I personally think this is a bad idea as it makes it unreadable and I'm not sure what it would do to screen readers (but maybe the book is to be printed only), but it is exactly where you have asked it to be. By the way, if you use example-image-a with maybe a scaling factor of .1 or so, instead of apple, your code will actually compile when others run it. Also, you don't need to load geometry twice!
    – cfr
    Feb 2 '14 at 4:53
  • For dropping Hello world, try something like \raisebox{-.5ex}[0pt][0pt]{Hello world} where you play around with -.5ex.
    – Werner
    Feb 2 '14 at 6:39
6

You can either adjust Hello World or the tikz picture to make them align. I have shown both the possibilities in the following code:

%Template for Technical Document
\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage{suffix}
\usepackage{lipsum}
\usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry}
%\renewcommand{\chaptername}{Article}
\usepackage{fancyhdr}
\usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry}
% Can also use centering, or hcentering


\fancypagestyle{plain}{
  \fancyhf{}
  \fancyfoot[LE,RO]{\tikz[baseline={(0,-0.7ex)},anchor=center,inner sep=0pt]   %% adjust -0.7ex
    \node(a){\includegraphics[scale=.25]{apple}}node[anchor=center,inner sep=0pt] at (a.center) {\thepage};}%
  \fancyfoot[C]{Hello World}
  \renewcommand{\footrulewidth}{0.4pt}
  \renewcommand{\headrulewidth}{0.0pt}
}


\fancypagestyle{myfancy}{
\fancyhf{}
\fancyhead[LE,RO]{\slshape\nouppercase{\leftmark}}
\fancyfoot[LE,RO]{\tikz[anchor=south] \node[label={center:\thepage},inner sep=1pt]{\includegraphics[scale=.25]{apple}};}%
\fancyfoot[CE,CO]{\raisebox{1.65ex}{Hello World}}                 %% adjust 1.65ex
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
}


\usepackage{microtype}

\usepackage{afterpage}
\let\oldcleardoublepage\cleardoublepage
\renewcommand{\cleardoublepage}{\afterpage{\thispagestyle{empty}}\oldcleardoublepage}

\pagestyle{myfancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}


\begin{document}
\chapter{Install Backtrack on an Android Device}
\section{What is Backtrack?}
\lipsum[1-10]
\section{Security Tools in Backtrack}
\lipsum[10]
\section{Installing Backtrack on Android Device}
\lipsum[10]
\end{document}

Adjust the baseline of tikz picture:

enter image description here

Adjusting Hello World:

enter image description here

As commented by Werner above you may also specify the reference points by \raisebox{1.65ex}[0pt][0pt]{Hello World}.

You have used \fancyhf[cf]{Hello World} in your code which will result in both header and footer. I assumed that you don't want it in header. Also cf is replaced by C.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.