编写新页面时不记住 \newgeometry

编写新页面时不记住 \newgeometry

我正在使用该包自定义我的文档。我在稍后要制作的标题后geometry指定我想要使用的几何图形。\newgeometry

如果我使用下面的代码执行此操作,则第一页没问题,但执行\newpage文档后似乎忘记了我想要对整个文档使用的几何图形,然后这个新页面不再相对于第一页居中。

\newgeometry有没有办法在页面中立即使用我定义的几何图形\newpage

\documentclass{book}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[a4paper]{geometry}

\usepackage{sidenotes} % Notes in the margin
\usepackage{comment}

\begin{comment} 

    \begin{marginfigure}
    \includegraphics[width=\marginparwidth]{example-image-a}%
    \caption{This is in the margin.}%
    \end{marginfigure}

\end{comment}

\usepackage{graphicx}

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

\begin{document}
    % Future title here
    \newgeometry{
        a4paper,
        centering, 
        layoutwidth=20cm,
        layouthoffset = -1cm,
        layoutheight = 34cm,
        layoutvoffset = -2.5cm
    }

    \setcounter{chapter}{-1}
    \chapter{Basic concepts}
    \thispagestyle{fancy}
    \section{Multiply two numbers}

    When we have to numbers $ a $ and $ b $ and we want to multiply them we have
    \[
    a\cdot b = c
    \]
    where $ c $ is the result of multiplying $ a $ and $ b $
    \newpage
    a
\end{document}

答案1

如果您要对整个文档使用相同的几何形状,则不需要\newgeometry在文档的开头调用命令,而是使用您希望拥有的选项调用\usepackage命令。geometry

另外,正如评论中提到的,您需要onesidedocumentclass。

因此,类似这样的方法可能适合您(调整数字以满足您的需要):

\documentclass[a4paper,oneside]{book}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[centering, 
        layoutwidth=20cm,
        layouthoffset = -0.5cm,
        layoutheight = 34cm,
        layoutvoffset = -2.5cm]{geometry}

\usepackage{sidenotes} % Notes in the margin
\usepackage{comment}

\begin{comment} 

    \begin{marginfigure}
    \includegraphics[width=\marginparwidth]{example-image-a}%
    \caption{This is in the margin.}%
    \end{marginfigure}

\end{comment}

\usepackage{graphicx}

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

\begin{document}
    % Future title here

    \setcounter{chapter}{-1}
    \chapter{Basic concepts}
    \thispagestyle{fancy}
    \section{Multiply two numbers}

    When we have to numbers $ a $ and $ b $ and we want to multiply them we have
    \[
    a\cdot b = c
    \]
    where $ c $ is the result of multiplying $ a $ and $ b $
    \newpage
    \noindent a
\end{document}

相关内容