This is an addendum of a previous question: How to place a \draw near the page number using tikzpicture environment.
What I want
I would like to have the section text moved to the top of every page, and place an image next to it. Look at this:
Why I mention sections? Because when the document is finished I want to make a ToC at the beginning.
- The image (
svgfile) is always the same.
For example:
- The full document has 8 pages in total.
- In page 1 there should be nothing.
- In pages 2-4, the green rectangle should have:
Section One: Textwith the image next to it. - In pages 5-7, the green rectangle should have:
Section Two: More textwith the image next to it. - In page 8, the green rectangle should have:
Bibliographywith the image next to it.
and we should be able to produce a ToC with those 3 sections (two sections and the bibliography).
What I have done
Consider this MWE (taken from the accepted answer of the addendum):
\documentclass{article}
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage[hidelinks]{hyperref}
\usepackage{lastpage}
\usepackage{refcount}
\usepackage{fancyhdr}
\pagestyle{fancy}
\newsavebox{\arrowL}
\newsavebox{\arrowR}
\sbox\arrowR{\begin{tikzpicture}
\draw[line width=1mm,white,line cap=round,line join=round]
(0,0) -- (7pt,8pt) -- (0pt,16pt);
\end{tikzpicture}}
\sbox\arrowL{\begin{tikzpicture}
\draw[line width=1mm,white,line cap=round,line join=round]
(0,0) -- (-7pt,8pt) -- (0pt,16pt);
\end{tikzpicture}}
\fancyhf{}
\rhead{
%\newcommand{\sec}[1]{%
\begin{tikzpicture}[remember picture,overlay]%
\fill[green] (current page.north west) rectangle ++(\paperwidth,-1.5cm);%
\node[text=white,anchor=west,xshift=4cm,yshift=-.75cm,font=\LARGE\bfseries] at (current page.north west) (a) {Section One: Text};%
\end{tikzpicture}%
%}
}
\rfoot{
\begin{tikzpicture}[remember picture,overlay]
\fill[black] (current page.south west) rectangle ++(\paperwidth,1.5cm)
node[midway,align=center,font=\LARGE\bfseries,text=white,xscale=1.5]
(pageno-\number\value{page})
{\thepage}; % From https://tex.stackexchange.com/a/443744/152550
\ifnum\value{page}<\getpagerefnumber{LastPage}
\path ([xshift=\paperwidth/4]pageno-\number\value{page})
node{\hyperlink{page.\the\numexpr\value{page}+1}{\usebox\arrowR}};
\fi
\ifnum\value{page}>1
\path ([xshift=-\paperwidth/4]pageno-\number\value{page})
node{\hyperlink{page.\the\numexpr\value{page}-1}{\usebox\arrowL}};
\fi % From https://tex.stackexchange.com/a/529698/152550
\end{tikzpicture}
}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\begin{document}
%\sec{Section One: Text}
\tikz\node[circle,draw,
path picture={
\node at (path picture bounding box.center){
\includegraphics[width=2.5cm]{Example.png}
};
}]{}; % From https://tex.stackexchange.com/a/193558/152550
Example
\newpage
Another example
\end{document}
Problems:
- I don't know how to use
\newcommand[1]{\sec}{...}to have different sections on pages, where the argument is the name of the section. - The cropped image does not show on the 2.5cm circle (inside
\begin{document}). (I have loadedgraphicxand put\graphicspath. I tried with\includegraphics{Example.png}outsidetikzpictureand it worked.)



Bibliography. – manooooh Feb 23 '20 at 23:31