將一對過滿的 PDF 置中

將一對過滿的 PDF 置中

我試圖弄清楚如何定位和居中事物的底部。

我在這裡並排放置了兩個非常大的 PDF。我將它們縮小到當前大小並嘗試將它們居中:

在此輸入影像描述

\documentclass{article}
\usepackage[margin=1in,showframe]{geometry}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\centering
\begin{figure}
%
\centering
  \begin{minipage}[c][1\totalheight][t]{0.45\textwidth}%
    \begin{center}
      {\includegraphics[scale=0.085]{diagrams/pdf/square.pdf}} 
    \end{center}
  \caption{I sit hard up against the left margin}
  \end{minipage}\hfill{}%
%
  \begin{minipage}[c][1\totalheight][t]{0.45\textwidth}%
    \begin{center}
    {\includegraphics[scale=0.085]{diagrams/pdf/square.pdf}}
    \end{center}
  \caption{I hang over the edge of the right margin}
  \end{minipage}\hfill{}%
%
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}

它有點有效,但它只懸掛在右邊距上,所以它並不是真正居中的。如果我進一步縮小它們,那麼到了一定程度就不再是問題了,但是讓它們小於0.085% 是不切實際的,你只是希望它看起來更像這樣:

在此輸入影像描述

請注意,頁面如何相對於兩個圖形的位置完全對稱,並且多餘部分均勻分佈在頁邊距之間?

我怎樣才能實現這個目標?我以為我的使用minipage可以解決這個問題,但我想不會。

答案1

這是一種使用方法這個答案

\documentclass{article}
\usepackage[margin=1in,showframe]{geometry}
\usepackage{graphicx}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\centering
\begin{figure}
%
\hspace{-0.025\textwidth}\makebox[1.05\textwidth][c]{
\noindent\begin{minipage}[t,outer sep=0]{0.45\textwidth}%
    \begin{center}
      {\includegraphics[width=\textwidth]{example-image-a}} 
    \end{center}
  \caption{I sit hard up against the left margin}
  \end{minipage}\hfill%
%
  \begin{minipage}[t,outer sep=0]{0.45\textwidth}%
    \begin{center}
    {\includegraphics[width=\textwidth]{example-image-b}}
    \end{center}
  \caption{I hang over the edge of the right margin}
  \end{minipage}}%
%
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}

輸出:

在此輸入影像描述

PS1:如果命令\makebox創建一個框,將在文字寬度之後添加...因此將其減少一半1.05\textwidth0.05\textwidth\hspace{-0.025\textwidth}

PS2:為迷你頁使用適當的寬度,但請注意外部 sep,以防您將使用命令的整個寬度\makebox

編輯:更好的方法:

\documentclass{article}
\usepackage[margin=1in,showframe]{geometry}
\usepackage{graphicx}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\centering
\begin{figure}
%
\noindent\makebox[\textwidth][c]{
\noindent\begin{minipage}[t,outer sep=0]{0.525\textwidth}%
    \begin{center}
      {\includegraphics[width=\textwidth]{example-image-a}} 
    \end{center}
  \caption{I sit hard up against the left margin}
  \end{minipage}\hspace{0.5cm}%
%
  \begin{minipage}[t,outer sep=0]{0.525\textwidth}%
    \begin{center}
    {\includegraphics[width=\textwidth]{example-image-b}}
    \end{center}
  \caption{I hang over the edge of the right margin}
  \end{minipage}}%
%
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}

相關內容