# Change words in a Tikz picture every page

I'd like to create a template, as below. But I'd like to make it so that I can have multiple pages of the same layout and be able to easily replace "Header 1" and "Header 2" with different words each time.

I am able to make the gray boxes and place the words using the code below. Right now I have them in as a header so that it'll easily be place on each page.

    \begin{tikzpicture}[remember picture,overlay, fill]
\path [fill=lightgray]
([yshift=9cm]current page.west) -- ([yshift=9cm,xshift=12cm]current page.west) -- ([yshift=8.5cm,xshift=12cm]current page.west) -- ([yshift=8.5cm]current page.west) -- cycle;
\path [fill=lightgray]
([yshift=0cm]current page.west) -- ([yshift=0cm,xshift=12cm]current page.west) -- ([yshift=-0.5cm,xshift=12cm]current page.west) -- ([yshift=-0.5cm]current page.west) -- cycle;
\node[font=\bfseries\color{black},anchor=west,
xshift=1cm,yshift=9.5cm] at (current page.west)
\node[font=\bfseries\color{black},anchor=west,
xshift=1cm,yshift=0.5cm] at (current page.west)
\end{tikzpicture}%


But I'm wondering if there's a way to define a new environment with a tikz picture so that I can just define that environment and change the words as needed without having to individually place the headers/words each time.

• Why not use \newcommand{\myheadertext}{Insert here} and then you simply change its value. Jun 6 '14 at 19:08
• I'm not quite sure I understand. How do I implement that in to the tikzpicture code? And how would I be able to define multiple headertexts?
– TLC
Jun 6 '14 at 19:14
• If I well understood you want to change the header text in a simple way. So you can define a variable to save the header text and you use it inside the tikz environment. For example, \selectfont\myheadertext. So when you redefine it and use the environment again you'll obtain another output. Jun 6 '14 at 19:19
• Ahh yes that works. I forgot about \renewcommand to change the words each new page.
– TLC
Jun 6 '14 at 20:51

If you do not want anything else in tikzpicture environment then you could define

\newcommand\PageHeader[2]{%
\begin{tikzpicture}[remember picture,overlay, fill]
\path [fill=lightgray]
([yshift=9cm]current page.west) -- ([yshift=9cm,xshift=12cm]current page.west) -- ([yshift=8.5cm,xshift=12cm]current page.west) -- ([yshift=8.5cm]current page.west) -- cycle;
\path [fill=lightgray]
([yshift=0cm]current page.west) -- ([yshift=0cm,xshift=12cm]current page.west) -- ([yshift=-0.5cm,xshift=12cm]current page.west) -- ([yshift=-0.5cm]current page.west) -- cycle;
\node[font=\bfseries\color{black},anchor=west,
xshift=1cm,yshift=9.5cm] at (current page.west)
{\fontsize{40}{60}\selectfont #1};
\node[font=\bfseries\color{black},anchor=west,
xshift=1cm,yshift=0.5cm] at (current page.west)
{\fontsize{40}{60}\selectfont #2};
\end{tikzpicture}%
}


and then use something like \PageHeader{Header 1}{Header 2} on each page.

If you would also like to able to add something inside the tikzpicture environment use:

\newenvironment{PageHeader}[2]{%
\begin{tikzpicture}[remember picture,overlay, fill]
\path [fill=lightgray]
([yshift=9cm]current page.west) -- ([yshift=9cm,xshift=12cm]current page.west) -- ([yshift=8.5cm,xshift=12cm]current page.west) -- ([yshift=8.5cm]current page.west) -- cycle;
\path [fill=lightgray]
([yshift=0cm]current page.west) -- ([yshift=0cm,xshift=12cm]current page.west) -- ([yshift=-0.5cm,xshift=12cm]current page.west) -- ([yshift=-0.5cm]current page.west) -- cycle;
\node[font=\bfseries\color{black},anchor=west,
xshift=1cm,yshift=9.5cm] at (current page.west)
{\fontsize{40}{60}\selectfont #1};
\node[font=\bfseries\color{black},anchor=west,
xshift=1cm,yshift=0.5cm] at (current page.west)
{\fontsize{40}{60}\selectfont #2};%
}{\end{tikzpicture}}


Now you can write something like this:

\begin{PageHeader}{Header 1}{Header 2}
\draw(0,0)--(1,1);