\newgeometry 不应用右边距

\newgeometry 不应用右边距

我为我的文档开发了以下代码:

\documentclass[10pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[headsepline,footsepline]{scrlayer-scrpage}
\usepackage{graphicx,xcolor}
\usepackage[margin=38mm,includeheadfoot,head=32pt]{geometry}
\usepackage{setspace, fontspec, hyperref, lastpage}
\usepackage[acronym]{glossaries}

\pagenumbering{arabic}
\onehalfspacing
\frenchspacing
\renewcommand{\headfont}{\normalfont}

\DeclareNewLayer[
    background,
    topmargin,
    mode=picture,
  contents={\includegraphics[height=\layerheight,width=\layerwidth]{Picture}}
]{top}

\DeclareNewLayer[
  background,
  bottommargin,
  mode=picture,
  contents={\includegraphics[height=\layerheight,width=\layerwidth]{Picture}}
]{bottom}

\DeclarePageStyleByLayers{Titlepage}{top,bottom}

\newpairofpagestyles[scrheadings]{Tableofcontents}
{
    \clearpairofpagestyles
    \ihead{Lorem ipsum}
    \chead{Lorem ipsum}
    \ohead{Lorem ipsum}
}

\newpairofpagestyles[scrheadings]{Content}
{
    \clearpairofpagestyles
    \ihead{Lorem ipsum}
    \chead{Lorem ipsum}
    \ohead{Lorem ipsum}
    \cfoot{\pagemark}
}
\renewcommand*{\pagemark}{{\usekomafont{pagenumber}Page~\thepage}}

\newcommand*{\Content}{
  \cleardoublepage
  \pagenumbering{arabic}
  \pagestyle{Content}
}

\makeglossaries

\begin{document}
    \pagenumbering{roman}
    \KOMAoption{headsepline}{false}
    \KOMAoption{footsepline}{false}
    Titlepage
    \newpage
    \newgeometry{left=2.5cm,right=2cm,top=2cm,bottom=2cm}
    \setlength{\headsep}{10pt}
    
    \KOMAoption{headsepline}{true}
    \KOMAoption{footsepline}{true}
    \Content
    Lorem ipsum

    \printglossary[type=\acronymtype]
    \printglossary
\end{document} 

现在我打印了文档,但文档边距没有我在“\newgeometry”中定义的大小。纸张上的实际边距不是:左=2.5cm、右=2cm、上=2cm、下=2cm,而是:左=2.8cm、右=2.3cm、上=1.4cm、下=2.6cm。所以边距肯定是不对的。我很高兴收到每一条解决此问题的建议。

编辑: 请使用 XeLaTeX-Compiler 进行编译。

答案1

我猜问题出在\setlength{\headsep}{10pt}。现在检查一下边距。

在此处输入图片描述

\documentclass[10pt,a4paper]{article}
\usepackage[german]{babel}
\usepackage[headsepline,footsepline]{scrlayer-scrpage}
\usepackage{graphicx,xcolor}
\usepackage[margin=38mm,includeheadfoot,
head=32pt,showframe]{geometry}
\usepackage{setspace, fontspec, hyperref, lastpage}
\usepackage[acronym]{glossaries}

\pagenumbering{arabic}
\onehalfspacing
\frenchspacing
\renewcommand{\headfont}{\normalfont}

\DeclareNewLayer[
    background,
    topmargin,
    mode=picture,
  contents={\includegraphics[height=\layerheight,width=\layerwidth]{Picture}}
]{top}

\DeclareNewLayer[
  background,
  bottommargin,
  mode=picture,
  contents={\includegraphics[height=\layerheight,width=\layerwidth]{Picture}}
]{bottom}

\DeclarePageStyleByLayers{Titlepage}{top,bottom}

\newpairofpagestyles[scrheadings]{Tableofcontents}
{
    \clearpairofpagestyles
    \ihead{Lorem ipsum}
    \chead{Lorem ipsum}
    \ohead{Lorem ipsum}
}

\newpairofpagestyles[scrheadings]{Content}
{
    \clearpairofpagestyles
    \ihead{Lorem ipsum}
    \chead{Lorem ipsum}
    \ohead{Lorem ipsum}
    \cfoot{\pagemark}
}
\renewcommand*{\pagemark}{{\usekomafont{pagenumber}Page~\thepage}}

\newcommand*{\Content}{
  \cleardoublepage
  \pagenumbering{arabic}
  \pagestyle{Content}
}

\makeglossaries

\DeclareNewLayer[
  background,
  %outermargin,
  %topmargin,
  contents=\layercontentsmeasure
]{measurelayer}



\AddLayersToPageStyle{@everystyle@}{measurelayer}

\begin{document}
 %   \pagenumbering{roman}
  %  \KOMAoption{headsepline}{false}
   % \KOMAoption{footsepline}{false}
%    Titlepage
 %   \newpage
\newgeometry{left=2.5cm,right=2cm,top=2cm,bottom=2cm}
%\setlength{\headsep}{10pt}
       % \setlength{\headheight}{1.5cm}
    
    \KOMAoption{headsepline}{true}
    \KOMAoption{footsepline}{true}
    \Content
    Lorem ipsum\footnote{asdf}

    \printglossary[type=\acronymtype]
    \printglossary
\end{document} 

相关内容