![如何使用几何图形和覆盖图完全填充页面](https://linux22.com/image/476872/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%E5%87%A0%E4%BD%95%E5%9B%BE%E5%BD%A2%E5%92%8C%E8%A6%86%E7%9B%96%E5%9B%BE%E5%AE%8C%E5%85%A8%E5%A1%AB%E5%85%85%E9%A1%B5%E9%9D%A2.png)
下面的 LaTeX 代码生成了两个页面。第二个页面符合我的预期:图片填满整个页面。但是当使用 overpic(用于覆盖一些文本)时,我无法获得相同的结果。
\documentclass[12pt]{article}
\usepackage[percent]{overpic}
\usepackage{graphicx}
\usepackage[paperwidth=38.205cm, paperheight=19.367cm,
margin=0cm]{geometry}
\setlength{\parindent}{0cm}
\begin{document}
\pagestyle{empty}
\begin{overpic}[width=\textwidth,height=\textheight]{picture}
\put (55,10) {This is some text}
\end{overpic}
\newpage
\includegraphics[width=\textwidth, height=\textheight]{picture}
\end{document}
当我使用 pdflatex 编译它时,我得到第二页,其中的图像填满整个页面,但是对于第一页,我在底部得到一个约 0.5 厘米的空行(白色),该行没有被图片填充(否则图片会填满页面的其余部分)。
我试过用边距、缩进、parskips 和许多其他技巧进行修改,但似乎都无济于事…… :-( 有什么想法吗
为了以防万一,我使用的图像是 JPEG,2811x1374(以像素为单位),我从 pdflatex 获得的输出如下:
jgb@parato:/tmp$ pdflatex \\nonstopmode\\input test.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2015/dev/Debian) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
LaTeX2e <2014/05/01>
Babel <3.9l> and hyphenation patterns for 7 languages loaded.
(./test.tex (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo))
(/usr/share/texlive/texmf-dist/tex/latex/overpic/overpic.sty
Package: overpic v0.53 <2010/09/13> (RN)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/graphics.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/pdftex-def/pdftex.def
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty))))
(/usr/share/texlive/texmf-dist/tex/latex/eepic/epic.sty
Enhancements to Picture Environment. Version 1.2 - Released June 1, 1986
)
overpic: relative positioning in percent
) (/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)) (./test.aux)
(/usr/share/texlive/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texlive/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty))
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty))
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/etexcmds.sty)))
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
<picture.jpg, id=1, 2821.54124pt x 1379.1525pt> <use picture.jpg> [1{/var/lib/t
exmf/fonts/map/pdftex/updmap/pdftex.map} <./picture.jpg>] <use picture.jpg>
[2] (./test.aux) )</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm
/cmr12.pfb>
Output written on test.pdf (2 pages, 1181833 bytes).
Transcript written on test.log.
答案1
这很容易实现eso-pic
作为备选:
\documentclass{article}
\usepackage{eso-pic,graphicx}
\usepackage[
paperwidth=38.205cm,
paperheight=19.367cm,
margin=0cm]{geometry}
\setlength{\parindent}{0cm}
\pagestyle{empty}
\begin{document}
\AddToShipoutPictureBG*{%
\AtPageLowerLeft{%
\includegraphics[width=\textwidth,height=\textheight]{example-image-a}%
}%
\AtPageLowerLeft{%
\hspace*{.55\textwidth}% 55% in from the left
\raisebox{.1\textheight}{This is some text}% baseline will be 10% up from the bottom edge
}
}
\mbox{}% Just to place something on the page.
\clearpage
\AddToShipoutPictureBG*{%
\AtPageLowerLeft{%
\includegraphics[width=\textwidth,height=\textheight]{example-image-b}%
}
}
\mbox{}% Just to place something on the page.
\end{document}
答案2
@Werner 的回答很有效。仅展示一些与问题更精确对应的代码:
\documentclass{article}
\usepackage{eso-pic,graphicx}
\usepackage[paperwidth=38.205cm, paperheight=19.367cm,
margin=0cm]{geometry}
\setlength{\parindent}{0cm}
\pagestyle{empty}
\begin{document}
\AddToShipoutPictureBG*{%
\AtPageLowerLeft{%
\includegraphics[width=\textwidth,height=\textheight]{picture}%
}%
\AtPageLowerLeft{%
\hspace*{.55\textwidth}% 55% in from the left
\raisebox{.1\textheight}{This is some text}% baseline will be 10% up from the bottom edge
}
}
\mbox{}% Just to place something on the page.
\newpage
\includegraphics[width=\textwidth, height=\textheight]{picture}
\end{document}
现在,正如我预期的那样,我得到了两页充满图片的页面。