我是 Latex 的新手。我曾尝试用它开发一个带有页眉和页脚的文档。借助谷歌资源和这个论坛,我几乎成功了。但我仍然需要解决两个问题,请帮助我。
- 在页眉和页脚框中添加栗色。
- 减小标题框的大小
以下是代码,请指导我。
\documentclass{article}
\usepackage{lipsum}%% a garbage package you don't need except to create examples.
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{calc}
\renewcommand{\headrulewidth}{0pt}
\newlength{\fminilength}%
\setlength{\fminilength}{\textwidth-2\fboxsep-2\fboxrule}%
\pagestyle{fancy}
\lhead{\noindent\fbox{%
\begin{minipage}{\fminilength}%
\ttfamily\upshape box upto end of this text \hfill
\end{minipage}%
}}
\renewcommand{\headrulewidth}{0.4 pt}
\lfoot{\noindent\fbox{%
\begin{minipage}{\fminilength}%
\ttfamily\upshape Wireless networking \hfill \thepage\ of \pageref{LastPage}
\end{minipage}%
}}
\cfoot{}
\renewcommand{\footrulewidth}{0.4pt}
\begin{document}
\lipsum[1]
\end{document}
下面是描述预期输出的图像;
!
答案1
也许这提供了所需的输出:
\documentclass{article}
\usepackage{lipsum}%% a garbage package you don't need except to create examples.
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{calc}
\usepackage{tcolorbox}
\definecolor{maroon}{RGB}{128,0,0}
\renewcommand{\headrulewidth}{0pt}
\newlength{\fminilength}%
\setlength{\fminilength}{\textwidth-2\fboxsep-2\fboxrule}%
\pagestyle{fancy}
\lhead{\noindent%
\begin{tcolorbox}[colback=maroon,width=0.3\textwidth,outer arc=0mm,top=1mm,bottom=1mm,boxrule=0mm]
Header
%\ttfamily\upshape box upto end of this text \hfill
\end{tcolorbox}%
}%
%\renewcommand{\headrulewidth}{0.4 pt}
\lfoot{\noindent%
\begin{tcolorbox}[colback=maroon,width=\textwidth,outer arc=0mm,top=1mm,bottom=1mm, boxrule=0mm]
Footer\hfill \thepage\ of \pageref{LastPage}
%% \ttfamily\upshape Wireless networking \hfill \thepage\ of \pageref{LastPage}
\end{tcolorbox}
}
\cfoot{}
\renewcommand{\footrulewidth}{0.4pt}
\begin{document}
\lipsum[1]
\end{document}
编辑
我删除了有关环境的方框规则tcolorbox
。