Tikz 在图片后面绘图

Tikz 在图片后面绘图

我目前正在学习 Latex,我想创建自己的标题页。目的是在顶部背景中放置一个矩形,并在其上方放置一张图片。但目前,图片位于绘图下方,而不是上方。所以这是我目前得到的结果: 在此处输入图片描述

使用以下代码:

\documentclass[10pt]{article}
\usepackage{graphicx}
\usepackage[utf8]{inputenc} % Required for including letters with accents
\usepackage[T1]{fontenc}% Use 8-bit encoding that has 256 glyphs
\usepackage{tikz,pgf} %package used for drawing
\usetikzlibrary{backgrounds}
\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}
\begin{document}
\begin{titlepage}
\begin{center}
\includegraphics[scale=.25]{land.png}\\[2cm]
{\huge \bfseries Test \\[0.8cm]} 
{\large \today}\\[3cm]
\noindent
\begin{minipage}{0.4\textwidth}
  \begin{flushleft} \large
    \emph{Author :}\\
    \textsc{Me}\\
  \end{flushleft}
\end{minipage}
\begin{minipage}{0.4\textwidth}
  \begin{flushright} \large
    \emph{Abstract :} \\Some text\end{flushright}
  \vfill
\end{minipage}
\end{center}

\begin{tikzpicture}[remember picture,overlay]
\begin{pgfonlayer}{background layer}
\coordinate (s) at (current page.south);%Bottom of the page
\node [name=colourbar,
anchor=base,
fill=blue!40,
text = white,
minimum width=\paperwidth,
minimum height=5cm] at (s){};
\coordinate (a) at (current page.north);%top of the page
\node [name=colourbar,
anchor=base,
fill=blue!50,
text = white,
minimum width=\paperwidth,
minimum height=10cm] at (a){};
\end{pgfonlayer}
\end{tikzpicture}
\end{titlepage}
\end{document}

有人知道怎么做吗?谢谢

答案1

很可能是我遗漏了一些东西,但首先我只想改变顺序:

\documentclass[10pt]{article}
\usepackage{graphicx}
\usepackage[utf8]{inputenc} % Required for including letters with accents
\usepackage[T1]{fontenc}% Use 8-bit encoding that has 256 glyphs
\usepackage{tikz,pgf} %package used for drawing
\usetikzlibrary{backgrounds}
\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}
\begin{document}
\begin{titlepage}
\begin{tikzpicture}[remember picture,overlay]
\begin{pgfonlayer}{background layer}
\coordinate (s) at (current page.south);%Bottom of the page
\node [name=colourbar,
anchor=base,
fill=blue!40,
text = white,
minimum width=\paperwidth,
minimum height=5cm] at (s){};
\coordinate (a) at (current page.north);%top of the page
\node [name=colourbar,
anchor=base,
fill=blue!50,
text = white,
minimum width=\paperwidth,
minimum height=10cm] at (a){};
\end{pgfonlayer}
\end{tikzpicture}
\vspace*{-3cm}
\begin{center}
\includegraphics[scale=1]{land.png}\\[2cm]
{\huge \bfseries Test \\[0.8cm]} 
{\large \today}\\[3cm]
\noindent
\begin{minipage}{0.4\textwidth}
  \begin{flushleft} \large
    \emph{Author :}\\
    \textsc{Me}\\
  \end{flushleft}
\end{minipage}
\begin{minipage}{0.4\textwidth}
  \begin{flushright} \large
    \emph{Abstract :} \\Some text\end{flushright}
  \vfill
\end{minipage}
\end{center}

\end{titlepage}
\end{document}

在此处输入图片描述

答案2

只是给你这个想法但会有更好的答案:

\documentclass[10pt]{article}
\usepackage{graphicx}
\usepackage[utf8]{inputenc} % Required for including letters with accents
\usepackage[T1]{fontenc}% Use 8-bit encoding that has 256 glyphs
\usepackage{tikz,pgf} %package used for drawing
\usetikzlibrary{backgrounds}
\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}
\begin{document}
\begin{titlepage}
\begin{center}
  \vspace*{3cm}

{\huge \bfseries Test \\[0.8cm]} 
{\large \today}\\[3cm]
\noindent
\begin{minipage}{0.4\textwidth}
  \begin{flushleft} \large
    \emph{Author :}\\
    \textsc{Me}\\
  \end{flushleft}
\end{minipage}
\begin{minipage}{0.4\textwidth}
  \begin{flushright} \large
    \emph{Abstract :} \\Some text\end{flushright}
  \vfill
\end{minipage}
\end{center}

\begin{tikzpicture}[remember picture,overlay]
\begin{pgfonlayer}{background layer}
\coordinate (s) at (current page.south);%Bottom of the page
\node [name=colourbar,
anchor=base,
fill=blue!40,
text = white,
minimum width=\paperwidth,
minimum height=5cm] at (s){};
\coordinate (a) at (current page.north);%top of the page
\node [name=colourbar,
anchor=base,
fill=blue!50,
text = white,
minimum width=\paperwidth,
minimum height=10cm] at (a){};
\node at ([yshift=-4cm]a) {\includegraphics[scale=.25]{example-image-a}};
\end{pgfonlayer}
\end{tikzpicture}
\end{titlepage}
\end{document}

我在 tikzpicture 中以及节点内的矩形后使用了 includegraphics。tikzpicture 中的节点一个接一个地创建(按照代码要求的创建顺序。因此,只需按适当的顺序添加它们即可解决您的特定问题)

PS:代码可以轻松变得更好...甚至不需要 pgfonlayer...但你可以尝试我给你的想法,并在得到更好的答案之前学到更多。

输出:

在此处输入图片描述

相关内容