页眉页脚

页眉页脚

如何获得一个覆盖纸张边缘的完整框,而不必定义\lhead{} \chead{} \rhead{}, \lfoot{} \cfoot{} \rfoot{}。另外,脚和头都不在纸张边缘。如何调整框以覆盖边缘。另外,在左侧和右侧绘制一个垂直框 vbox 的命令是什么,该命令覆盖纸张的边缘。我想要的是绘制一个覆盖纸张边缘的彩色框,这样我的lipsum就会留在里面。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}         % Latin Modern fonts
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{geometry}

\geometry{
  height=180mm,
  width=180mm,
 left=0mm,
 right=0mm,
 top=0mm,
headheight=0mm, 
textheight=20cm,
 }
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage[many]{tcolorbox}

\usepackage{fancyhdr}
\pagestyle{fancy}

\lhead{\parbox[b][21mm][c]{10cm}{\tcboxfit[colback=blue,colframe=blue,width=10cm,height=2cm,fit basedim=20pt,fit fontsize macros,valign=center,frame style={fill=blue}]{\centering \textcolor{white}{\bfseries Test Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.}}}}
\chead{\parbox[b][21mm][c]{10cm}{\tcboxfit[colback=blue,colframe=blue,width=10cm,height=2cm,fit basedim=20pt,fit fontsize macros,valign=center,frame style={fill=blue}]{\centering \textcolor{white}{\bfseries Test Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.}}}}
\lfoot{\parbox[b][21mm][c]{10cm}{\tcboxfit[colback=red,colframe=red,width=10cm,height=2cm,fit basedim=20pt,fit fontsize macros,valign=center,frame style={fill=red}]{\centering \textcolor{white}{\bfseries Test Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.}}}}
\rfoot{\parbox[b][21mm][c]{10cm}{\tcboxfit[colback=red,colframe=red,width=10cm,height=2cm,fit basedim=20pt,fit fontsize macros,valign=center,frame style={fill=red}]{\centering \textcolor{white}{\bfseries Test Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.}}}}
\begin{document}
\lipsum[1]
\newpage
\lipsum[1]
\end{document}

答案1

这是您需要的设计吗:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}         % Latin Modern fonts
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage[hmargin=1cm, vmargin=3cm]{geometry}
%\usepackage{layout} % checking things


\usepackage{lipsum}
\usepackage{xcolor}
\usepackage[many]{tcolorbox}


\usepackage{eso-pic}
\usepackage{picture}

\AddToShipoutPictureBG{%
    \put(0,\paperheight){\raisebox{-\height}{\tcboxfit[colback=blue, colframe=blue,
    width=10cm, height=2cm, fit basedim=20pt, fit fontsize macros, frame
    style={fill=blue}]{\centering \textcolor{white}{\bfseries Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis.}}}}%
%
    \put(\paperwidth,\paperheight){\llap{\raisebox{-\height}{\tcboxfit[colback=blue, colframe=blue,
    width=10cm, height=2cm, fit basedim=20pt, fit fontsize macros, frame
    style={fill=blue}]{\centering \textcolor{white}{\bfseries Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis.}}}}}%
%
    \put(\paperwidth,0){\llap{\tcboxfit[colback=red, colframe=red,
    width=10cm, height=2cm, fit basedim=20pt, fit fontsize macros, frame
    style={fill=red}]{\centering \textcolor{white}{\bfseries Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis.}}}}%
%
    \put(0,0){\tcboxfit[colback=red, colframe=red,
    width=10cm, height=2cm, fit basedim=20pt, fit fontsize macros, frame
    style={fill=red}]{\centering \textcolor{white}{\bfseries Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis.}}}%
}


\begin{document}
%\layout
\lipsum[1-18]
\end{document}

在此处输入图片描述


也许根据评论你更想要这样的东西

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}         % Latin Modern fonts
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage[hmargin=5cm, vmargin=3cm]{geometry}
%\usepackage{layout} % checking things


\usepackage{lipsum}
\usepackage{xcolor}
\usepackage[many]{tcolorbox}


\usepackage{eso-pic}
\usepackage{picture}

\usepackage{ragged2e}

\AddToShipoutPictureBG{%
% HEAD
    \put(0,\dimexpr\paperheight-2cm\relax){\tcboxfit[colback=blue, colframe=blue,
    width=\paperwidth, height=2cm, fit basedim=20pt, fit fontsize macros, frame
    style={fill=blue}, sharp corners]{\centering \textcolor{white}{\bfseries Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis.}}}%
%
% FOOT
    \put(0,0){\tcboxfit[colback=red, colframe=red,
    width=\paperwidth, height=2cm, fit basedim=20pt, fit fontsize macros, frame
    style={fill=red}, sharp corners]{\centering \textcolor{white}{\bfseries Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis.}}}%
% %
% LEFT VERTICAL (width=4cm, inner margin = 0.5cm each side)
  \put(0,2cm){\fboxsep0pt \colorbox{green}{\kern.5cm\parbox[b][\dimexpr\paperheight-4cm][c]{3cm}{\bfseries
        \RaggedRight\color{white}Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis. Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis. Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis. Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis. Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis. }\kern.5cm}}
%
% RIGHT VERTICAL (width=4cm, inner margin = 0.5cm each side)
  \put(\dimexpr\paperwidth-4cm,2cm){\fboxsep0pt \colorbox{magenta}{\kern.5cm\parbox[b][\dimexpr\paperheight-4cm][c]{3cm}{\bfseries
        \RaggedLeft\color{white}Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis. Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis. Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis. Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis. Test Lorem ipsum
        dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
        vestibulum ut, placerat ac, adipiscing vitae, felis. }\kern.5cm}}
%
}


\begin{document}
%\layout
\lipsum[1-18]
\end{document}

生产

在此处输入图片描述 请注意,我在侧面使用了简单的 parboxes,没有缩放字体。顶部和底部也可以避免\scalebox使用tcolorbox包。

我不清楚这是否是预期的设计。页码需要一些处理,也许借助几何选项将其移到更高的位置。

相关内容