请问我怎样才能在乳胶中的所有页面的底部以及每个页面内放置一个矩形来显示“机密”内容?
我怎样才能显示当前页数/总页数?实际上,我只显示了当前页数。
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{hyperref}
\hypersetup{pdfstartview = {XYZ null null 1.00}}
\usepackage[hmargin=2cm,vmargin=3cm]{geometry}
\usepackage{wrapfig}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage{float}
\usepackage{eurosym}
\usepackage{tabto}
\pagestyle{fancy}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{xspace}
\usepackage{lastpage}
\usepackage{fancyhdr}
\usepackage[sorting=none]{biblatex}
\usepackage{lastpage}
% References
\usepackage{biblatex}
\addbibresource{references.bib}
\usepackage{csquotes}
\colorlet{punct}{red!60!black}
\definecolor{background}{HTML}{EEEEEE}
\definecolor{delim}{RGB}{20,105,176}
\colorlet{numb}{magenta!60!black}
\renewcommand{\footrulewidth}{1pt}
\fancyfoot[L]{blabla}
\fancyfoot[R]{\textbf{\thepage /\pageref{LastPage}}}
\fancyfoot[C]{\fbox{Confidential}} % added <<<<<<<<<<<<<<<
\newcommand{\hsp}{\hspace{20pt}}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\begin{document}
\begin{titlepage}
\begin{sffamily}
\begin{center}
% Upper part of the page. The '~' is needed because \\
% only works if a paragraph has started.
\begin{figure}[th]
\includegraphics[width=5cm]{images/p1.png}\hfill
\includegraphics[width=5cm]{images/m9.png}
\end{figure}
\vspace{3cm}
% \textsc{\Large }\\[1.5cm]
% Title
\HRule \\[0.4cm]
{ \huge \bfseries blabla\\[0.4cm] }
\HRule \\[1cm]
%\includegraphics[width=12cm]{images/f5.png}
% Author and supervisor
\Large blabla\\
\Large{blabla} \\
\Large blabla\\[1cm]
\vspace{3cm}
\begin{minipage}{0.4\textwidth}
\begin{flushleft} \large
\emph{\textbf{blabla}}\\
\textsc{blabla}\\
\textsc{blabla}\\
\end{flushleft}
\end{minipage}
~
\begin{minipage}{0.4\textwidth}
\begin{flushright} \large
\emph{\textbf{blabla}}\\
\textsc{blabla}\\
\textsc{blabla}\\
\end{flushright}
\end{minipage}
\vfill
% Bottom of the page
\vspace{1cm}
{\large 2021 - 2022}
\end{center}
\end{sffamily}
\end{titlepage}
\newpage
%HEADER
\renewcommand{\headrulewidth}{1pt}
\fancyhead[H]{\leftmark }
\fancyhead[L]{\includegraphics[scale=0.15]{images/p1.png}}
\fancyhead[R]{\includegraphics[scale=0.2]{images/p2.png}}
\fancyfoot[C]{\thepage}
{\ \vspace{-1cm}}
\section{blabka}
blabla
\vspace{-0.5cm}
\newpage
\tableofcontents
\end{document}
答案1
尝试一下此代码。它将生成一份 5 页的文档。
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[hmargin=2cm,vmargin=3cm,headheight=15pt]{geometry}% expand the header
\usepackage{wrapfig}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage{float}
\usepackage{eurosym}
\usepackage{tabto}
\pagestyle{fancy}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{xspace}
\usepackage[sorting=none]{biblatex}
% References
%\addbibresource{references.bib}
\usepackage{hyperref}
\usepackage{csquotes}
\colorlet{punct}{red!60!black}
\definecolor{background}{HTML}{EEEEEE}
\definecolor{delim}{RGB}{20,105,176}
\colorlet{numb}{magenta!60!black}
\renewcommand{\footrulewidth}{1pt}
\fancyfoot[R]{\textbf{\thepage /\pageref{LastPage}}} % changed <<<<<<<
\fancyfoot[L]{blabla}
\fancyfoot[C]{\fbox{CONFIDENTIAL}} % added <<<<<<<<<<<<<<<
%\fancyfoot[R]{\leftmark}
%\setlength{\parindent}{0cm}
%\setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}
\newcommand{\hsp}{\hspace{20pt}}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\usepackage{lastpage}% last page <<<<<<<<<<<<
\usepackage{kantlipsum} % ONLY dummy text
\begin{document}
\kant[1-20]
\end{document}
该包lastpage
将添加对文档最后一页(物理页)的引用,允许使用\fancyfoot[R]{\textbf{\thepage /\pageref{LastPage}}}
(需要两次编译)
要添加方框中的单词“机密”,请使用 \fancyfoot[C]{\fbox{CONFIDENTIAL}}
更新在使用新代码进行后续问题之后。
此代码将生成一份两页的文档加标题页。
主要变化:(a)页眉定义应在序言中。(b)页眉高度增加。(\usepackage[hmargin=2cm,vmargin=3cm,headheight=65pt]{geometry}
)
删除重复的包!!!
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
%\usepackage[hmargin=2cm,vmargin=3cm]{geometry}
\usepackage[hmargin=2cm,vmargin=3cm,headheight=65pt]{geometry}% CHANGED expand the header <<<<<<<<<<<<<<<<
\usepackage{wrapfig}
\usepackage{enumitem}
\usepackage{float}
\usepackage{eurosym}
\usepackage{tabto}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{xspace}
\usepackage{fancyhdr}
\usepackage{lastpage} % needed <<<<<<<<<<<<<<<
% References
\usepackage{biblatex}
%\addbibresource{references.bib}
\usepackage{hyperref} % put here <<<<<<<<<<<<<<<<<
\hypersetup{pdfstartview = {XYZ null null 1.00}}
\usepackage{csquotes}
\colorlet{punct}{red!60!black}
\definecolor{background}{HTML}{EEEEEE}
\definecolor{delim}{RGB}{20,105,176}
\colorlet{numb}{magenta!60!black}
%HEADER <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<,
\renewcommand{\footrulewidth}{1pt}
\renewcommand{\headrulewidth}{1pt}
\fancyhead[C]{\leftmark }
\fancyhead[L]{\includegraphics[scale=0.15]{example-image-c}}
\fancyhead[R]{\includegraphics[scale=0.2]{example-image-c}}
%\fancyfoot[C]{\thepage}
\fancyfoot[L]{blabla}
\fancyfoot[R]{\textbf{\thepage /\pageref{LastPage}}} % added <<<<<<<<<<<<<<<
\fancyfoot[C]{\fbox{Confidential}} % added <<<<<<<<<<<<<<<
\pagestyle{fancy}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\newcommand{\hsp}{\hspace{20pt}}
\begin{document}
\begin{titlepage}
\begin{sffamily}
\begin{center}
% Upper part of the page. The '~' is needed because \\
% only works if a paragraph has started.
\begin{figure}[th]
\includegraphics[width=5cm]{example-image-a}\hfill
\includegraphics[width=5cm]{example-image-b}
\end{figure}
\vspace{3cm}
% \textsc{\Large }\\[1.5cm]
% Title
\HRule \\[0.4cm]
{ \huge \bfseries blabla\\[0.4cm] }
\HRule \\[1cm]
%\includegraphics[width=12cm]{images/f5.png}
% Author and supervisor
\Large blabla\\
\Large{blabla} \\
\Large blabla\\[1cm]
\vspace{3cm}
\begin{minipage}{0.4\textwidth}
\begin{flushleft} \large
\emph{\textbf{blabla}}\\
\textsc{blabla}\\
\textsc{blabla}\\
\end{flushleft}
\end{minipage}
~
\begin{minipage}{0.4\textwidth}
\begin{flushright} \large
\emph{\textbf{blabla}}\\
\textsc{blabla}\\
\textsc{blabla}\\
\end{flushright}
\end{minipage}
\vfill
% Bottom of the page
\vspace{1cm}
{\large 2021 - 2022}
\end{center}
\end{sffamily}
\end{titlepage}
\newpage
\section{blabka}
blabla
\vspace{-0.5cm}
\newpage
\tableofcontents
\end{document}