在 LaTeX 中使用 pdfpages 时,如何避免在第一页之前分页?

发布于 2024-08-17 11:41:29 字数 377 浏览 1 评论 0原文

我正在创建一个大型 LaTeX 文档,我的附录中有几本 PDF 格式的小册子的复制品。我正在尝试创建一个节标题,然后以稍低的比例包含页面。例如:

\section{Booklet about Yada Yada Yada}

\includepdf[pages={-}, frame=true, scale=0.8]{booklet_yadayada.pdf}

然而,pdfpagex 做了两件烦人的事情。首先,它为包含的文档页面提供一个输出文档页面。我可以接受这一点,因为我使用的是 80% 的比例。然而,主要问题是第一页也是一个新页面,所以我有一个页面只有一个部分标题,然后是一个带有小册子的单独页面。

有没有办法让 pdfpages 变得更聪明一点?

I am creating a large LaTeX document, and my appendix has reproductions of several booklets that I have as PDFs. I am trying to create a section header and then include the pages at a slightly lower scale. For example:

\section{Booklet about Yada Yada Yada}

\includepdf[pages={-}, frame=true, scale=0.8]{booklet_yadayada.pdf}

However, pdfpagex does two annoying things. First, it devotes one output document page for included document page. I can live with that as I am using 80% scale. The main problem, however, is that the first page is also a new page, so I have a page with just a section title, and then a separate page with the booklet.

Is there some way to get pdfpages to be a little smarter here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

浮生未歇 2024-08-24 11:41:29

\includepdf 在内部使用 \includegraphics ,因此类似的内容

\section{Foo}
\fbox{\includegraphics[page=1,scale=0.8]{foo.pdf}}

会包含页面而无需开始新页面,尽管它一次只处理一页。

\includepdf uses \includegraphics internally, so something like

\section{Foo}
\fbox{\includegraphics[page=1,scale=0.8]{foo.pdf}}

would include the page without starting a new one, although it only does one page at a time.

-残月青衣踏尘吟 2024-08-24 11:41:29

对我来说,以下方法效果很好:

\includepdf[pages=1,pagecommand=\section{Section Heading}]{testpdf}
\includepdf[pages=2-,pagecommand={}]{testpdf}

For me the following worked just fine:

\includepdf[pages=1,pagecommand=\section{Section Heading}]{testpdf}
\includepdf[pages=2-,pagecommand={}]{testpdf}
谁的新欢旧爱 2024-08-24 11:41:29

我也尝试了这个解决方案,但是 \includepdf 保留了在边距上输出文件的优势(输出从页面边缘居中)。
所以我打开 pdfpages.sty,然后搜索 \newpage 命令。我删除了第一次出现的情况(第326行),只是为了尝试,保存后再次编译,就不再出现分页符了。

I tried this solution too, but \includepdf keeps the advantage of outputting the file over the margin (the output is centered from the edges of the page).
So I openned pdfpages.sty, and I searched for \newpage command. I deleted the first occurance (line 326), just to try, and after saving then compiling again, there were no page break anymore.

智商已欠费 2024-08-24 11:41:29

使用 minipage 环境:

\chapter*{Sujet du stage}
%\fbox{
\begin{minipage}{\textwidth}
\includepdf[scale=0.8]{../sujet-stage/main.pdf}
\end{minipage}

它不会添加任何额外的页面,并且可以与 includepdf 一起使用。

Use the minipage environement :

\chapter*{Sujet du stage}
%\fbox{
\begin{minipage}{\textwidth}
\includepdf[scale=0.8]{../sujet-stage/main.pdf}
\end{minipage}

It doesn't add any extra page and it works with includepdf.

意中人 2024-08-24 11:41:29

感谢您的所有答案 - 我一生都无法弄清楚 \includepdf 使用什么逻辑来插入空白页;通过 \includegraphics 包含第一页的技巧解决了大部分(但不是全部)这些问题;所以这里有一些注意事项:

首先,出于好奇,我也尝试仅使用 \includepdf ,但分为两部分:

\includepdf[pages=1]{MYINCLDOC.pdf} 
\includepdf[pages=2-last]{MYINCLDOC.pdf} 

...不幸的是,这与OP中的问题有相同的问题。

  • @WASE 的回答以来,源代码中现在有多个 \newpage (<代码>pdfpages.sty)。我尝试阅读源代码,但发现很难;所以我尝试暂时将 \newpage 设置为 \relax 仅适用于 \includepdf - 这会将文档中的所有页面放在彼此之上;所以盲目地摆脱 \newpage 可能不是一个好主意。
  • 只是 \includegraphics[page=1,scale=0.8]{foo.pdf} 有效 - 但是(如 @ WASE 还请注意)它与页面正文的左上角对齐,也就是说在页边距内;对于整页,我们希望 pdf 内容覆盖在整个页面上,包括边距。

此页面:graphics - 如何使用 TikZ 在左上角添加图像,graphicx - TeX - LaTeX 指出了在页面边缘上方定位的几种可能性;但对我来说,包含整页 PDF 的最佳解决方案是使用包 tikz 将其居中到页面:

\begin{tikzpicture}[remember picture,overlay]
  \node at (current page.center) {\includegraphics[page=1]{MYINCLDOC.pdf}};
\end{tikzpicture}
\includepdf[pages=2-last]{MYINCLDOC.pdf} 

完成此操作后,作为奖励,我还体验到了:

  • PDF 的正确目标书签(单击时转到右侧页面)
  • 如果您使用包 pax,则数据似乎也包含在 \includegraphics 独立首页中,因此没有区别
  • 如果您有一个双面文档 - pdfpages,其中第一页的上述分割位于 \includegraphics 中,现在(看起来)将正确插入 \cleardoublepages< 的等效内容/code> 连续包含的 pdf 之间(因此我不必手动插入这样的命令)。

希望这对某人有帮助,
干杯!

Thanks for all the answers - I couldn't for the life of me figure out what logic \includepdf uses to insert blank pages; the trick with including the first page via \includegraphics solved most (but not all) of those problems; so here are some notes:

First, out of curiosity, I have also tried to use only \includepdf, but split in two parts:

\includepdf[pages=1]{MYINCLDOC.pdf} 
\includepdf[pages=2-last]{MYINCLDOC.pdf} 

... unfortunately, this has the same problem as the question in OP.

  • Since @WASE's answer, there are now multiple \newpages in the source (pdfpages.sty). I tried reading the source, but I found it quite difficult; so I tried temporarily setting \newpage to \relax only for \includepdf - and that puts all pages in the document on top of each other; so probably not a good idea to get rid of \newpage blindly.
  • Just \includegraphics[page=1,scale=0.8]{foo.pdf} works - but (as @WASE also note) it is aligned at the top-left corner of the page body, which is to say inside the margins; for a full page we'd want the pdf inclusion overlaid over the whole page, margins included.

This page: graphics - How do I add an image in the upper, left-hand corner using TikZ and graphicx - TeX - LaTeX points to several possibilities for positioning on page over the margins; but for me, the best solution for a full page PDF inclusion is to use package tikz to center it to the page:

\begin{tikzpicture}[remember picture,overlay]
  \node at (current page.center) {\includegraphics[page=1]{MYINCLDOC.pdf}};
\end{tikzpicture}
\includepdf[pages=2-last]{MYINCLDOC.pdf} 

After this is done, as a bonus, I have also experienced:

  • Proper targets of PDF bookmarks (going to the right page when clicked)
  • If you use package pax, the data seems to be included also for the \includegraphics standalone first page, so no difference there
  • If you have a twoside document - pdfpages, with the above split of the first page in \includegraphics, will now (seemingly) correctly insert the equivalent of \cleardoublepages between pdfs that are included back to back (so I don't have to insert such a command manually).

Hope this helps someone,
Cheers!

千纸鹤带着心事 2024-08-24 11:41:29

我有点晚了,但以下解决方案对我有用:

\includepdf[pages={-},angle=90, scale=0.7]{lorem-ipsum.pdf}

所有页面均导入、缩放并旋转 90 度。
与 Texmaker 5.0.4 配合使用

I'm a little late, but the following solution worked for me:

\includepdf[pages={-},angle=90, scale=0.7]{lorem-ipsum.pdf}

All pages are imported, scaled and rotated by 90 degrees.
Works with Texmaker 5.0.4

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文