LaTeX 中的自定义标题

LaTeX 中的自定义标题

我有一个基于框的标题模板,它看起来像这样:

    \documentclass[10pt,a4paper]{article}
    \usepackage[MeX]{polski}
    \usepackage[utf8]{inputenc}

    \setlength{\parindent}{0pt}

    \usepackage[
      top    = 1.50cm,
      bottom = 1.50cm,
      left   = 1.50cm,
      right  = 1.50cm,
    ]{geometry}

    \usepackage{tabularx}

    \pagestyle{empty}

    \renewcommand{\familydefault}{\sfdefault}

    \newcommand{\datasprzedazy}{3.03.2006}
    \newcommand{\terminplatnosci}{17.03.2006}
    \newcommand{\nrfaktury}{3/2006} 
    \newcommand{\netto}{1000.00} 
    \newcommand{\vat}{220.00}
    \newcommand{\brutto}{1220.00}
    \newcommand{\slownie}{jeden tysiąc dwieście dwadzieścia złotych}

    \begin{document}

    \renewcommand\arraystretch{1.3}
    \renewcommand\tabcolsep{0pt}


    \setbox0=\vtop{
      \hrule height 0pt
      \hbox{\fbox{%
        \begin{minipage}[t]{0.47\textwidth}
        \begin{tabular}[t]{ l l }
          Company Name & Logo\\
          Address & \\
          Street & \\
          Tax ID &\\
          Other Info
        \end{tabular}
        \end{minipage}%
      }}% end the \fbox and the \hbox
      \hrule height 0pt
      }% end the \vtop

    \setbox2=\vtop to \dp0{
      \hrule height 0pt
      \hbox{\framebox[0.47\textwidth]{\textbf{Faktura VAT nr \nrfaktury}}}
      \vfill
      \hbox{\begin{tabular}{lr}
        Data sprzedaży: & \datasprzedazy \\
        Data wystawienia: & \datasprzedazy
      \end{tabular}}
      \vfill
      \hbox{\framebox[0.47\textwidth]{\textbf{ORYGINAŁ}}}
      \hrule height 0pt
      }

    \leavevmode\box0\hfill\box2\par
    \end{document}

但是,当我尝试将它与 fancyhdr 一起使用时,如下所示:

    \documentclass[10pt,a4paper]{article}
    \usepackage[MeX]{polski}
    \usepackage[utf8]{inputenc}

    \setlength{\parindent}{0pt}

    \usepackage[
      top    = 1.50cm,
      bottom = 1.50cm,
      left   = 1.50cm,
      right  = 1.50cm,
    ]{geometry}
    \usepackage{fancyhdr}

    \usepackage{tabularx}

    \pagestyle{empty}
    \pagestyle{fancy}

    \renewcommand{\familydefault}{\sfdefault}

    \newcommand{\datasprzedazy}{3.03.2006}
    \newcommand{\terminplatnosci}{17.03.2006}
    \newcommand{\nrfaktury}{3/2006} 
    \newcommand{\netto}{1000.00} 
    \newcommand{\vat}{220.00}
    \newcommand{\brutto}{1220.00}
    \newcommand{\slownie}{jeden tysiąc dwieście dwadzieścia złotych}

    \chead
    {
    \setbox0=\vtop{
      \hrule height 0pt
      \hbox{\fbox{%
        \begin{minipage}[t]{0.47\textwidth}
        \begin{tabular}[t]{ l l }
          Company Name & Logo\\
          Address & \\
          Street & \\
          Tax ID &\\
          Other Info
        \end{tabular}
        \end{minipage}%
      }}% end the \fbox and the \hbox
      \hrule height 0pt
      }% end the \vtop

    \setbox2=\vtop to \dp0{
      \hrule height 0pt
      \hbox{\framebox[0.47\textwidth]{\textbf{Faktura VAT nr \nrfaktury}}}
      \vfill
      \hbox{\begin{tabular}{lr}
        Data sprzedaży: & \datasprzedazy \\
        Data wystawienia: & \datasprzedazy
      \end{tabular}}
      \vfill
      \hbox{\framebox[0.47\textwidth]{\textbf{ORYGINAŁ}}}
      \hrule height 0pt
      }
    \leavevmode\box0\hfill\box2\par
    }

    \begin{document}

    \renewcommand\arraystretch{1.3}
    \renewcommand\tabcolsep{0pt}
    Content
    \end{document}

我收到如下解析错误:

    Runaway argument?
    { \setbox 0=\vtop { \hrule height 0pt \hbox {\fbox {\begin {minipage}\ETC.
    ! Paragraph ended before \@ychead was complete.

有没有更简单的方法可以让这个标题出现在每一页上?

答案1

\par段落中 不能有空行,也不能有空格\chead。使用:

\chead
{%
\setbox0=\vtop{
  \hrule height 0pt
  \hbox{\fbox{%
    \begin{minipage}[t]{0.47\textwidth}
    \begin{tabular}[t]{ l l }
      Company Name & Logo\\
      Address & \\
      Street & \\
      Tax ID &\\
      Other Info
    \end{tabular}
    \end{minipage}%
  }}% end the \fbox and the \hbox
  \hrule height 0pt
  }% end the \vtop
\setbox2=\vtop to \dp0{%
  \hrule height 0pt
  \hbox{\framebox[0.47\textwidth]{\textbf{Faktura VAT nr \nrfaktury}}}
  \vfill
  \hbox{\begin{tabular}{lr}
    Data sprzedaży: & \datasprzedazy \\
    Data wystawienia: & \datasprzedazy
  \end{tabular}}
  \vfill
  \hbox{\framebox[0.47\textwidth]{\textbf{ORYGINAŁ}}}
  \hrule height 0pt
  }%
\leavevmode\box0\hfill\box2
}

但是,使用简单的表格也可以实现相同的效果,而无需使用,因为它应该已经在命令setbox之外定义\chead

相关内容