[Tex/LaTex] How to edit the length of a color box

alignboxescolor

I've typed my Resume and Im using a color box, with a line underneath it. However the grey colored box doesn't reach the full length of the page width.

\documentclass[letterpaper,11pt]{article}
\usepackage[left=0.9in, right=0.8in]{geometry}
\pagestyle{empty}
\raggedright
\def\bull{\vrule height 0.8ex width .7ex depth -.1ex }    

\newcommand{\lineunder}{\vspace*{-8pt} \\ \hspace*{-18pt} \hrulefill \\} %command for the Line to be drawn

\usepackage[usenames,dvipsnames]{color}
\definecolor{mygrey}{gray}{.90}
\newcommand{\headergrey}[1]{\hspace*{-18pt} \colorbox{mygrey} 
    {\begin{minipage}
    {\textwidth}{\textsc{#1}}
    \end{minipage}}\lineunder}

\begin{document}

\headergrey{Objective}
    Seeking a Full Time position in the area of Blah blah blah Blah 
\end{document}

See the image attached so as to what i mean please. Image

Best Answer

You should not ignore LaTeX warnings about overfull boxes. The basic problem in your original is that the box constructed does not fit on the page. The inner minipage is \textwidth wide but \colorbox, like \fbox adds padding around the box of length \fboxsep so the box was 2\fboxsep (6pt) too wide and then it was at the start of a paragraph so further indented by the paragraph indent, sticking it into the left margin.

enter image description here

\documentclass[letterpaper,11pt]{article}
\usepackage[left=0.9in, right=0.8in]{geometry}
\pagestyle{empty}
\raggedright
\def\bull{\vrule height 0.8ex width .7ex depth -.1ex }    


\usepackage[usenames,dvipsnames]{color}
\definecolor{mygrey}{gray}{.90}
\newcommand{\headergrey}[1]{\par\noindent{\setlength\fboxsep{0pt}\hspace*{-18pt}\colorbox{mygrey} 
    {\begin{minipage}{\dimexpr\textwidth-2\fboxsep+18pt\relax}
\vspace{2pt}%
\textsc{\strut\hspace{3pt}#1}\par
\hrule
    \end{minipage}}\par\smallskip}}

\begin{document}

\headergrey{Objective}
    Seeking a Full Time position in the area of Blah blah blah Blah 
\end{document}