标题与装饰线不对齐

标题与装饰线不对齐

tabular在 header 中使用了 package fancyhdr。我添加了settototalheight计算 header 高度的功能。下面是一个小例子。问题是 header 不与右端的装饰线对齐。但它与左端对齐。问题是什么?

\documentclass[titlepage,a4paper]{article}

\usepackage{fancyhdr}
\usepackage{calc}

\usepackage[english]{babel}
\usepackage{datetime}   
\renewcommand{\dateseparator}{-}
\newcommand{\headertoday}{\the\year \dateseparator \twodigit\month \dateseparator \twodigit\day}

\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{}
\newcommand\leftheadercalc[1]{%
\begin{TabLocalVerticalSpacing}{#1}[b]{@{}ll}\footnotesize{Static Calculation Foundation Loads and concrete columns basic parameter}&\footnotesize{}\\\footnotesize{Project: xxxxxx}&\footnotesize{}\end{TabLocalVerticalSpacing}
}
\newcommand\rightheadercalc[1]{%
\begin{TabLocalVerticalSpacing}{#1}[b]{rr@{}}\footnotesize{Date:}&\footnotesize{\headertoday}\\\footnotesize{Page:}&\footnotesize{\thepage}\end{TabLocalVerticalSpacing}
}
\newcommand\midheadercalc[1]{%
\begin{TabLocalVerticalSpacing}{#1}[b]{cc}\footnotesize{}&\footnotesize{}\\\footnotesize{}&\footnotesize{}\end{TabLocalVerticalSpacing}
}
\settototalheight\headheight{\maxof{\leftheadercalc{0.600000}}{\rightheadercalc{0.600000}}{\midheadercalc{0.600000}}}
\lhead{\leftheadercalc{0.600000}}
\rhead{\rightheadercalc{0.600000}}
\chead{\midheadercalc{0.600000}}

%########## header decorative lines
\makeatletter
\def\headrule{{\if@fancyplain\let\headrulewidth\plainheadrulewidth\fi%
\hrule\@height 0.500000pt \@width\headwidth\vskip1.000000pt
\hrule\@height 0.500000pt\@width\headwidth}}    
\makeatother


%########## footer decorative lines
\makeatletter   
\def\footrule{{\if@fancyplain\let\footrulewidth\plainfootrulewidth\fi%
\hrule\@height 0.500000pt \@width\headwidth\vskip1.000000pt 
\hrule\@height 0.500000pt\@width\headwidth}}    
\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}

答案1

您需要查找空格的引入位置;一个简单的方法是用 LaTeX3\ExplSyntaxOn\ExplSyntaxOff标签将代码部分括起来(只需包含expl3包)。

\ExplSyntaxOn
\newcommand\rightheadercalc[1]{%
\begin{TabLocalVerticalSpacing}{#1}[b]{rr@{}}\footnotesize{Date:}&\footnotesize{\headertoday}\\\footnotesize{Page:}&\footnotesize{\thepage}\end{TabLocalVerticalSpacing}
}
\ExplSyntaxOff

这纠正了右上角的问题,通过检查,这个问题%在最后应该有一个。

\end{TabLocalVerticalSpacing}%

在此处输入图片描述

底部页脚也一样!

相关内容