![如何选择 pdf 页面的前 50%?](https://linux22.com/image/344762/%E5%A6%82%E4%BD%95%E9%80%89%E6%8B%A9%20pdf%20%E9%A1%B5%E9%9D%A2%E7%9A%84%E5%89%8D%2050%EF%BC%85%EF%BC%9F.png)
我想选择 PDF 文档的顶部(50%),然后将两个这样的文档接连放置。底部 50% 为空白。
这里有一个示例代码,它并排列出了两个 PDF 文档,但字体太小。
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{0.45\textwidth}
\includegraphics[page=2,width=\textwidth]{{P100C1}.pdf}
\caption{P100 C1.}
\end{subfigure}
%
\begin{subfigure}{0.45\textwidth}
\includegraphics[page=2,width=\textwidth]{{P100C2}.pdf}
\caption{P100 C2.}
\end{subfigure}
\caption{Descriptive statistics.}
\end{figure}
\end{document}
测试 Werner 的方法
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[export]{adjustbox}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{1\textwidth}
\adjustbox{trim=0 .5\height{} 0 0, clip, width=.3\linewidth} % show top 50\%
{\includegraphics[page=2,width=\textwidth]{{P100C1}.pdf}}
\caption{P100 C1.}
\end{subfigure}
%
\begin{subfigure}{1\textwidth}
\adjustbox{trim=0 .5\height{} 0 0, clip, width=.3\linewidth}
{\includegraphics[page=2,width=\textwidth]{{P100C2}.pdf}}
\caption{P100 C2.}
\end{subfigure}
\caption{Descriptive statistics.}
\end{figure}
\end{document}
输出正确(只是尺寸减小)
测试 Dan 的答案
输出:某些东西从侧面被裁剪
TeXLive:2016
Debian:8.5
答案1
adjustbox
提供对图像尺寸的访问,具体来说\height
。将其用作trim
-and-clip
选项的一部分:
\documentclass{article}
\usepackage[export]{adjustbox}
\begin{document}
\begin{figure}
\centering
\includegraphics[width=.3\linewidth]{example-image-a}%
\qquad
\includegraphics[width=.3\linewidth]{example-image-b}%
\bigskip
\adjustbox{trim=0 .5\height{} 0 0, clip, width=.3\linewidth}
{\includegraphics{example-image-a}}% Show top 50%
\qquad
\adjustbox{trim=0 0 0 .5\height, clip, width=.3\linewidth}
{\includegraphics{example-image-b}}% Show bottom 50%
\caption{Figure caption}
\end{figure}
\end{document}
trim=llx lly urx ury
llx
从左侧和urx
右侧以及lly
底部和ury
顶部水平修剪图像。
答案2
viewport
和clip
选项的组合\includegraphics
:
\begin{figure}
\centering
\begin{subfigure}{\textwidth}
% top half of page 2 of X.pdf
\includegraphics[page=2,viewport=72 396 540 720,width=\textwidth,clip]%
{X.pdf}
\caption{P100 C1.}
\end{subfigure}\\
% bottom half of page 2 of Y.pdf
\begin{subfigure}{\textwidth}
\includegraphics[page=2,viewport=72 72 540 396,width=\textwidth,clip]%
{Y.pdf}
\caption{P100 C2.}
\end{subfigure}
\caption{Descriptive statistics.}
\end{figure}