Unequal page margins

marginspaper-size

I have the following code:

\documentclass{article}
\usepackage[paperheight=11.69in,paperwidth=8.27in]{geometry}
\geometry{vmargin={1.4in,0.3in},hmargin={1.4in,1.4in},footskip=20pt}

\newcommand{\header}[1]{{
\hspace*{-15pt}\vspace*{6pt} \textsc{#1}} \vspace*{-6pt} 
\lineunder
}

\newcommand{\lineunder}{
\vspace*{-8pt} \\ \hspace*{-18pt} 
\hrulefill \\
}

\begin{document}
\header{Blablabla}
\end{document}

Which produces the following document:

enter image description here

When I print out the document on an A4 paper, the left margin is 3 centimetres wide and the right one is 3.5 centimetres despite me setting them to an equal size (hmargin={1.4in,1.4in} in line 3). What is causing the problem and how can I fix it?

Best Answer

It's unclear what you want to achieve. If you're trying to set a page header, you should use fancyhdr or similar package.

Anyway, this produces equal spaces on either side. Beware of unprotected endlines; you have very strange \vspace instructions.

I replaced the complicated lengths in inches by the simpler a4paper option.

\documentclass{article}
\usepackage[a4paper]{geometry}
\geometry{vmargin={1.4in,0.3in},hmargin={1.4in,1.4in},footskip=20pt}

\newcommand{\header}[1]{%
\noindent\textsc{#1}\\[-6pt]\mbox{}\hrulefill\par
}

\begin{document}

\header{Blablabla}

\end{document}

enter image description here

Related Question