更改侧边距时,如何防止 \newgeometry 影响底边距?

更改侧边距时,如何防止 \newgeometry 影响底边距?
\documentclass{article}
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2cm]{geometry}
\usepackage[demo]{graphicx}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage{titlesec}
\begin{document}


\begin{figure}
\centering
\renewcommand{\arraystretch}{3}
\begin{tabular*}{\textwidth}{@{}ccc@{}}
  \includegraphics[width=0.31\linewidth,height=2cm]{dummy} &
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}&
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}\\
    \includegraphics[width=0.31\linewidth,height=2cm]{dummy} &
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}&
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}
\end{tabular*}
\end{figure}

\blindtext

\clearpage

\newgeometry{left=10mm,right=10mm}
\begin{figure}
\centering
\renewcommand{\arraystretch}{3}
\begin{tabular*}{\textwidth}{@{}ccc@{}}
  \includegraphics[width=0.31\linewidth,height=2cm]{dummy} &
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}&
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}\\
    \includegraphics[width=0.31\linewidth,height=2cm]{dummy} &
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}&
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}
\end{tabular*}
\end{figure}
\blindtext

\end{document}

由于某种原因,这会改变页码的位置。我不确定发生了什么。

答案1

当您指定新的几何图形时,旧值不会保留,因此geometry使用其标准方法,即在应用默认文本高度后,按 2:3 的比例在顶部和底部之间划分空白垂直空间。

指定缺少的参数。

\documentclass{article}
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2cm]{geometry}
\usepackage[demo]{graphicx}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage{titlesec}
\begin{document}


\begin{figure}
\centering
\renewcommand{\arraystretch}{3}
\begin{tabular*}{\textwidth}{@{}ccc@{}}
  \includegraphics[width=0.31\linewidth,height=2cm]{dummy} &
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}&
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}\\
    \includegraphics[width=0.31\linewidth,height=2cm]{dummy} &
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}&
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}
\end{tabular*}
\end{figure}

\blindtext

\clearpage

\newgeometry{left=10mm,right=10mm,top=2.5cm,bottom=2cm}
\begin{figure}
\centering
\renewcommand{\arraystretch}{3}
\begin{tabular*}{\textwidth}{@{}ccc@{}}
  \includegraphics[width=0.31\linewidth,height=2cm]{dummy} &
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}&
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}\\
    \includegraphics[width=0.31\linewidth,height=2cm]{dummy} &
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}&
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}
\end{tabular*}
\end{figure}
\blindtext

\end{document}

但是,这是在图形中容纳宽对象的错误方法。使用changepage及其adjustwidth环境,这样不需要强制分页。

\documentclass{article}
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2cm]{geometry}
\usepackage[demo]{graphicx}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage{titlesec}
\usepackage{changepage}

\begin{document}


\begin{figure}
\centering
\renewcommand{\arraystretch}{3}
\begin{tabular*}{\textwidth}{@{}ccc@{}}
  \includegraphics[width=0.31\linewidth,height=2cm]{dummy} &
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}&
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}\\
    \includegraphics[width=0.31\linewidth,height=2cm]{dummy} &
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}&
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}
\end{tabular*}
\end{figure}

\blindtext

\begin{figure}
\centering
\begin{adjustwidth}{-1.5cm}{-1.5cm}
\renewcommand{\arraystretch}{3}
\begin{tabular*}{\textwidth}{@{}ccc@{}}
  \includegraphics[width=0.31\linewidth,height=2cm]{dummy} &
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}&
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}\\
    \includegraphics[width=0.31\linewidth,height=2cm]{dummy} &
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}&
        \includegraphics[width=0.31\linewidth,height=2cm]{dummy}
\end{tabular*}
\end{adjustwidth}
\end{figure}
\blindtext

\end{document}

相关内容