# Header doesn't align with decorative line

I use tabular in header with package fancyhdr. I added settototalheight to calculate the header height. Following is a small example. The question is that header doesn't align with the decorative line at the right end. But it does at the left end. What is the problem?

\documentclass[titlepage,a4paper]{article}

\usepackage{fancyhdr}
\usepackage{calc}

\usepackage[english]{babel}
\usepackage{datetime}
\renewcommand{\dateseparator}{-}

\usepackage[lmargin=1.800000cm,rmargin=1.000000cm,tmargin=2.500000cm,bmargin=1.000000cm]{geometry}

%### define an environment to have a local \arraystretch'
\newenvironment{TabLocalVerticalSpacing}[1]
{\def\arraystretch{#1}\tabular}
{\endtabular}
%#####################################

\pagestyle{fancy}
\fancyhf{}
\begin{TabLocalVerticalSpacing}{#1}[b]{@{}ll}\footnotesize{Static Calculation Foundation Loads and concrete columns basic parameter}&\footnotesize{}\\\footnotesize{Project: xxxxxx}&\footnotesize{}\end{TabLocalVerticalSpacing}
}
}
\begin{TabLocalVerticalSpacing}{#1}[b]{cc}\footnotesize{}&\footnotesize{}\\\footnotesize{}&\footnotesize{}\end{TabLocalVerticalSpacing}
}

\makeatletter
\makeatother

%########## footer decorative lines
\makeatletter
\def\footrule{{\if@fancyplain\let\footrulewidth\plainfootrulewidth\fi%
\makeatother

\newcommand\leftfootercalc[1]{%
\footnotesize{xxx GmbH}
}
\newcommand\rightfootercalc[1]{%
\footnotesize{Document: g-zzz}
}
\newcommand\midfootercalc[1]{%
\footnotesize{Principal: civil eng. yyy}
}
\settototalheight\footskip{\maxof{\leftfootercalc{0.600000}}{\rightfootercalc{0.600000}}{\midfootercalc{0.600000}}}
\lfoot{\leftfootercalc{0.600000}}
\rfoot{\rightfootercalc{0.600000}}
\cfoot{\midfootercalc{0.600000}}

\begin{document}
balala
\end{document}


You need to look for where a space is introduced; an easy way to do that is to enclose sections of the code with LaTeX3 \ExplSyntaxOn and \ExplSyntaxOff tags (just include the expl3 package).

\ExplSyntaxOn
}
\ExplSyntaxOff


This corrected the problem on the top right, which by inspection should have had a % at the end.

\end{TabLocalVerticalSpacing}%


Same for the bottom footer!

• @Yiannis: due to leave, i can't test your method. from your answer, i found two interesting things. first, use \ExplSyntaxOn and \ExplSyntaxOff. it looks like syntax check. but it can cancel out redundant space. i will refer to expl3's manual to see what it means. second, add % at the end of sentence. what i only know is that % just means a comment. but here it means something else more. i will try your answer as soon as i come back. thanks a lot. – warem Mar 11 '11 at 0:35
• @warem: The % is really just a comment, but the line end is taken as a space(!) which is commented out by %. Spaces after macros are ignored, but not after { or }. – Martin Scharrer Mar 11 '11 at 9:16
• @Yiannis: i am using Miktex 2.4. adding \usepackage{expl3} said that file expl3.sty not found. – warem Mar 14 '11 at 10:50
• @Yiannis: if i installed latest expl3 manually then compiled, i got this error: Package l3names Error: Required primitive not found: \pdfstrcmp. after type H for immediately help, i got LaTeX3 requires the e-TeX primitives and \pdfstrcmp. this is available in pdftex 1.3 or later`. for miktex 2.4, the pdftex version is 3.141592-1.21a. so what's the matter? – warem Mar 14 '11 at 13:05
• @warem you need to update the MikTeX distribution as you are one version behind on pdftex. If you do not want to, just adding the missing "%" would do the trick. – Yiannis Lazarides Mar 14 '11 at 17:24