\fancypagestyle{myfancy}{
\fancyhf{}
\fancyhead[LE,RO]{\slshape\nouppercase{\leftmark}}
\fancyfoot[LE,RO]{\tikz[baseline={(0,0)},anchor=center] \node[label={center:\thepage}]{\includegraphics[scale=.25]{apple}};}%
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
}
上述代码生成页眉,并在页脚中生成页码,并在奇数页和偶数页的角落显示图像。现在我想在中心的页脚区域添加名人名言,我尝试使用 \fancyfoot[C] 导致覆盖现有设置。我该怎么做呢?其次,我在 .csv 文件中有引言和作者。我想逐一阅读作者和引言,并且对于每一页我都希望显示一个。我知道数据工具包,但是我该怎么做呢?
以下是源代码:
%Template for Technical Document
\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage{suffix}
\usepackage{lipsum}
\usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry}
%\renewcommand{\chaptername}{Article}
\usepackage{fancyhdr}
\usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry}
% Can also use centering, or hcentering
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[LE,RO]{\tikz[baseline={(0,0)},anchor=center]
\node[label={center:\thepage}]{\includegraphics[scale=.25]{apple}};}%
\fancyhf[cf]{Hello World}
\renewcommand{\footrulewidth}{0.4pt}
\renewcommand{\headrulewidth}{0.0pt}
}
\fancypagestyle{myfancy}{
\fancyhf{}
\fancyhead[LE,RO]{\slshape\nouppercase{\leftmark}}
\fancyfoot[LE,RO]{\tikz[baseline={(0,0)},anchor=center] \node[label={center:\thepage}]{\includegraphics[scale=.25]{apple}};}%
\fancyhf[cf]{Hello World}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
}
\usepackage{microtype}
\usepackage{afterpage}
\let\oldcleardoublepage\cleardoublepage
\renewcommand{\cleardoublepage}{\afterpage{\thispagestyle{empty}}\oldcleardoublepage}
\pagestyle{myfancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\begin{document}
\chapter{Install Backtrack on an Android Device}
\section{What is Backtrack?}
\lipsum[10]
\section{Security Tools in Backtrack}
\lipsum[10]
\section{Installing Backtrack on Android Device}
\lipsum[10]
\end{document}
页脚中心文本也与页码不对齐。如何修改?
答案1
您可以调整Hello World
或调整 tikz 图片以使其对齐。我在以下代码中展示了这两种可能性:
%Template for Technical Document
\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage{suffix}
\usepackage{lipsum}
\usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry}
%\renewcommand{\chaptername}{Article}
\usepackage{fancyhdr}
\usepackage[a4paper,margin=1in,bindingoffset=0.2in,centering,headheight=0.3in,heightrounded]{geometry}
% Can also use centering, or hcentering
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[LE,RO]{\tikz[baseline={(0,-0.7ex)},anchor=center,inner sep=0pt] %% adjust -0.7ex
\node(a){\includegraphics[scale=.25]{apple}}node[anchor=center,inner sep=0pt] at (a.center) {\thepage};}%
\fancyfoot[C]{Hello World}
\renewcommand{\footrulewidth}{0.4pt}
\renewcommand{\headrulewidth}{0.0pt}
}
\fancypagestyle{myfancy}{
\fancyhf{}
\fancyhead[LE,RO]{\slshape\nouppercase{\leftmark}}
\fancyfoot[LE,RO]{\tikz[anchor=south] \node[label={center:\thepage},inner sep=1pt]{\includegraphics[scale=.25]{apple}};}%
\fancyfoot[CE,CO]{\raisebox{1.65ex}{Hello World}} %% adjust 1.65ex
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
}
\usepackage{microtype}
\usepackage{afterpage}
\let\oldcleardoublepage\cleardoublepage
\renewcommand{\cleardoublepage}{\afterpage{\thispagestyle{empty}}\oldcleardoublepage}
\pagestyle{myfancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\begin{document}
\chapter{Install Backtrack on an Android Device}
\section{What is Backtrack?}
\lipsum[1-10]
\section{Security Tools in Backtrack}
\lipsum[10]
\section{Installing Backtrack on Android Device}
\lipsum[10]
\end{document}
调整baseline
tikz 图片:
调整Hello World
:
正如上面 Werner 所评论的,您也可以通过 指定参考点\raisebox{1.65ex}[0pt][0pt]{Hello World}
。
您在代码中使用了\fancyhf[cf]{Hello World}
,这将导致页眉和页脚同时出现。我假设您不希望它在页眉中出现。也cf
被 替换C
。