我正在尝试制作一个文档模板。
我设置了与以下 MWE 非常相似的页眉和页脚:
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[letterpaper, left=19mm, right=19mm, top=2.54cm, bottom=2.54cm, headheight=31pt]{geometry}
\usepackage{amssymb}
% set the font of the document
\usepackage{fontspec}
\setmainfont{Arial}
\usepackage{titling}
\usepackage{setspace}
\setstretch{1.15}
\usepackage{xcolor}
\definecolor{my-orange}{RGB}{238,113,43}
\definecolor{my-light-grey}{RGB}{144,147,146}
\usepackage{titlesec}
\titlespacing\section{0pt}{6pt plus 4pt minus 2pt}{6pt plus 2pt minus 2pt}
\titlespacing\subsection{0pt}{6pt plus 4pt minus 2pt}{6pt plus 2pt minus 2pt}
\titlespacing\subsubsection{0pt}{6pt plus 4pt minus 2pt}{6pt plus 2pt minus 2pt}
\titleformat*{\section}{\Large\bfseries\color{my-orange}}
\titleformat*{\subsection}{\large\bfseries}
\titleformat*{\subsubsection}{\normalsize\itshape}
\usepackage{graphicx}
\usepackage{tabu}
\usepackage{fancyhdr}
\fancypagestyle{my-style}{
\fancyhf{} %Clear Everything.
\renewcommand{\headrulewidth}{0.75pt}
\renewcommand{\footrulewidth}{0.75pt}
\fancyhead[R]{\raisebox{-0.5\height}[0pt][0pt]{\includegraphics[width=5.15cm]{test_logo.png}}\vspace{2pt}}
\renewcommand{\headrule}{\hbox to\headwidth{%
\color{my-orange}\leaders\hrule height \headrulewidth\hfill}}
\renewcommand{\footrule}{\hbox to\headwidth{%
\color{my-orange}\leaders\hrule height \headrulewidth\hfill}}
\fancyfoot[C]{\vspace{-20pt}\noindent
\begin{tabu} to \textwidth {X[l]X[c]X[c]X[r]}
{\scriptsize \color{my-light-grey}\hspace{-2ex} Sample Company} & {\scriptsize \color{my-light-grey}+44(0)99 9999 9999} & {\scriptsize \color{my-light-grey} [email protected]} & {\scriptsize \color{my-light-grey}www.samplecompany.com}\\
\end{tabu}\\ \vspace{5pt} {\scriptsize \color{my-light-grey}This is a placeholder sentence.}\\\vspace{-6pt}{\scriptsize \color{my-light-grey}This is also just another placeholder sentence.} }
\fancyfoot[R]{\scriptsize \color{my-light-grey} Page | \thepage}
}
\pagestyle{my-style}
\usepackage{microtype}
\usepackage{lipsum}
\begin{document}
\section*{An example section}
\lipsum[1]
\end{document}
我正在使用 XeLaTeX 进行编译。
我正在使用该tabu
包在文档的页脚中创建一行。这个想法是,tabu 允许多个元素以等间距分布在页脚的宽度上。
我遇到的问题是元素的间距不均匀,并且禁忌中的最后一个元素没有完全到达页脚水平规则的末尾,如下所示:
如何修复此问题?
或者,有没有更好的方法将多个单独的文本元素放在一行中,等距分布,并跨越整个页脚水平规则?
答案1
我不会为此使用任何包;我只会使用一些\hfill
:
\documentclass[12pt]{article}
\usepackage[letterpaper, left=19mm, right=19mm, top=2.54cm, bottom=2.54cm, headheight=31pt]{geometry}
\usepackage{amssymb}
% set the font of the document
\usepackage{fontspec}
\setmainfont{Arial}
\usepackage{titling}
\usepackage{setspace}
\setstretch{1.15}
\usepackage{xcolor}
\definecolor{my-orange}{RGB}{238,113,43}
\definecolor{my-light-grey}{RGB}{144,147,146}
\usepackage{titlesec}
\titlespacing\section{0pt}{6pt plus 4pt minus 2pt}{6pt plus 2pt minus 2pt}
\titlespacing\subsection{0pt}{6pt plus 4pt minus 2pt}{6pt plus 2pt minus 2pt}
\titlespacing\subsubsection{0pt}{6pt plus 4pt minus 2pt}{6pt plus 2pt minus 2pt}
\titleformat*{\section}{\Large\bfseries\color{my-orange}}
\titleformat*{\subsection}{\large\bfseries}
\titleformat*{\subsubsection}{\normalsize\itshape}
\usepackage{graphicx}
\usepackage{fancyhdr}
\fancypagestyle{my-style}{
\fancyhf{} %Clear Everything.
\renewcommand{\headrulewidth}{0.75pt}
\renewcommand{\footrulewidth}{0.75pt}
\fancyhead[R]{\raisebox{-0.5\height}[0pt][0pt]{\includegraphics[width=5.15cm]{test_logo.png}}\vspace{2pt}}
\renewcommand{\headrule}{\hbox to\headwidth{%
\color{my-orange}\leaders\hrule height \headrulewidth\hfill}}
\renewcommand{\footrule}{\hbox to\headwidth{%
\color{my-orange}\leaders\hrule height \headrulewidth\hfill}}
\fancyfoot[C]{\vspace{-10pt}
{\scriptsize\color{my-light-grey} Sample Company\hfill +44(0)99 9999 9999\hfill [email protected] \hfill www.samplecompany.com \\
\vspace{5pt} This is a placeholder sentence.\\\vspace{-6pt}This is also just another placeholder sentence.}}
\fancyfoot[R]{\scriptsize \color{my-light-grey} Page | \thepage}
}
\pagestyle{my-style}
\usepackage{microtype}
\usepackage{lipsum}
\begin{document}
\section*{An example section}
\lipsum[1]
\end{document}
生成的页脚: