答案1
这是一个使用选项eso-pic
使用相对于文本块的定位来放置侧边栏、顶部栏和文本:
\documentclass{article}
\usepackage{xcolor,eso-pic}
\usepackage{lipsum}
\definecolor{sidebarcolour}{RGB}{248,203,173}
\definecolor{toprulecolour}{RGB}{192,0,0}
\pagestyle{empty}
\AddToShipoutPictureFG{%
\AtTextLowerLeft{%
% Side bar
\makebox[0pt][r]{%
\textcolor{sidebarcolour}{\rule[-5\baselineskip]{\marginparwidth}{\dimexpr\textheight+5\baselineskip}}%
\hspace{10pt}%
}%
}%
\AtTextUpperLeft{%
% Top bar
\hspace{-\dimexpr\marginparwidth+10pt}%
\textcolor{toprulecolour}{\rule{\dimexpr\marginparwidth+\textwidth+20pt}{2\baselineskip}}%
}%
\AtTextUpperLeft{%
% Top text
\makebox[\textwidth]{\raisebox{3\baselineskip}{\Large Text}}%
}%
}
\begin{document}
\sloppy % Just for this example
\lipsum[1-50]
\end{document}
长度和其他定位可以根据需要改变。
答案2
欢迎来到 TeX.SE!这是一种可行的方法。我并不是说这是最优雅的方法。
\documentclass{article}
\usepackage{tikzpagenodes,eso-pic}
\newcommand{\PageTitle}[1]{\xdef\myPageTitle{#1}}
\AddToShipoutPictureBG{%
\begin{tikzpicture}[overlay,remember picture]
\fill[orange!70] (current page.south west) rectangle
([xshift=-2mm,yshift=1mm]current page text area.north west);
\fill[red] ([yshift=1mm]current page text area.north -| current page.west)
rectangle ([yshift=11mm]current page text area.north -| current page.east);
\node[anchor=south] at ([yshift=11mm]current page text area.north) {\myPageTitle};
\end{tikzpicture}}
\usepackage{lipsum}
\begin{document}
\PageTitle{Some text}
\lipsum[1-6]
\PageTitle{Some other text}
\lipsum[7-8]
\end{document}
答案3
使用tcolorbox
:
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{tikz,tcolorbox}
\tcbuselibrary{skins,breakable}
\usepackage{lipsum}
\begin{document}
\begin{tcolorbox}[sharp corners,boxrule=0mm,colback=white,colframe=red!70!black,title={\strut},
titlerule=6mm,left=0pt,right=0pt,top=0pt,]
\begin{tcolorbox}[enhanced,breakable,sharp corners,
boxrule=0mm,right=0pt,
leftrule=3cm,grow to left by=1mm,
interior style={fill=white},
frame style={fill=red, fill opacity=0.15},
title style={fill=red, fill opacity=0.9},
]
\lipsum[1-5]
\end{tcolorbox}
\end{tcolorbox}
\end{document}