我正在尝试为文档创建标题页,但在背景图像覆盖文本方面遇到了一些问题。
它看起来是这样的:
如您所见,单词位于蓝色区域下方,而不是顶部。我想将单词放在左侧蓝色框的顶部,并将整个 tikz 图片作为背景。
这是我的代码:
\documentclass[11pt]{article}
\usepackage[hmargin=0.5cm,bmargin=2.3cm,tmargin=2cm,centering]{geometry}
\usepackage[contents= ,color=white,scale=1,opacity=1,angle=0]{background}
\usepackage{graphicx}
\usepackage{amssymb}
%\usepackage{xcolor}
\usepackage{here}
\usepackage{framed}
\usepackage{multicol}
\usepackage{wrapfig}
\usepackage{lipsum}
\usepackage[none]{hyphenat}
\usepackage{parskip}
\definecolor{altncolor}{rgb}{.8,0,0}
\usepackage[absolute]{textpos}
\setlength{\TPHorizModule}{4cm}
\setlength{\TPVertModule}{\TPHorizModule}
\textblockorigin{5mm}{10mm} % start everything near the top-left corner
\definecolor{bluey}{RGB}{0,121,194} %Alcon color
\definecolor{lightgray}{RGB}{235,235,235}
\definecolor{alightb}{RGB}{223,233,243}
\usepackage{tikz}
\usepackage{tikzpagenodes}
\usepackage{atbegshi}
\newcommand\Footer{%
\begin{tikzpicture}[remember picture,overlay]
\fill[bluey]
(current page.south west) -- (current page.south east) --
([yshift=-40pt]current page.south east|-current page text area.south east) --
([yshift=-40pt]current page.south west|-current page text area.south west) -- cycle;
\node[yshift=0.5cm,font=\bfseries\color{white}] at (current page.south) {\fontsize{15}{24}\selectfont};;
\end{tikzpicture}%
}
\newcommand\HeaderCurve{%
\begin{tikzpicture}[remember picture,overlay]
\path [fill=alightb]
([xshift=0cm]current page.north west) -- ([xshift=10cm]current page.north west) -- ([xshift=10cm]current page.south west) -- ([xshift=0cm]current page.south west) -- cycle;
\path [fill=lightgray]
([yshift=-2cm]current page.north west) .. controls (4,9) .. (current page.north east) --
([yshift=-9.5cm]current page.north east) .. controls (2,5.7) ..
([yshift=-10.5cm]current page.north west) -- cycle;
\end{tikzpicture}%
}
\pagestyle{empty}
% add header depending on the value of the page modulo 3
\AddEverypageHook{%
\ifnum\value{page}=1\relax
\backgroundsetup{contents={\HeaderCurve}}
\else
\ifnum\value{page}=2\relax
\backgroundsetup{contents={\HeaderHalf}}
\else
\ifnum\value{page}=3\relax
\backgroundsetup{contents={\HeaderCurve}}
\else
\ifnum\value{page}=4\relax
\backgroundsetup{contents={\HeaderHalf}}
\fi\fi\fi\fi
\BgMaterial
}
% add common footer for all pages
\AddEverypageHook{%
\backgroundsetup{contents=\Footer}
\BgMaterial
}
\begin{document}
\vspace*{2.cm}
\begin{textblock}{2}(2,3)
HEADER ONE
\lipsum[2]
\end{textblock}
\end{document}
任何帮助,将不胜感激。
答案1
您所需要的只是overlay
以下选项textpos
:
\documentclass[11pt]{article}
\usepackage[hmargin=0.5cm,bmargin=2.3cm,tmargin=2cm,centering]{geometry}
\usepackage[contents= ,color=white,scale=1,opacity=1,angle=0]{background}
\usepackage{graphicx}
\usepackage{amssymb}
%\usepackage{xcolor}
\usepackage{here}
\usepackage{framed}
\usepackage{multicol}
\usepackage{wrapfig}
\usepackage{lipsum}
\usepackage[none]{hyphenat}
\usepackage{parskip}
\definecolor{altncolor}{rgb}{.8,0,0}
\usepackage[absolute,overlay]{textpos}
\setlength{\TPHorizModule}{4cm}
\setlength{\TPVertModule}{\TPHorizModule}
\textblockorigin{5mm}{10mm} % start everything near the top-left corner
\definecolor{bluey}{RGB}{0,121,194} %Alcon color
\definecolor{lightgray}{RGB}{235,235,235}
\definecolor{alightb}{RGB}{223,233,243}
\usepackage{tikz}
\usepackage{tikzpagenodes}
\usepackage{atbegshi}
\newcommand\Footer{%
\begin{tikzpicture}[remember picture,overlay]
\fill[bluey]
(current page.south west) -- (current page.south east) --
([yshift=-40pt]current page.south east|-current page text area.south east) --
([yshift=-40pt]current page.south west|-current page text area.south west) -- cycle;
\node[yshift=0.5cm,font=\bfseries\color{white}] at (current page.south) {\fontsize{15}{24}\selectfont};;
\end{tikzpicture}%
}
\newcommand\HeaderCurve{%
\begin{tikzpicture}[remember picture,overlay]
\path [fill=alightb]
([xshift=0cm]current page.north west) -- ([xshift=10cm]current page.north west) -- ([xshift=10cm]current page.south west) -- ([xshift=0cm]current page.south west) -- cycle;
\path [fill=lightgray]
([yshift=-2cm]current page.north west) .. controls (4,9) .. (current page.north east) --
([yshift=-9.5cm]current page.north east) .. controls (2,5.7) ..
([yshift=-10.5cm]current page.north west) -- cycle;
\end{tikzpicture}%
}
\pagestyle{empty}
% add header depending on the value of the page modulo 3
\AddEverypageHook{%
\ifnum\value{page}=1\relax
\backgroundsetup{contents={\HeaderCurve}}
\else
\ifnum\value{page}=2\relax
\backgroundsetup{contents={\HeaderHalf}}
\else
\ifnum\value{page}=3\relax
\backgroundsetup{contents={\HeaderCurve}}
\else
\ifnum\value{page}=4\relax
\backgroundsetup{contents={\HeaderHalf}}
\fi\fi\fi\fi
\BgMaterial
}
% add common footer for all pages
\AddEverypageHook{%
\backgroundsetup{contents=\Footer}
\BgMaterial
}
\begin{document}
\vspace*{2.cm}
\begin{textblock}{2}(2,3)
HEADER ONE
\lipsum[2]
\end{textblock}
\end{document}