在我的 latex 文档的某些页面上,我希望有一个全尺寸、无边距、覆盖整个页面的图像,就像您在杂志上经常看到的那样。此外,我希望这幅图像是可引用的,即它应该符合图号顺序,并应出现在文档的“图列表”中。此外,它应该有一个常规的图标题叠加(即“图 1.1.:foo”)和一个可引用的标签。
我尝试了图形尺寸和负空间:
\newpage
\begin{figure}[p]
\vspace*{-4.4cm}
\makebox[\linewidth]{
\includegraphics[width=\paperwidth,height=\paperheight]{universe.jpg}}
\vspace*{-5em}
\caption{\textcolor{white}{test}}
\label{fig:test1}
\end{figure}
\newpage
但是当使用不同的页边距/几何形状时,该解决方案并不可靠。有没有办法精确设置 vspace,以免出现框过满警告?
我尝试过background
:
\usepackage[pages=some,angle=0,opacity=1,scale=1]{background}
\newcommand\BackImage[1]{%
\BgThispage
\backgroundsetup{contents={\includegraphics[width=\paperwidth,height=\paperheight]{#1}}}}
\begin{document}
\BackImage{universe.jpg}
\vspace*{-3cm}
\begin{figure}
\caption{\textcolor{white}{test}}
\label{fig:test2}
\end{figure}
\clearpage
但对于我来说,使用没有实际图像的图形似乎很奇怪。
在这两种解决方案中,我都不知道如何正确定位标题,即我需要在页面左下角有一个多行标题框,宽度为 5 厘米。
有没有一个优雅的解决方案或方案?
答案1
您可以执行类似下面的操作。这里我旋转了图例作为示例,但您可以根据需要避免这种情况。如果图像本身的纵横比与页面不相同,则图像本身会失真(如果您愿意,可以使用各种方法避免这种情况)。您可以使用 caption 包来设置图例本身的样式。我已将图例放在彩色框中,但您也可以避免这种情况并更改图例的颜色以适合图像。
\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{eso-pic}
\usepackage{caption}
%for convenience I define a coordinate system for page runs -1 to +1
%so you can move the legend
\makeatletter
\def\parsecomma#1,#2\endparsecomma{\def\page@x{#1}\def\page@y{#2}}
\tikzdeclarecoordinatesystem{page}{
\parsecomma#1\endparsecomma
\pgfpointanchor{current page}{north east}
\pgf@xc=\pgf@x%
\pgf@yc=\pgf@y%
\pgfpointanchor{current page}{south west}
\pgf@xb=\pgf@x%
\pgf@yb=\pgf@y%
\pgfmathparse{(\pgf@xc-\pgf@xb)/2.*\page@x+(\pgf@xc+\pgf@xb)/2.}
\expandafter\pgf@x\expandafter=\pgfmathresult pt
\pgfmathparse{(\pgf@yc-\pgf@yb)/2.*\page@y+(\pgf@yc+\pgf@yb)/2.}
\expandafter\pgf@y\expandafter=\pgfmathresult pt
}
\makeatother
\begin{document}
\lipsum[5]
\clearpage
\thispagestyle{empty}
\AddToShipoutPicture*{\includegraphics[width=\paperwidth,height=\paperheight]{example-image-a}}
\begin{tikzpicture}[remember picture,overlay,every node/.style={anchor=center}]%
\node [fill = yellow!30, anchor = north west, minimum height = 6mm, minimum width = 0.20\paperheight, align = flush left, inner xsep = 3mm, text width=0.30\paperheight-5mm, rotate = 90] at (page cs:-0.8,-0.5) {\captionof{figure}[Legend for table of figures]{This is my legend}\label{im:first}};
\end{tikzpicture}
\clearpage
\lipsum[5]
\clearpage
\thispagestyle{empty}
\AddToShipoutPicture*{\includegraphics[width=\paperwidth,height=\paperheight]{example-image-a}}
\begin{tikzpicture}[remember picture,overlay,every node/.style={anchor=center}]%
\node [fill = yellow!30, anchor = north west, minimum height = 6mm, minimum width = 0.20\paperheight, align = flush left, inner xsep = 3mm, text width=0.30\paperheight-5mm, rotate = 90] at (page cs:-0.8,-0.5) {\captionof{figure}[Legend for table of figures]{This is my legend}\label{im:second}};
\end{tikzpicture}
\clearpage
This is a reference to Figure \ref{im:second} and this to This is a reference to Figure \ref{im:first}
\end{document}