Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am new to the Latex. I have tried my hand on this in developing a document with the header and footer. I almost succeeded with the google resources plus this forum. But still I need to fix two issues, please help me with that.

  • To add a maroon color in the header and footer box.
  • To reduce the box size of the header

Below is the code, please guide me.

\documentclass{article}
\usepackage{lipsum}%% a garbage package you don't need except to create examples.
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{calc}
\renewcommand{\headrulewidth}{0pt}
\newlength{\fminilength}%
\setlength{\fminilength}{\textwidth-2\fboxsep-2\fboxrule}%
\pagestyle{fancy}

\lhead{\noindent\fbox{%
    \begin{minipage}{\fminilength}%
      \ttfamily\upshape box upto end of this text \hfill 
    \end{minipage}%
  }}
\renewcommand{\headrulewidth}{0.4 pt}  

\lfoot{\noindent\fbox{%
    \begin{minipage}{\fminilength}%
      \ttfamily\upshape Wireless networking \hfill \thepage\ of \pageref{LastPage}
    \end{minipage}%
  }}
\cfoot{}

\renewcommand{\footrulewidth}{0.4pt}

\begin{document}



\lipsum[1]

\end{document}

below is the image to describe the expecting output;

!enter image description here

share|improve this question
    
Welcome to TeX.SE!. Your question is tagged with tcolorbox but that package is not used at all? –  Christian Hupfer Apr 22 at 11:07
    
I am not sure but I think "tcolorbox" package is used to color the header and footer box. In that way, was looking for someone to guide me in using that package and solve the issue posted. –  user50327 Apr 22 at 11:15
    
Perhaps you could provide a screen shot how your document (or a page of it) should look like? And at a quick look on your code I cannot recognize where tcolorbox is used. –  Christian Hupfer Apr 22 at 11:18
    
Thanks for pointing it, I have added the picture on how document should like. And maybe I have misguided you, I did not add 'tcolorbox' package and was looking for help whether the package could solve issues. –  user50327 Apr 22 at 11:33
    
Maroon is a dark color, at least according to Wikipedia (RGB 128,0,0) –  Christian Hupfer Apr 22 at 11:35

1 Answer 1

up vote 1 down vote accepted

Perhaps this provides the desired output:

\documentclass{article}
\usepackage{lipsum}%% a garbage package you don't need except to create examples.
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{calc}

\usepackage{tcolorbox}


\definecolor{maroon}{RGB}{128,0,0}



\renewcommand{\headrulewidth}{0pt}
\newlength{\fminilength}%
\setlength{\fminilength}{\textwidth-2\fboxsep-2\fboxrule}%
\pagestyle{fancy}

\lhead{\noindent%
\begin{tcolorbox}[colback=maroon,width=0.3\textwidth,outer arc=0mm,top=1mm,bottom=1mm,boxrule=0mm]
Header
%\ttfamily\upshape box upto end of this text \hfill
\end{tcolorbox}%
}%
%\renewcommand{\headrulewidth}{0.4 pt}  

\lfoot{\noindent%
\begin{tcolorbox}[colback=maroon,width=\textwidth,outer arc=0mm,top=1mm,bottom=1mm, boxrule=0mm]
Footer\hfill \thepage\ of \pageref{LastPage}
%%      \ttfamily\upshape Wireless networking \hfill \thepage\ of \pageref{LastPage}
\end{tcolorbox}
}
\cfoot{}

\renewcommand{\footrulewidth}{0.4pt}

\begin{document}
\lipsum[1]

\end{document}

Edit

I removed the boxrules about the tcolorbox environments.

enter image description here

share|improve this answer
    
Thanks, This was exact document what I was looking for, but I could not able to load tcolorbox.sty. There was an error stating tcolorbox.sty is not found. –  user50327 Apr 22 at 11:40
    
Normaly it is included on TeXlive. See the rich documentation of tcolorbox. It is full of examples etc, in order to do fine tuning of your boxes. –  Christian Hupfer Apr 22 at 11:42
    
I am uing Miktex andd Texmaker, would that be a problem?? –  user50327 Apr 22 at 11:43
    
@user50327: I use neither of them, but it should be not too difficult to install the package from CTAN and place it at some place where TeXMaker etc. finds it. See mirrors.ctan.org/macros/latex/contrib/tcolorbox.zip –  Christian Hupfer Apr 22 at 11:44
    
It works completely fine. There was some kind of black border around the footer and header box. Any means to remove that, please help on that. thank you!! –  user50327 Apr 22 at 12:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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