0

I want to use geometry package for custom page margin setting after the header. Currently my documents looks like

enter image description here

I want to use geometry package to expand EDUCATION section so it should look like as follows

enter image description here

I've generated the above image using following code

\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage[parfill]{parskip} % Remove paragraph indentation
\usepackage{array} % Required for boldface (\bf and \bfseries) tabular columns
\usepackage{ifthen} % Required for ifthenelse statements
\pagenumbering{gobble} 
\usepackage[left=0.75in,top=0.6in,right=0.75in,bottom=0.6in]{geometry} 

\definecolor{darkgray}{HTML}{394456}
\definecolor{blue}{HTML}{5A7294}
\definecolor{white}{RGB}{255,255,255}

\def\sectionlineskip{\medskip}
\def\sectionskip{\medskip} % The space after the heading section

% Defines the rSection environment for the large sections within the CV
\newenvironment{rSection}[1]{ % 1 input argument - section name
  \sectionskip
  \MakeUppercase{\bf #1} % Section title
  \sectionlineskip
  \hrule % Horizontal line
  \begin{list}{}{ % List for each individual item in the section
    \setlength{\leftmargin}{1.5em} % Margin within the section
  }
  \item[]
}{
  \end{list}
}



\begin{document}


\begin{rSection}{Education}

{\bf University} \hfill {\em Start - End} 
\\ Degree\hfill { Overall CGPA: 4}

\end{rSection}

\end{document

Now if I don't use the geometry package my code for the first image would be

\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage[parfill]{parskip} % Remove paragraph indentation
\usepackage{array} % Required for boldface (\bf and \bfseries) tabular columns
\usepackage{ifthen} % Required for ifthenelse statements
\pagenumbering{gobble} 


\definecolor{darkgray}{HTML}{394456}
\definecolor{blue}{HTML}{5A7294}
\definecolor{white}{RGB}{255,255,255}

\def\sectionlineskip{\medskip}
\def\sectionskip{\medskip} % The space after the heading section

% Defines the rSection environment for the large sections within the CV
\newenvironment{rSection}[1]{ % 1 input argument - section name
  \sectionskip
  \MakeUppercase{\bf #1} % Section title
  \sectionlineskip
  \hrule % Horizontal line
  \begin{list}{}{ % List for each individual item in the section
    \setlength{\leftmargin}{1.5em} % Margin within the section
  }
  \item[]
}{
  \end{list}
}

\begin{document}


\begin{tikzpicture}[remember picture,overlay]
\node [rectangle, fill=darkgray, anchor=north, minimum width=\paperwidth, minimum height=3cm] (box) at (current page.north){};


\node [text=white,font=\fontsize{45pt}{65pt}\bfseries\sffamily,anchor=north
west] (name) at ([xshift=2em,yshift=-2em]box.north west) {%
John Doe
};
\node [text=blue!20,font=\fontsize{15pt}{15pt}\bfseries\sffamily,anchor=north
west] (name) at ([xshift=0.5ex]name.south west) {%
Job title
};

\node[anchor=east] at ([xshift=-2em]box.east)
{\includegraphics[height=2cm]{example-image-duck}};
\end{tikzpicture}


\begin{rSection}{Education}

{\bf University} \hfill {\em Start - End} 
\\ Degree\hfill { Overall CGPA: 4}

\end{rSection}

\end{document}

How can I get header from first image and education section with custom margin settings using geometry package as demonstrated in second image?

I need to use margin settings only for the part after my header.

  • why do you want to use geometry here? your page heading and page size isn't changing, you have just defined rSection to be a list so aren't you just asking about the list margins within the existing page? – David Carlisle Feb 8 at 14:56
  • @DavidCarlisle yes I just want to change margins for rSection you can provide a method if you know of that would work other than using geometry – Furqan Hashim Feb 8 at 14:58
  • @DavidCarlisle by tweaking \setlength{\leftmargin}{1.5em} margins would only change for items in the list, not for the horizontal line above those items and the section heading. – Furqan Hashim Feb 8 at 15:12
1

Just include the tikzpicture after \begin{document} and increase the top margin to leave enough space (the TikZ picture takes no space because it uses the overlay option—it appears as a zero-size box for TeX at the point where it occurs).

Use \newcommand rather than \def and \textbf rather than \bf. \emph is easier to use than \em in general because it automatically provides italic correction.

I removed possible spurious spaces and added \par\nopagebreak after your section title to ensure the following \medskip isn't a legal breakpoint.

The font sizes your code requests are not available unless you change your font setup. I added \usepackage{lmodern}, this makes them available. I also replaced Start - End with Start -- End (em dash: longer than a hyphen).

\documentclass{article}
\usepackage{lmodern}
\usepackage{tikz}
\usepackage[parfill]{parskip} % Remove paragraph indentation
\usepackage[left=0.75in,top=3cm,right=0.75in,bottom=0.6in]{geometry}

\definecolor{darkgray}{HTML}{394456}
\definecolor{blue}{HTML}{5A7294}
\definecolor{white}{RGB}{255,255,255}

\newcommand{\sectionlineskip}{\medskip}
\newcommand{\sectionskip}{\medskip}

% Defines the rSection environment for the large sections within the CV
\newenvironment{rSection}[1]{% 1 input argument - section name
  \sectionskip
  \MakeUppercase{\bf #1}% Section title
  \par\nopagebreak
  \sectionlineskip
  \hrule % Horizontal line
  \begin{list}{}{% List for each individual item in the section
    \setlength{\leftmargin}{1.5em} % Margin within the section
  }%
  \item[]
}{%
  \end{list}
}

\pagestyle{empty}

\begin{document}

\begin{tikzpicture}[remember picture, overlay]
\node[rectangle, fill=darkgray, anchor=north, minimum width=\paperwidth,
      minimum height=3cm] (box) at (current page.north) {};

\node[text=white,font=\fontsize{45pt}{65pt}\bfseries\sffamily,
      anchor=north west] (name) at ([xshift=2em,yshift=-2em]box.north west)
  {John Doe};

\node[text=blue!20, font=\fontsize{15pt}{15pt}\bfseries\sffamily,
      anchor=north west] (name) at ([xshift=0.5ex]name.south west)
  {Job title};

\node[anchor=east] at ([xshift=-2em]box.east)
  {\includegraphics[height=2cm]{example-image-duck}};
\end{tikzpicture}

\begin{rSection}{Education}
\textbf{University}\hfill \emph{Start -- End}\\
Degree\hfill Overall CGPA: 4
\end{rSection}

\end{document}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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