1

I want to configure my page header such as enter image description here

I've tried using the eso-pic package suggested in this answer, but it seems like it doesn't allow add images or text too.

\documentclass[letterpaper,12pt,oneside]{book}%
\usepackage{newpxtext, newpxmath}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{geometry}%[showframe]
\usepackage[svgnames]{xcolor}

\usepackage{tikz} \usepackage{fancyhdr} \usepackage[explicit,]{titlesec} \usepackage{eso-pic} \usepackage{lipsum}

\pagestyle{empty}

\begin{document}

\AddToShipoutPictureBG{\color{DarkGreen} \AtPageUpperLeft{\rule[-20mm]{\paperwidth}{20mm} \begin{picture}(0,0) {\includegraphics[height=0.6cm,width=0.6cm]{images/ufabc.png}} \end{picture}}% }

teste

\end{document}

enter image description here

Could anyone help me find how to make it work with this package or how could I do this in other way?

FHZ
  • 3,939
LeoDays
  • 13
  • Welcome to TeX.SE and saudações da UFABC! This is one or the rare occasions I find someone here not only from Brazil, but also from the university I graduated myself. Are you looking for a header for a subset of pages or for all pages? – FHZ May 02 '22 at 04:56
  • 1
    @FHZ greetings from a newbie. This project actually is supposed to be a doc for a code with only one/two pages using this same template – LeoDays May 02 '22 at 09:09

1 Answers1

0

One among many possible solutions is the use of eso-pic to draw your style. Notice you may editing the measures or make them automatic to any page geometry your are using.

This solution applies the same background to each page. If your are looking for a header in specific page, I may check how to adapt it using fancyhdr for specific cases. I think you would like it since you wrote fancyhdr and it seems to be a page in a report.

OBS.: As you are writing in Brazilian Portuguese, I suggest using \usepackage[brazil]{babel} and \usepackage[utf8]{inputenc} (it'd be probably better).

\documentclass[letterpaper,12pt,oneside]{book}%
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{graphicx} \usepackage{geometry}[showframe] \usepackage[svgnames]{xcolor}

\usepackage[brazil]{babel}

\usepackage{tikz} \usetikzlibrary{calc}

\usepackage{eso-pic} \usepackage{lipsum}

\AddToShipoutPictureBG{% \begin{tikzpicture}[remember picture, overlay] \fill[opacity=1,line width=2pt,DarkGreen] ($ (current page.north west) + (0cm,-2cm) $) rectangle ($ (current page.north east)$); \node[opacity=.8, inner sep=0pt] at ($ (current page.north west) + (3cm,-1cm) $) {\includegraphics[height=1.5cm]{example-image-duck}}; %*(\thepage-1) \node[font=\bfseries\LARGE, white] at ($ (current page.north) + (0cm,-1cm) $) {Dicionário de Dados}; \end{tikzpicture} } \begin{document} \lipsum[1-10] \end{document}

enter image description here


Edit:

Adapting the previous example for fancyhdr, you can add your header to the pages you want and only them.

I'd suggest to learn how to Make your own .sty files and making this style part of your own library of styles.

\documentclass[letterpaper,12pt,oneside]{book}%
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{graphicx} \usepackage{geometry}[showframe] \usepackage[svgnames]{xcolor}

\usepackage[brazil]{babel}

\usepackage{tikz} \usetikzlibrary{calc}

\usepackage{eso-pic} \usepackage{lipsum}

\usepackage{fancyhdr} %\pagestyle{mystyle} % fancy, myheadings, headings \fancypagestyle{mystyle}{ % alteração de estilo pré-definido. \fancyhf{} % clear all header and footer fields \fancyhead[R]{\thepage} % except the right top corner \fancyhead[L]{ \begin{tikzpicture}[remember picture, overlay] \fill[opacity=1,line width=2pt,DarkGreen] ($ (current page.north west) + (0cm,-2cm) $) rectangle ($ (current page.north east)$); \node[opacity=.8, inner sep=0pt] at ($ (current page.north west) + (3cm,-1cm) $) {\includegraphics[height=1.5cm]{example-image-duck}}; %*(\thepage-1) \node[font=\bfseries\LARGE, white] at ($ (current page.north) + (0cm,-1cm) $) {Dicionário de Dados}; \end{tikzpicture} } % except the left top corner \renewcommand{\headrulewidth}{0pt} % remove line between header and main text }

\begin{document} \chapter{C} \section{S1} \pagestyle{headings} \lipsum[1-10] \clearpage \section{S2} \pagestyle{mystyle} \lipsum[1-10] \clearpage \section{S2} \pagestyle{headings} \lipsum[1-10] \end{document}

The following picture presents pages 4 and 5, the ones under \pagestyle{mystyle}. Pages from other sections don't have it.

enter image description here


Edit 2:

Using \fontfamily{phv}\selectfont at \node[font=\bfseries\LARGE, white] at ($ (current page.north) + (0cm,-1cm) $) {\fontfamily{phv}\selectfont Dicionário de Dados}; changes font to Helvetica, which is very similar to Arial and not easy to spot differences.

enter image description here

FHZ
  • 3,939
  • The font of your example is probably Arial or Arial black, is it mandatory to be this font? I used the default font of LaTeX. – FHZ May 02 '22 at 04:58
  • 1
    No really, I was actually trying some things before and it ends up in this mess. Thank you very much for your answer @FHZ, I am looking forward for your tip specially for my future bigger projects – LeoDays May 02 '22 at 09:13