我有一个带有背景设置的文档。当我在页面上使用另一个 tikzpicture(例如坐标系)时,背景图片会放置在错误的位置(见图)。它应该在右上角。有人能提示如何修复它吗?
\documentclass[12pt]{article}
....
\backgroundsetup{
scale=1,
angle=0,
opacity=1,
color=black,
contents={\begin{tikzpicture}[remember picture, overlay]
\node at ([xshift=18cm,yshift=-1cm] current page.north west)
{\includegraphics[width = 7cm]{logo_minerva}}; %<- change the name of image
\end{tikzpicture}}
}
.....
\newpage
\textbf{Aufgabe 6: Lineare Funktionen Textaufgabe}\hfill \textbf{6 Punkte}
\hrule
\relax
\vspace{1cm}
Eine Mathematikprüfung wird mit einer linearen Skala bewertet. Das Punktemaximum von 24
Punkten entspricht der Note 6. Für 0 Punkte gibt es die Note 1.
\begin{center}
\begin{tikzpicture}[scale=1]
\begin{axis}[
axis lines=middle,
axis line style={Stealth-Stealth, thick},
xmin=-0.5,xmax=25,ymin=-0.5,ymax=8.5,
xtick distance=6,
ytick distance=1,
xlabel=$Punkte$,
ylabel=$Note$,
title={Notenskala},
grid=both,
grid style={line width=.1pt, draw=darkgray!10},
major grid style={line width=.2pt,draw=darkgray!50},
axis lines=middle
]
\end{axis}
\end{tikzpicture}
\end{center}
答案1
我想这就是你想要的:
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage{mwe}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% background package setup %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{background}
\backgroundsetup{
scale=1,
angle=0,
opacity=1,
color=black,
position=current page.north west,
hshift=18cm,
vshift=-1cm,
contents={\includegraphics[width=2cm]{example-image-a}}
}
% Another method:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Direct setup without background package %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\AddToHook{shipout/background}{
%\begin{tikzpicture}[remember picture, overlay]
%\node at ([xshift=18cm,yshift=-1cm] current page.north west) {\includegraphics[width=2cm]{example-image-a}};
%\end{tikzpicture}
%}
\begin{document}
\textbf{Aufgabe 6: Lineare Funktionen Textaufgabe}\hfill \textbf{6 Punkte}
\hrule
\relax
\vspace{1cm}
Eine Mathematikprüfung wird mit einer linearen Skala bewertet. Das Punktemaximum von 24
Punkten entspricht der Note 6. Für 0 Punkte gibt es die Note 1.
\begin{center}
\begin{tikzpicture}[scale=1]
\begin{axis}[
axis lines=middle,
axis line style={Stealth-Stealth, thick},
xmin=-0.5,xmax=25,ymin=-0.5,ymax=8.5,
xtick distance=6,
ytick distance=1,
xlabel=$Punkte$,
ylabel=$Note$,
title={Notenskala},
grid=both,
grid style={line width=.1pt, draw=darkgray!10},
major grid style={line width=.2pt,draw=darkgray!50},
axis lines=middle
]
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}