花哨标题中放置错误的迷你页面

花哨标题中放置错误的迷你页面

我的一封信的布局相当复杂。它需要在每一页上显示页眉的某个部分,而另一部分只能显示在第一页。整个布局可以在这里找到: 平均能量损失

\documentclass[12pt,a4paper]{article}
\usepackage[
top=9cm,
bottom=3.5cm,
head=220pt,
left=2cm, 
right=2cm]{geometry}

\usepackage[table]{xcolor}
\usepackage{fancyhdr}
\usepackage{microtype}
\usepackage[hidelinks]{hyperref}
\usepackage[german]{babel}
\usepackage{tabularx}
\usepackage{enumitem}
\usepackage{lastpage}
\usepackage{parskip}
\usepackage{eurosym}

%Color definition
\definecolor{light-gray}{gray}{0.6}

%Remove par indent
\setlength{\parindent}{0cm}

%----------- Defined Variables -------------------------
\def\adress{company, Street 1, 123 City}
\def\aname{other company}
\def\aadd{Some Person}
\def\astreet{Street 2}
\def\apostal{321 City}
\def\onr{2014001}
\def\cnr{10}
\def\subject{Some Subject}
%----------- End Defined Variables ---------------------

%Settings for fancy table
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}

%Fancy Header stuff
\pagestyle{fancy}

\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.4pt}% default is 0pt
\renewcommand{\footrule}{\color{light-gray}{\hrule} \vspace{10pt}}

%Actual Header and Footer Layout
\newcommand{\baseheader}{\fontsize{14pt}{1em}\selectfont 
    \textbf{\textcolor{light-gray}{company}}
    \color{light-gray}{\hrule}
    \vspace{10pt}
    }

\newcommand{\rightheader}{
  \hfill
  \begin{minipage}[b]{.49\textwidth}
    \fontsize{10pt}{1em}\selectfont
    \begin{flushright}
     \textcolor{black}{
      \begin{tabular}{lr}
        \textbf{Some info:} & \\
        Date: & \today \\
        Some Number: & \onr \\          
        Other Number: & \cnr \\
        Page: & \thepage\ of \pageref{LastPage} \\
      \end{tabular} 
      }     
    \end{flushright}
  \end{minipage}  
}
\newsavebox{\eheaderbox}
\begin{lrbox}{\eheaderbox}%
  \begin{minipage}[t]{.5\textwidth}
    \begin{flushleft}        
      {        
        \fontsize{8pt}{1em}\selectfont 
        \color{light-gray}\underline{
        \textcolor{light-gray}{\adress}}
      }        
      \fontsize{12pt}{1em}\selectfont
      \begin{itemize}[noitemsep,leftmargin=0pt,topsep=0px]      
        \item[] \aname
        \item[] \aadd
        \item[] \astreet
        \item[] \apostal        
      \end{itemize}        
    \end{flushleft}
  \end{minipage}
  \rightheader
\end{lrbox}

\fancypagestyle{firststyle}
{
   \fancyhf{}
   \fancyhead[R]{  
   \baseheader
   \vspace*{1.8cm}
   \usebox{\eheaderbox}
}
}

\fancyhf{}
\fancyhead[R]{  
  \baseheader
  \vspace*{1.8cm}
  \rightheader
}

\fancyfoot[L]{
  \fontsize{10pt}{1em}\selectfont
  Account Data:\\
  Acountholder\\
  IBAN: 123\\
  BIC: YAYBIC\\
  Bank: Some Bank
}
\fancyfoot[C]{
  \begin{minipage}[t]{3cm}
  \fontsize{10pt}{1em}\selectfont
  \begin{flushleft}
    Postal:\\
    comp name\\
    Street 1\\
    123 City
  \end{flushleft}
  \end{minipage}
}
\fancyfoot[R]{
\begin{minipage}[t]{4.5cm}
  \fontsize{10pt}{1em}\selectfont
  \begin{flushleft}  
    Contact:\\
    \href{http://www.comp.com/}{www.comp.com}\\
    Phone: 987654321
  \end{flushleft}    
  \end{minipage}
}
%End Actual Header and Footer Layout

\begin{document}
\thispagestyle{firststyle}
\textbf{\subject}
\par
Yadda
\par
More Yadda

\newpage
Second Page Yadda
\end{document}

我的方法似乎存在一些问题。对我来说最紧迫的问题是左侧的小页面位置错误。我就是搞不清楚如何让标题的两个部分对齐。有什么想法吗?

答案1

看来这只是我的一个疏忽。正如 Harish Kumar 和 John Kormylo 指出的那样,我只需在 中的定义[t]中删除该参数即可。minipagelrbox

[...]
\newsavebox{\eheaderbox}
  \begin{lrbox}{\eheaderbox}%
    \begin{minipage}{.5\textwidth} % remove HERE
    \begin{flushleft}
    [...]

相关内容