我正在尝试根据下图制作相等的页眉和页脚
我将页眉和页脚保存为图片。在我的尝试下,页眉是正确的,但文本没有左边距,也没有底部边距
\documentclass[a4paper, 12pt]{article}
\usepackage[top=3cm, bottom=4.3cm, left=3cm, right=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphics,graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,arrows,shapes,shadows,fit,patterns,quotes,spy}
\usepackage{lipsum}
\usepackage[fontsize=12pt]{scrextend}
%\renewcommand{\footrulewidth}{1pt}
\geometry{a4paper, includehead, top=-0.4cm, left=0cm}
\setlength\headheight{3cm}
\setlength\headwidth{\paperwidth}
\cfoot{\includegraphics[height=2.3cm]{g.png}}
\renewcommand{\headrulewidth}{0pt}
\chead{\includegraphics[width=\headwidth]{k.png}}
\renewcommand{\headrulewidth}{1pt}
%\chead{\makebox[\paperwidth][c]{\includegraphics{k.png}}}
\begin{document}
\lipsum
\end{document}
答案1
以下代码使用eso-pic
将相应的图像放置在页边界。这样,您仍然可以设置常规页眉/页脚和/或更改页面geometry
而不影响放置。
\documentclass{article}
\usepackage{graphicx,eso-pic}
\usepackage{lipsum}
\AddToShipoutPictureBG{%
\AtPageUpperLeft{%
\raisebox{-\height}{\includegraphics[width=\paperwidth]{k.png}}
}
\AtPageLowerLeft{%
\makebox[\paperwidth]{\includegraphics[height=2.3cm]{g.png}}
}%
}
\begin{document}
\lipsum
\end{document}
答案2
像这样?我必须\fancyhfoffset
在两边定义值,使其等于左右边距:
\documentclass[a4paper, brazil, 12pt]{article}
\usepackage[top=120pt, bottom=4.3cm, left=3cm, right=2cm, headheight=95pt, footskip=66pt]{geometry}%
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,arrows,shapes,shadows,fit,patterns,quotes,spy}
\usepackage{lipsum}
\usepackage[fontsize=12pt]{scrextend}
%\renewcommand{\footrulewidth}{1pt}
%\geometry{a4paper, includehead, top=-0.4cm, left=2cm}
\setlength\headwidth{\paperwidth}
\fancyhfoffset[L]{3cm}\fancyhfoffset[R]{2cm}
\cfoot{\includegraphics[width=\headwidth]{g.png}}
\renewcommand{\headrulewidth}{0pt}
\chead{\includegraphics[width=\headwidth]{k.png}}
\renewcommand{\headrulewidth}{1pt}
\begin{document}
\lipsum
\end{document}