INWTlab / ireports

R package with RMarkdown Business Reports
GNU General Public License v3.0
82 stars 33 forks source link

Header and footer with no margins in template #25

Closed Seba-Vargas closed 1 year ago

Seba-Vargas commented 2 years ago

Hi everyone! First, i want to thank you for the post "R Markdown Template for Business Reports", it's really helping me with my reports. Now, i have a question that maybe you can help me. I been trying to put header and footers with no margins in my reports, but with no success. I'm currently using your template (defs.tex) and Rmd code and playing with both of them. I'm adding the PDF i generate and the header i'm trying to use. Untitled.pdf logo Thanks a lot! :)

SarahWagner commented 2 years ago

Hi @Seba-Vargas, is this what you're looking for?

image

Here's the defs.tex to create a no margin header with your provided image. In line 13 I set top to 0 cm and headsep to 4 cm. And in line 97 I made the header image full width, so to say. I hope this helps.

% Author: Karol KozioL
% License: GPL-3
% Modified by: Sarah Wagner

% % % packages -----------------------------------------------------------------------------------
\usepackage{amsmath}
\usepackage{array}
\usepackage{booktabs}
\usepackage{calc}
\usepackage{eso-pic}
\usepackage{fancyhdr}
\usepackage{fontspec}
\usepackage[left = 2.5cm, right = 2.5cm, top = 0cm, bottom = 1.2cm, headsep=4cm, includeheadfoot]{geometry}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{lastpage}
\usepackage{multirow}
\usepackage{tabularx} 
\usepackage{tikz}
\usepackage{titlesec}
\usepackage{xcolor, colortbl}

% % % settings -----------------------------------------------------------------------------------

% % custom colors
\definecolor{iblue}{HTML}{\iblue}
\definecolor{igray}{HTML}{\igray}

% definition of pagename
\newcommand\pagename{Page}

% % fonts 
\defaultfontfeatures{Mapping = tex-text}
\setmainfont[BoldFont = Lato-Bold.ttf, ItalicFont = Lato-Italic.ttf, BoldItalicFont = Lato-BoldItalic.ttf]{Lato-Regular.ttf}
\newfontfamily\headingfont[ItalicFont = Lato-BlackItalic.ttf]{Lato-Black.ttf}

% % sections
\titleformat{\section}{\color{iblue}\headingfont\Large\bfseries}{\thesection}{1em}{}[\titlerule]
\titleformat{\subsection}{\color{iblue}\headingfont\large\bfseries}{\thesubsection}{1em}{}
\titleformat{\subsubsection}{\color{iblue}\headingfont\bfseries}{\thesubsubsection}{1em}{}

% % misc
\setlength{\parindent}{0em} 
\linespread{1}
\raggedright
\newcolumntype{C}{>{\centering\arraybackslash}X}

% % % custom titlepage ----------------------------------------------------------------------------
\newcommand\BackgroundPic{%
    \put(0,0){%
        \parbox[b][\paperheight]{\paperwidth}{%
            \vfill
            \centering
            \includegraphics[width=\paperwidth,height=\paperheight]{\cover}%
            \vfill
}}}

\makeatletter

% pagestyle titlepage
\fancypagestyle{customtitle}{
    \lhead{}
    \chead{}
    \rhead{}
    \makeatother
    \lfoot{}
    \cfoot{}
    \rfoot{}
}

% titlepage
\renewcommand{\maketitle}{
    \thispagestyle{customtitle}
    \AddToShipoutPicture*{\BackgroundPic}
    \ClearShipoutPicture

    \phantom{a}\hfill
    \vspace{14cm}

    \begin{tabular}[l]{@{}p{\textwidth}@{}}
        \color{iblue}\headingfont\LARGE\@title\\[1em]
        \color{iblue}\headingfont\large\@author\\[1em]
        \color{iblue}\headingfont\small\@date\\[1em]
    \end{tabular}

    \clearpage
}
\makeatother

% % % header and footer ---------------------------------------------------------------------------
\pagestyle{fancy}
\lhead{\makebox[\textwidth][c]{\includegraphics[width=1.31\textwidth]{\logo}}}
\chead{}
\rhead{}
\makeatother
\newlength{\myheight}
\lfoot{}
\cfoot{}
\rfoot{\pagename~\thepage \hspace{1pt} / \pageref{LastPage}}
\renewcommand\headrulewidth{0pt}
\renewcommand\footrulewidth{0pt}